Cyber Security For Beginners: Part 9

Arjun Suresh
CyberSec 101
Published in
7 min readJul 10, 2021

Hey guys! Welcome back to this beginner friendly blog series on Cyber Security. In the last blog, we were discussing about computer networks. We are going to dive a bit deeper and try to learn about one of the fundamental concepts in networking: the OSI model.

The Open Systems Interconnection (OSI) model is a conceptual model which was developed in the late 1970s as computer networks were becoming more and more popular. The primary objective of the OSI model was to standardize network communications between two or more different devices. As each device used within a network can be made with a different technology, there needed to be a standard for enabling communication between them. Due to its widespread popularity, the OSI model was adopted by the International Organization for Standardization (ISO) as a standard soon after. The OSI model provides a set of protocols which defines how networked devices can communicate and share resources with each other.

The OSI model consists of 7 different layers:

  1. Physical Layer
  2. Data Link Layer
  3. Network Layer
  4. Transport Layer
  5. Session Layer
  6. Presentation Layer
  7. Application Layer
Layers of the OSI model

Each of these layers perform a particular function which enables messages or data to be transferred from one device to another. Now let’s look at each of these layers in a little more detail.

Layer 1: Physical Layer

This layer is responsible for the physical connection and transmission of data between devices. Data exists in the physical layer as bits. Bits include a combination of ones and zeroes that the computer systems can understand.

Bit representation

The physical layer is also concerned with the network topology and point-to-point transmission of data. This means that if a device, for eg., a smartphone, wants to send a message to a computer which exists within the same network, then according to the network configuration shown below, the data has to first reach the router. The router then forwards the data to the laptop.

Networked Devices

Even though the destination of the message is the computer, the physical layer at the smartphone is only concerned with getting the data to the next directly connected device, which in this case, is the router. The router then forwards the message to the laptop. Physical layer performs various other functions including controlling the data rate, setting the transmission modes etc. But we won’t be going into all those details in this blog because we want to keep this as simple as possible.

Layer 2: Data Link Layer

The next layer in the OSI model is the data link layer. This layer is responsible for various activities like framing, error detection and correction, flow control , and physical addressing. Data exists in this layer in the form of frames. A frame can be considered as a cover for the actual data. It contains various additional information like headers, trailers, CRC etc. in addition to the actual data.

Layer 2 Frame

The process of breaking up data received from the upper layer (network layer) into smaller fragments is known as framing. Data may be corrupted during transmission and may need to be resend. All these activities are taken care of by the data link layer. In layer 2, we work with physical addresses of devices. These 48 bit physical addresses are known as MAC (Media Access Control) addresses. These addresses are unique and permanent for a device and they are not meant to be changed. The frame header contains information like source MAC, destination MAC, control fields, and other information about the frame. When data is received from the upper layer, the data link layer first breaks it down to smaller units called frames. It adds various header and trailer information to the frame and then passes it down to the next layer, i.e., the physical layer.

Layer 3: Network Layer

Layer 3 of the model is the Network layer. Primary functions of this layer include routing and logical addressing. Routing is the process of transferring a piece of data from the source device to the destination device across a network or between networks. Network layer does this with the help of logical addresses, a.k.a., IP addresses. Unlike MAC addresses, IP addresses are not permanent and can be changed as and when required. It is a 32 bit address used to uniquely identify each device in a network. Data exists in this layer in the form of packets. A network packet contains far more information when compared to frames.

Layer 3 Packet

The primary function of the Network layer is to deliver packets from the source IP to the destination IP. The network layer is responsible for choosing a path for the packets to travel from source to destination via routing.

Layer 4: Transport Layer

Transport layer is responsible for establishing and maintaining communications between processes running on the source and destination machines. It provides logical communication between processes. Data is handled by the transport layer in the form of segments. The transport layer enables multiple processes to communicate with other processes and services using the concept of ports. A port can be considered as an interface for communication. In a network, there are 65535 ports for communication. While some ports are used by well known services, the majority of them are used for normal communications by processes. Different processes communicating with other services are distinguished from each other based on the port that they are using. The data segment used in this layer contains information related to the ports pertaining to that segment of data.

Layer 4 data segment

Two important protocols used in this layer for communication are TCP (Transmission Control Protocol) and UDP (User Datagram Protocol). TCP is considered to be reliable but slower. UDP is unreliable and faster. The reason why TCP is slower than UDP is because TCP establishes the communication channel first before sending any data. UDP does not do this. More differences between TCP and UDP can be found in the table below:

Differences between TCP and UDP

Layer 5: Session Layer

The session layer is responsible for establishing, managing, synchronizing, and terminating sessions between services and processes running on the source and destination machines. A session can be considered as temporary communication going on between different processes/services. The session layer keeps track of these sessions. The session layer also adds synchronizations points or check points while transferring data between the communicating entities. If the data somehow gets lost in transmission, there is no need for the sender to retransmit the entire data. Since checkpoints are added after every few bytes, the data needs to be transmitted only from the last successfully received checkpoint.

Layer 6: Presentation Layer

This layer is responsible for performing various types of transformations on the data like compression and decompression, encryption and decryption, etc. It converts data from one type to another before passing it to the layers above or below it.

Working of the presentation layer

Presentation layer decides how the data is represented and displayed by the application layer. If some kind of transformations have been applied to the data by the sender, then the reverse operation needs to be performed by the presentation layer at the receiver to get back the original data.

Layer 7: Application Layer

This is the top most layer of the OSI model. Application layer enables the users to access the services offered by the network. In other words, it acts as an interface between the end users and the network. Application layer uses various types of protocols like HTTP, FTP, etc. for accessing the various services offered in a network.

The Application Layer

So that’s it guys. This is the end of this particular blog describing the various layers of the OSI model. Remember: the contents of this blog are written in a way for you to easily understand the concepts that we are talking about. There’s more to learn about these layers which will be attached in the resources section of this blog. Do go through them!

In the next blog, we will be talking about yet another model that we use in networking: The TCP/IP model. Till then, take care. Ba-bye!

Resources

--

--

Arjun Suresh
CyberSec 101

Cyber Security Researcher And Blogger | Bug Bounty Hunter | CTF Player