Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why the ip fragments must be in multiples of 8 bytes

Tags:

networking

ip

In the text book Computer Networking James F.Kurose Fifth Ed, ch4 mentioned

the ip fragments must be in multiples of 8 bytes, and because the Flags in the IP header takes 3 bits. I don't understand why ip fragmentation must be in multiples of 8 bytes.

like image 486
user991482 Avatar asked Oct 21 '11 07:10

user991482


2 Answers

Every fragment except the last must contain a multiple of 8 bytes of data.

Fragment Offset can hold 8192 (2^13) units but the datagram can't have 8192 * 8 = 65536 bytes of data because "Total Length" field of IP header records the total size including the header and data.

An IP header is at least 20 bytes long, so the maximum value for "Fragment Offset" is restricted to 8189, which leaves room for 3 bytes in the last fragment.

Hope this helps.

like image 123
Legend1989 Avatar answered Sep 18 '22 21:09

Legend1989


Note that Fragment Offset field is expressed in 8-byte units, not in bytes. This is the reason why the payload size inside each of the fragment, except the last fragment, must be multiple of 8 bytes.

As the Fragment Offset is coded on 13bits, it results that its range is between 0 and 8191 units of 8 bytes. However, because the Total Length takes into account also the IP Header, the Fragment Offset maximum limit is in fact 8189 units, not 8191 units, see below:

Total Length being coded on 16 bits it means it is limited to 65535 bytes. Then, as the IP header is at least 20 bytes it results that the Payload is limited to maximum 65535 bytes - 20 bytes = 65515 bytes. Dividing these 65515 bytes in 8-byte units it results that there could be maximum 8189 units, hence Fragmentation Offset is limited to maximum 8189 units.

An IP fragment having the Fragment Offset value set to this maximum value of 8189, could have a payload of maximum 3 bytes:

Maximum 65535 bytes - minimum 20 bytes - (8189 units * 8 bytes per unit) = maximum 3 bytes

Rurre

like image 30
Rurre Avatar answered Sep 22 '22 21:09

Rurre