Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Chapter 8 Internet Protocol (IP) Chapter 8 Internet Protocol (IP) Mi-Jung Choi Dept. of Computer Science and Engineering

Similar presentations


Presentation on theme: "1 Chapter 8 Internet Protocol (IP) Chapter 8 Internet Protocol (IP) Mi-Jung Choi Dept. of Computer Science and Engineering"— Presentation transcript:

1 1 Chapter 8 Internet Protocol (IP) Chapter 8 Internet Protocol (IP) Mi-Jung Choi Dept. of Computer Science and Engineering mjchoi@kangwon.ac.kr

2 2 8.1 DATAGRAM 8.2 FRAGMENTATION 8.3OPTIONS 8.4CHECKSUM 8.5IP PACKAGE 8.6KEY TERMS 8.7 SUMMARY Contents

3 3 Objectives o Upon completion you will be able to: Understand the format and fields of a datagram Understand the need for fragmentation and the fields involved Understand the options available in an IP datagram Be able to perform a checksum calculation Understand the components and interactions of an IP package

4 4 Position of IP in TCP/IP protocol suite

5 5 Internet Protocol (IP) oPacket delivery mechanism in TCP/IP oUnreliable connectionless datagram protocol Each datagram handled independently Each datagram can follow a different route to destination. datagrams sent by same source and destination could arrive out of order oBest effort delivery oNo error checking or tracking

6 6 A packet in the IP layer is called a datagram, a variable-length packet consisting of two parts: header and data. The header is 20 to 60 bytes in length and contains information essential to routing and delivery 8.1 IP Datagram

7 7 oVersion(VER) 4BIT field Currently, the version is 4 oHeader Length(HLEN) 4BIT field The total length of the datagram header in 4byte words No options : 5(5*4=20), with maximum option size : 15(15*4=60) 8.1 DATAGRAM

8 8 oDifferentiated Services (formerly Service Type): 8bits 1. Service type The first 3bit : precedence bit Precedence l 1(000) to 7(111) l The priority of the datagram (congestion) l Not used in version 4 000 routine 001 Priority 010 Immediate 011 Flash 100 Flash override 101 Critical 110 Internetwork control 111 Network control TOS Bits Description 0000 Normal (default) 0001 Minimize cost 0010 Maximize reliability 0100 Maximize throughput 1000 Minimize delay  The precedence subfield was designed, but never used in version 4.

9 9 Table 8.2 Default types of service ProtocolTOS Bits Description ICMP 0000 Normal BOOTP 0000 Normal NNTP 0001 Minimize cost IGP 0010 Maximize reliability SNMP 0010 Maximize reliability TELNET 1000 Minimize delay FTP (data) 0100 Maximize throughput FTP (control) 1000 Minimize delay TFTP 1000 Minimize delay SMTP (command) 1000 Minimize delay SMTP (data) 0100 Maximize throughput DNS (UDP query) 1000 Minimize delay DNS (TCP query) 0000 Normal DNS (zone) 0100 Maximize throughput

10 10 8.1 DATAGRAM 2. Differentiated Services First 6bit : code point Last 2bit : not used The codepoint subfield can be used in two different ways 1.When the 3bit right-most bits are 0s, the 3bit left-most bits are interpreted the same as the precedence bits in the Service Type Interpretation 2.When the 3bit right-most bits are not all 0s, the 6bits define 64 services based on the priority assignment Temporary or experimentalXXXX013 LocalXXXX112 InternetXXXXX01 Assignment AuthorityCodepointCategory

11 11 8.1 DATAGRAM (cont.) oTotal length The total length field defines the total length of the datagram including the header. Total length of the IP datagram in byte(header + data) l Length of data = total length – HLEN l Maximum size : 65535 bytes (2 16 – 1) l Encapsulation is needed to transfer datagram in some case (some padding added)

12 12 8.1 DATAGRAM (cont.) oIdentification Used in fragmentation oFlags. Used in fragmentation oFragmentation offset Used in fragmentation fragmentation

13 13 8.1 DATAGRAM (cont.) oTime to live Datagram should have a limited lifetime l Decremented by each visited router l Discarded when zero l All the machine must have synchronized clocks and how long it takes for a datagram to go from one machine to another Cases l Corrupted router l Intentionally limit the journey of the packet 25 24 23 22

