The Wayback Machine - https://web.archive.org/web/20240811222915/https://www.geeksforgeeks.org/packet-flow-in-the-same-network/
Open In App

Packet flow in the same Network

Last Updated : 13 Jun, 2022
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

Prerequisite – How ARP works? 
To transfer a packet from source to destination, both the MAC address and IP address of the destination should be known. If the destination MAC address is not present then ARP will resolve this issue first then the packet will be delivered to a destination host. 

There are simple rules for a packet flow in a network: 

  1. If the destination host is present in the same network as the source host then the packet will be delivered directly to the destination host using MAC address.
  2. Within a network, the packet will be delivered on the basis of MAC address.
  3. MAC address never crosses its broadcast domain.

Now, first, we have to take an idea about ARP. 

Address Resolution Protocol – 
Address Resolution Protocol is a layer 2(Data link layer) protocol that is used to find the MAC address of the known IP address. 

There are some important terms associated with ARP: 

ARP cache is a table maintained by ARP that contains an IP address with its associated MAC address and type. If MAC address is learned dynamically then the type will be dynamic and if MAC address is added manually then the type will be static. 

ARP request is a broadcast message generated by the source to find the destination MAC address if the ARP is not resolved initially. 

ARP reply is a unicast message from destination to source device containing the destination MAC address. 

Explanation –  

The steps included in the ARP process are as follows:- 

When a source wants to send a packet to the destination device then, 

1. The source ARP cache is checked if the ARP is resolved or not. If the ARP is not resolved, it puts the packet on hold and generates an ARP request. 

2. If the ARP is already resolved then the packet will be delivered to the destination host.

3. The ARP request is broadcast all over the network to find out the device has a destination IP address. 
Note – If the destination is present in the same network then ARP will find out destination MAC address but if it is present in a different network then ARP will find out default gateway MAC address. 

4. When the device having the destination IP address receives the ARP request, it updates its own ARP cache.

5. The destination host machine generates an ARP reply containing its own MAC address.

6. Now, the device having the source IP address receives the ARP reply and updates its ARP cache. 

7. Since, both source and destination IP address and MAC address are available now, therefore, the packet is delivered to the destination host.

Now, we have taken an idea about the ARP protocol. Let’s see about the packet flow. 

Now we will understand how the packet is delivered to the destination when the destination is present in the same network(network of the source). 

Here is the topology in which host A has IP address 192.168.1.1, host B has IP address 192.168.1.2, and the router has IP address 192.168.1.3 on interface fa0/0. 

Now how to source device will know that the destination is present in the same or different network. Let us understand:- 

AND operation is performed between the source IP address, source subnet mask and destination IP address, source subnet mask. If the resultant of both are the same then the destination is present in the same network otherwise in a different network. 

Let us try to ping host B from host A. 

As you can see 2 packets are generated, one of ICMP and the other of ARP(green). ARP frame is generated because host A has not yet communicated to host B i.e. the ARP has not been resolved i.e ARP will be resolved first so that host A has an entry for host B MAC address. 

As already explained the ARP request will be broadcast first for the target IP address within the network because routers do not forward broadcast packets. The broadcast request is received by the switch as shown in the above figure. 

The switch broadcasts the ARP request as the entry in the ethernet header is FFFF.FFFF.FFFF (broadcast MAC address). 

The request is received by Host B as shown in the above figure. Host B generates an ARP reply immediately specifying its own MAC address. 

 

Now the host B unicast the ARP reply to host A which is received by the switch which in turn forward it to host A as shown in the above 2 figures. 

Note – 
The switch is able to unicast the reply because the switch has put an entry for host A in its MAC table when hosting A broadcasts the ARP request.in the same way, a switch has also put an entry for the host B when the switch receives

 the ARP reply. 

Now the ARP has been resolved and the ICMP will be unicast to the host B from host A(as shown above).  

Now the ICMP acknowledgement packet will be unicast from host B to host A i.e. host B is successfully pinged from host A as shown in the above figures. 

 



Similar Reads

Packet flow in different Network
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 destina
4 min read
Setting up a Basic Home Network using Packet Tracer
Packet Tracer is a network simulation tool that allows us to create network topologies by building virtual networking devices. Packet Tracer is highly encouraged for network enthusiasts as it allows them to have keen in-depth knowledge of networking. Let us see how to easily create a simple home network using Packet Tracer. Step-1: Open Packet Trac
1 min read
How to Connect Between Devices Via Network Wire on Cisco Packet Tracer(Virtual Program)?
In this article, we will look into how we can connect two computers/laptops using a virtual program called CISCO Packet Tracer. It can help us share files among the systems easily. A virtual program is used to set up the appropriate connection as it gives us a brief idea about the requirements for establishing a physical connection like hubs, switc
3 min read
Types of EIGRP Packet in Computer Network
EIGRP (Enhanced Interior Gateway Routing Protocol) is a distance-vector routing protocol that is used to automate routing decisions and configuration on a computer network. It's a network protocol that allows routers to exchange data more quickly than prior protocols like the Interior Gateway Routing Protocol (IGRP) or the Border Gateway Protocol (
10 min read
Network Monitoring and Packet Capture Techniques
Computer networking is the interconnection of some devices which can communicate and exchange data among themselves. The communication can be either wired or wireless. In this article we will discuss how we can monitor and packet packets. What is Network Monitoring and Packet Capture?Network monitoring is the process of continuously monitoring a ne
6 min read
Packet Sniffing and Network Analysis Tools: Wireshark, tcpdump
Packet sniffing means intercepting data packets as they pass through a network, just like looking inside envelopes in the mail. Experts use tools like Wireshark and tcpdump to track, troubleshoot, or secure networks. The packet analyzer Wireshark, or just Shark for short, functions as a magnifying glass; it captures and organizes the packets so you
6 min read
How does the Packet Find the Shortest Path in a Computer Network?
Answer: Packets find the shortest path in a computer network using routing algorithms like OSPF or BGP, which calculate the most efficient route based on various metrics.Routing AlgorithmsVarious routing algorithms determine the shortest path for packets to travel from the source to the destination. Examples include Dijkstra's algorithm, Bellman-Fo
1 min read
Packet Switching and Delays in Computer Network
Packet Switching in computer networks is a method of transferring data to a network in the form of packets. In order to transfer the file fast and efficiently over the network and minimize the transmission latency, the data is broken into small pieces of variable length, called Packet. At the destination, all these small parts (packets) have to be
6 min read
Why Star network is More Efficient in Network Fault Tolerance in Place of Bus Network?
Answer: Star networks offer better fault tolerance than bus networks because a single point of failure in a star network (the central hub) affects only the connected device, while a fault in a bus network can disrupt communication for all devices on the bus.Advantages of Star Topology Over Bus Topology Individual Connection Points: In a star networ
2 min read
Cuts and Network Flow
The backbone analysis of any network is broadly accomplished by using Graph Theory and its Algorithms. The performance constraints are Reliability, Delay/Throughput and the goal is to minimize cost. In the backbone designing of a network the concerned points and considerations are : What should be the backbone topology ?Assignment of Line Capacitie
4 min read
Article Tags :
three90RightbarBannerImg