How IP fragmentation occurs ?
The physical network layer normally imposes an upper limit on the size of the frame that can be transmitted. Whenever the IP layer receives an IP datagram to send, it determines which local interface the datagram is being sent on (routing), and queries that interface to obtain its MTU. IP compares the MTU with the datagram size and performs fragmentation, if necessary. Fragmentation can take place either at the original sending host or at an intermediate router. When an IP datagram is fragmented, it is not reassembled until it reaches its final destination.(This handling of reassembly differs from some other networking protocols that require reassembly to take place at the next hop, not at the final destination.) The IP layer at the destination performs the reassembly. The goal is to make fragmentation and reassembly transparent to the transport layer (TCP and UDP), which it is, except for possible performance degradation. It is also possible for the fragment of a datagram to again be fragmented (possibly more than once). The information maintained in the IP header for fragmentation and reassembly provides enough information to do this.
When an IP datagram is fragmented, each fragment becomes its own packet, with its own IP header, and is routed independently of any other packets. This makes it possible for the fragments of a datagram to arrive at the final destination out of order, but there is enough information in the IP header to allow the receiver to reassemble the fragments correctly.
Using UDP it is easy to generate IP fragmentation. (We'll see later that TCP tries to avoid fragmentation and that it is nearly impossible for an application to force TCP to send segments large enough to require fragmentation.) We can use our sock program and increase the size of the datagram until fragmentation occurs.
Purpose of the Lab:
The purpose of the lab is to observe fragmentation
Lab Setup:
Prior to this lab and the next one we have to set the MTU the path between routerB and routerC. The commands are:
goto routerB sudo ifconfig e2 mtu 1064
exit
goto routerC
sudo ifconfig e1 mtu 1064
exit
On hostC1 start tcpdump filtering on host hostB1 and host hostB1. sudo tcpdump -n -v host hostC1 and host hostB1
Use sock to send UDP datagrams of IP size between 1100 and 1500 from hostB1 to hostC1 sock -u -i -n1 -w1200 hostC1 discard
Observe the frames arriving in the tcpdump output
Results and Discussion:
tcpdump output:
15:58:54.988126 IP (tos 0x0, ttl 62, id 30699, offset 1040, flags [none], proto UDP (17), length 188)
10.1.2.1 > 10.1.3.1: udp
15:58:54.989080 IP (tos 0x0, ttl 62, id 30699, offset 0, flags [+], proto UDP (17), length 1060)
10.1.2.1.51740 > 10.1.3.1.9: UDP, length 1200
Discussion:
Frame 1 is the second fragment with same id =30699, offset= 1040 and flags none (MF=0).
Total IP length=188
Frame 2 is the first fragment with id =30699, offset =0, flags MF =1. Total IP length = 1060.
The MTU on a link can be found by observing fragments arriving at a destination. The exact value of the MTU is only known up to 4 bytes due to the restriction that the offset must be a multiple of 8 bytes.