14 14 8.1 DATAGRAM(cont.) oProtocol Define the higher level protocol that uses the services of the IP layer. l Encapsulate data from several higher level protocol(TCP,UDP,ICMP,IGMP) l Specify the final destination protocol to which datagram should be delivered Value Protocol 1 ICMP 2 IGMP 6 TCP 8 EGP 17 UDP 41 IPv6 89 OSPF

15 15 8.1 DATAGRAM (cont.) oChecksum Later present oSource IP address Define the IP address of the source oDestination IP address Define the IP address of the destination

16 16  Example 1 :  Example 1 : An IP packet has arrived with the first 8 bits as shown:  01000010 The receiver discards the packet. Why?  There is an error in this packet. The 4 left-most bits (0100) show the version, which is correct. The next 4 bits (0010) show the header length, which means (2  4  8), which is wrong. The minimum number of bytes in the header must be 20. The packet has been corrupted in transmission.  Example 2 :  Example 2 : In an IP packet, the value of HLEN is 1000 in binary. How many bytes of options are being carried by this packet?  The HLEN value is 8, which means the total number of bytes in the header is 8  4 or 32 bytes. The first 20 bytes are the main header, the next 12 bytes are the options. 8.1 DATAGRAM (cont.)

17 17  Example 3 :  Example 3 : In an IP packet, the value of HLEN is 5 16 and the value of the total length field is 0028 16. How many bytes of data are being carried by this packet?  The HLEN value is 5, which means the total number of bytes in the header is 5  4 or 20 bytes (no options). The total length is 40 bytes, which means the packet is carrying 20 bytes of data (40  20).  Example 4 :  Example 4 : An IP packet has arrived with the first few hexadecimal digits as shown below:  45000028000100000102................... How many hops can this packet travel before being dropped? The data belong to what upper layer protocol?  To find the time-to-live field, we should skip 8 bytes (16 hexadecimal digits). The time-to-live field is the ninth byte, which is 01. This means the packet can travel only one hop. The protocol field is the next byte (02), which means that the upper layer protocol is IGMP. 8.1 DATAGRAM (cont.)

18 18 8.2 FRAGMENTATION oThe format and size of a frame depend on the protocol used by the physical network. A datagram may have to be fragmented to fit the protocol regulations. o The topics discussed in this section include: Maximum Transfer Unit (MTU) Fields Related to Fragmentation router Ethernet formatted frame Token ring formatted frame Ethernet network Token ring network

19 19 8.2 FRAGMENTATION oMaximum Transfer Unit (MTU) Maximum size of the data field l The total size of encapsulated datagram in a frame must be less than maximum size l Differ from one physical network protocol to another IP datagram

20 20 8.2 FRAGMENTATION - MTUs for different network - Table 8.5 MTUs for some networks

21 21 8.2 FRAGMENTATION oFragmentation Divide the datagram to make it possible to pass some networks l Each fragment has its own header – With most of the fields repeated, but some changed l A datagram can be fragmented several times l Only final destination can reassembly of the datagram l Required parts of the header must be copied by all fragments l Three fields(flags, fragmentation offsets, total length) changed

22 22 8.2 FRAGMENTATION oFields related to fragmentation Identification(16bits) l Identify a datagram originating from the source host l Combination of the identification and source IP address must be unique l IP protocol uses positive number counter(guarantee uniqueness) – Kept in the Main Memory l All fragment of a datagram have the same identification number

23 23 8.2 FRAGMENTATION Flags (3bits) l First bit : reserved l Second bit : do not fragment – 1 : must not fragment the datagram – If cannot pass the datagram through any physical network, discards the datagram and return ICMP error message to source host – 0 : the datagram can be fragmented if necessary l Third bit : more fragment – 1 : more fragments after this one – 0 : last or only fragment

24 24 8.2 FRAGMENTATION oFragmentation offset (13bits) Relative position of fragment with respect to the whole datagram Offset of the data in the original datagram measured in units of eight bytes (The size of first fragment is divisible by eight) Reassemble step in final destination host: l First fragment offset value is 0. l Divide the length of 1st fragment by 8. This value is the offset value of 2nd fragment. l Divide the length of 2st fragment by 8. This value is the offset value of 3rd fragment. l Continue the process. The last fragment has more bit value of 0.

