Packet flow in different Network
Last Updated :
25 Oct, 2021
Prerequisite - How ARP works, Packet flow in the same network
To deliver the packet to the destination host, the source IP, destination IP, source MAC address and destination MAC address should be known. Some basic rules for the packet flow:
- If the destination host is present in the same network, then the packet is delivered directly to the destination host.
- If the destination host is present in a different network then the packet is delivered to the default gateway first which in turn delivers the packet to the destination host.
- If ARP is not resolved then ARP will be resolved first.
- MAC address never crosses its broadcast domain.
Explanation -
Here is a topology, in which there is host A (IP address - 10.0.0.10 and MAC address - 000D.BD22.7C22), host C (IP address - 10.0.0.9), host B (IP address - 20.0.0.10), host C (IP address-20.0.0.9 and MAC address - 00E0.A3E2.03DC) and the router (IP address - 10.0.0.20 and MAC address - 000B.BE8E.5201 on fa0/0,IP address - 20.0.0.20 and MAC address - 000B.BE8E.5202 on fa0/1 ).
Now we will try to ping from host A (IP address - 10.0.0.10) to host B (IP address - 20.0.0.10). First, AND operation is performed by source host between source IP address, source subnet mask, and destination IP address, source subnet mask to know if the destination is present in same or different network.
If the result is the same then the destination is in the same network otherwise in a different network. Here, the destination is present in different networks, therefore, the result will be different and the packet will be delivered to a default gateway.
We see that 2 messages are generated ICMP(purple) and ARP(green). ARP has been generated because ARP has not been resolved.
Now as the ARP should be resolved first, therefore the ARP request will be broadcast which is received by switch:
The switch in turn broadcast the ARP request to the host and the router. The PC discards the request and the router accepts it.
Now the ARP reply is unicast to host A by the router as shown in the above figure.
Now the ICMP packet will be unicast to the default gateway (IP address - 10.0.0.20 and MAC address - 000B.BE8E.5201) as shown in the above figures.
Note - The ICMP packet will be unicast to the default gateway as the ARP has been resolved now.
Now the ARP has to be resolved again because the router has to deliver the packet to host B and the ARP table has no entry for host B. Therefore, the ARP request is broadcast in the network 20.0.0.0/24. The packet is received by the Switch which in turn broadcast the request to host B and D. Host D will reject the request and host B will accept it and generate an ARP reply for the MAC address 000B.BE8E.5202 (router fa0/1 MAC address) because the ARP reply has to be given to that MAC address from which the ARP request has been received.
As you can see in the figure, the ARP reply packet is unicast to the router's interface fa0/1 MAC address(000B.BE8E.5202) and the source MAC is 00E0.A3E2.03DC.
Note - Here, the target MAC address is the MAC address of host B (000B.BE8E.5202). Target MAC address is the MAC address of a device that the host wants to know through its ARP request to resolve ARP.
Now the ICMP echo-request packet will be unicast to the host B as shown in the above 3 figures.
Host B will generate an ICMP echo reply in response to the ICMP echo request for host A which will be delivered to the 20.0.0.20 (router's interface IP address) first and then unicast to host A.
How does the MAC address never crosses its broadcast domain?
This is the IP and Ethernet header when host A forwards the ICMP echo request to its default gateway. Therefore source IP is 10.0.0.10 and destination IP is 10.0.0.20, source MAC address is 000D.BD22.7C22 (host A MAC address) and destination MAC address is 000B.BE8E.5201 (router's fa0/0 interface MAC address).
But now when the ICMP echo request message is forwarded from the router's fa0/1 interface to host B then the source MAC address is changed to 000B.BE8E.5202 (router's fa0/1 interface MAC address) and destination MAC address is 00E0.A3E2.03DC (host B MAC address).
Here router's fa0/0 interface MAC address is not used as the source MAC address, instead the fa0/1 MAC address is used as a MAC address. Therefore, fa0/0 is not used in other broadcast domains (20.0.0.0/24 network) therefore MAC address never crosses its broadcast domain. IN this way, PING is performed in 2 different networks.
Similar Reads
What is OSI Model? - Layers of OSI Model The OSI (Open Systems Interconnection) Model is a set of rules that explains how different computer systems communicate over a network. OSI Model was developed by the International Organization for Standardization (ISO). The OSI Model consists of 7 layers and each layer has specific functions and re
13 min read
SQL Commands | DDL, DQL, DML, DCL and TCL Commands SQL commands are crucial for managing databases effectively. These commands are divided into categories such as Data Definition Language (DDL), Data Manipulation Language (DML), Data Control Language (DCL), Data Query Language (DQL), and Transaction Control Language (TCL). In this article, we will e
7 min read
TCP/IP Model The TCP/IP model is a framework that is used to model the communication in a network. It is mainly a collection of network protocols and organization of these protocols in different layers for modeling the network.It has four layers, Application, Transport, Network/Internet and Network Access.While
7 min read
Types of Network Topology Network topology refers to the arrangement of different elements like nodes, links, or devices in a computer network. Common types of network topology include bus, star, ring, mesh, and tree topologies, each with its advantages and disadvantages. In this article, we will discuss different types of n
12 min read
Computer Network Tutorial A Computer Network is a system where two or more devices are linked together to share data, resources and information. These networks can range from simple setups, like connecting two devices in your home, to massive global systems, like the Internet. Below are the main components of a computer netw
7 min read
Basics of Computer Networking A computer network is a collection of interconnected devices that share resources and information. These devices can include computers, servers, printers, and other hardware. Networks allow for the efficient exchange of data, enabling various applications such as email, file sharing, and internet br
14 min read
Java Programs - Java Programming Examples In this article, we will learn and prepare for Interviews using Java Programming Examples. From basic Java programs like the Fibonacci series, Prime numbers, Factorial numbers, and Palindrome numbers to advanced Java programs.Java is one of the most popular programming languages today because of its
8 min read
Unified Modeling Language (UML) Diagrams Unified Modeling Language (UML) is a general-purpose modeling language. The main aim of UML is to define a standard way to visualize the way a system has been designed. It is quite similar to blueprints used in other fields of engineering. UML is not a programming language, it is rather a visual lan
14 min read
Second Largest Element in an Array Given an array of positive integers arr[] of size n, the task is to find second largest distinct element in the array.Note: If the second largest element does not exist, return -1. Examples:Input: arr[] = [12, 35, 1, 10, 34, 1]Output: 34Explanation: The largest element of the array is 35 and the sec
14 min read
Introduction to Java Java is a high-level, object-oriented programming language developed by Sun Microsystems in 1995. It is platform-independent, which means we can write code once and run it anywhere using the Java Virtual Machine (JVM). Java is mostly used for building desktop applications, web applications, Android
4 min read