Understanding TCP /IP communication between two networks

network communicationThe article explains the protocols and technology which is involved when two computers on different TCP/IP networks communicate with each other.

In the diagram, a router is used to segregate two networks. The networks are and The corresponding interface IP address on the routers are and as shown in the diagram.

The interfaces on the router are connected to ports on the switch , to which the computers are connected. The IP address of the computers are (PC1) and (PC2).

Take a scenario where PC1 wants to communicate with PC2.  For the communication to be succesfull, the TCP/IP adapter settings of PC1 and PC2 should be configured with the corresponding gateway addresses. The gateway addresses are required , since , communication is to be achieved between devices on two different networks.

The gateway for PC1 should be a device , which is accessible to it , and which is capable of forwarding the information to the intended network. In the diagram, the router would be the ideal gateway. But the router has two interfaces, which are configured for two different IP addresses.

 So which IP address should the PCs use. For example, the IP address should be used as the gateway IP address for PC1 and IP address should be used as the gateway IP address for PC2. What would happen if is used as the gateway for PC1 ?

PC1 would not be able to access it since , the IP address ( itself is on a different network.Gateways are devices which should belong to the same network, and has knowledge about how to reach other networks. The following sequence of events follow, once the TCP/IP adapter settings is configured with the gateway address.

1. PC1 pings PC2

2. The routing table on PC1 identifies that PC2 ( is on a different network

3. The packet would be sent to the gateway IP address configured on the PC as the destination is on a different network and the PC does not have any other option as a specific route to the network is unavailable on the routing table of the PC.  

4. Since the specific route is unavailable, the default route on the PC, which is populated by the operating system after the gateway IP address is configure would be used.

5. The packet has to be encapsulated in a frame and sent to the gateway

6. To generate the frame, the destination mac-address of the gateway is required.

7. PC1 sends ARP request to find out the mac-address of the interface of the router configured with the IP address ( Note: If the ARP Cache on the PC contains the IP/Mac mapping for, this step would skipped and the frame encapsulating the IP packet would be sent directly to

8. The router responds with an ARP reply.

9. PC1 uses the mac-address in the ARP reply, constructs the frame and sends the packet to the router.

10. The router is configured with two IP addresses, and When configured, routing tables are populated and and ( the corresponding network addresses) are listed as directly connected networks.

11. When the packet reaches the router, the destination IP address is looked into ( The router checks if it is aware of the destination network for the destination IP packet.

12. Since the network is a directly connected network, the router knows which interface to use.

13. The router sends out an ARP request to find out the mac-address of PC2 (( Note: If the ARP Cache on the router contains the IP/Mac mapping for PC2, this step would be skipped and Step 15 would be executed)

14. PC2 would send an ARP Reply with it's mac-address.

15. The router would encapsulate the packet with the new frame, where the source mac-address is the mac-address of the interface corresponding to and the destination mac-address would be PC2'S

Check out my Ebook TCP/IP Interview Questions and answers - http://tcpipguru.com/tcpip-interview-questions-answers/

Comments (1)

9. PC will construct Ethernet II type Ethernet frame.

Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.