25 25 8.2 FRAGMENTATION (cont.) Fragmentation example

26 26 8.2 FRAGMENTATION (cont.)

27 27  Example 5 :  Example 5 : A packet has arrived with an M bit value of 0. Is this the first fragment, the last fragment, or a middle fragment? Do we know if the packet was fragmented?  If the M bit is 0, it means that there are no more fragments; the fragment is the last one. However, we cannot say if the original packet was fragmented or not. A nonfragmented packet is considered the last fragment.  Example 6 :  Example 6 : A packet has arrived with an M bit value of 1. Is this the first fragment, the last fragment, or a middle fragment? Do we know if the packet was fragmented?  If the M bit is 1, it means that there is at least one more fragment. This fragment can be the first one or a middle one, but not the last one. We don’t know if it is the first one or a middle one; we need more information (the value of the fragmentation offset). However, we can definitely say the original packet has been fragmented because the M bit value is 1. 8.2 FRAGMENTATION (cont.)

28 28  Example 7 :  Example 7 : A packet has arrived with an M bit value of 1 and a fragmentation offset value of zero. Is this the first fragment, the last fragment, or a middle fragment?  Because the M bit is 1, it is either the first fragment or a middle one. Because the offset value is 0, it is the first fragment.  Example 8 :  Example 8 : A packet has arrived in which the offset value is 100. What is the number of the first byte? Do we know the number of the last byte?  To find the number of the first byte, we multiply the offset value by 8. This means that the first byte number is 800. We cannot determine the number of the last byte unless we know the length of the data.  Example 9 :  Example 9 : A packet has arrived in which the offset value is 100, the value of HLEN is 5 and the value of the total length field is 100. What is the number of the first byte and the last byte?  The first byte number is 100  8  800. The total length is 100 bytes and the header length is 20 bytes (5  4), which means that there are 80 bytes in this datagram. If the first byte number is 800, the last byte number must 879. 8.2 FRAGMENTATION (cont.)

29 29 8.3 Options The header of the IP datagram is made of two parts: a fixed part and a variable part. The variable part comprises the options that can be a maximum of 40 bytes. o The header of the IP datagram is made of two parts: a fixed part and a variable part. The variable part comprises the options that can be a maximum of 40 bytes. The topics discussed in this section include: o The topics discussed in this section include:Format Option Types

30 30 8.3 OPTIONS oSecurity, Source routing, Record route, Timestamp oUsed for network testing and debugging oNot required for every datagram oTLV (Type, Length, Value) Format

31 31 8.3 OPTIONS oCode (8bits) : Type Copy(1bit) l Control the presence of the option in fragmentation – 0 : only copied to the first fragment – 1 : coped to all fragments Class(2bits) l General purpose of the option – 00 : datagram control – 10 : debugging and management(01& 11 not defined) Number(5bits) l Type of the option(only six types are in use) oLength Total length of the option(including code and length fields) Not present in all of the option types oData : Value The data that specific options require Not present in all of the option types

32 32 8.3 OPTIONS oOption types(6 types) Two types l 1 byte l Do not require the length or the the data fields Four types l Multiple bytes l Require the length and the data fields

33 33 8.3 OPTIONS (cont.) oNo Operation (00001) 1 byte option Used as a filler between options

34 34 8.3 OPTIONS (cont.) oEnd of Option (00000) 1 byte option Used for padding at the end of the option field Only one end of option can be used Search payload(data) after option

35 35 8.3 OPTIONS (cont.) o 경로 기록 - Record Route(00111) Used to record the internet routers that handle the datagram Nine router IP can be contained(4byte×9 = 36 bytes ≤ 40bytes) Uses a pointer field containing the byte number of the first empty entry l Initialized by 4 and increased by 4 until over the length value

36 36 8.3 OPTIONS (cont.)

37 37 oStrict Source Route (01001) Used by the source to predetermine a rout for the datagram All of the routers defined in the option must be visited by datagram If the datagram visits a router that is not on the list, the datagram is discarded and an error message is issued If the datagram arrives at the destination and some of the entries were not visited, it is also discarded and an error message issued

38 38 8.3 OPTIONS (cont.) Strict source route concept

