290 likes | 303 Views
This article explains the position of IP in the TCP/IP protocol suite and the concept of datagram forwarding. It covers the format and header of IP datagrams, including information on service type, total length, identification, TTL, protocol, and more. The article also discusses the best effort delivery of IP and the problems it can encounter. Finally, it touches on IP encapsulation and fragmentation.
E N D
22-Datagram Forwarding Dr. John P. Abraham Professor UTRGV
Virtual Packets • Virtual means that the packet is not bound to a particular hardware. • Connectionless service allows a sender to transmit individual packets across the internet. • Source computer sends the packet with the destination address to its router. The router extracts the destination address and selects the best path next router. The last router sends it to the destination machine. • Internet protocol defines a packet format that is independent of the underlying hardware.
IP datagram • Header and payload • The amount of data carried in a datagram is not fixed. The size of the datagram is determined by the application that sends data. In v4 It can contain as little as single octet of data or maximum of 64K octets, including the header. The size of the header is fixed.
IP header format • 4bit version number • 4-bit header length. Number of 32-bit quantities in the header. Default value is 5. You need to multiply this value by 4 to get bytes. • 8-bit service type (differentiates services), originally it was called type of service (TOS). Even though changed to handle codepoint, it still is backward compatible. See below. • the first 6 bits make up the codepoint the other two not used (used in traffic management QOS). When the 3 right-most bits are 0s, the 3 left-most bits are interpreted as the TOS for backward comparibility. It is called the precedence bits, defining priority of the datagram from 0 to 7, in issues such as congestion. Datagrams with lowest priority are discarded first. • When the rightmost 3 bits are not 0s, all six bits define 56 service based on the priority assignment.
IP header continued. • 16bits-total length. Header plus data in bytes. Total length is limited to 216-1 or 65,535. The header can be 20 to 60 bytes long, rest can be data. • 16bits identification. Used in fragmentation. Explained later. • 3bits flags. Used in fragmentation. • 13bits fragmentation offset. Used in fragmentation. • 8bits TTL. Value is approximately two times the maximum number of routers between any two hosts. Each router will decrement it by one. On zero the packet is discarded. Different default values for different implementations of operating system. TCP generally has TTL of 64, UDP 30, Windows use 32, 64 or 128 depending on the version.
IP header continued • 8 bits protocol. • 16-bits header checksum • Source address 32bits • Destination address 32 bits. • Options and padding 0 to 40 bytes.
Example 1 An IP packet has arrived with the first 8 bits as shown: 01000010 The receiver discards the packet. Why? SolutionThere 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 In an IP packet, the value of HLEN is 1000 in binary. How many bytes of options are being carried by this packet? SolutionThe 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 base header, the next 12 bytes are the options.
Example 3 In an IP packet, the value of HLEN is 516 and the value of the total length field is 002816 . Howmany bytes of data are being carried by this packet? SolutionThe 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 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? SolutionTo find the time-to-live field, we 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.
Forwarding an IP datagram • Next hop forwarding. • Each router extracts the destination address, determines the next hop from the table and forwards to the next hop. • Take a look at a table on page 367, fig 22.3
Best effort delivery • IP makes a best effort to deliver each datagram, but does not guarantee delivery. The following are accepted problems of IP: • Datagram duplication • Delayed or out of order delivery • Corruption of data • Datagram los • Many of these problems can be solved by using TCP along with IP
IP encapsulation and fragmentation The 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. The topics discussed in this section include: Maximum Transfer Unit (MTU) Fields Related to Fragmentation
Network hardware treats a frame that contains a datagram like any other frame How does a receiver know whether the payload of an incoming fram contains an IP datagram or other data? The sender and receiver must agree on the value used in the frame type field. See page 372 fig 22.5 that explains how a datagram travels through the internet. MTU
Fragmentation • When a datagram is larger than the MTU of the network, the router divides the datagram into smaller pieces. • The flags field of the header indicates if the datagram is a fragment. The fragment offset is needed to place the fragment into the appropriate part of the whole original datagram.
Fragmentation Offset • This 13 bit filed shows the relative position of this fragment with respect to the whole datagram. The offset of data in the original datagram measured in units of 8 bytes. Suppose we have an original datagram of 4000 bytes numbered from 0 to 3999. The first offset is 0. If the fragment has 1400 bytes, the second offset is 1400, and the third is 2800. In order to fit in the offset field we divide each offset by 8. so we place 0 in the first, 175 in the second and 350 in the third. When a router make fragments, it is forced choose the offset of each fragment to be divisible by 8. Fragments can also be further fragmented.
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? SolutionIf 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 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? SolutionIf 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). See also the next example.
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?. SolutionBecause 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 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? SolutionTo 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 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? SolutionThe 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 be 879.
Collecting the fragments of a frame • Fragments from multiple datagrams can arrive in arbitrary order. • A sender places a unique identification number in the header (ID field). The router copies this ID number to each fragment. Frag offset is used to reassemble. • A datagram can’t be reassembled untill all fragments arrive. IP specifies a maximum time to hold fragments. Upon receiving the first fragment, a reassembly timer is started. If the timer expires and all fragments are not in, all the received fragments are discarded. All or nothing.