What is the OSI Model?

The OSI Model or Open Systems Interconnection model is a conceptual model that is used to understand how data is communicated between one device to another within a computer network. It was developed by ISO (International Organization of Standardization) in 1984. OSI Model consists of 7 abstraction layers, wherein each layer is a package of standard communication protocols specifically designed to perform specific functionalities.

The 7-layer architecture (from the highest- to the lowest-level representation of data) consists of the application layer, the presentation layer, the session layer, the transport layer, the network layer, the data link layer, and the physical layer. The application layer, presentation layer, session layer are considered as the software layer; while the network layer, data link layer, and physical layer are considered as the hardware layer. All these 7 layers work collaboratively to transmit the data from one device to another across the globe.

In its simplest form, OSI Model can be illustrated using two computers forming a network, connected with connectors and cables sharing data between each other with the help of network interface cards. For example, one computer is a Windows desktop computer, and the other is an iOS smartphone. The OSI Model can provide a conceptual framework on how these two computers are going to transmit and receive data with each other.

We will illustrate how OSI data is transferred between 2 communicating devices within networks by describing the functions of each OSI layer below.

1. Application Layer L7

The application layer is the highest in the OSI Model. It is responsible for presenting and creating user data, and communicating this data to other applications or another device, and is implemented by network applications. Network applications are software applications that use the internet. Examples of these are browsers like Firefox, email applications like Outlook, messengers like Skype, and others. These network applications produce data, which will need to be transferred over the network. These data are in the form which the user can understand and use, e.g. document, text, photo, video, application files, etc. In addition, being the layer that is closest to the end-user, both the application layer and the end-user interact directly with these network applications. 

To provide various network services, network applications utilize application layer protocols in order to function. For example, HTTP or HTTPS protocols are used to provide web surfing services, FTP protocol to provide file transfer services, SMTP protocol for email services, DNS for domain name directory services, Websocket for maintained bidirectional communication, TELNET for virtual terminal services, etc. All these protocols collectively form the application layer.

The application layer also serves as a window for the application services to access the network, and to display the received data from the network to the user.

2. Presentation Layer L6

The presentation layer is responsible for extracting and manipulating data obtained from the application layer, based on the required format to transmit over the network. The data from the application layer is usually in the form of characters and numbers, e.g. ASCII code. The presentation layer converts these characters and numbers to machine-understandable binary format e.g. EBCDIC code. This conversion process is called translation. 

After translation, the presentation layer reduces the number of bits that are used to represent the original data. This bit reduction process is called data compression. Data compression reduces the amount of space used to store the file, and it can be lossy or lossless. By reducing the size of the data, data transmission can be done much faster. This makes data compression very useful for applications such as real-time video and audio streaming. 

Finally, data is converted to another form of code to enhance security features and to maintain the integrity of data before transmission. This process of conversion is called encryption. The decrypted data is known as plain text, while the encrypted data is known as the ciphertext. Secure sockets layer (SSL) protocol is used in the presentation layer for encryption and decryption, wherein a key value is used to encrypt and decrypt data.

3. Session Layer L5

The session layer is responsible for session authentication, session authorization, and session management (establishment, maintenance, and termination) to enable sending, tracking, and receiving data. The session layer uses application programming interfaces (API), such as NetBIOS (network basic input-output system) which allows applications on different devices (computers or servers) to communicate with each other (i.e. to establish a session). 

Just before a session is established with a device, e.g. a server, the host device performs a function called authentication. Authentication is the process of verifying who you are. Here, the device uses a username and a password. Once the username and password are matched, a session is established between the requesting device (e.g. computer) and the host device (e.g. server). After authenticating, authorization will be done. Authorization is the process used by the host device to determine if you have permission to access a file or a service. If not, then you will get a notification stating that you are not authorized to access the file.

For session maintenance, the session layer sets checkpoints during data transfer. These checkpoints are also considered as synchronization points into the data. In case a session is interrupted, the data is re-synchronized and resumes the session from the last checkpoint. This ensures that the data are not prematurely cut, hence avoiding data loss. In addition, session maintenance also keeps track of the files that are being downloaded. For example, when a webpage containing text, images, etc. are downloaded, the text and image files are stored separately on the webserver. When you request on a website, your web browser will create a separate session to the webserver to download different types of files. The session layer keeps a track of which session each of the different files goes to. The files that are received by the session layer are in the form of data. 

Extra: Web browser performs all functions of the session, presentation, and application layers. The protocol data unit in the session, presentation, and application layer is the data.

4. Transport Layer L4

The transport layer is the heart of the OSI model, and it is responsible for providing transport services between the application/session layer and network layer. It ensures that data is delivered to the correct application services, that the end-to-end data communication is successful, and that delivery of data is error-free. In order to function, transport layer utilizes transport layer protocols such as transmission control protocol (TCP) and user datagram protocol (UDP).

