# Fragmentation offset



## zillah (Mar 18, 2005)

I am looking to understand the concept of fragmentation offset, because I get confused with 13 bits and 8 bytes (64 bits), I have read many article online without clear understanding


----------



## Resolution (Sep 17, 2005)

Are you confused about the fragmentation process of a datagram, or are you confused about the concept of bits and bytes?


----------



## zillah (Mar 18, 2005)

> or are you confused about the concept of bits and bytes?


This one


----------



## Resolution (Sep 17, 2005)

Read the following for a quick explanation...

Bits, Bytes, Mega, Giga, Tera (explained)


----------



## zillah (Mar 18, 2005)

Sory for that , I meant realtion between bit and bytes in the context of datagram offset,,look at this ( here my confusion)

Could you please read this from (Data Communications and Networking) by Forouzan page chapter 20 page 524:

((This 13-bit field shows the relative position of this fragment with respect to the whole datagram. It is the offset of the data in the original datagram measured in units of 8 bytes . If we have a data size of 4000 bytes fragmented into three parts. 

The byte in the original datagram are numbered 0 to 3999. 

The first datagram carries bytes 0 to 1399. The offset for this datagram is 0/8 = 0. 

The second fragment carries bytes 1400 to 2799; the offset value for this fragment is 1400/8 = 175.

Finally , the third fragment carries bytes 2800 to 3999; the offset value for this fragment is 2800/8 = 350.

Remember that the value of the offset is measured in units 8 bytes. This is done because the length of the offset field is only 13 bits long and cannot represent a sequence of bytes greater than 8191.

This forces hosts or routers that fragment datagram to choose the size of each fragment so that the first byte number is divisible by 8)).


----------



## Resolution (Sep 17, 2005)

Hopefully, I didn't make this too confusing. I urge anyone to correct me if I am wrong.


The fragment offset field in an IP header is 13 bits in length. If the total length of the IP header is measured in 32 bit words (0-31 or 1-32 in most diagrams), then


```
18		    31	 (31 bits - 18 bits = 13 bits)
+-------------------+
|  Fragment Offset  |
+-------------------+
```
Take this diagram for example...

http://school.wilth.net/prru/kapitel5-Dateien/image004.gif

The length of the IP header is 32 bits long, but the size is 20 bytes. Notice that this *does not* include the size of the data. 

If the datagram is fragmented, the value in the fragment offset field must be a multiple of 8 bytes. The offset field can be a value from 0 to 8191. 

8191 * 8 = 65528 which is just under the maximum size allowed for an IP Datagram (65535). *This is including the 20 byte header size*, because not only is the data fragmented from the original datagram, but the IP header is also copied to each fragment as well. This is part of the dreaded overhead that plagues the TCP/IP protocol. 


```
+-----------+---------------------------------+
| IP Header |	          Data                |     Original Datagram
+-----------+---------------------------------+


+-----------+--------+ +-----------+--------+ +-----------+--------+
| IP Header |  Data  | | IP Header |  Data  | | IP Header |  Data  |  Fragmented Datagrams
+-----------+--------+ +-----------+--------+ +-----------+--------+
```
Notice the IP header is the same size in each fragment, however, due to the fragmentation, four fields in each header are changed: Total Length, the More Fragments flag is set, Fragment Offset, and the Header Checksum. More on this in a minute...


Now, onto the book's example...



> This 13-bit field shows the relative position of this fragment with respect to the whole datagram. It is the offset of the data in the original datagram measured in units of 8 bytes . If we have a data size of 4000 bytes fragmented into three parts.
> 
> The byte in the original datagram are numbered 0 to 3999.


You should be able to understand this part now. A 13 bit long Fragment Offset field measured in multiples of 8 bytes, which would tell the receiving router the position of that specific fragment. Let's say, for example, that a fragment offset field has a value of 320, then 320*8=2560, which means that particular fragment would start at byte 2560.



