This tutorial explains basic IP routing process step by step with examples.
When we talk about routing protocol, first thing that comes in our mind is routing. Basically routing is a process of taking packet from one device and sending it to another device on a different network. Routers are used for routing. Every packet has two address; source and destination. Router uses destination address to deliver the packet.
In following figure we have two PCs. Both are located in different network. Assume that PC0 sends a packet to PC1. It will go through the following steps.
Upper layers (application, presentation, session) and transport layer prepare the data segments and handed down to network layer.
Network layer determines the routed protocol. Routed protocol is used to transmit user data packet across the network. IP and IPX are the example of routed protocol. CCNA exam syllabus includes only IP protocol. Thus we will also use IP protocol to explain the routing.
Network layer attaches IP header to the segment. With IP header segment becomes packet. IP header includes several fields. One of them is the destination address filed. It plays leading role in routing. Based on it network layer decides whether packet will remain in local network or goes to the remote network. All remote requests are sent to the default gateway. Default gateway is the router that switches packets between different networks.
Since our destination address is located in remote network, the packet need to be sent to the default gateway.
Network layer handed down this packet to Data link layer. Data link layer appends header. It adds source and destination MAC address in header and FCS in tail. After this modification packet becomes frame.
Data link layer uses ARP cache to resolve MAC address. If destination IP address is located in local network, hosts MAC address will be used. If destination IP address is located in remote network then default gateways MAC address will be used. In our example, destination address is located in remote network so default gateways MAC address will be used.
Frames are converted in signals. Physical layer puts these signals in media. Media carries these signals across the network.
Every device in collision domain receives these signals. Signals are converted in frame. Frame has destination MAC address. Device matches destination MAC address of frame with its own MAC address. If both addresses do not match, the frame is discarded.
Router receives these signals in FastEthernet port 0/0. It converts signals in frame. It compares MAC address. Since both MAC addresses are same, frame will be processed.
Packet will be pulled from frame. Packet contains destination IP address.
Router only matches network portion from IP address. Routing table is built from network address rather than host address.
Router checks its routing table for destination IP address network.
Routing table must have an entry for destination address network otherwise packet will be discarded immediately.
If router finds an entry for destination address network in routing table, the packet will be switched to the exit interface. In our example it will be FastEthernet 0/1.
Exit interface uses ARP protocol to find the MAC address of destination host. It converts packet in frame by attaching header and tail. In header it adds its MAC address in source MAC address field and destination hosts MAC address in destination MAC address field.
Frame is converted in signals. These signals are put in physical media.
All devices in collision domain receive these signals. PC1 also receives these signals. It converts signals in frame.
Frame has its MAC address in destination MAC address field. So it will pull packet from frame and hand over the packet to network layer.
Network layer checks IP address in destination IP address fields and compare it with its own IP address.
If both addresses match, packet will be processed. Segments will be pulled from packet.
Segments will be handed over to the transport layer.
Transport layer reassemble segments in data and gives it to upper layer.
Upper layers (session, presentation, application) process data and present it to user.
Same process is repeated every time when two hosts communicate with each other via router. Routing is a complex process. Every step given above has several additional steps and has added complexity. In this article we explained this complex process in easy steps. Following articles of this series will describe routing in more details.