3 IP is the transmission mechanism used by the TCP/IP protocol IntroductionIP is the transmission mechanism used by the TCP/IP protocolIt is unreliable and connectionless datagram protocolProviding Best-effort delivery service (best-effort : no error checking and tracking)
4 8.1 Datagram Packets in the IP layer : called datagrams IP datagram formatVariable-length packet consisting of header and dataHeader20 ~ 60 bytesContaining information that is essential for routing and deliveryIP headerVersion (VER) : Version 4 or 6 (IPng)Header length (HLEN) : represented by in 4 byte wordsEx) if HLEN = 5, the real header length is 20 bytes
6 Datagram (cont’d) Service Type Defining how the datagram should be handled by the routersPrecedence : 3 bitsDefining the priority of the datagram in issues such as congestionEx) a datagram for network management vs. optional information to a group of peopleAt present, not used in version 4service type : 4 bits (TOS bits)With only one bit set at a timeRemaining bit : not used
7 Datagram (cont’d)Service type or Differentiated Services
8 Datagram (cont’d) Types of service TOS bits Description 0000 Normal 0001Minimize cost0010Maximize reliability0100Maximize throughput1000Minimize delay
9 Datagram (cont’d) Default types for some applications in use of TOS ProtocolTOS bitsDescriptionICMP0000NormalBOOTPNNTP0001Minimize costIGP0010Maximize reliabilitySNMPTELNET1000Minimize delayFTP (data)0100Maximize throughputFTP (control)TFTPSMTP (command)SMTP (data)DNS (UDP query)DNS (TCP query)DNS (zone)
10 Datagram (cont’d) Differentiated Services Category Codepoint The first 6 bits : codepoint subfieldValues for codepointsCategoryCodepointAssigning Authority1XXXXX0Internet2XXXX11Local3XXXX01Temporary or experiment
11 Datagram (cont’d) Total Length : head + data Defining the total length of the datagram including the headerLength of data = total length – header lengthLimited to 65,535 (216 – 1) bytesEncapsulation of a small datagram in an Ethernet FrameEthernet Frame size : 46 ~ 1500 bytes
12 Datagram (cont’d) Flags : used in fragmentation Fragmentation offset : used in fragmentationTime to liveUsed to control the maximum number of hops (routers) visited by the datagramIf the value is Zero, the routers discardedIf the source wants to confine the packet to the local network, it can store 1 in this field
13 Datagram (cont’d) Protocol Defining the higher level protocol that uses the services of the IP layerTCP, UDP, ICMP, and IGMPMultiplexing data from different higher level protocolsValueProtocol1ICMP2IGMP6TCP8EGP17UDP89OSPF
14 Datagram (cont’d)Example 1An arriving IP packet : The receiver discards the packet, Why ?- 2 x 4 bytes = 8bytes : Minimum number of bytes in the header must be 20
15 Datagram (cont’d)Example 2The value of HLEN is 1000 in binaryHow many bytes of options are being carried by this packet ?8 x 4 bytes = 32 bytes : 20 bytes + 12 bytes (option)
16 Datagram (cont’d)Example 3- In an IP packet, the value of HLEN is 5 16 and the value of the total length field is How many bytes of data are being carried by this packet?AnswerThe 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 ( ).
17 Datagram (cont’d)Example 4An IP packet has arrived with the first few hexadecimal digits as shown below: How many hops can this packet travel before being dropped? The data belong to what upper layer protocol?
18 Datagram (cont’d)AnswerTo 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.
19 Datagram (cont’d) Checksum : header checksum- 16 bits Source IP address : 32 bit-fieldDestination IP address : 32 bit-field
20 8.2 FragmentationThe format and size of the received frame depend on the protocol used by the physical networkEx) A router connecting Ethernet to token ring
21 Fragmentation (cont’d) MTU (Maximum Transfer Unit)When a datagram is encapsulated in a frame, the total size of the datagram must be less than this maximum size
22 Fragmentation (cont’d) MTUs for different networksProtocolMTUHyperchannel65,535Token ring (16Mbps)17,914Token ring (4Mbps)4,464FDDI4,352Ethernet1,500X.25576PPP296Hyperchannel : Network Systems Corporation, 1988 (RFC 1044)
23 Fragmentation (cont’d) The maximum length of the IP datagram equals to the largest MTU defined so far (65,535 bytes)Therefore, for the other physical networks we must divide the datagram : fragmentationdatagram that can be fragmented by the source host or any router in the path, but the reassembly of datagram is done by the destinationWhen a datagram is fragmented, required parts of the header must be copied by all fragments.Changing the values of the three fields : flags, fragmentation offset, and total lengthThe rest of fields must be copiedChecksum must be recalculated
24 Fragmentation (cont’d) Fields related to fragmentationIdentification : 16 bit-fieldDatagram id that is originated by the source hostTherefore, Source IP address + datagram id (identification)All fragments having same identification numberIdentification No. to be used for the destination in reassembling the datagramFlags : 3 bit-fieldD : Do not fragment (1)If it can not pass the datagram through any available physical network, it discards the datagram and send ICMP error message to the source hostM : More fragment (0)0 : last fragment or only fragment
25 Fragmentation (cont’d) Fragmentation offset : 13-bit fieldShowing relative position of this fragment with respect to the whole datagramMeasured in units of 8 bytes : forcing hosts or routers that fragment datagrams to choose the size of each fragment so that the first byte number is divisible by eight
27 8.3 Options Variable part of the IP datagram : the maximum of 40 bytes Format : Code, Length, and Data
28 Options (cont’d) Code field 8 bits length and containing 3 subfields : copy, class, and numberCopyControlling the presence of the option in fragmentation0 : meaning that option must be copied only to the first fragment1 : meaning the option must be copied to all fragmentsClassDefining the general purpose of the option00 : datagram control, 01 : reserved, 10 : Debugging and management, 11: reserved
29 Options (cont’d) Length Number Defining the type of the option : only 6 options that are currently being usedLengthdefining the total length of the option including the code field and length field itselfDatacontaining the data that specific options require
31 Options (cont’d) No Operation one byte option used as a filler between options
32 Options (cont’d) End of Option one-byte option used for padding at the end of the option fieldused as the last option
33 Options (cont’d) Record Route used to record the internet routers that handle the datagramlist up to 9 router IP addresses since the max. size of the header is 60 bytes (Base header : 20 bytes)pointer fieldAn offset integer field containing the byte number of the first empty entry (available entry)When leaving the source, the pointer field has a value of four, pointing to the first empty field
36 Options (cont’d) Strict Source Route used by the source to predetermine a route for the datagram as it travels through the Internetcan choose a route with specific type of service : minimum delay or maximum throughput
38 Options (cont’d) Loose Source Route similar to the strict source route, but it is more relaxedeach router in the list must be visited, but the datagram can visit other routers as well
39 Options (cont’d) Time Stamp used to record the time of datagram processing by a routerexpressed in millisecond from the midnight, Universal Time
40 Options (cont’d)overflow field : recording the number of routers that could not add their timestamp because no more fields were availableUse of flag in timestamp
41 Options (cont’d)Timestamp concept (when flag =1)
42 Error detection method used by most TCP/IP protocols 8.4 ChecksumError detection method used by most TCP/IP protocolsChecksum calculation at the senderThe packet is divided into k sections, each of n bits ( n is usually 16)All sections are added together using one’s complement arithmeticThe final result is complemented to make the checksum
43 Checksum calculation at the receiver Checksum (cont’d)Checksum calculation at the receiverThe packet is divided into k sections, each of n bits.All sections are added together using one’s complement arithmeticThe result is complementedIf the final result is 0, the packet is accepted; otherwise it is rejected
45 Checksum (cont’d)Checksum in one’s complement arithmetic
46 Checksum in the IP Packet Checksum (cont’d)Checksum in the IP Packetcovering only the header, not the dataall higher level protocols that encapsulate data in the IP datagram have a checksum field that covers the whole packetthe header changes with each visited router, but data does not. So the checksum includes only the part which has changedif each router must recalculates the checksum, it is needed to have the more processing time for each router
50 The operation of IP package IP Package(cont’d)The operation of IP packagereceiving an IP packet, either from the data link layer or a higher level protocolif the packet comes from a upper layer protocol, it should be delivered to the data link layerif the packet comes from the data link layer, forwarding to data link or a upper layer ( the destination is same as the station address)
51 IP Package (cont’d) Header-adding Module Receive : data, destination addressEncapsulate the data in an IP datagramCalculate the checksum and insert it in the checksum fieldSend the data to the corresponding input queueReturn
52 IP Package (cont’d) Processing Module Remove one datagram from one of the input queuesif (destination address is 127.X.Y.Z or matches one of the local addresses)Send datagram to the reassembly module.Returnif (machine is a router)Decrement TTLif (TTL less than or equal to zero)Discard the datagramSend an ICMP error messageSend the datagram to the routing module
53 IP Package (cont’d) Queues Routing table Routing module Input queues and output queuesRouting tableused by the routing module to determine the next-hop address of the packetRouting modulereceiving an IP packet from the processing modulesending the packet with the information to the fragmentation module
54 IP Package (cont’d) MTU Table to find the maximum transfer unit of a particular interface.
55 IP Package (cont’d) Fragmentation Module Receive : an IP packet from routing moduleExtract the size of the datagramif (size > MTU of the corresponding network)If (D (do not fragment) bit is setDiscard the datagramSend an ICMP error messageReturnElseCalculate the maximum sizeDivide the datagram into fragmentsAdd header to each fragmentAdd required options to each fragmentSend the datagram
56 IP Package (cont’d) Reassembly Table State field : FREE or IN-USE Source IP address of datagramDatagram IDTime-out : a predetermined amount of time in which all fragments must arriveFragment field : a pointer to a linked list of fragments
58 IP Package (cont’d) Reassembly Module Receive : an IP packet from the processing moduleIf (offset value is zero and the M bit is 0)Send the datagram to the appropriate queueReturnSearch the reassembly table for the corresponding entryIf (not found)Create a new entry
59 IP Package (cont’d) 5. Return 4. Insert the fragment at the appropriate place in the linked listif (all fragments have arrived)Reassemble the fragmentsDeliver the datagram to the corresponding upper layer protocolReturnElseCheck the time-outif (time-out expired)Discard all fragmentSend an ICMP error message5. Return
60 Summary (1)IP is an unreliable connectionless protocol responsible for source-to-destination delivery.Packets in the IP layer are called datagramsA datagram consists of a header (20 to 60 bytes) and data.The IP header contains the following information: version number, header length, differentiated services, datagram length, identification number, fragmentation flags, fragmentation offset, time to live, protocol, checksum, source address, destination address, and options.The maximum length of a datagram is 65,535 bytes.The MTU is the maximum number of bytes that a data link protocol can encapsulate. MTUs vary from protocol to protocol.
61 Summary (2)Fragmentation is the division of a datagram into smaller units to accommodate the MTU of a data link protocol.The fields in the IP header that relate to fragmentation are the identification number, the fragmentation flags, and the fragmentation offset.The IP datagram header consists of a fixed, 20-byte section and a variable options section with a maximum of 40 bytes.The options section of the IP header is used for network testing and debugging.The options header contains the following information: a code field that identifies the option, option length, and the specific data.
62 Summary (3)The six IP options each have a specific function. They are as follows: filler between options for alignment purposes, padding, recording the route the datagram takes, selection of a mandatory route by the sender, selection of certain routers that must be visited, and recording of processing times at routers.The ping and traceroute utilities in UNIX can be used to implement some of the IP options.The error detection method used by IP is the checksum.The checksum uses one's complement arithmetic to add equal-size sections of the IP header. The complemented result is stored in the checksum field. The receiver also uses one's complement arithmetic to check the header.An IP package can consist of the following: a header-adding module, a processing module, a forwarding module, a fragmentation module, a reassembly module, a routing table, an MTU table, and a reassembly table.