From Data to Frame: The Evolution of PDUs Across the OSI Model
Tags: networking, backend, ccn, beginners
Published: 2023-08-26 09:21:44


## Introduction

![intro image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3io9u6vcrk4nkx4tq933.png)
In a recent exploration, I delved into the intricacies of the OSI model, detailing the distinct roles played by each layer throughout the networking stack. If you haven't had the chance to read that article, I recommend starting there [Unpacking The OSI Model](https://dev.to/stungnet/unpacking-the-osi-model-3fha). Building on that foundation, this article aims to dive deeper, specifically focusing on the Protocol Data Units (PDUs) across the OSI layers – illuminating their operations and their crucial encapsulations. So let's commence, by starting at the layer you interact with the: Application Layer.

---

### Application Layer (Layer 7) - Data

Within the Application Layer, the PDU is referred to simply as "Data". This data is raw and unstructured. Meaning it is the user's actual message, the file they're transferring, the content of the webpage they're accessing, or even the video they're streaming. As this data descends the networking stack, it undergoes layers of encapsulation, only to be de-encapsulated at its destination, reverting to its original, unadulterated form. 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w8kzakfasqonhkcawfmh.png)

---

### Presentation Layer (Layer 6) - Data

The PDU within the Presentation layer is still known as "Data", though the Data doesn't remain the same raw data we have in the Application Layer. This Data gets reformatted for compatibility, encrypted for security and compressed for transmission speed. The process here sets the stage for its journey further through the stack.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4c1bex4wf7g1j96bz2u5.png)

---

### Session Layer (Layer 5) - Data

Within the Session Layer, our PDU is still recognized as "Data", marking its final appearance under this name. This layer is crucial in orchestrating the rhythm of communication: it not only establishes, maintains, and terminates sessions between two devices but also ensures the synchronization and structured management of the data being transferred. It's here that the mechanics of dialogue come into play, guaranteeing that the conversation between devices remains harmonious and coordinated.  


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4783bpn80y6uqsxrignt.png)


---

### Transport Layer 4 (Layer 4) - Segment/Datagram

At the Transport Layer, our PDU evolves distinctly, transitioning from the generalized "Data" to either "Segment" (within the realm of TCP) or "Datagram" (when dealing with UDP). This transformation is pivotal to end-to-end communication, as data is systematically divided into segments or datagrams for efficient transport, the PDU gains these essential attributes, encapsulated within what's known as the L4 Header.  
 <br>
**Transport Layer Header (L4 Header):**

- **Type of PDU:** Data is categorized as either "Segment" (TCP) or "Datagram" (UDP).
- **Port Numbers:** PDUs are endowed with source and destination port numbers to guide the data to its designated application.
- **Sequencing:** Every PDU receives a unique sequence number, safeguarding the order of data upon its arrival.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p2zwqt5tinl6p3ij91cr.png)


---

### Network Layer (Layer 3) - Packet

At the Network Layer, our evolving PDU gains another vital header, morphing it into what we recognize as a 'Packet'. This transformation isn't merely structural; the new header equips the packet with essential attributes to navigate the vast topology of interconnected networks. Specifically, it incorporates logical addressing (IP addresses), routing indicators, and other metadata that routers and switches utilize to determine the packet's optimal path through the network. This layer ensures that each packet, regardless of its source or the path it takes, will find its way to its intended destination. 
 <br>
**Network Layer Header (L3 Header):**

- **Logical Addressing:** The introduction of source and destination IP addresses.
- **Lifetime Management:** Incorporation of the TTL field.
- **Service Type Specification:** The addition of the ToS field.
- **Header Integrity:** Implementation of the header checksum.
- **Protocol Specification:** Insertion of the protocol number.
- **Packet Size Management:** Fragmentation and reassembly details added.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xrcgw5lt51wnra3lcdwq.png)


---
### Data Link Layer (Layer 2) - Frame

At the Data Link Layer, our PDU is framed and readied for its voyage across the local network. This encapsulation introduces the frame's 'local address', guiding it toward its destination within the immediate network. Moreover, mechanisms such as error-checking ensure its safe transit.  
 <br> 
**Data Link Layer Header (Frame Header):**
- **Source MAC Address:** A unique identifier hardwired into the sending device's network interface card.
- **Destination MAC Address:** The physical address of the intended recipient within the local network.
- **Type/Length Field:** Indicates either the type of protocol encapsulated within or the frame's length.
 
**Data Link Layer Trailer (Frame Trailer):**

- **Frame Check Sequence (FCS):** A CRC-based value, calculated from the frame's content, ensuring transmission accuracy.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jk6n00vfpd83j19v3odu.png)

---
### Physical Layer (Layer 1) - Bits
Entering the foundational depths of our OSI journey, we reach the Physical Layer. Here, our meticulously crafted frame is translated into electrical pulses, optical signals, or radio waves, depending on the transmission medium. It's not about the content anymore; it's about the signal and its representation. This layer doesn't concern itself with headers or PDUs; it simply transmits raw binary data, one bit at a time.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m5p20ydx4173zk1p3lwo.png)

---

### Conclusion

As we journeyed through the OSI model, we've observed data undergoing encapsulation, layer by layer, prepped for its digital voyage. But this is only half the tale. For the end user to interact with this data, the reverse occurs. De-encapsulation systematically peels away the headers, restoring the data to its original form at the Application Layer. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q8ilutm69gnv51jbk5a0.png)
 <br>
However, it's worth noting that while the OSI provides a structured blueprint, it's primarily a conceptual model. In practice, data handling might not always align perfectly with each OSI layer's defined function. In every online exchange, it's these rapid, detailed processes that make our digital communications possible. Truly, it showcases the wonders of today's network technologies. Thank you for joining me on this exploration, and I appreciate your time spent reading!  

---

_In my upcoming blog post, I'll delve deeper into this subject using Packet Tracer, offering a hands-on, simulated exploration of networking intricacies. Stay tuned for a dynamic journey through virtual network configurations!_