> The first datagram carries bytes 0 to 1399. The offset for this datagram is 0/8 = 0.


The first fragment. It starts at byte 0, so the Fragment Offset is set to 0 (zero) in the header. The "More Fragments" flag is set to 1 because there are more fragments being sent.



> The second fragment carries bytes 1400 to 2799; the offset value for this fragment is 1400/8 = 175.


The second fragment. It starts at byte 1400. The Fragment Offset is set to 175 in the header. 175*8 gives you the start position of this datagram (byte 1400). The "More Fragments" flag is set to 1.



> Finally , the third fragment carries bytes 2800 to 3999; the offset value for this fragment is 2800/8 = 350.


The last fragment. It starts at byte 2800. The Fragment Offset is set to 350 in the header. 350*8 gives you the start position of this datagram (byte 2800), however, this isn't really necessary since the "More Fragments" flag is set to 0 (zero) indicating that this is the last fragment.



> Remember that the value of the offset is measured in units 8 bytes. This is done because the length of the offset field is only 13 bits long and cannot represent a sequence of bytes greater than 8191.


This sounds confusing, but it's really not. As you now know, the Fragment Offset field is 13 bits long. The value in this field can only be from 0 to 8191. 8191 is the largest number in binary that can fit into a 13 bit length field. 

8191 in binary is 10000000000100 

If you remember, a bit represents one number (either a 1 or a 0). As you can see, there are 13 bits (numbers) when representing 8191 in binary. This is the maximum number of bits that can fit in the Fragment Offset field. Any number higher than 8191 will go over the 13 bit binary limit.

I hope this helped you to understand what the book was trying to tell you.


----------



## zillah (Mar 18, 2005)

First of all , thanks for this effort.



> I hope this helped you to understand what the book was trying to tell you.


I will go through what you have written carefuly,and I will raise any question not clear.


----------



## zillah (Mar 18, 2005)

> 8191 in binary is 10000000000100


What did you mean here by "10000000000100" ? Why have you not choosen this format for instance "10000110000100" ?


----------



## Resolution (Sep 17, 2005)

Sorry, the binary number I wrote is wrong. I knew I would screw something up typing all of that. Just ignore it.

8191 in binary should be 1111111111111

Count the 1's and 0's and you will see that there are 13 in total, which means that it is 13 bits in length. 8191, in binary notation, is the largest 13 bit number, and the largest number (in binary) that will fit in the fragment offset field.


----------



## Resolution (Sep 17, 2005)

Resolution said:


> Count the 1's and 0's


I meant count the 1's.


----------



## zillah (Mar 18, 2005)

> 8191 in binary should be 1111111111111


Do we need to convert binary number to decimal and add them up like below:

2^0+2^1+2^2+--------+2^10---+2^13=will be more than 8191!!!!


----------



## JamesO (Mar 30, 2005)

Decimal to Binary Conversion 

Or just open up a Windows Calculator (Start, Run, type calc, then enter) and select View and choose Scientific. 

Enter 8191 and then select Bin.

JamesO


----------



## chinti (Feb 8, 2009)

hi
i need a prob solved plz help me


----------



## chinti (Feb 8, 2009)

If a router recieves an IP packet containing 840 data bytes and forwards to a newtwork whose maximum transmission unit of 200 bytes.Assume the IP header is 20 bytes,and show the relevant fields(total length,fragmented offset and more bit fields)of the fragmented segments that are sent by the router


----------



## chinti (Feb 8, 2009)

pls reply me fast anyone i have an exam on feb11


----------



## johnwill (Sep 26, 2002)

From the Tech Support Forum Rules & Conduct



> EDUCATIONAL ASSISTANCE
> 
> While we are happy to promote the education of users, we feel it is inappropriate to circumvent the learning process by directly assisting with assignments and projects of an educational nature. Direct answers to school or college assignments are not allowed and will not be given. However, if a user is having trouble comprehending a certain topic, the members and staff at TSF will be happy to provide assistance with understanding the topic.


----------

