Table of Contents
From One Application to Another
The packet journey is the story of how data moves from an application on one device to an application on another device, using the OSI layers in order. In this chapter you will follow that journey once, end to end, without re‑explaining each layer itself. The goal is to see how all the separate pieces you learned fit together in practice.
Imagine you type a URL in your web browser and press Enter. Your browser wants to talk to a web server somewhere on the internet. Everything that happens between these two applications is the packet journey.
Step 1: Application Creates Data
At the source device, the journey begins in the Application layer. The browser creates an HTTP request. This is plain data from the point of view of the lower layers. The Presentation and Session layers prepare and manage this data according to their roles, but for the packet journey you can think of the result as an application message that is ready to be sent to the Transport layer.
The important idea is that the upper layers only care about the meaning of the data, such as “GET this web page,” and do not care how it will be moved across the network.
Step 2: Transport Layer Builds a Segment
The Transport layer receives the application data and wraps it with its own header. If the application chose TCP, the result is a TCP segment. If it chose UDP, the result is a UDP datagram. The transport header includes things like source and destination port numbers and may include sequence and acknowledgment numbers if TCP is used.
This step introduces the first clear end‑to‑end view of communication. The Transport layer at the source is directly concerned with the Transport layer at the destination. It does not care about which routers or paths will be used in between.
As more application data is generated, the Transport layer may split it into multiple segments if it is too large. Each segment will travel separately and can follow its own path through the network.
Step 3: Network Layer Builds a Packet
Next, the segment is handed to the Network layer. The Network layer attaches an IP header and creates an IP packet. Now the data has a source IP address and a destination IP address, which identifies the end devices involved.
At this point, a very important decision happens. The Network layer decides where to send the packet next. The destination IP address does not indicate the next device, but the final device. The network stack compares the destination IP with the local IP configuration and routing information. If the destination is remote, the host selects a default gateway router. If the destination is in the same IP network, the host can send the packet directly to the destination host.
The packet itself does not store the entire path. Routers ahead will make new forwarding decisions for it at each hop.
Step 4: Data Link Layer Builds a Frame
The Network layer passes the IP packet down to the Data Link layer. Here the packet is wrapped again, this time into a frame. The frame includes source and destination MAC (or other link layer) addresses, plus link specific information such as a frame check sequence.
The Data Link layer only cares about the local link. It does not know about the full internet. It needs to find the hardware address of the next device on this link. If the packet should go to the default gateway, the destination MAC address of the frame will be that of the router’s interface. If the packet should go directly to another host on the same network, the destination MAC will be that host’s interface.
If the sender does not know the correct MAC address for a given IP address, it uses a separate protocol, such as ARP, to discover it. Once the MAC address is known, the frame can be completed.
Now the data has three main layers of wrapping: a Transport header inside a Network header inside a Data Link header. Each wrapping was added by a different layer.
Step 5: Physical Layer Sends Bits
The final step on the sending host is the Physical layer. The complete frame is converted into a stream of bits. These bits are then translated into electrical, optical, or radio signals, depending on the medium. The Physical layer is concerned with timing, voltages, light pulses, or radio characteristics, not with addresses or ports.
The bits are sent across the physical medium to the next device, which is often a switch or an access point or a router.
The journey has now left the original host and entered the network.
Step 6: Inside the Local Network
When the first switch receives the incoming signals, its own Physical layer turns them back into bits. It passes these bits to its Data Link layer, which reconstructs the frame. The switch checks the destination MAC address and uses its forwarding table to decide which outgoing port to use.
The key point here is that the switch is only working with frames. It normally does not inspect the IP packet or higher layers. It forwards the frame out toward the selected port, where its Physical layer again converts the frame into signals for the next segment of the link.
As long as the packet stays inside the same local Ethernet segment, intermediate switches will repeat this process. The IP packet and the TCP or UDP segment travel unchanged inside their frame envelope. Only the outermost envelope, the frame, is opened and recreated at each Data Link hop.
The journey across the local network continues until the frame arrives at the next logical device, which could be either the final destination host, if it is local, or a router if the destination is remote.
Step 7: Reaching the First Router
When the frame arrives at a router’s interface, the router’s Physical layer and Data Link layer reconstruct the frame, verify it, and then pass the contained packet up to the Network layer.
Here comes a crucial moment. The router strips off the original Data Link header and trailer. It keeps the IP packet and ignores the old MAC addresses. The Network layer on the router inspects the destination IP address and consults its routing table to decide where the packet should go next.
Important rule: At each router, the IP packet is kept, but the Data Link frame is removed and rebuilt for the next link. Routers forward based on IP addresses, not MAC addresses.
After deciding the next hop, the router hands the packet down to the Data Link layer associated with the outgoing interface.
Step 8: New Link, New Frame
The Data Link layer on the router now builds a new frame for the next link in the path. The source MAC address becomes the router’s outgoing interface MAC. The destination MAC address becomes either the next router’s interface MAC, or the final host’s MAC if this is the last link.
If the next link uses a different technology, such as Ethernet on one side and a point to point link on the other, the frame format itself may change. The packet remains the same IP packet, but the Data Link encapsulation is specific to each link.
The Physical layer on the router then converts the new frame into signals and sends them toward the next hop. The journey then repeats across each segment of the network.
Step 9: Multiple Hops across the Internet
Across the internet, the packet may pass through many routers. At every hop, the same cycle repeats. The router receives a frame, strips its Data Link layer information, examines the IP header, forwards the packet based on its routing table, and constructs a new frame for the outgoing link.
During this part of the journey, the key part that stays consistent end to end is the Network layer view of the packet and the Transport layer segment inside it. The actual physical paths and Data Link formats can vary across segments.
Routers might also modify some fields in the IP header, such as the Time To Live (TTL) value. When TTL reaches zero, the packet is discarded to avoid endless looping.
Important statement: Routers change Data Link layer information hop by hop, but the IP addresses in the Network layer stay the same from source host to destination host.
The packet continues this hop by hop process until it reaches a router that has a directly connected network containing the destination IP address.
Step 10: Final Router to Destination Network
The last router in the path has an interface connected to the destination network. When the packet reaches this router, it is handled just like at previous routers, but the routing decision is now straightforward. The router sees that the destination IP is within one of its directly connected networks.
The router must then deliver the packet directly to the destination host’s MAC address on that local network. It uses the local Data Link protocol, such as Ethernet, to build a frame addressed to the destination host. If it does not know the host’s MAC address, it must discover it using the local address resolution mechanism.
Once this is done, the router’s Data Link layer builds the final frame for the last hop, and the Physical layer sends the bits over the local medium.
Step 11: Arrival at the Destination Host
The destination host receives signals on its network interface. Its Physical layer converts the signals to bits and passes them up to the Data Link layer. The Data Link layer reconstructs the received frame and checks its integrity.
The host checks if the destination MAC address in the frame matches its own interface or possibly a broadcast or multicast value that it is listening for. If it matches, the host accepts the frame and removes the Data Link header and trailer. What remains is the IP packet.
The packet now moves up to the Network layer on the destination host.
Step 12: Network Layer Delivers the Packet
The Network layer on the destination host inspects the IP header. It checks if the destination IP address matches one of its own addresses. If it does, the host accepts the packet.
The Network layer discards the IP header and passes the remaining content, the Transport segment, up to the Transport layer. At this point, the network level journey across routers has ended. The packet is now back inside the destination host.
Step 13: Transport Layer Reassembles Data
At the Transport layer, the host looks at the source and destination port numbers and uses them to identify which application should receive this data. For TCP, the Transport layer might reorder segments, check for missing segments, request retransmissions, and remove any reliability or control information. For UDP, the process is simpler and usually involves less overhead.
If the original application data was split into multiple segments, the Transport layer reassembles them in the correct order before passing them up. It then hands a clean byte stream or message to the upper layers.
From the Transport layer perspective, the journey is complete when all the data has reached the correct application in the correct order.
Step 14: Application Receives the Message
Finally, the Application layer on the destination host receives the reconstructed data, such as an HTTP request. The application can now interpret and respond to it, for example by sending back a web page.
On the return path, the process is mirrored in the opposite direction. The response goes from the application down through the layers, across the network using routers and switches, and back up the stack on the original source.
Throughout this process, each layer only interacts directly with the layers immediately above and below it on the same device. The same numbered layer on different devices communicates using protocols and headers that both ends understand, but no layer directly manipulates another layer on a remote device.
Encapsulation and Decapsulation in the Journey
The concepts of encapsulation and decapsulation are at the core of the packet journey. At the source, each layer adds its own header around the data it receives from the layer above. This is encapsulation. At the destination, each layer removes its own header and hands the remaining data upward. This is decapsulation.
You can visualize a typical journey for a TCP over IP over Ethernet scenario in a simple table.
| Stage | Data unit name | Main header added or removed |
|---|---|---|
| Application creates data | Data | Application header |
| Transport encapsulates | Segment | TCP or UDP header |
| Network encapsulates | Packet | IP header |
| Data Link encapsulates | Frame | MAC and link header and trailer |
| Physical transmits | Bits | Signals on the medium |
| Routers along the path | Packet | Replace frame, keep IP header |
| Destination Data Link layer | Packet | Remove frame header and trailer |
| Destination Network layer | Segment | Remove IP header |
| Destination Transport layer | Data | Remove TCP or UDP header |
| Destination Application | Message | Interprets original content |
Key rule: Encapsulation happens when data moves down the stack on the sender. Decapsulation happens when data moves up the stack on the receiver. Only routers in the middle remove and recreate Data Link headers, not Transport headers.
By following the packet on this complete trip, you can now see how the OSI layers work together as a system. Each layer plays its own specific role in moving data from one application to another, and the packet journey is the combined effect of all these roles working in sequence.