The OSI Model

Last Update By Kim - June 21, 2020

The OSI (Open Systems Interconnection) model is a reference model used to describe how computers communicate with each other using standard protocols. Basically, it can be seen as the universal language of computer networking.

The OSI model is divided into seven different layers where each layer describes a different function of data traveling through a network. When combined together, each function contributes to enable end-to-end communication between computers.

Why is the OSI model important?

When you are faced with a significant network issue, which appears to be affecting a large number of the network's users, then time is of the essence, and you must be able to solve this issue as soon as possible.One way to do this is to think in OSI layers. It’s a great way to troubleshoot by narrowing down the problem to one specific layer of the model. This way, a lot of unnecessary work can be avoided. Here’s an example of how the model can be used to solve a problem.

A user complains that she cannot connect to the internet. Several IT people have tried to solve this issue, but with no luck. Where would you start?

You could start your troubleshooting at the physical layer. From here, you could start with the basics and check these things first:

  • Is the ethernet cable plugged all the way in?
  • Is the net card working?
  • Is the router/switch functioning at the other end?
  • Is the ethernet cable bent or damaged from misuse?

By eliminating all the possibilities on the physical side, you can then move on to the next layer of the OSI model, which is the data link layer. Don’t worry about the terminology for now; this is just an example.

  • Is the computer a member of the right VLAN?
  • Are the ARP tables consistent?
  • Is spanning tree causing issues?

You get the idea. Eliminate possibilities from each layer until you find the root cause.

Layer 1 - Physical

This layer includes the physical equipment involved in data transfers such as routers, switches and cables. This layer is responsible for the transfer of bits - the 1s and 0s that make up all computer code.

It’s important to note that since the model is quite old , the terminology used can get a bit confusing sometimes. WiFi, for instance, is also included in the layer 1 protocol because it transmits bits over radio waves, even though it’s technically not physical.

Layer 2 - Data Link

The data link layer’s main responsibility is to pull or push those 1’s and 0’s onto or from the wire and encapsulate them into frames. A frame contains a header and a trailer:

  • Media Access Control (header)
  • Logical Link Control (trailer)

The header consists of a source and a destination MAC address. A MAC address is a unique identifier of a network interface card (NIC). All devices in the world have their own unique address, which is usually printed on the network card by the manufacturer. This makes it possible for devices on the same network to deliver packets from one NIC to another.

The trailer contains a Frame Check Sequence field, which is used for flow control and detection of transmission errors.

Layer 3 - Network

The main purpose of the network layer is to deliver packets between two different networks. If two devices are communicating on the same network, then the network layer is unnecessary. At this layer routers come into play to route information correctly between networks.

To be able to send packets from one network to another, a new addressing scheme has been incorporated into this layer. This addressing scheme is known as the Internet Protocol address, or the IP Address. It’s considered a logical address because the IP address can be changed unlike the MAC which is a physical address.

Layer 4 - Transport

The primary function of the transport layer is to distinguish between network streams. Imagine being a computer wired up to a network and you get a steady stream of 1s and 0s - it’s valuable data, but what goes where? Here, port numbers come to the rescue!

With port numbers added to the data, the computer can distinguish between network traffic; so you can play music, browse the web and send emails at the same time without any issues.

It’s accomplished by adding a source and destination port to the packet. There are two protocols within the transport layer used for sending bits of data over the internet:

  • Transmission Control Protocol (TCP)
  • User Datagram Protocol (UDP)

Both TCP and UDP have 65,536 port numbers each. However the main difference between the two protocols is the way they handle streams of data.

TCP provides error-checking and guarantees delivery of data. If a packet is missing it will be resent. This protocol is the most widely used. UDP on the other hand does not error check and does not care if the recipient loses a packet on the way.

“Why would anyone choose UDP?”, you might think to yourself. The reason is quite simple. In some applications it’s not critical if a packet is lost in transit, such as live video streaming. In this example, faster delivery is more important than the loss of a few packets.

Layer 5 - Session

The next 3 layers are not important from a Network Engineer’s perspective. However, they will be briefly covered here. If you are interested in more in-depth information regarding these layers, I recommend taking a look here.

As the name suggests, this layer manages sessions between computers to coordinate communication. The period between the opening and closing of the correspondence is known as the session.

Layer 6 - Presentation

This is the layer in which the operating system operates with the data. The main responsibility here is translation, formatting, encryption, and compression of data.

Layer 7 - Application

This layer is the closest to the user. In a nutshell, it serves as a window for an application to access the network and to display the received information to the user. This is where the protocol utilized by the program or application is chosen, such as HTTP for web, FTP for file transfers, etc.

Datas journey through the OSI model

For now, this has been a lot of theory; let's try and put it into practise with a real-world example. In order for human-readable information to be transferred over a network, the data must go through all seven layers of the OSI model and in both directions between the devices communicating on either end of the network channel.

Let’s say that grandma Grace Hopper wants to send an email to her new friend Bjarne Stroustrup. The first thing she does is to open an email application on her laptop and write down a sweet message.

When she hits send, the application picks a protocol, which in this case would be SMTP (Simple Mail Transfer Protocol). The data will then go down from the application layer to the presentation layer where it’s formatted in a way that the receiving device will understand. In this case, she is just writing text in her email, so it would be simple ASCII formatting. Remember: this layer could also encrypt the data if needed.

It will then hit the session layer, which will initialize a communication session with a mail server such as those of Gmail, Hotmail, etc. The next step down the layers of the model corresponds to the transport layer, where the decision to use TCP or UDP is made. Emails are almost always sent using TCP for reliable transfers. A source and a destination port are then attached to the data, which in this case is port 25 for SMTP.

At the network layer, a source and a destination IP address will be added to the data to be able to transfer it between networks. At the data link layer, the source MAC address of Grace’s laptop and the next hop address (her router) will be added to the data. The source and destination MAC address will change for each hop along the way to Bjarne.

In the final step, the data will finally be converted into a bitstream of 1s and 0s and sent through the ethernet cable (grandma is smart for using cable).

From Bjarne Stroustrup’s perspective, the OSI model will go in the opposite direction. The physical layer will convert the bitstream into frames, and these frames would then continue on to the next layers.

Comments: