Protocol Type - Protocol number that this IP packet is encapsulating
It can be:
- TCP (6), UDP (17) =>Transport protocols
- ICMP (1) => Error reporting and diagnostics
- IP (4)
- OSPF (89)
- RSVP (46)
Header Checksum - It is used to test if IP Header is corrupted. It is computed by setting checksum field to Ø and then adding the 2 byte words in the header.
- -For error detection
- -If No error All ones in checksum
- -This is recalculated at each router
- -TCP,UDP,ICMP uses their own checksum; therefore it is not much useful and removed in IPv6
Source IP - IP address of source
Destination IP - IP address of the destination
Note: Source IP and Destination IP do not change when IP packet is forwarded.
IP Options - It is an optional field that is variable in size.
- Record route - record all routers that have forwarded the packet
- Source route (loose or strict) - you can also set the path that the IP packet should take. Each router forwards the packet to the next router in the list.
Fragmentation and Reassembly
- To send a packet a host can send the packet directly to destination or forward packet to a router.
- Fragmentation will happen when the IP-Packet cannot fit in the MTU (Maximum Transfer Unit) of a network.
- 0 means 1st fragment
- If any fragment misses, then whole packet must be send. This causes disproportional delay and congestion
- Fragmentation is done only by routers and reassembly by destination host.
- In a host, the IP layer will ask the hardware layer for the MTU and the IP layer will make sure that IP packets fit in the MTU.
- The fragments will have their own header that will share almost all the fields of the original packet.
- A fragment may also be fragmented
- Reassembly is only done by the destination host
- Routers do not do reassembly
Why? Routers would need to have reassembly buffers and also they would need to keep history of fragments that the router has forwarded. This is too expensive
Also, not all the fragments may follow the same path
Fragments may follow different paths
- When fragments arrive at the destination they are reassembled
Algorithm for reassembly
1. The first time a fragment arrives, a reassembly timer starts. This timer will limit the reassembly time in case one fragment is lost. After the time is expired, reassembly buffer is released if reassembly is not completed. The time for the timer is 255 secs that is the maximum TTL(time to live). Usually the time used is less than that (ex. 20 secs)
2. The fragments are placed in a reassembly list in the destination. The list is sorted by offset
3. The field used for reassembly are:
IP SRC - IP address of the source
ID - All fragments of the same packet have the same id
Fragment Offset - Used to sort the packets in the list
Total Length - Tells the length of the fragment; with offset and length we can identify if there are still gaps
More Fragments Flag - It tells if it is the last fragment; once the last fragment arrives we can determine the total size of the original packet
4. The reassembler stops when
- The last fragment arrived and there are no gaps in the reassembly list or when the timer expires
Note: Fragments may be received out of order