The OSI Model

The OSI model, or Open Systems Interconnection model, is a way of thinking about computer networking (specifically, the functionality and protocols that comprise it) as different layers of abstraction.

There are 7 layers: physical, data-link, network, transport, session, presentation and application. The layers build on one another, so each layer depends on the functionality of lower layers, and provides functionality to the layers above it.

Admittedly (at the time of writing this), networking isn’t something I know in-depth… yet. I have an EE degree and am searching out the CS concepts that I haven’t picked up by osmosis or studying during my time as a programmer. My takeaway so far is that the OSI Model is a nice taxonomy for understanding how computer networking happens. But… it doesn’t necessarily buy you anything in “real life”. It’s more of a compass than a detailed map.

Why do I need to know this? What is it used for?

Communicating with another computer is a much more involved involved process than you might think. Sleek, modern technology and UX hides a lot of the complexity from us as users.

But, as programmers, we need a way of reasoning about the complicated and interrelated set of protocols used for devices to communicate with one another.

By separating these protocols into layers of abstraction, we can reason about the system a little bit easier. It also gives us a shared model to talk about when discussing things with other programmers.  If/when new protocols are developed, there’s a taxonomy to add them into (the OSI model).

A not-quite-perfect analogy might be bodily systems. There’s the nervous system, skeletal system, muscular system, and so on. They each have their own set of functions, and interact with other systems.  When you want to do a certain task (for example, move your arm), the systems must communicate with one another to execute that task. For example, the nervous system might tell the muscular system to engage in a certain way to change the positioning of your arm.

Like the OSI model, some systems require other systems to serve underlying functions. For example, the muscular system would have a tough time without the framework of the skeletal system. Similarly, some systems serve higher-order systems, like how the muscular system relies on the nervous system to provide electrical signals and tell it what to do.

Of course, this isn’t a perfect metaphor.  For instance, the body systems example isn’t as strictly hierarchical as the OSI model. Still, it helped me understand the point of the OSI model.

What would be a convenient and logical way to sort out the many parts required to make this whole “networking” thing, well, work?

The 7 Layers of the OSI Model

There are seven layers, with the first layer (physical) being shown at the bottom and the seventh layer (application) being shown at the top, like so:

All seven layers must be implemented for someone to send or receive data (ex: you are browsing the internet or emailing from your computer). Routers are responsible for sending data packets to and from networks but don’t care what’s actually in the packets, so routers only need to implement up to the first three layers of the OSI model (physical, data-link and network).

Physical layer

The physical layer is the actual physical connection between the two network nodes (computers, etc.) trying to communicate. This layer describes the transmission of raw bit streams, which are physically manifested as pulses of electricity or light.

This layer describes the physical medium being used, including hardware: connectors, cable types, etc. and voltage levels, data rates, etc.

In short, the physical layer describes the physical infrastructure needed to make communication possible.

Examples: DSL, fiber optic cables, etc.

The data-link layer describes how bitstreams are grouped into frames and actually transmitted over the physical layer described previously. It is responsible for communication between two connected network nodes. Network switches operate at this layer.

There are two sublayers: Logic Link Control (LLC) and Media Access Control (MAC).

The physical layer (beneath the data-link layer) transports data as bits; the network layer (the layer above the data-link layer) transports data as packets. The data-link layer groups bits and then transports this data as frames. The LLC sublayer synchronizes these frames, does detection and handling of errors created at the physical layer, and flow control.

The MAC sublayer handles physical addressing, and regulates communication such that nodes are not transmitting data at the same time.  Switches operate on this level, and keep a record of all of the MAC addresses of the devices on that network.

Example protocols: Ethernet, IEEE 802.11 wireless LAN

Network Layer

The network layer is responsible for passing information between the bottom two layers (physical and data link) and the higher layers. It provides addressing and routing.

Routers operate at this level. Routers can move packets from network nodes that are not directly connected (meaning that they have to be routed through other network nodes to arrive at their final destination).

This means that the network layer is concerned with finding the best available paths from one network to another (logical addressing, routing, traffic control), and ensuring that the data arrives at its destination (splitting up and reassembly packets of data, reporting errors, etc.).

Example protocol: IPv4/IPv6

Transport Layer

The transport layer ensures delivery of messages between systems, and handles reliability- and efficiency-related concerns so higher layers don’t have to.

The transport layer is like the traffic cop for the network layer. It makes sure that each node can start the data transfer process. The transport layer also handles traffic flow to reduce network congestion. It lost or duplicate packets, and does error-checking and recovery.

Encryption and firewalls happen on this layer.

Example protocol: Transmission Control Protocol (TCP)

Session Layer

The session layer establishes and maintains connections between two network applications. Request and response communication happens at this layer, and this is the first layer where the concept of “client” and “server” exists.

This layer handles connections being established, managed, restarted, gracefully terminated. Information can be transmitted either simultaneously, in both directions at once (full duplex) or sequentially, with each direction taking a turn (half duplex).

Example protocols include: Network Basic Input Output System (NetBIOS), Short Message Peer-to-Peer (SMPP),

Presentation Layer

The presentation layer presents data to applications in a syntax that they can understand. In other words, it provides compatibility for the application layer to function. Data encryption, decryption, and compression also happens at this layer.

This layer must translate information into formats that the application layer can understand (like HTML). The presentation layer provides a mapping between different application-layer formats.

Application Layer

The application layer is the user-facing layer. It is the interface between network protocols and the software the the user interacts with.

Example application protocols include: File Transfer Protocol (FTP), Simple Mail Transfer Protocol (SMTP), Internet Message Access Protocol (IMAP), and Hypertext Transfer Protocol (HTTP)