The OSI Reference Model for Network Protocols
By
Gabriel Torres
on March 22, 2007
OSI is a model that is used to understand how network protocols work. Usually when we are studying how networks work this is one of the first topics on the study guide. The problem, however, is that usually people don’t understand why this model exists nor how it really works – even people that memorized the names of all the seven layers of this model to take an exam at college or a certification exam still have no clue. In this tutorial we will explain you why the OSI model exists and how it works and we will also present a quick correlation between TCP/IP and the OSI model.
When computer networks first appeared many years ago they usually used proprietary solutions, i.e. only one company manufactured all technologies used by the network, so this manufacturer was in charge of all systems present on the network. There is no option to use equipments from different vendors.
In order to help the interconnection of different networks, ISO (International Standards Organization) developed a reference model called OSI (Open Systems Interconnection) in order to allow manufacturers to create protocols using this model. Some people get confused with these two acronyms, as they use the same letters. ISO is the name of the organization, while OSI is the name of the reference model for developing protocols.
Protocol is a “language” used to transmit data over a network. In order to two computers talk to each other, they must be using the same protocol (i.e. language).
When you send an e-mail from your computer, your e-mail program (called e-mail client) sends data (your e-mail) to the protocol stack, which does a lot of things we will be explaining in this tutorial, then this protocol stack sends data to the networking media (usually cable or air, on wireless networks) then the protocol stack on the computer on the other side (the e-mail server) gets the data do some processing we will explain later and sends data (your e-mail) to the e-mail server program.
The protocol stack does a lot of things and the role of the OSI model is to standardize the order under which the protocol stack does these things. Two different protocols may be incompatible but if they follow the OSI model, both will do things on the same order, making it easier to software developers to understand how they work.
You may have notice that we used the word “stack”. This is because protocols like TCP/IP aren’t really a single protocol, but several protocols working together. So the most appropriate name for it isn’t simple “protocol” but “protocol stack”.
The OSI model is divided into seven layers. It is very interesting to note that TCP/IP (probably the most used network protocol nowadays) and other “famous” protocols like IPX/SPX (used by Novell Netware) and NetBEUI (used by Microsoft products) don’t fully follow this model, corresponding only to part of the OSI model. On the other hand, by studying the OSI model you will understand how protocols work in a general fashion, meaning that it will be easier for you to understand how real-world protocols like TCP/IP work.
The basic idea of the OSI reference model is this: each layer is in charge of some kind of processing and each layer only talks to the layers immediately below and above it. For example, the sixth layer will only talk to the seventh and fifth layers, and never directly with the first layer.
When your computer is transmitting data to the network, one given layer will receive data from the layer above, process what it is receiving, add some control information to the data that this particular layer is in charge of, and sending the new data with this new control information added to the layer below.
When your computer is receiving data, the contrary process will occur: one given layer will receive data from the layer below, process what it is receiving, removing control information from the data that this particular layer is in charge of, and sending the new data without the control information to the layer above.
What is important to keep in mind is that each layer will add (when your computer is sending data) or remove (when your computer is receiving data) control information that it is in charge of.
Let’s now see the 7-layer OSI model.
On Figure 1 you can see an illustration of the OSI reference model. Programs only talk to the seventh layer, Application, while the layer “below” the first layer is the network physical media (for example, cable or air, in the case of wireless networks). The network cabling is thus sometimes referred as “layer 0”.
click to enlarge
Figure 1: The OSI reference model.
The seven layers can be grouped into three groups, Application, Transport and Network, as you can see on Figure 1:
Below we will explain each layer from the OSI reference model. On our examples we are assuming that our computer is sending data to the network – for example, you are sending out an e-mail thru your e-mail program.
As we explained before, each layer only talks to the layer above or below it. When your computer is transmitting data, the flow of information is from the program to the network (i.e. the data path is from top to bottom), so the program talks to the seventh layer, which in turns talks to the sixth layer and so on. When your computer is receiving data, the flow of information is from the network to the program (i.e. the data path is from bottom to the top), so the network talks to the first layer, which in turn talks to the second layer and so on.
When transmitting data, each layer adds some control information to the data it got from the layer above, and when receiving data the opposite process occurs: each layer removes control information from the data it got from the layer below.
So when sending data to the network, the seventh layer gets the data send by the program and adds its own control information, and sends this new packet formed by the original data plus its own control data to the layer below. The sixth layer will add its own control data to the packet it received from above and sends the new packet down to the fifth layer, now containing the original data, control data added by the seventh layer plus control data added by the sixth layer. And so on. When receiving data the opposite process occurs: each layer will remove the control data it is in charge of.
Each layer only understands control data it is in charge of. When a layer receives data from the layer above it doesn’t understand the control data added by the above layer, so it treats the set data plus control data as if everything was a single data packet.
On Figure 2 we illustrate this idea, where you can see a computer sending data to the network. Each number added to the original data represents the control data added by each layer. Each layer treats the packet it is receiving from the layer above it as a single packet, not differentiating what is the original data from what is control data added by the upper layers.
click to enlarge
Figure 2: How OSI model works.
We can also say that each layer on the transmitting computer talks directly to the same layer on the receiving computer. For example, the fourth layer on the transmitting computer is talking directly to the fourth layer on the receiving computer. We can say that because the control data added by each layer can only be interpreted by the same layer on the receiving computer.
Since TCP/IP is the most used network protocol nowadays, let’s make a correlation between the TCP/IP protocol and the OSI reference model. This will probably help you to better understand both the OSI reference model and the TCP/IP protocol.
As we’ve just seen, the OSI reference model has seven layers. TCP/IP, on the other hand, has only four, so some layers from the TCP/IP protocol represents more than one layer from the OSI model.
On Figure 3 you can see a correlation between the OSI reference model and the TCP/IP protocol.
Figure 3: TCP/IP architecture.
The idea behind TCP/IP is exactly the same we explained about the OSI reference model: when transmitting data, programs talk to the Application layer, which in turn talks to the Transport layer, which then talks to the Internet layer, which then talks to the Network Interface layer, which sends frames over the transmission media (cable, air, etc).
As we mentioned earlier, TCP/IP isn’t the name of a specific protocol, but the name of a protocol stack, i.e. a set of protocols. Each individual protocol used on the TCP/IP stack works on a different layer. For example, TCP is a protocol that works on the Transport layer, while IP is a protocol that works on the Internet layer.
It is possible to have more than one protocol on each layer. They won’t conflict with each other because they are used for different tasks. For example, when you send out e-mails, your e-mail program talks to the SMTP protocol located on the Application layer. Then this protocol, after processing the e-mails received from your e-mail program, sends them to the layer below, Transport. There data will be processed by the TCP protocol. When you browse the web, your web browser will also talk to the Application layer, but this time using a different protocol, HTTP, as this is the protocol in charge of processing web browsing.
Here is a brief explanation of each TCP/IP layer:
We’ll stop here. To learn more about the TCP/IP protocol please read our How TCP/IP Protocol Works tutorial.
Originally at http://www.hardwaresecrets.com/article/431