Hi, today I am going to talk about the life of a packet which means the process that happens when an IP packet needs to arrive at a destination that must pass through intermediate routers. This is one of the most important topics to truly understand networking.
When a PC on one subnet wants to communicate with a server or another PC in a different subnet, an IP packet has the potential to cross paths with multiple routers. Each router must perform decapsulation, routing table lookups, ARP if needed and forward packets to the next hop. This happens continually until the packet arrives at the destination. I have put a topology below and will walk through it step by step.

As you can see I have one PC to the left and one PC to the right separated by 3 routers. Say PC1 wants to send a packet to PC2 what would happen? First the packet would go through the process of encapsulation at PC1. When the packet is being encapsulated at the network layer, PC1 will put the destination IP of PC2. But during layer 2 where the destination MAC will be added, the MAC address will not be the MAC address of PC2. Why? Because PC1 can only talk to hosts on their subnet, if PC1 wants to talk to a host on a different subnet, the default gateway in this case Router1 must take care of that traffic. So when adding an ethernet header and trailers, PC1 will put the MAC address of the Router1 interface that is in the same subnet as PC1. If there is no MAC address to the default gateway, an ARP request must be done before the destination MAC is added. Once the MAC address is resolved the data is fully encapsulated and sent to Router1 in this scenario.
Once Router1 receives the data, it will decapsulate the data all the way up until the network layer. It will stop at the network layer, to specifically look at the destination IP. It then does a routing table look up to find a route to a network where the destination IP resides. Once it finds that route, it will either have a next hop address or an outgoing interface to the next hop. In order for the data to be sent, the layer 2 frame must be redone so the source MAC will be the MAC address to Router1 and the destination MAC will be the MAC address of the next hop in this case Router 2. If Router1 does not know Router2’s MAC address, it will send an ARP request and when it receives an ARP reply will add the destination MAC address in the layer 2 frame. The data will then be fully encapsulated and sent on the wire to Router2.
When the encapsulated data arrives at Router2, it will then perform the same process that Router1 did, I will list it in steps this time.
1) Decapsulate all the way up until the network layer
2) Gather destination IP information
3) Perform a routing table look up to match a route with destination IP
4) Find the next hop address
5) Reconstruct layer 2 frame with an updated source and destination MAC address
6) Perform ARP if destination MAC is unknown
7) Fully encapsulate data and send the data over the wire to the next hop
Router 3 will now receive this data, and it is the final router to process this packet. It will perform the same process but a little bit differently. Decapsulate the data until the network layer, see that the destination IP is a host on the same subnet. It will redo the ethernet header and trailer, add the source MAC as its own MAC and the destination MAC as PC2s MAC. It will perform an ARP if needed and then the data will then be fully encapsulated and sent to the host PC2.
PC2 will then decapsulate, when it gets to the network layer it will see that the destination IP matches its own IP meaning that the packet belongs to it. Once it realizes that the packet is meant for them, it will decapsulate the data fully, and be completely processed all the way up to the application layer.
Leave a Reply