39 39 8.3 OPTIONS (cont.) oLoose Source Route(00011) Similar to the strict source route Each router in the list must be visited, but the datagram can visit other routers

40 40 8.3 OPTIONS(cont.) oTimestamp(00101) Used to record the time of datagram processing by a router l Milliseconds from midnight, Universal Time Overflow field l Records the number of routers that could not add their timestamp because of no more fields available Flags field l Specify the visited router responsibilities

41 41 8.3 OPTIONS (cont.) Use of flag in timestamp -0 : add only the timestamp in the provided field -1 : add each router’s outgoing IP address and the timestamp -3 : each router must check the given IP address with its own incoming IP address If matched, the router overwrites the IP address with its outgoing IP address and adds the timestamp

42 42 8.3 OPTIONS (cont.) Timestamp concept

43 43  Example 10: Which of the six options must be copied to each fragment? We look at the first (left-most) bit of the code for each option. No operation: Code is 00000001; no copy. End of option: Code is 00000000; no copy. Record route: Code is 00000111; no copy. Strict source route: Code is 10001001; copied. Loose source route: Code is 10000011; copied. Timestamp: Code is 01000100; no copy.  Example 11 : Which of the six options are used for datagram control and which are used for debugging and management? We look at the second and third (left-most) bits of the code. No operation: Code is 00000001; control. End of option: Code is 00000000; control. Record route: Code is 00000111; control. Strict source route: Code is 10001001; control. Loose source route: Code is 10000011; control. Timestamp: Code is 01000100; debugging 8.3 OPTIONS (cont.)

44 44 One of the utilities available in UNIX to check the travelling of the IP packets is ping. In the next chapter, we talk about the ping program in more detail. In this example, we want to show how to use the program to see if a host is available. We ping a server at De Anza College named fhda.edu. The result shows that the IP address of the host is 153.18.8.1. $ ping fhda.edu PING fhda.edu (153.18.8.1) 56(84) bytes of data. 64 bytes from tiptoe.fhda.edu (153.18.8.1):.... The result shows the IP address of the host and the number of bytes used. Example 12

45 45 We can also use the ping utility with the -R option to implement the record route option. $ ping -R fhda.edu PING fhda.edu (153.18.8.1) 56(124) bytes of data. 64 bytes from tiptoe.fhda.edu (153.18.8.1): icmp_seq=0 ttl=62 time=2.70 ms RR: voyager.deanza.fhda.edu (153.18.17.11) Dcore_G0_3-69.fhda.edu (153.18.251.3) Dbackup_V13.fhda.edu (153.18.191.249) tiptoe.fhda.edu (153.18.8.1) Dbackup_V62.fhda.edu (153.18.251.34) Dcore_G0_1-6.fhda.edu (153.18.31.254) voyager.deanza.fhda.edu (153.18.17.11) The result shows the interfaces and IP addresses. Example 13

46 46 The traceroute utility can also be used to keep track of the route of a packet. $ traceroute fhda.edu traceroute to fhda.edu (153.18.8.1), 30 hops max, 38 byte packets 1 Dcore_G0_1-6.fhda.edu (153.18.31.254) 0.972 ms 0.902 ms 0.881 ms 2 Dbackup_V69.fhda.edu (153.18.251.4) 2.113 ms 1.996 ms 2.059 ms 3 tiptoe.fhda.edu (153.18.8.1) 1.791 ms 1.741 ms 1.751 ms The result shows the three routers visited. Example 14

47 47 The traceroute program can be used to implement loose source routing. The -g option allows us to define the routers to be visited, from the source to destination. The following shows how we can send a packet to the fhda.edu server with the requirement that the packet visit the router 153.18.251.4. $ traceroute -g 153.18.251.4 fhda.edu. traceroute to fhda.edu (153.18.8.1), 30 hops max, 46 byte packets 1 Dcore_G0_1-6.fhda.edu (153.18.31.254) 0.976 ms 0.906 ms 0.889 ms 2 Dbackup_V69.fhda.edu (153.18.251.4) 2.168 ms 2.148 ms 2.037 ms Example 15

