In the previous article, we discussed many fundamental concepts of networking.
Now, imagine you're on a WhatsApp video call with your friend.
You're in India, connected to your home Wi-Fi, while your friend is in the US, connected to their home Wi-Fi.
As you speak, your voice and video travel from your phone, through your Wi-Fi router, ISP, and several other networks, before reaching your friend's phone.
All this happens almost instantly!
But what exactly happens to our data during this journey? How does our phone prepare it, how do routers forward it, and how does our friend's phone understand it?
We'll follow the journey in three phases:
- Our phone → Our home router: How our phone prepares and sends the data.
- Our router → Our friend's router: How the data travels across different networks.
- Our friend's router → Our friend's phone: How the data reaches our friend's phone and gets processed.
Along the way, we'll understand how the OSI and TCP/IP models help us organize these networking responsibilities.
Phase 1: From Our Phone to Our Home Router
Let's start with our phone in India.
Before our voice and video can travel to our friend in the US, our phone needs to prepare the data and send it to our home Wi-Fi router.
We'll follow what happens inside our phone, step by step.
OSI Model
The OSI (Open Systems Interconnection) model was developed by the International Organization for Standardization (ISO).
It divides network communication into 7 layers, each with its own responsibility.
Here's how the seven layers are arranged:
1. Application Layer (Layer 7)
So, we've opened WhatsApp and started a video call with our friend.
WhatsApp needs a way to send and receive information over the network, right?
The Application Layer handles how applications exchange information using network protocols.
For example, when we open a website:
- DNS: When we enter a website name like google.com, DNS helps find its IP address so our browser knows which server to connect to.
- HTTP or HTTPS defines how requests are formed and how responses are received.
Similarly, WhatsApp uses communication protocols to initiate calls and exchange information with other devices.
We'll learn more about HTTP, HTTPS, and DNS later.
But where does all this happen?
This mainly happens in the application software and the networking libraries it uses.
For example, when we write code to make an API request, we might use JavaScript's fetch() function. The browser then handles creating the HTTP request using its networking code.
Similarly, WhatsApp's developers write code that uses networking libraries and protocols to communicate with other devices.
So, the Application Layer isn't a separate physical component. It represents the networking responsibilities handled by applications and the software they use.
Now that the application has prepared the information, let's see how the Presentation Layer handles its representation.
2. Presentation Layer (Layer 6)
Our voice and video contain a lot of data. Sending everything in its original form would require transferring a large amount of data, which could make our video call slow.
So, we compress the data to reduce its size.
We also don't want anyone else listening to our conversation, right? So, we encrypt the data to keep it private.
And our friend's phone needs to understand the audio and video format so it can play them correctly.
These are the three main responsibilities of the Presentation Layer:
- Compression: Reducing the size of data so less data needs to be transferred. For example, video codecs like H.264 compress video by reducing repeated information between frames.
- Encoding: Converting data into a specific format. For example, H.264 encodes video so the receiving phone can decode and display it. Similarly, when a website sends text, character encodings like UTF-8 help the browser interpret it correctly.
-
Encryption: Protecting data so others cannot easily understand it. We can see this in two examples:
- WhatsApp video call: WhatsApp uses end-to-end encryption so only the call participants can access the contents of their conversation.
- Opening an HTTPS website: TLS (Transport Layer Security) encrypts the communication between our browser and the website's server. SSL was its older predecessor and is no longer considered secure.
But where does all this happen?
These tasks are handled by software running on our devices, sometimes with help from hardware.
For example, video codecs handle encoding and compression on our phones, while browsers use TLS libraries to protect HTTPS connections.
So, there isn't necessarily a separate Presentation Layer program running on our devices. These are responsibilities grouped under this layer in the OSI model.
Now that our data is prepared, let's see how the communication between devices is managed in the Session Layer.
3. Session Layer (Layer 5)
But the call shouldn't end after sending just one piece of audio or video, right? We need to keep the communication going until one of us ends the call.
The Session Layer represents how communication sessions between applications are established, maintained, and ended.
For example:
- Starting a session: When we start a WhatsApp call, the app sets up the communication needed for the call.
- Maintaining a session: As we continue talking, the app keeps track of the ongoing call.
- Ending a session: When we hang up, the app closes the call session.
We can see something similar when we open a website. After logging in, the website may remember that we're logged in using a session cookie, so we don't have to enter our password on every page.
But remember, a website's login session isn't exactly the same as an OSI Session Layer session. It's an application-level way of maintaining user state.
But where does this happen?
In real applications like WhatsApp, the code responsible for call setup, tracking, and termination handles these tasks. For websites, application code and session-management libraries may handle user sessions.
So, just like the Presentation Layer, we don't necessarily have a separate Session Layer program running on our devices.
Now, we have an ongoing call session, but we still need to move the actual audio and video data between the devices.
Why Do We Have Both OSI and TCP/IP Models?
Until now, we've covered three layers of the OSI model: Application, Presentation, and Session.
If you noticed, most of the work we discussed happens in the application code or the libraries it uses.
For example, WhatsApp manages the call, video codecs handle encoding and compression, and encryption libraries protect the communication.
Since these responsibilities are often handled together in applications, the TCP/IP model groups all three into a single Application Layer.
But why do we have two different models?
Back in the 1970s, researchers were developing TCP/IP to connect different networks. By 1983, TCP/IP was already being used on ARPANET.
Around the same time, different companies had their own networking systems, and getting them to communicate wasn't easy.
So, the International Organization for Standardization (ISO) developed the OSI model to provide a common framework for networking standards. It divided communication into seven layers, making each responsibility clearer.
Over time, TCP/IP became widely adopted because its protocols were already working in real networks, while the OSI protocol suite didn't achieve the same adoption.
But we still use the OSI model to understand networking and troubleshoot problems because its seven layers help us identify where something might be going wrong.
So, we have 7 layers in OSI, while the TCP/IP model is commonly shown with 4 layers.
We'll see how the remaining layers relate to each other as we continue.
Now, let's move to the Transport Layer, which is present in both models.
4. Transport Layer (Layer 4)
Our video call is going on, and our phone has audio and video data to send to our friend.
The Transport Layer handles communication between applications running on different devices.
TCP and UDP
During our video call, if a small piece of audio is lost, waiting for it again might interrupt our conversation.
But if we're transferring an important file, we don't want any part of it missing.
So, the Transport Layer mainly uses two protocols:
- TCP (Transmission Control Protocol): When we need all our data to arrive correctly and in order, TCP takes care of missing data by sending it again.
- UDP (User Datagram Protocol): When receiving data quickly is more important than recovering every missing piece, UDP lets us send data without waiting for those confirmations.
UDP is commonly used for real-time communication like video calls, while TCP is useful for communication that needs reliable delivery.
We'll learn more about both protocols later.
What Happens at the Transport Layer?
1. Segmentation
During our video call, our phone keeps producing audio and video data.
Instead of handling everything as one large piece, the data is handled in smaller pieces.
In TCP, these pieces are called segments, while UDP sends individual messages called datagrams.
We'll understand why dividing data into smaller pieces is useful in a moment.
2. Adding Port Numbers
Our phone might have WhatsApp, Chrome, and other applications running at the same time.
When data arrives, how does our phone know which application should receive it?
The Transport Layer adds source and destination port numbers to help identify the correct application.
For example, HTTPS commonly uses destination port 443.
But what if we open Google and ChatGPT in two different Chrome tabs? Both use HTTPS and commonly connect to port 443, right?
Along with port numbers, the source and destination IP addresses help distinguish different TCP connections.
A TCP connection is identified using four values:
(Source IP, Source Port, Destination IP, Destination Port)
So, even if multiple HTTPS connections use destination port 443, the operating system can identify them correctly.
Note: IP addresses are handled by the Network Layer, which we'll discuss next. The Transport Layer adds the port numbers.
3. Sequence Control
Suppose we send three pieces of data in this order:
1 → 2 → 3
But they arrive in a different order:
2 → 1 → 3
If the application needs the data in the correct order, we must keep track of which piece comes first.
Sequence control helps arrange the received data in the correct order when ordered delivery is required.
4. Flow Control
Suppose our phone sends data faster than our friend's phone can receive it.
If we keep sending too much data, the receiving device's buffer might fill up.
Flow control helps adjust how much data the sender can send based on what the receiver can handle.
5. Error Control
Suppose we send:
1 → 2 → 3
But only 1 → 3 arrives.
The second piece might have been lost somewhere along the way. Sometimes, data might also get corrupted during transmission.
Error control helps detect these problems and, when reliable delivery is needed, recover the missing data.
Why Do We Break Data into Smaller Pieces?
There are a few practical reasons:
- Packet size limits: Networks have limits on how much data can fit into a single packet. We can't send an unlimited amount of data at once.
- Continuous communication: During our video call, smaller pieces can be sent as audio and video are produced, without waiting for a large amount of data to accumulate.
- Easier retransmission: If a piece of data is lost, a reliable protocol can resend the missing data instead of the entire large message.
- Sharing the network: Smaller packets make it easier for different applications, like WhatsApp and YouTube, to share the same network link. Network devices can send packets from different applications without waiting for an entire large transfer to finish.
The last point is also related to packet switching, which we'll understand when discussing how data travels through networks.
Where Does All This Happen?
Most TCP and UDP processing happens inside our phone's operating system, such as Android or iOS.
Applications use networking APIs to send data, while the operating system usually handles these protocols.
So, when we write application code, we don't normally have to manage TCP sequence numbers, acknowledgements, or retransmissions ourselves.
The Transport Layer is present in both the OSI and TCP/IP models.
After handling the outgoing data, it passes it to the Network Layer.
5. Network Layer (Layer 3)
Now, the Transport Layer has handled our data and added the port numbers.
But our friend is connected to a different network in the US. How does the data reach their device?
The Network Layer takes care of getting data from the source device toward the destination device across different networks.
It mainly handles two things:
1. IP Addressing
We already learned about IP addresses in Part 1.
Just like port numbers help identify the correct application, IP addresses help identify the source and destination devices.
The Network Layer adds an IP header containing the source and destination IP addresses.
The data, along with this header, is called an IP packet.
2. Routing
Our friend's phone isn't directly connected to our phone.
The packet may need to pass through several routers before reaching the destination.
Each router checks the destination IP address and uses its routing table to decide where to forward the packet next.
This process is called routing.
Where Does This Happen?
On our phone, the operating system (Android or iOS) creates the IP packet by adding the source and destination IP addresses.
Now, depending on how we're connected to the Internet:
- Wi-Fi: The packet goes through our Wi-Fi router.
- Mobile Data (4G/5G): The packet travels through a nearby mobile tower into our mobile operator's network, such as Jio or Airtel.
From there, routers check the destination IP address and forward the packet toward its destination.
So, the Network Layer works both inside our phone's operating system and in routers across the network.
The Network Layer in OSI is called the Internet Layer in the TCP/IP model.
Now, our packet has the IP addresses needed to travel across networks. But how does it actually move from our phone to the next device?
We'll see that in the Data Link Layer.
6. Data Link Layer (Layer 2)
Our phone has prepared the IP packet, and now it needs to send it to our home Wi-Fi router.
We already know the router's IP address. But how does our phone actually identify the router on the local network?
A MAC (Media Access Control) address is a unique identifier assigned to a network interface, such as the Wi-Fi interface on our phone or router, to identify it on a local network.
So, our phone needs to find the router's MAC address before sending the data.
How Does Our Phone Find the MAC Address?
Suppose our Wi-Fi router's IP address is 192.168.1.1.
Our phone knows this IP address, but it doesn't know the corresponding MAC address.
For IPv4, it uses something called ARP (Address Resolution Protocol).
Our phone sends a broadcast message to the local network, essentially asking:
"Hey, who has the IP address 192.168.1.1? Tell me your MAC address."
Since it's a broadcast, all devices on that local network can receive the request.
The router recognizes its IP address and replies with its MAC address.
Our phone now knows the router's MAC address and saves it in its ARP cache, so it doesn't need to ask again for every packet.
Framing
Now our phone knows where to send the packet on the local network.
The Data Link Layer takes the IP packet and wraps it inside a frame.
For our Wi-Fi connection, the frame includes:
- Source MAC: Our phone's Wi-Fi MAC address.
- Receiver MAC: Our Wi-Fi router's MAC address.
- IP packet: Contains the source and destination IP addresses added by the Network Layer.
Error Detection
The Data Link Layer also adds error-detection information to the frame.
This helps detect whether bits have been corrupted during transmission.
Where Does This Happen?
On our phone, the operating system handles tasks such as finding the router's MAC address using ARP.
The Wi-Fi driver and Wi-Fi hardware work together to prepare the Wi-Fi frame for transmission.
If we use mobile data instead, our phone's cellular modem handles communication with the mobile network using cellular protocols rather than Wi-Fi.
In the TCP/IP model, the Data Link Layer is grouped with the Physical Layer under the Network Access Layer.
Now our phone has prepared the frame with the required information. The Physical Layer takes care of transmitting it as signals over the connection.
7. Physical Layer (Layer 1)
Our phone has prepared the Wi-Fi frame with the required MAC addresses and IP packet.
But everything we've discussed so far is still information inside our phone.
How does this data actually travel from our phone to our Wi-Fi router?
The Physical Layer handles the actual transmission of data through a physical medium, such as wireless signals, electrical signals, or light.
How Does Our Phone Send the Data?
Our Wi-Fi frame contains digital data, represented as bits (0s and 1s).
But our router cannot receive these bits directly from our phone's memory.
They need to be transmitted as signals.
Since we're using Wi-Fi, our phone's Wi-Fi hardware converts the digital information into radio signals and transmits them through the air.
Our router's Wi-Fi hardware receives these signals and recovers the transmitted bits.
What Happens When We Use a Cable?
Not every network connection uses Wi-Fi.
For example, when we connect a computer to a router using an Ethernet cable, the data travels through electrical signals.
Similarly, Internet service providers often use fiber-optic cables to carry data over long distances.
In fiber-optic connections, data is transmitted using light signals.
So, the physical medium changes depending on the connection:
- Wi-Fi: Radio signals through the air.
- Ethernet cables: Electrical signals through copper wires.
- Fiber-optic cables: Light signals through optical fibers.
The Physical Layer defines how bits are represented and transmitted over these different media.
Where Does This Happen?
On our phone, the Wi-Fi hardware, including its radio circuitry and antenna, handles the wireless transmission.
When using mobile data, the phone's cellular modem and antenna communicate with the mobile network using radio signals.
For wired connections, network interface hardware converts digital data into electrical or optical signals, depending on the technology.
So, unlike the upper layers that mainly involve software, the Physical Layer is closely connected to the actual networking hardware.
In the TCP/IP model, the Physical Layer is grouped with the Data Link Layer under the Network Access Layer.
Our data has now left the phone and started its journey through the network.
Phase 2: From Our Router to Our Friend's Router
Our data has reached our home Wi-Fi router in India.
Now, let's see how it travels to our friend's home router in the US.
Physical Layer (Layer 1): Our router receives the Wi-Fi signals from our phone and converts them back into bits.
Data Link Layer (Layer 2): The router processes the Wi-Fi frame and extracts the IP packet.
Network Layer (Layer 3): The router checks the destination IP address and uses its routing table to decide the next hop toward our friend's network.
Data Link Layer (Layer 2): The router prepares the IP packet for the next connection, using the link-layer protocol supported by that connection.
Physical Layer (Layer 1): The router transmits the data toward our Internet Service Provider (ISP), such as Jio or Airtel, through its outgoing connection.
When the packet reaches the ISP's router, the same Layer 1 → Layer 2 → Layer 3 → Layer 2 → Layer 1 process repeats.
This continues as the packet passes through different routers and networks.
Since our friend is in the US, the data may also travel through submarine fiber-optic cables connecting networks across oceans. These cables transmit data using light signals, as we learned in the Physical Layer.
Eventually, the packet reaches our friend's ISP in the US and is forwarded toward their home router.
Throughout this journey, routers mainly use Layers 1, 2, and 3 to forward packets. They don't need to process all seven layers like our phone does.
Now that our data has reached our friend's home router, let's see how it reaches their phone in Phase 3.
Phase 3: From Our Friend's Router to Their Phone
Our data has finally reached our friend's home Wi-Fi router in the US.
Now, the router needs to send it to our friend's phone.
Just like our phone used the router's MAC address in Phase 1, our friend's router uses their phone's MAC address to prepare a Wi-Fi frame.
The router then transmits it using Wi-Fi signals.
But our friend's home might have multiple phones and laptops connected to the same Wi-Fi network.
Since Wi-Fi uses radio signals, other nearby devices may also detect the transmission.
So how do they know which device should accept the data?
The Wi-Fi frame contains the receiver's MAC address.
Each device's Wi-Fi hardware checks this address. If the frame is meant for another device, it normally ignores it without passing the data to the operating system.
Our friend's phone sees that the receiver MAC address matches its own and accepts the frame.
This is called unicast, where data is sent to one specific device rather than broadcast to everyone.
Now, let's see how our friend's phone processes the data through the seven layers, in reverse order.
Physical Layer (Layer 1): The phone's Wi-Fi hardware receives the radio signals and converts them back into bits (
0s and1s).Data Link Layer (Layer 2): The Wi-Fi hardware checks the receiver MAC address, verifies that the frame isn't corrupted, and extracts the IP packet.
Network Layer (Layer 3): The phone checks whether the destination IP address belongs to it. If it does, the IP packet is processed and its contents are passed to the appropriate transport protocol.
Transport Layer (Layer 4): The operating system checks the destination port and other connection information to find the correct application socket. If TCP is being used, it also handles ordering and retransmission of missing data. With UDP, it delivers the received datagram without those guarantees.
Session Layer (Layer 5): WhatsApp identifies the incoming audio and video as part of our ongoing video call.
Presentation Layer (Layer 6): WhatsApp decrypts the data and decodes the compressed audio and video so the phone can play them.
Application Layer (Layer 7): WhatsApp plays our voice through the speaker and displays our video on the screen.
Our voice and video have now reached our friend's phone in the US, after travelling through multiple networks.
When our friend speaks, the same journey happens in the opposite direction, allowing us to have a real-time conversation.
The next time you're on a video call, think about how your voice and video travel through these layers and across different networks before reaching the other person. All of this happens in just milliseconds!









Top comments (0)