Christmas Offer - Every Learner Must Check Out - Flat 88% OFF on All Access Pass
00
days
:
00
hours
:
00
minutes
:
00
seconds
PyNet Labs- Network Automation Specialists

How Does Packet Flow in Network?

Author : PyNet Labs
Last Modified: February 21, 2024 
A blog featured image with text - How does Packet Flow in Network and an image of a basic network topology

Introduction

Packets are the basic units of data that are transmitted over a network. A packet is a small piece of information that contains the source and destination addresses, the data itself, and some additional information for error checking and routing. Packets are sent from one device to another through various intermediate devices, such as routers and switches, until they reach their final destination. But how do packets know where to go and how to get there?

Packet flow in a network refers to the movement of data packets from a source to a destination. These packets contain information and are routed through intermediate devices like routers and switches. They are transmitted, forwarded, and eventually reassembled at the destination, ensuring efficient communication across the network.

In this blog, we will discuss the packet flow in a network, and we will look into different cases, i.e., packet flow in the same network as well as packet flow in different networks.

Let’s begin by first understanding how packets flow in the same network.

How Does Packet Flow in Same Network?

A network is a group of devices connected by a common medium, such as a cable or wireless signal. A network can be divided into smaller segments called subnets, which have their own range of IP addresses. Devices that belong to the same subnet can communicate directly with each other without going through a router. This is called intra-network communication.

Let’s understand the flow of a packet in the same network with the help of an example.

Basic network topology with 4 PCs and a switch in middle. All the 4 PCs are connected to the switch.

In this topology, we have four devices: PC1, PC2, PC3, and PC4. They all belong to the same subnet, 192.168.1.0/24, which means they have IP addresses from 192.168.1.1 to 192.168.1.254. The subnet mask is 255.255.255.0, which means the first three octets of the IP address identify the network, and the last octet identifies the host.

Let us assume that PC1 wants to send a packet to PC4. Below, we will be discussing the process behind it.

First, PC1 needs to know the MAC address of PC4. A MAC address is a unique identifier for a network interface card (NIC), which is the hardware component that connects a device to a network. A MAC address is 48 bits long and usually written in hexadecimal format, such as 00:0C:29:AB:CD:EF.

To find out the MAC address of PC4, PC1 uses a protocol called Address Resolution Protocol (ARP). ARP is used to map an IP address to a MAC address on a local network. PC1 sends an ARP request packet to the broadcast address of the subnet, which is 192.168.1.255. This packet contains the IP address of PC1 and PC4, and the MAC address of PC1.

Network Topology of 4 PCs connected to a single switch in middle and each PC having its own packet.

The ARP request packet reaches all devices on the subnet, but only PC4 responds with an ARP reply packet, which contains its MAC address. PC1 receives the ARP reply packet and stores the mapping of PC4’s IP and MAC addresses in its ARP cache for future reference.

Network Topology with 4 PCs, all connected to a Switch in the middle and PC4 sends ARP Reply to PC1.

Now that PC1 knows the MAC address of PC4, it can send the data packet to it. The data packet contains the source and destination IP addresses, the source and destination MAC addresses, and the data itself.

The data packet reaches the switch, which is a device that forwards packets based on their MAC addresses. The switch has a table called the MAC address table, which stores the mapping of MAC addresses and ports. The switch looks up the destination MAC address of the packet in its MAC address table and finds out which port it is connected to. In this case, it is port 4.

A network topology of 4 PCs connected to a Switch in Middle which also have the packet to be sent to PC4.

The switch forwards the packet to port 4, where PC4 receives it. PC4 checks the destination IP address of the packet and sees that it matches its own IP address. It then processes the data according to the protocol and application.

Network Topology with 4 PCs which are connected to a Switch in middle and PC4 receiving the desired packet.

This is how packet flow works in the same network.

We have now a better understanding of packet flow in the same network. Let’s discuss the flow of a packet in different networks.

How Does Packet Flow in Different Networks?

Sometimes, a device needs to communicate with another device that is not in the same subnet. This is called indirect communication. To communicate with another device in a different subnet, a device needs to use an intermediary device called a router. A router is a device that connects different subnets and forwards packets between them based on their IP addresses.

To communicate with another device in a different subnet, a device needs to know two things: the IP address of the destination device and the IP address of the default gateway. The default gateway is a router that connects the subnet of the source device to other subnets or networks. The default gateway is usually configured by the network administrator or assigned by a protocol called Dynamic Host Configuration Protocol (DHCP).

Let’s understand how packets flow in different networks with the help of an example.

Let us assume that A wants to send a packet to B.

A Network topology containing 2 PCs which are connected to 2 different Switches which are further connected to a single router.

Suppose A has an IP address of 192.168.1.10 and B has an IP address of 10.0.0.20. These two addresses belong to different subnets, so A and B cannot communicate directly with each other.

In this case, A and B need a router to relay their packets between different networks. A router is a device that connects multiple networks and forwards packets based on their destination IP addresses.

To send a packet from A to B, A first needs to find out the IP address of the router’s interface that is connected to its network. This IP address is called the default gateway, and it is usually configured on each device or assigned by a DHCP server.

Suppose A’s default gateway is 192.168.1.1, the IP address of router R1’s interface connected to A’s network. A then sends an ARP request to find R1’s MAC address, just like it did for B before.

R1 responds with its MAC address, which is 00:AA:BB:CC:DD:EE, and A sends the packet to R1 by adding R1’s MAC address as the destination address in the packet header.

R1 receives the packet from A and examines its destination IP address, which is 10.0.0.20. R1 then looks up its routing table to find out which interface it should use to forward the packet to reach that destination.

Suppose R1 has another interface that is connected to another network, which has an IP address of 10.0.0.1 and a subnet mask of 255.255.255.0. This means that R1 can reach any device on the 10.0.0.x network through this interface.

R1 then sends an ARP request to find out B’s MAC address on the 10.0.0.x network, just like A did for R1 before.

B responds with its MAC address, which is 00:66:77:88:99:AA, and R1 sends the packet to B by adding B’s MAC address as the destination address in the packet header.

B receives the packet from R1 and processes it accordingly.

This is how packet flow in different networks.

Frequently Asked Questions

Q1. What is a network packet flow?

A network packet flow is the sequence of packets that travel from a source to a destination in a network.

Q2. What are packets in a network?

Packets are defined as small data units that can be easily transmitted across different devices in a network. These packets contain information about the source, destination, and payload. Packets are transmitted via networking devices known as routers or switches.

Q3. How do packets move in a network?

Packets move in a network based on different network topologies and routing protocols. After reaching the destination, packets are reassembled into original data.

Q4. What are flows in networking?

Flows in networking are defined as the movements of packets, resources, or any other entities over a network of interconnected nodes.

Conclusion

In this blog, we have learned how packets flow in a network, both within the same network and across different networks. We have seen how devices use IP addresses and MAC addresses to identify each other and how they use ARP requests and replies to find out each other’s MAC addresses.

We hope this blog has helped you understand how packet flow in a network works and why it is essential for efficient and reliable communication. If you have any queries or suggestions, please use the comment section below.

Recent Blog Post

Leave a Reply

Your email address will not be published. Required fields are marked *

linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram