MHB Why is Fragmentation Offset Multiple of 8? Understanding IPv4 Fragmentation

  • Thread starter Thread starter shivajikobardan
  • Start date Start date
  • Tags Tags
    Bit Multiple
AI Thread Summary
IPv4 fragmentation involves breaking down packets into smaller pieces to fit within the Maximum Transmission Unit (MTU). The fragment offset is specified in units of 8 bytes, meaning that each offset value represents the starting point of the fragment in multiples of 8. This design allows for a maximum of 8191 fragments, as the 13-bit offset field can represent values from 0 to 8191. The confusion arises from the relationship between the maximum data size and the offset, as the total length includes the header, which must be accounted for. Understanding this concept is crucial for grasping IPv4 fragmentation and moving on to IPv6.
shivajikobardan
Messages
637
Reaction score
54
I am studying about ipv4 fragmentation.
This is ipv4 header. The fields of concern here are-:
-> identification(16 bit)

-> Flags(3 bit)

-> fragment offset(13 bit)

-> Total length(16 bit)
https://lh3.googleusercontent.com/8Y0WQH1CIjTD8sNFl7zgvsAvtDiRhARdvqQfjmMl6V2oq2yj1_s-lqrNsBbjlW5da_ikcbgFO1UWZO6KabHrZgSZHdHrJXR7wt7xXuYQQdciO8thEnTmdKxXGAZj0OoCndyYOS4h7gO29k0Zdw

In order to understand these concepts of fragmentation, I have solved multiple problems. One of them is below.
https://lh5.googleusercontent.com/KGoIeWXvaUJ9YfueI30jZJCMkNQ_1WeHwhAVvHSwzVXSPHtPAK-QFo34HOFH3soJH8L3Cv-1Y3N4H10K2mcDxouB8jYN9zL7G1UOFyZA1kyRXb9mhPEy8a6CSNfKLv57sml60ojHmHCLaCBGAg
Here initially we have 5000 byte datagram of which 20 byte is header.
The MTU is 1500 bytes.

The answer is this-:
https://lh3.googleusercontent.com/Vv0wXkbY74BGwiupDCe0sxhGJtLEapDcpVjwkBuDb3u_58UZCzQvLPy4Ohrxh2bpJAf_V_3vKou0D_Fgf9IfqUclc3oeExGQtjani0zAXRJvyfMbAcPNzUiDVK7RHzTlbsStewUBP1tU0s_cWQ
But I am unable to realize this simple concept that I believe even a 5th grader can understand even though I am college level undergraduate student. It is being pretty shameful for me.I am leaving my shame aside and asking this instead of giving up. I have asked this everywhere and everyone says this is basic math but it is not clicking in my head. Imma memorize this lol. I can solve any numerical problem related to fragmentation but this curiosity isn’t letting me to learn further and go to ipv6.
It would be immensely helpful to me if anyone can help me via that above example to understand this simple concept. I am unable to relate with this concept.
I agree there are 2^13 offset values ie 0,1,2,3,4,5,6,7,8,9…..8191. So that is the total no. of fragments possible 8192 fragments. But datagram can be only as big as 2^16-1 bytes. But why are we dividing them? It doesn’t make any sense. Maybe it is trying to say that 8192 fragments need to span 65535 bytes which gives 7.99987793 as the answer. But I have calculated it later, and fragmentation doesn’t work like that.

Opinion 1-:

Max “true” fragment offset possible=sum of all previous DATA ONLY excluding header
=65535-n*20 bytes.

Where 65535 is the max total length possible.n is the number of fragments and 20 bytes is the header length
The max value of offset possible is 8191. 65535-n*20 bytes should be represented by 8191 (both max values). But this opinion takes nowhere.Opinion 2-:
Max. 13 bit number=8191
Max 16 bit number=65535
So 65535/8191=8.0000sthsth (not exactly 8).

So the problem is like how can max offset value represent the max data size. But as i said in opinion 1, max data size can never be 65535 as header also takes up some space.

Opinion 3–:
Say i want to understand this example by a dummy example. Say fragmentation offset field is of 1 bit. And total length field is of 4 bit. What would happen?

Here are some answers that I have read which gave me further confusions-:
https://networkengineering.stackexc...26/why-ip-fragmentation-is-on-8-byte-boundary

https://learningnetwork.cisco.com/s/question/0D53i00000Kt7dxCAB/fragment-offset-concept
 
Technology news on Phys.org
@shivajikobardan, you posted this on mathhelpboard, but I don't remember whether you also posted this here at PF.

From the above, "The fragment offset ... is measured in unit (sic) of 8 bytes." It's not in units of single bytes. So for example, if the fragment offset is 9, what this means is that the fragment offset is really 72 (= 9 * 8). In binary, 9 is 1001 (base-2). Multiplying by 8 gives us 72, which in binary is 100 1000 (base 2). In hex, this is 0x48, or decimal 72.

Another example: Suppose the first fragment has a length of 32,768 bytes, at byte offsets 0 through 32,767. The next available storage location would be at offset 32,768. In hex, this is 0x8000, and in binary it would be 1000 0000 0000 0000 (base 2). Since the fragment offset is in units of 8 bytes, we need to divide 32,768 by 8, which is 4096. In hex, this is 0x1000, or in binary it would be 0001 0000 0000 0000 (base 2), which will fit into 13 bits.
 
  • Like
Likes shivajikobardan
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...

Similar threads

Back
Top