Ask Your Question
0

How can a 13 bit number represent 16 bit number?Or why is fragmentation offset multiple of 8?

asked 2022-05-22 10:03:16 +0000

This is more of a mathematics confusion so hope to get resolved here. So please don't leave it telling it is basic math, that basic math is what I am confused about.

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)

Image link-: https://imgur.com/a/HyqRFjZ

In order to understand these concepts of fragmentation, I have solved multiple problems. One of them is below. Image link-: https://imgur.com/a/qRq1aTB

Here initially we have 5000 byte datagram of which 20 byte is header. The MTU is 1500 bytes.

The answer is this-: Image link-: https://imgur.com/a/4XTT41M

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 ... (more)

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2022-05-22 21:02:28 +0000

grahamb gravatar image

Reading RFC 791, Section 3.1 - Internet Header Format should help resolve your questions.

From the RFC:

Fragment Offset: 13 bits

This field indicates where in the datagram this fragm)ent belongs. The fragment offset is measured in units of 8 octets (64 bits). The first fragment has offset zero.

Also Section 3.2 - Discussion has the following text (my emphasis):

Fragmentation and Reassembly.

The internet identification field (ID) is used together with the source and destination address, and the protocol fields, to identify datagram fragments for reassembly.

The More Fragments flag bit (MF) is set if the datagram is not the last fragment. The Fragment Offset field identifies the fragment location, relative to the beginning of the original unfragmented datagram. Fragments are counted in units of 8 octets. The fragmentation strategy is designed so than an unfragmented datagram has all zero fragmentation information (MF = 0, fragment offset = 0). If an internet datagram is fragmented, its data portion must be broken on 8 octet boundaries.

This format allows 2**13 = 8192 fragments of 8 octets each for a total of 65,536 octets. Note that this is consistent with the the datagram total length field (of course, the header is counted in the total length and not in the fragments).

When fragmentation occurs, some options are copied, but others remain with the first fragment only.

Every internet module must be able to forward a datagram of 68 octets without further fragmentation. This is because an internet header may be up to 60 octets, and the minimum fragment is 8 octets.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2022-05-22 10:03:16 +0000

Seen: 487 times

Last updated: May 22 '22