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

Discussion in 'CCENT / CCNA' started by shivaji, May 22, 2022.

  1. 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)


    In order to understand these concepts of fragmentation, I have solved multiple problems. One of them is below.


    Here initially we have 5000 byte datagram of which 20 byte is header.

    The MTU is 1500 bytes.

    The answer is this-:

    Image link-:


    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?
  2. dmarsh
    Honorary Member

    dmarsh Petabyte Poster

    I would say think of it as a data bus, where the width is not one byte wide but 8 bytes wide (64 bits).
    Each 'address' points to an eight byte wide area, you do not have single byte resolution but it doesn't appear to matter in this instance.
    You use the 'address' (offset) to get to an 8 byte range, then you read all 8 bytes.

    Similar stuff happens in computers with words, longwords, 32/64/128 bit buses and registers. In this case its an offset into a datagram.

    A lot similar stuff happens in compilers when doing array indexing or matrix manipulation. Also different processors can also have different addressing modes.

    2 pow 3 = 2x2x2 = 8
    2 pow 13 = 8192
    2 pow 16 = 65536
    2 pow 13 x 2 pow 3 = 2 pow (13+3) = 2 pow 16
    8192 x 8 = 65536

    So basically your option 2 is most correct (your math was a little off).

    No idea what option 1 or option 3 is going on about. In general the whole text (yours and theirs) is very confusing way to explain quite basic concepts.

    Never learned TCP/IP fragmentation but from what I can gather above its using the MTU to split up the packet. Then it assigns each datagram a header. The body must be a multple of 8 bytes and the header 4.

    0x8 = 0 offset
    185x8 = 2959 offset
    370x8= 2960 offset
    555x8 = 4440 offset

    Basically this stuff is simple to programmers, digital electronics engineers, or mathematicians, other people over complicate it trying to explain it with lots of english.

    English generally sucks at explaining math or engineering problems.
    Last edited: May 22, 2022
    shivaji and JK2447 like this.
  3. dmarsh
    Honorary Member

    dmarsh Petabyte Poster

    A 1 bit field can only hold two values 0 or 1. If its the offset it would allow you to point to 'slot' zero or 'slot' 1.
    If the 'slot' is 4 bits wide. You can have a number 0-15 in 'slot' zero and another number 0-15 in 'slot' one.

    If you understand a memory address in assembler or pointers in C this is all basic stuff.

    If you are going to do network programming you might as well learn C.
    shivaji and JK2447 like this.
  4. dmarsh
    Honorary Member

    dmarsh Petabyte Poster

    Here you mix apples and oranges. The total size of data based on offsets doesnt seem to be related to combined header sizes across datagrams.

    8192x8=65536 This is total data size it doesn't include the headers.

    Every IP datagram has a 20 byte header, there are as many datagrams as necessary to accomodate the data based on the original packet and the MTU.
    shivaji and JK2447 like this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.