OSI Model - The Standardization of Computer Networking
Ding! A new email.
Title: OSI Model & TCP/IP Model - The Standardization of Computer Networking.
How does the internet know I subscribed to TheLearnersWeek? Why doesn’t it send it to someone else? How does a page of words and graphs reach my phone? Will Meng know whether I have clicked the email or not? Will this information return to Meng with the same path?
If you have questions like the above, I am here to solve them in this post.
Introducing the OSI (Open Systems Interconnection) model – a conceptual framework that serves as a foundation for understanding network communication. In this post, let’s embark on a journey to demystify the OSI model, unraveling its layers and uncovering the key principles governing information flow across networks.
OSI has seven layers, each performing a task to ensure the data arrive fast, secure, and complete. I will use the sending and receiving of this newsletter as an example to explain how the OSI model functions.
L7 - Application Layer. This layer represents the applications that we humans directly interact with.
Substack is what I use to compose and send the newsletter. It's the interface through which I create and publish the letter. I can compose my newsletter content, format it, and add any necessary attachments or media. This layer also handles interactions with subscribers (you), managing subscriptions, and delivering notifications. In the context of this specific newsletter, the platform uses SMTP (Simple Mail Transfer Protocol) to transfer emails composed by this article between email clients (you) and Substack servers.
Mail app (Apple Mail, Gmail, Outlook, etc.) is what you use to receive email from the application mail server. It used either POP or IMAP protocols. The main distinction lies in how POP and IMAP handle emails. POP retrieves emails from the server and stores them locally, providing permanent storage. On the other hand, IMAP keeps emails on the server while temporarily caching them locally.
L6 - Presentation Layer. The Presentation layer is responsible for formatting the email content into a suitable format for transmission. This may involve converting the content into HTML or other compatible formats, compressing the data to reduce transmission size, or encrypting the content for security purposes.
I used various formatting options in this newsletter, such as rich text, embedded images, and hyperlinks. When I hit the publish button, the Presentation layer comes into action. It converts the raw content into a standardized format, typically HTML, which email clients and web browsers widely support. During this conversion process, the Presentation layer handles the translation of my formatting choices into HTML tags. It wraps the text in appropriate tags to indicate headings, paragraphs, bold or italic formatting, and other stylistic elements. Images are encoded and embedded using HTML tags, and hyperlinks are converted into clickable anchor tags.
Furthermore, the Presentation layer compresses the newsletter content to reduce the overall file size, allowing for faster transmission and better utilization of network resources. It can also apply encryption algorithms to protect sensitive information within the newsletter, such as subscriber data or embargoed content, ensuring confidentiality during transmission.
On your end, the Presentation layer performs the reverse process. It receives the data packets containing the HTML representation of the newsletter and translates it back into a format that your email client or web browser can interpret. The Presentation layer converts the HTML tags into the appropriate visual elements, such as styled text, images, and clickable links, ensuring that you see the newsletter as I intended.
L5 - Session Layer. In our scenario, the Session layer establishes, maintains, and terminates the session between my laptop browser and the Substack servers. It manages the interaction between the Substack platform and Safari, ensuring a seamless and uninterrupted experience during the newsletter creation and submission process. During the session establishment phase, my identity is verified, and authorized to publish the content I created. When I write the content, the Session layer handles the communication and synchronization between my browser and the Substack servers, facilitating real-time updates and ensuring that the data remains consistent. Once I schedule the post and close the tab, the session will be terminated, and the resources on Safari and Substack servers will be freed up.
L4 - Transport Layer. Once my post (now in HTML format) is ordered to be sent, the Transport layer comes into play. It breaks down the HTML file, according to Transmission Control Protocol (TCP), into smaller data segments suitable for transmission across the network.
TCP adds important control information to each segment, called the segment header. This header includes the source and destination port numbers, sequence numbers, acknowledgment numbers, and error detection codes. These mechanisms help ensure that the data segments are delivered in the correct order, can be reassembled at the destination, and are free from errors. If one segment is lost during transmission, a re-send request is sent to ensure the email can be reconstructed properly.
L3 - Network Layer. Immediately after the segment headers are added, the Network Layer is on the stage. It packs the segments into packets with an additional header called packet header.
The header includes logical addressing like the source IP (Substack server’s IP) and destination IP addresses (your email server’s IP). This addressing scheme allows for proper identification and routing of the data packets. The total number of packets is also included in the header as length. Together with the sequence number inside the segment header, the receiver can determine whether all data pieces have arrived.
Routing is another crucial aspect of the Network layer. It involves determining the most efficient path for the data packets to reach you. The routers along the path use the destination IP address to guide the packets through the network, ensuring they reach the correct destination.
L2 - Data Link Layer. Once the packets arrive at the switch of your local network, the Data Link layer encapsulates them into frames. Frames are the basic data units at this layer and contain the data and control information necessary for transmission in bits. When your phone receives the data through WiFi or a carrier, the bits are decoded from bits into frames. One major difference between a frame and a packet or a segment is that the frame consists of two parts, a frame header and a frame trailer.
The Data Link layer adds the frames' source and destination MAC (Media Access Control) addresses. MAC addresses are unique identifiers assigned to network interfaces, allowing devices on the same local network to distinguish from each other. MAC addresses are physically burnt on the NIC (Network Interface Controller).
L1 - Physical Layer. This is the highway where the stream bits flow from one device to another. It ensures that the email data's electrical, optical, or radio signals are accurately transmitted and received without significant degradation or loss. It manages factors like signal quality, noise, interference, and attenuation to maintain the integrity of the email data during transmission. The ethernet cables, hubs, or modems are located on this layer.
Now you know all layers that data passes through. Let’s put them in a bigger picture.
The drawing symbolizes some possible locations the post passes between my Mac and your phone. When the data follows the layers going downwards, it is called encapsulation. The opposite direction is called decapsulation. Depending on which device is used, the capsulation levels are different along the path. Therefore, a post may pass those layers multiple times at various locations. The data is reconstructed and deconstructed numerous times before reaching the destination. It is fascinating that, given the complexity of the route, our network still manages to deliver data precisely within a snap.