48 48 The traceroute program can also be used to implement strict source routing. The -G option forces the packet to visit the routers defined in the command line. The following shows how we can send a packet to the fhda.edu server and force the packet to visit only the router 153.18.251.4, not any other one. $ traceroute -G 153.18.251.4 fhda.edu. traceroute to fhda.edu (153.18.8.1), 30 hops max, 46 byte packets 1 Dbackup_V69.fhda.edu (153.18.251.4) 2.168 ms 2.148 ms 2.037 ms Example 16

49 49 8.4 CheckSum The error detection method used by most TCP/IP protocols is called the checksum. The checksum protects against the corruption that may occur during the transmission of a packet. It is redundant information added to the packet. o The error detection method used by most TCP/IP protocols is called the checksum. The checksum protects against the corruption that may occur during the transmission of a packet. It is redundant information added to the packet. oThe topics discussed in this section include: Checksum Calculation at the Sender Checksum Calculation at the Receiver Checksum in the IP Packet

50 50 8.4 CheckSum in IP oTo create the checksum the sender does the following: 1. The packet is divided into k sections, each of n bits. 2. All sections are added together using one’s complement arithmetic. 3. The final result is complemented to make the checksum. oChecksum in one’s complement arithmetic

51 51 Checksum concept

52 52 An example of IP header checksum calculation in binary and hexadecimal

53 53 Check Appendix C for a detailed description of checksum calculation and the handling of carries. Note:

54 54 Modulo 2 Arithmetic 1111 11001 +1010  11 -------- -------- 0101 11001 11001 --------- 101011 1100 11 | 10101 / 11 --------- x11 11 -------- x00 00 ----- x01 00 ---- x1 0102 0113 ------ 0011 Mod 2 1015 Binary

55 55 8.5 IP PACKAGE We give an example of a simplified IP software package to show its components and the relationships between the components. This IP package involves eight modules. The topics discussed in this section include:  Header-adding module  Processing module  Routing module  Fragmentation module  Reassembly module  Routing table  MTU table  Reassembly table

56 56 8.5 IP PACKAGE

57 57 Header-adding module Receive : data, destination address 1. Encapsulate the data in an IP datagram 2.Calculate the checksum and insert it in the checksum field 3. Send the data to the corresponding input queue 4. Return

58 58 8.5 IP PACKAGE Processing module 1. 1. Remove one datagram from one of the input queues 2. 2. If(destination address is 127.X.Y.Z or matches one of the local addresses) 1. 1. Send the datagram to the reassembly module 2. 2. Return 3. 3. If(machine is a router) 1. 1. Decrement TTL 4. 4. If(TTL less than or equal to zero) 1. 1. Discard the datagram 2. 2. Send an ICMP error message 3. 3. Return 5. 5. Send the datagram to the routing module 6. 6. Return

59 59 8.5 IP PACKAGE Fragmentation module Receive : an IP datagram from the routing module 1. Extract the size of the datagram 2. If(size > MTU of the corresponding network) 1. If(D(do not fragment) bit is set) 1. Discard the datagram 2. Send an ICMP error message 3. Return 2. Else 1. Calculate the maximum size 2. Divide the datagram into fragments 3. Add header to each fragment 4. Add required options to each fragment 5. Send the datagrams 6. Return 3. Else 1. Send the datagram 4. Return MTU table

60 60 8.5 IP PACKAGE Reassembly table Used by the reassembly module Five field - State(FREE or IN-USE) - Source IP address(source IP of the datagram) - Datagram ID(uniquely define a datagram) - Time-out(predetermined amount of time, in which all fragments must arrive) - Fragments(a pointer to a linked list of fragments)

61 61 8.5 IP PACKAGE (cont.) Reassembly module Receive : an IP packet from the processing module 1.If (offset value is zero and the M bit is 0) 1. Send the datagram to the appropriate queue 2. Return 2. Search the reassembly table for the corresponding entry 3. If (not found) 1. Create a new entry 4. Insert the fragment at the appropriate place in the linked list 1. if (all fragments have arrived) 1. Reassemble the fragments 2. Deliver the datagram to the corresponding upper layer protocol 3. Return 2. Else 1. Check the time-out 2. if (time-out expired) 1. Discard all fragment 2. Send an ICMP error message 5.Return


Download ppt "1 Chapter 8 Internet Protocol (IP) Chapter 8 Internet Protocol (IP) Mi-Jung Choi Dept. of Computer Science and Engineering"

Similar presentations


Ads by Google