The transport layer provides two types of services: connection-oriented transmission and connectionless transmission. Connection-oriented transmission is done via TCP. TCP is a three-phase process that includes connection establishment, data transfer, and disconnection. In addition, during the data transfer, the receiver sends an acknowledgment back to the source after a segment or group of segments are received. Due to this feedback mechanism, lost data can be retransmitted which allows this type of transmission service to be more reliable and secure. This transmission service is really useful for services where full data delivery is a must, such as worldwide web, email, file transfer, etc. 

While the connectionless transmission is done via UDP. UDP is a one-phase process that only includes data transfer. In this type of transmission, the receiver does not send an acknowledgment after it receives a segment. Due to the lack of feedback mechanism, it doesn’t concern itself whether the receiver received all the data or not, which then allows this type of transmission service to be faster. This transmission service is really useful for services where time of arrival is more important than reliability, such as online streaming (like movies or songs), games, voice over IP, DNS, TFTP, etc.

After the transport layer receives the formatted data from the upper layers, the transport layer protocol (TCP or UDP) performs these following functions: segmentation/service point addressing, flow control, and error control to the data in order to achieve reliable inter-network data transmission. 

In segmentation/service point addressing, the data received from the session layer is divided into smaller data packets, and each data packet is encapsulated by a transport header which contains source and destination port numbers, and a sequence number to form a segment. Protocol data units in the transport layer are the segment. By specifying the port (service point) addresses, the transport layer makes sure that the message is delivered to the correct application services, and by assigning the sequence number transport layer will be able to reassemble segments in the correct order to form the whole data at the receiver. Generally, the destination port number is configured by default or manually. Check this link to learn more about ports.

After this, the segmented data will be transmitted to the network layer. During data transmission, the transport layer performs transmission rate control, wherein the transport layer will control the amount of data being transmitted per unit time. For example, consider a smartphone connected to a server. Suppose the server can transmit data at 100 Mbps (max), while the smartphone can only process data at 10 Mbps (max). Suppose, the smartphone wants to download a file from the server, but then the server starts sending data at 50 Mbps. Since the data transmission rate is greater than the rate the smartphone can process, the transport layer of the smartphone will instruct the server to slow down the data transmission rate to 10 Mbps, to prevent data from getting lost. Conversely, if the server is sending data only at a rate of 5 Mbps, the transport layer of the phone will tell the server to speed up the data transmission rate up to 10 Mbps, to maintain system performance. 

For the case of TCP, the transport layer also performs error control. Here, the transport layer uses automatic repeat request schemes to re-transmit the data that failed to arrive at the destination (lost data), or even corrupted data. To find out received corrupted segments, a group of bits called checksum is added to each segment. In error control, the transport layer also provides acknowledgment if the data transmission is successful.

5. Network Layer L3

The network layer is responsible for the transmission of the received data from one device/host in one network to another device/host in another network. The network layer is implemented by networking devices such as routers. To function, the network layer utilizes network protocols such as IP, ICMP, IGMP, etc. IP or internet protocol is the most common network layer protocol and it performs several functions, such as logical addressing/framing, routing, and path determination.

To understand logical addressing, first, we have to recall that every device in a network has a unique IP address. What the network layer does is encapsulates each data segment received from the transport layer with a network header containing the sender’s and receiver’s IP addresses and a mask to form an IP packet. The protocol data unit in the network layer is the IP packet (please note that we call IP packet in this article to differentiate it from the data packet produced during segmentation in the transport layer). Such an address scheme allows the devices to be uniquely and universally identified between networks hence, making sure that each IP packet reaches the correct network destination. 

Based on logical addressing, the network layer determines which route is suitable to move the IP packets from its source network to its destination network. This route determination is called routing. To illustrate routing, suppose device A having an IP address of 192.168.10.1 is connected to network A, and device B having an IP address of 192.168.20.1 is connected to network B. For example device B requested access to mlytics.com from the mlytics server (having an IP address of 192.168.30.1), and mlytics server will send a reply to device B in the form of IP packet. Since each device has a unique IP address, the network layer of the mlytics server will add the sender’s and receiver’s IP addresses and a mask into that packet. This packet needs to be delivered only to device b. Suppose the mask used is 255.255.255.0 (the first three numbers represent the network, while the last number represents the host or device). Based on the given logical addressing, the IP packet will be routed only to network B, and then eventually to device B.

Finally, a device or a network can be connected to a host server or another network in many possible ways. Choosing the best possible path for data delivery from source to destination is called path determination. The network layer uses protocols such as open shortest path first (OSPF), border gateway protocol (BOP), intermediate system to intermediate system (IS-IS), to determine the best possible path for data delivery between networks.

6. Data Link Layer L2

The data link layer is responsible for making sure that the data transfer is error-free from one node to another over the physical layer. The data link layer is implemented by data link devices such as switches, bridges, and network interface cards (NIC) of devices. To function, the data link layer utilizes data link protocols such as ethernet, wifi, ARP, PPP, NDP, etc.

Data Link Layer is divided into two sub-layers: Media Access Control (MAC) layer and Logical Link Control (LLC) layer. The MAC layer is responsible for controlling how devices in a network gain access to a transmission medium and permission to transmit data. While, the LLC layer is responsible for identifying network layer protocols; physical addressing and framing; and controls error checking and frame synchronization.

