Routing examples: ---- Example 1: Router R receives an IP packet with the following header: 01000101000000000000000011110000 01010101010101010000000000000000 00011111000100010000000000000000 00010100000101000001010000010100 10101010101010100001010100001111 (Note that the checksum field is identical zero: I did not bother to compute the checksum). The router identifies the various fields and gets: VERS = 4, HLEN = 5, ToS = 0, TL = 240 Ident = 21845, Flags = 0, FragOffset = 0 TTL = 31, PROT = 17, HCheckS = 0 SourceAddr = 20.20.20.20 DestAddr = 170.170.21.15 (We see that the header is 5x4 = 20 bytes, the Total Length is 240 bytes, so there are 220 data bytes) The router always first checks the checksum. Henceforth I no longer mention that. The router next decreases the TTL by one, to 30. That is still positive: the packet will be routed. The router checks what part of 170.170.21.15 is the destination network address, and looks up that network in its routing table. It finds the next hop. It finds the next network has MTU (Maximum Transmission Unit) greater than (or equal to) 240, so no fragmentation is needed. The router re-computes the checksum (not shown). This is necessary because the header has changed (!). The router puts the appropriate LAN wrapper around the packet, and sends it out on the appropriate port. The packet now has header VERS = 4, HLEN = 5, ToS = 0, TL = 240 Ident = 21845, Flags = 0, FragOffset = 0 TTL = 30, PROT = 17, HCheckS = 0 SourceAddr = 20.20.20.20 DestAddr = 170.170.21.15 (I did not bother to compute the checksum). The packet still has 220 data bytes. Aside: the Protocol is 17, so the data contains a UDP packet. See Forouzan p 152. ---- Example 2: Router R receives a packet and translates the header into: VERS = 4, HLEN = 5, ToS = 0, TL = 5376 Ident = 21845, Flags = 0, FragOffset = 0 TTL = 31, PROT = 17, HCheckS = 0 SourceAddr = 170.170.129.17 DestAddr = 170.170.17.17 The router first decreases the TTL to 30, which is positive. Then it determines the destination network address and looks it up in its routing table. It determines the outgoing port and network. It finds the next network has MTU = 4464 bytes (certain Token Rings have MTU = 4464 bytes, see Forouzan p 153). Now: Total Length = 5376 > 4464, so fragmentation is necessary. Flags = (000), so the DF bit is zero, so fragmentation is allowed. The header will be 20 bytes, so at most 4464 - 20 = 4444 bytes are available for data. However, the data must be a multiple of 8 bytes. The first of the fragments will have a header of 20 bytes and will have 4440 data bytes, for a total length of 4460 bytes. The router sets the More bit to 1 and recomputes the Header Checksum (the header has changed!). (We do not bother with the header checksum.) The first fragment will have header: Fragment 1 VERS = 4, HLEN = 5, ToS = 0, TL = 4460 Ident = 21845, Flags = 1, FragOffset = 0 TTL = 30, PROT = 17, HCheckS = 0 SourceAddr = 170.170.129.17 DestAddr = 170.170.17.17 DataField = 4440 bytes There are ((5376 - 20) - 4440) = 916 data bytes left over. 916 + 20 = 936 < 4464, so the remaining data fit in one fragment. That fragment has fragmentation offset 4440/8 = 555, and does not have the More bit set. The router recomputes the Header Check Sum (we do not bother). The second (and last) fragment has header: Fragment 2 VERS = 4, HLEN = 5, ToS = 0, TL = 936 Ident = 21845, Flags = 0, FragOffset = 555 TTL = 30, PROT = 17, HCheckS = 0 SourceAddr = 170.170.129.17 DestAddr = 170.170.17.17 DataField = 916 bytes ---- Example 3: VERS = 4, HLEN = 5, ToS = 0, TL = 4460 Ident = 43690, Flags = 1, FragOffset = 555 TTL = 10, PROT = 17, HCheckS = 0 SourceAddr = 170.170.17.17 DestAddr = 170.170.5.85 This packet is part of a large datagram that has been fragmented before. There are 555x8 = 4440 databytes in preceding fragments, and there are more fragments to follow. The next network is an ethernet with MTU = 1500 bytes. This fragment is further fragmented into three fragments. All three have the More bit set: Fragment 1 VERS = 4, HLEN = 5, ToS = 0, TL = 1500 Ident = 43690, Flags = 1, FragOffset = 555 TTL = 9, PROT = 17, HCheckS = 0 SourceAddr = 170.170.17.17 DestAddr = 170.170.5.85 DataField = 1480 bytes Fragment 2 VERS = 4, HLEN = 5, ToS = 0, TL = 1500 Ident = 43690, Flags = 1, FragOffset = 740 TTL = 9, PROT = 17, HCheckS = 0 SourceAddr = 170.170.17.17 DestAddr = 170.170.5.85 DataField = 1480 bytes Fragment 3 VERS = 4, HLEN = 5, ToS = 0, TL = 1500 Ident = 43690, Flags = 1, FragOffset = 925 TTL = 9, PROT = 17, HCheckS = 0 SourceAddr = 170.170.17.17 DestAddr = 170.170.5.85 DataField = 1480 bytes It so happens that 3x1480 = 4440. Otherwise, the last fragment would have been smaller than the first fragments. ---- Example 4: VERS = 4, HLEN = 5, ToS = 0, TL = 5376 Ident = 21845, Flags = 2, FragOffset = 0 TTL = 1, PROT = 17, HCheckS = 0 SourceAddr = 170.170.129.17 DestAddr = 170.170.17.17 The first thing the router does is decrease the TTL by one. The new TTL is zero, so the packet is ``dropped on the floor''. An ICMP packet is sent to the source. ---- Example 5: VERS = 4, HLEN = 5, ToS = 0, TL = 5376 Ident = 21845, Flags = 2, FragOffset = 0 TTL = 31, PROT = 17, HCheckS = 0 SourceAddr = 170.170.129.17 DestAddr = 170.170.17.17 The router decreases the TTL to 30, which is positive. It finds the next hop and next network. The next network has MTU 4464, so the packet is too large. However, the DF bit is set (Flags = (010) = 2), so fragmentation is not allowed. The packet is ``dropped on the floor'', and an ICMP packet is sent to the source. ----