I have an IP packet of header length of 20 Bytes and data length of 4096 Bytes. The maximum transfer unit of the network is only 1500 Bytes. As I understand fragmentation, the fragmented packet will look like below.
FRAGMENT 1 will carry 0-1499 Bytes of data.
FRAGMENT 2 will carry 1500-2999 Bytes of data
FRAGMENT 3 will carry 3000 - 4096 Bytes of data
The fragment offset field values should be as below.
FRAGMENT 1 - 0/8 = 0;
FRAGMENT 2 - 1500/8 = 187.5 (Does this means that we will add 4 Bytes of padding and set the fragment offset field as 188? From my understanding of networking, this should be obvious way to do it but I can't seem to find any info on Google to support this.)
FRAGMENT 3 = 3000/8 = 375.
Any suggestions would be appreciated.
There are no guarantees as to exactly where the fragmentation boundaries will be. It's even allowed to have "the same bytes" in the tail-end of one fragment as well as in the beginning of the following fragment ("following" is in increasing position of the fragment as compared to the unfragmented original, not necessarily in on-the-wire time order).