1

When we sent packets from one router to another router on the network layer and the packet size is greater than the MTU (maximum transferable unit) of the router, we have to fragment the packet. My questions is: suppose we need to add padding bits in last fragment, then where do we add padding bits (in the LSB or MSB) and how does the destination router differentiate between packet bits or padding bits?

midor
  • 5,487
  • 2
  • 23
  • 52
PDP
  • 143
  • 9
  • 1
    Those bits should not be relevant, since each package specifies a specific frame size. Thus the additional bits will nether be visible to anything above the network layer which actually makes sense. – arkascha Sep 27 '15 at 17:16
  • If the last frame not multiple of 8 than we add padding bits and other side router get the data as multiple of 8 and how it calculate actual size of last frame – PDP Sep 27 '15 at 17:23
  • As said: it is explicitly specified inside the package. Take a network sniffer, caputure a few packages and take a look yourself. – arkascha Sep 27 '15 at 17:26
  • I will suggest the same thing as arkascha. Install wire-shark and start looking at the packets flowing in and out of your system. It will help a lot in grasping working of networks and protocols. – Ugnes Oct 24 '16 at 22:07

2 Answers2

2

I want you to consider the following things before:

  • Limit on the maximum size of IP data-gram is imposed by data link protocol.
  • IP is the highest layer protocol that is implemented both at routers and hosts.
  • Reassembly of original data-grams is only done at destination host. This takes off the extra work that need to be done by the routers present in the network core.

I will use the information from the following image to help you get to the answer with an example.
enter image description here

Here initial length of the packet is 2400 bytes which needs to to fragmented according to MTU limit of 1000 bytes.
There are only 13 bits available for the fragment offset and the offset is given as a multiple of eight bytes. This is why the data fields in first and second fragment has size of 976 bytes (It is the highest number divisible by 8, which is smaller than 1000 - 20 bytes). This makes first and second fragment of total size of 996 bytes. The last fragment contains the remaining of 428 bytes of payload (with 448 bytes of total).

Offset can be calculated as 0; 976/8 = 122 and 1952/8 = 244.
When these fragments reach the destination host, reassembly needs to be done. Host uses identification, flag and fragmentation offset for this task. In order to make sure which fragments belong to which data-gram, host uses source, destination addresses and identification to uniquely identify them. Offset values and more fragment bits are used to determine whether all fragments have arrived or not.

Answer to your question
The need to divide payload into multiples of 8 is only required for non-last fragment. Reason of using offset dividing by 8 helps the host to identify the starting address of the next fragment. The host don't need the address of the next fragment if it encounters the last fragment. Thus, no need to worry about payload being multiple of 8 in case of last fragment. Host checks the more fragment flag to identify the last fragment.
A bit of additional information: It is not the responsibility of the network layer to guarantee the delivery of the data-gram. If it encounters that one or more fragment(s) have not arrived then, it simply discards the whole data-gram. Transport layer, which is working above network layer, will take care of this thing, if it is using TCP, by asking the source to re-transmit the data.
Reference: Computer Networking-A Top Down Approach, James F. Kurose, Keith W. Ross (Fifth Edition)

Ugnes
  • 709
  • 1
  • 9
  • 23
0

You don't need to add any padding bits. All bits will be push on down the route until the full frame has been sent.

Donaldr
  • 1
  • 2