ICMP - Path MTU discovery
Before you start with this tutorial I recommend you to read my first tutorial on ICMP.
Every network on the internet has MTU. MTU is an acronym for Maximum Transmissible Unit. It is defined as the maximum size of the packet that a network can carry. If a packet whose size is more than the size of MTU arrives, it is discarded by the default router or the router which is at the entry point of the network.
It is able to do so because every router has the information about the network to which it is connected to. Not only this, every router has as many IP addresses as the number of interfaces on the router. If suppose a router is connected to 4 different networks using 4 different interfaces then it will have 4 different IP addresses with respect to the networks it is connected to.
This might feel little strange but this is what happens with your computer as well. As many interfaces, you have, that many IP addresses you can get.
Let's now discuss the PMTU problem and how ICMP helps in solving the problem. Consider the following scenario, where we have two nodes namely S the source and D the destination. Both are present in different networks with different MTU sizes. There are two intermediate routers and a network of MTU = 500 Bytes between S and D.
The source should know the minimum MTU of the networks, which comes in the path of the packet transmitted from S to D. If it doesn't know the minimum MTU then every time the packet will be discarded by the network and we will never be able to send the packet from S to D. The solution to this problem is given by ICMP Path MTU discovery technique.
Let's say we want to send some data from S to D. The packet size is 1500 Bytes. We will intentionally set DF = 1 (DF means do not fragment). You will come to know why we have set the DF bit. When this packet is transmitted by S onto the network there could be two chances: 1. The packet size is very big and cannot be forward by the network and eventually, it is discarded 2. The packet is transmitted successfully.
In this case, the packet is transmitted successfully. It is because the network in which we are transmitting the packet is our own network and we would be knowing the MTU of our network. So we will not make packets whose size is greater than our network MTU size.
The problem comes in when the packet crosses the default router of the network. In this case, when the packet reaches router R1 it finds out that network onto another side of the router has lesser MTU and the packet cannot be transmitted further. One obvious choice would be to fragment the packet and then transmit it. But we have set DF = 1. Which means the packet cannot be fragmented.
It is because of this very reason the packet is discarded at the router and an ICMP is sent back to S. ICMP will carry the message that Destination host is unreachable because MTU of next network is 500 Bytes. On reading this message S will create three new packets from 1500 Bytes packet whose MTU = 500 Bytes. Again this packet is transmitted.
Now the packet is rejected by router R2. It is because the MTU of the next network is less than the packet size. Now, router R2 creates an ICMP and sends it back to S. Sender now comes to know that there is a network on the way whose MTU = 300 Bytes. So now it breaks the 1500 Bytes packet into 5 equal parts of size = 300 Bytes.
Again these 5 packets are transmitted by S. Now when these packets reach router R2, they are accepted and delivered to the D. And this is how the ICMP helps in delivering the packets across the networks which have variable MTU sizes.
Now you would have understood why we have set DF = 1. Had we not set DF = 1, the packet would have been fragmented and happily transmitted and we would have never come to know the path MTU.
Now you might get a doubt that why should we do this. Can't we leave DF = 0 and let routers do the fragmentation and then they can easily transmit it. Why do we need to do all this tedious stuff?
Well, it might look tedious but it's the best choice we have.
Assume we have a packet of 1000000 Bytes. Now to send it across the network shown above imagine how much amount of work the routers have to do. To make it worse let's say there are 10,000 packets of the same size. To fragment these many packets and then do the transmission, is very much inefficient.
The better option would be to find out the least MTU and generate packets of that size and then transmit them. This will help routers to process the packets faster and packets will not be discarded due to congestion.
So this was one another application of ICMP which is used everywhere.
Hope this was helpful. If you have any questions related to any of my posts feel free to ask. I will be happy to help you. At the same time, if you have any suggestions for me, you can put it in the comments section below. Do follow us on Facebook and google+ to get latest updates.
Thank you!
No comments :
Post a Comment