This tutorial will be going over the basic information of how a router routes IP packets. Routers are used in the OSI layer three or the network layer. These routers have IP addresses and forward IP packets to the proper destination. This guide is somewhat basic and is assuming you have some information of how IP addressing works and along with what routing protocols are.
So let’s focus first on how a host or a computer forwards traffic and then look at how a router forwards traffic. Computers forward or send packets based on these two steps.
If the destination IP address is in the same network or subnet as PC-1 then send the packet directly to that host (without the routers help)
For example PC-1 (192.168.1.1) is trying to send to PC-2 (192.1681.2) since both of these computers are on the same network, (PC-1 checks the destination subnet mask and IP address to see if they are on the same network which they are) if PC-1 knows the MAC address of PC-2 it will put the IP address of PC-2 in the destination address field along with other information not related to this tutorial and forward the packet. If PC-1 does not know the MAC address it will send and ARP request, what this request does is send a broadcast message to all other PCs and devices connected on the 192.168.1.0 network. This message wants to find the MAC address of the host connected to 192.168.1.2, once PC-2 gets the message it will send its MAC address to PC-1. PC-1 will then forward the packet to PC-2.
If the destination IP address is not in the same subnet or network has PC-1 then PC-1 will send the packet to its default gateway.
- If PC-1 does not have the MAC address to the default gateway (R1) then send a ARP request to get the MAC address
For example PC-1 (192.168.1.1) is trying to send to R1 (192.168.1.254) because the packet is not in the same network, PC-1’s main goal is to send to a webserver (22.214.171.124) (PC-1 checks the destination subnet mask and IP address to see if they are on the same network which they are not) if PC-1 knows the MAC address of R1 it will put the IP address of R1 in the destination address field along with other information not related to this tutorial, and forward the packet. If PC-1 does not know the MAC address it will send and ARP request, what this request does is send a broadcast message to all other PCs and devices connected on the 192.168.1.0 network. This message wants to find the MAC address of the host connected to 192.168.1.254, once R1 gets the message it will send its MAC address to PC-1. PC-1 will then forward the packet/frame.
Once the frame is received by R1 the router will first check the data-link FCS field. If the frame received errors the router will drop the packet. If the frame has no errors the router will rip off the old data link header and trailer and then look at the IP packet. The router then compares the IP packet’s destination address. If the router has the IP address in its routing table the router will encapsulate the IP packet inside a new data link layer header and trailer and forward it out the correct interface, thus forwarding the frame.
Confusued? Let’s go into some more detail of what happened.
Looking at the topology PC-1 wants to send a packet to the web server. Since the web server is not on PC-1’s network it will need to send the packet to its default gateway which is R1. PC-1 will build an IP packet with the destination IP address of the web server (126.96.36.199). PC-1 sends this has an Ethernet frame with the destination IP address of R1 and has the MAC address of R1.
R1 receives the frame and because the MAC address matches R1, the router will copy the frame and process it. R1 checks the FCS and no errors have occurred, next the router will then discard the old Ethernet header and trailer. R1 will compare the address and see if it has a match in its routing table; if there is not match the router will drop the frame. However the router finds an entry in its table to (188.8.131.52) the frame is forwarded out the router serial interface. The router encapsulates the packet and forwards out serial interface in an HDLC frame towards the next router.
This will repeat the same steps in each router as along as the routers have a route to that destination it will then eventually be received by the router connected to the web server. This router will send an ARP message that wants to know who is 184.108.40.206? That broadcast message will be received by all devices connected to the 220.127.116.11 network. The web server will respond and send the MAC address to the router and the router will then forward the packet to the web server.
That’s the basic understanding of how routers forward traffic, this tutorial only scratched the surface with how routers route along with keeping it simple some things were skipped in this tutorial. If you would like to find more information take a look at Cisco.com which is a great place to get started. Questions or comments are also welcomed.