LLC layer allows network layer and upper layers of OSI model to access transmission media using techniques such as physical addressing/framing. Framing and physical addressing is a process when the data link layer receives packets from the network layer, each packet is encapsulated by a header containing the MAC addresses of sender and receiver, and a footer/trailer containing a frame check sequence to form a frame. MAC address is a 12-digit alphanumeric code embedded in NIC which is assigned by the manufacturer. Since there is a possibility that errors might occur during data transmission due to inherent limitations of the transmission media, the LLC layer adds the frame check sequence on each frame to check and identify errors from the received frame. The protocol data unit in the data link layer is the frame.

MAC layer provides means to transfer data from one device to another via transmission media. Transmission media refers to the physical links between two or more devices or networks, it can be copper cable, optical fiber, or air. 

To understand how the data link layer works, consider two distant devices: a desktop and a smartphone communicating with each other. As the devices are connected to different networks, they will be using network layer protocol to communicate between networks, and they will use data link protocol to communicate between two physically connected devices. 

In this example, the desktop is connected to router R1 via an ethernet cable, routers R1 and R2 are connected via a satellite link, and the smartphone is connected to router R2 via a wireless link. Now the desktop wants to send some data to the smartphone. Based on the transmission medium used to connect desktop and router R1, the data link layer uses ethernet protocol to add header and trailer to the IP packet and converts it to an ethernet data link frame. Router R1 receives this ethernet frame, decapsulates it to an IP packet, and then encapsulates it again to a frame so that it can cross satellite links to reach router Router R2 will use wifi protocol to decapsulate the received frame and encapsulate it again to form a wireless data link frame. The smartphone receives this wireless data link frame, decapsulates it, and moves the data to higher layers. Finally, the data arrives at the application layer, then makes the received data visible on the computer screen.

Finally, the MAC layer also determines which device has control over a given transmission media at a given time, and on how data is placed and received from that media. For instance, if two or more devices connected to the same transmission media and send data at the same time, media control access keeps an eye on when the shared transmission media is free so that the device can transmit data to the receiver while avoiding the possibility of collision of data coming from the two devices. This technique is also known as carrier sense multiple access (CSMA).

7. Physical Layer L1

The physical layer is the lowest layer of the OSI model and is responsible for the actual connection between devices. The physical layer is implemented by physical devices such as a hub, repeater, modem, cables, etc. Recall, data from the application has been segmented by the transport layer, placed into packets by the network layer, and framed by the data link layer. The physical layer receives this frame from the data link layer and converts them to a sequence of binary digits of zeros and ones called bits. The protocol data unit in the physical layer is the bits.

These machine-friendly bits are now converted into signals and transmitted over transmission media. The signal generated by the physical layer depends on the type of transmission media used to connect two devices. The signal can be an electrical signal which is transmitted through copper cable or LAN cable, or it can be a light signal transmitted through an optical fiber or a radio signal transmitted in the air. 

The physical layer also performs transmission rate control to control the speed of data transfer along with the transmission medium. The rate is measured in bits per second. Finally, the physical layer also defines how transmission mode of data, or how data can flow between devices. Types of transmission modes are simplex, half-duplex, or duplex.

Completing the whole picture

The process described above starts from the highest level of the OSI model going down to the lowest level, i.e. the process of sending data. However, data has to be received as well. The OSI model can also describe this process by simply going through the process in the opposite direction, i.e. describing the process starting from the lowest level of the OSI model to the highest level.

Reversing the process, the signal is first received by the physical layer then converting these signals to bits, and then to frames. Then pass the frames to the data link. The data link layer will then decapsulate the frame by removing the data link headers and footers as it moves to the network layer. The network layer will decapsulate the IP packets by removing the network headers, and then pass the segments to the transport layer. The transport layer will then decapsulate the segments by removing the transport header, then reassembling the data packets into one whole data, and finally transporting it to the presentation layer with the help of the session layer. The presentation layer will then transform data into the form that the application accepts. Finally, the data arrives at the application layer, where the data will be converted to a readable format that is made visible by the receiver’s device.

The Utility of OSI Model

The OSI model only acts as a reference model and is not implemented on the Internet. The model that is being used on the Internet is the TCP/IP model. But why do people still use the OSI Model?

The OSI model helps users and operators of computer networks. For users and operators, the OSI model serves as a guide to determine the required hardware and software to build their network. It also helps to understand and communicate the process followed by components communicating across a network. And it is also useful in troubleshooting since it helps identify which layer is causing an issue and hence can effectively focus attention on that layer.

The OSI model also helps network device manufacturers and networking software vendors. For manufacturers and vendors, the OSI Model helps to create devices and software that can communicate with products from any other vendor, allowing open interoperability. It also helps in defining which parts of the network their products should work with. Moreover, it also assists in communicating to users at which layers their product operates, for example, cybersecurity solutions applied at the application layer, or across several layers.