Routing is the logic that is used end-to-end forwarding of data. The logic that works behind these is easy to understand. The PC only has to lead the packet to the nearest router (R1) which is responsible for sending it to the next nearest router (R2). The process continues till the packet reaches its destination. The process can be divided into three stages:
Stage 1: PC1's Logic: Transmitting Data to a Nearby Router
Data has to sent across from one system (PC1) to another system (PC2) which is not housed on the same Ethernet. PC1 is required to forward a packet to a router attached on the same Ethernet. A data link frame is sent by the sender to the router that is closest. The packet is contained in the data part of the frame. The frame brings into use data link layer (Layer 2) addressing contained in the header in order to make sure that the frame is received by the nearest router.
Stage 2: R1 and R2's Logic: Routing (Forwarding) Data across the Network
Both R1 and R2 bring into use a general process for routing of packets. A list of groupings of network layer addresses are contained in the routing table. This is applicable to a specific network layer protocol. In place of having a single entry in a routing table for an individual destination network layer address, a routing table entry is made for each group. Comparison of the destination network layer address with the routing tables is made by the router. An identified match results in the routing table informing the router about the next destination of the packet. The network layer address grouping concept is identical to the U.S. postal code system. For example, in the network who have the address whose address begins with identical values, say 168.1 is present the same Ethernet as the destination system. This means that the there can be a single routing table entry.
The intervening routers undergo identical process. Comparison of the packet's destination network layer (Layer 3) address is made against the groups that are listed in the relevant routing table. The matched entry prompts the router for where the packet has to be next forwarded. Finally the packet gets transmitted to the router (R3) that is connected to the subnet or the network.
Stage 3: R3's Logic: Delivering Data to the End Destination
R3, the last router to a large extent uses identical logic as used for transmitting the packet from R1 to R2. The one point of difference is that R3 is expected to deliver the packet to a system and not to a router. Apparently the difference may not look to be major but there are significant differences in terms of data link layer which is discussed in the next section.
Network Layer Interaction with the Data Link Layer
When the packet is being processed by the network layer protocol, the decision for sending the packet to the right interface is made. A step that precedes the actual placement of bits on the physical interface is the packet is handed over to data link layer protocols. The data link layer protocols prompts the physical layer to forward the data.
The right header and trailer entries are added to the packet by the data link layer. It creates a frame before the same are transmitted over the physical network. Only the packets are forwarded by the process for routing. The packet is delivered end to end using the network layer process by using successive data link headers and trailers. This is done in order to ensure that the packet reaches the next router. Succeeding data link layers transmit the packet from one device to the next.
As the routers build on new data link headers and trailers and the fact that the headers house the data link addresses , the PCs and the routers need to have ways to determine the data link addresses to be used. One of the methods used for this is ARP - Address Resolution Protocol which is used dynamically. There are two main concepts in routing -
- L3 PDU - Layer 3 Protocol Data Units which are based on the destination Layer 3 address contained in the packets.
- Use of data link layer for encapsulating Layer 3 packets to Layer frames preparing them for transmission to successive data links.