Router Switching Function

The router is a device which received a packet from the source on any interface and forwards to their destination on another interface. This is done by router switching function. The router switching function encapsulates packets in the data link frame type for the outgoing data link. The router routing function selects the best path for packet destination and the router switching function encapsulate the packet into the data link frame of the outgoing interface. The router switching function performs the following function with receiving a packet from one network and destined for another network.

1.       Router received Layer 2 encapsulated frame and then de-encapsulates the Layer 2 frame header and trailer.
2.       After De-encapsulation the router read Layer 3 information and the destination IP address of the IP packet to select the best path in the routing table.
3.       When selecting a path for the packet destination, router encapsulates the Layer 3 packet into a new Layer 2 frame and forwards the frame out the exit interface.

Figure 1 to Figure 6 illustrates the packet switching over the routed network. As shown in figure 1, the laptop generates an ICMP message for the server in the topology. The packet is containing layer 3 information of source and destination layer 3 addresses. The source layer 3 address is the address of the laptop and the destination layer 3 address is the IP address of the server. As a packet travels from the source to the destination, the Layer 3 IP addresses do not change because the Layer 3 PDU does not change.

But, the Layer 2 data link addresses change at every hop as the packet is de-encapsulated and re-encapsulated in a new Layer 2 frame by each router. In figure 1 the Layer 3 packet encapsulated for the wireless access point and forwarded to Layer 2 (wireless card of the laptop) and then to Layer 1 for transmitting on port 1. The wireless port is a virtual port, not the physical port.

Encapsulation into a different type of Layer 2 frame than the one type is common for receiving packets. For example, a home router received a frame from the wireless port and then sends it to router 3 over an Ethernet interface. So, the encapsulation for wireless and Ethernet is different. Also, encapsulation for Fast Ethernet, Giga Ethernet, and serial interfaces are different.

Router Switching Function

Figure 2 illustrates that the home router receives the layer 2 packets in the shape of bits from layer 1 and then de-encapsulate; the packet to read layer 3 information. When reading the source and destination the router select the proper outgoing interface and again encapsulate the packet, and send it to Layer 2 and then to Layer 1.

Router Switching Function 6

Notice in the source and destination MAC addresses and IP addresses; at the home router and then on all the router. At each router, the source and destination MAC addresses are changing; but the IP address at each router is not changing.

Router Switching Function 7

Also, notice figure 3 and Figure 4 that the ports between Router3; and Router2 have no MAC addresses in the frame. Because this is a serial link and MAC addresses are only required on multi-access networks, such as Ethernet. A serial link is a point-to-point connection and uses a different Layer 2 frame that not required the MAC address.

Router Switching Function 8

For example, when Ethernet frames received on Router3 from the Fa0/0 interface; destined for Server0, it is de-encapsulated and then re-encapsulated for the serial interface. When Router2 receives the frame, it is de-encapsulated again; and then re-encapsulated into an Ethernet frame with a destination MAC address.

Router Switching Function 9

Router Switching Function 10

The table below better summarizes the process of sending a packet from Laptop 1 to server 0. You can see the packet source IP and MAC address and Destination IP and MAC address. Notice that the source and destination IP address is not changing until the packet is reached to the final destination. But the Source and destination MAC addresses are changing on each hop. At stage 11th where server response to Laptop 1 the source and destination; addresses accordingly changed because now server 0 is sending a reply message to Laptop 1. So, this time the source is server 0.

SerialHopSource IP AddressDestination IP Address Source MAC AddressDestination MAC Address
2Wireless Router172.
10Wireless Router10.200.100.2192.168.0.100--