OSI Model

Image of Author
March 22, 2022 (last updated September 1, 2024)

The OSI model, or Open Systems Interconnection model, is a model developed by the OSI group of ISO. (ISO is an international standards body which is well known in the dev community for ISO 8601 for time and date formats).

The Internet Protocol suite is a model developed by IETF. (IETF is the body that controls the well known RFCs that often evolve into standards, specifications, etc).

Theoretical points

The internet is a physical system. It's electrons moving across metals. The reason software developers don't have to think about that is because of all the layers of abstraction they don't have to think about. The deepest layer is the physical layer of the OSI model. The highest layer is the application layer of both the OSI model and IP suite model.

Physical Layer (OSI L1)

This layer is where people get together and choose which physical properties will represent different types of data. They will all agree on things like, "if this metal wire here receives a 5 volt pulse, let that represent a 1-bit". "If this radio receiver registers a phase-shift greater than 90 degrees between these two radio waves, let that represent a 1-bit." (Phase-shift encoding is something like checking every 5 mins on the angle between a minute and hour hand on a clock. If the angle between them is greater than 90 degrees, let that be a 1-bit, otherwise it's a 0-bit. Every 5 mins you'd get a new bit.)

Abstracting over this layer means you don't have to think about the physics of transmitting data anymore. You know you can get 1-bits and 0-bits out of this layer. You are in the world of boolean logic from here on out.

Examples of data transmission using this layer: Ethernet, WiFi

This layer is the lowest digital-only layer, and so is fundamental to networking. It is made to handle transmission issues like: "what happens if two machines send data across the same wire at the same time?" "What happens if a transmission of data fails?" "What if the sender is sending data faster than the receiver can receive it?" "What if the sender switches between ethernet and wifi half way through sending data?"

Your MAC address, or Medium Access Control address, exists to faciliate data transfers across various communication mediums. The MAC sublayer of L2 is a "control abstraction" that is used by the higher-level LLC (Logical Link Control) sublayer of L2, so that the LLC doesn't have to think about the transmission medium, transmission errors, or waiting for receiver availability, etc. This means LLC can concern itself primiarly with multiplexing. (Multiplexing is combining signals together for more efficient communication.)

Abstracting over this layer means you don't have to think about how you transmit data anymore. You can just say to your L2, "here's my packet of data, here's where I want you to send it (aka, here's the MAC address I want you to send it to)."

Network Layer (OSI L3), Internet Layer (IP suite)

Examples of data transmission using this layer: IP, ICMP

This is where the "internet" becomes a thing. This layer is where the IP protocol sits. What if I'm not directly linked (L2) to the computer (MAC adress) I want to send data to? What if the amount of data I what to send is large, and I want to break it down into smaller chunks? How will the receiver reconsititute those chunks? How will the receiver know if some of those chunks of data, or, packets of data, got lost during transmission?

Transport Layer (OSI L4), Transport Layer (IP suite)

Examples of data transmission using this layer: TCP, UDP

This is where "transmission features" live. Once you can actually send data across networks (L3), you now have to ask the question of "how will I send the data"? Do you care if some packets fail to get delivered? Do you care if the receiver is "ready" to receive the data? Do you want the receiver to tell you when it has received a packet, or when to re-send a packet it never received? Do you want to break down individual data packets into even smaller packet segments? How do you want to handle all the different types of errors.

A quick example of the kind of "transmission features" that can exist at this layer, let's look at a difference between TCP and UDP, both of which normally operate over IP (L3). TCP keeps track of packet-loss and packet order, and will resend lost packets. This takes time, and so reliability of transmission is prioritized over speed of delivery. The receiver will keep track of packet order and request re-sending of missing packets. This is overhead that slows down the processing of the packets. TCP/IP is a common protocol pairing due to its reliability. But, if you want to stream data, you will prefer UDP because it doesn't care about dropped packets. It's focused on performance. You don't want to buffer a video while you re-request packets. You instead want to let the pixels glitch-out because they didn't have the packets they needed, but you can still comprehend the video in general, and might not even notice the glitch.

Session Layer (OSI L5) and Presentation Layer (OSI L6)

The confusing nature of these two layers is why the IP suite doesn't include them, and/or wraps all of L5-L7 into the Application Layer. Examples of session layer on wikipediate are RTP, SOCKS, and even the named pipe in unix. It leverages an L4 protocol to transmit packets of data within the context of a larger concept of a session. You can imagine wrapping the TCP packet in another packet with a header of session_id: [number], which would allow the receiver to know which session the TCP packet belonged to.

The presentation layer exists as a translation layer between the "network layers" of L5 and below, and the "application layer" of L7. If this layer is being used, it is translating an L7 protocol to either an L5 or L4 protocol. A good example (arguably) is MIME. You have data to be presented within some L7 application, like in an email client. The application wants to know how to display that. Are these 1s and 0s ASCII text? Is is image data? And emoji? What encoding paradigm do I use to decode these bytes? L6 will do that conversion (or tell L7 how to do it via headers, like the MIME headers in SMTP emails or HTTP requests).

Application Layer (OSI L7), Application Layer (IP suite)

Examples of data transmission using this layer: HTTP, FTP, MQTT, SSH

This is the final layer and controls the end-game communications between devices.

IP suite as OSI L7,4,3,2

When it comes to networking and the internet, some prefer the simplicity of the IP suite over the OSI model because it's a more to-the-point encapsulation of the complexity of networks. It can be hard to understand L5 and L6, and often it will feel like you are working with an L7 technology. So, to some, it's easier to wrap all of this up as the Application Layer vis-a-vie the IP suite. In this paradigm, the Application Layer takes the L4 payload of network data and takes care of preparing for application usage.