Here we will discuss the role of the network layer and data link layer when devices communicating on a remote network. Here is the example of PC1 which is communicating with a web server on a different network.
Role of the Network Layer Addresses
When the sender of the packet is on a different network from the receiver, the source and destination IP addresses will represent hosts on different networks. This will be indicated by the network portion of the IP address of the destination host.
Source IP address
The IP address of the sending device, the client computer PC1: 192.168.5.100.
Destination IP address
The IP address of the receiving device, the server, Web Server: 172.17.5.254.
Important is that the network of both sending and receiving end is different.
Role of the Data Link Layer Addresses
When the sender and receiver of the IP packet are on different networks, the Ethernet data link frame cannot be sent directly to the destination host because the host is not directly reachable in the network of the sender. In that case, the Ethernet frame must be sent to another device known as the router or default gateway. In the present example, the default gateway is R1. R1 has an Ethernet data link address that is on the same network as PC1. This allows PC1 to reach the router directly.
Source MAC address
Sending device MAC address which is PC1 – 22-22-22-22-22-22
Destination MAC address
When the receiving device, the destination IP address, is on a different network from the sending device, the sending device uses the Ethernet MAC address of the default gateway or router. In this example, the destination MAC address is the MAC address of R1’s Ethernet interface, BB-BB-BB-BB-BB-BB. This is the interface that is attached to the same network as PC1.
The Ethernet frame with the encapsulated IP packet can now be transmitted to R1. R1 forwards the packet to the destination, Web Server. This may mean that R1 forwards the packet to another router or directly to Web Server if the destination is on a network connected to R1.
It is important that the IP address of the default gateway be configured on each host on the local network. All packets to a destination on remote networks are sent to the default gateway.