OSI Model and TCP/IP Model

Prabhjeetsingh
7 min readOct 2, 2022

OSI Model

The Open Source Interconnection (OSI) reference model is a 7-layer model which was designed by International Organization for Standardization (ISO).

Top to bottom PDU(Protocol Data Unit)
7. Application Layer Data
6. Presentation Layer Data
5. Session Layer Data
4. Transport Layer Segment
3. Network Layer Packet
2. Data link Layer Frame
1. Physical Layer Bits

Layer 7 — Application Layer

The Application layer is closest to the user within the protocol suite.
It provides an interface between the running applications of a local system and the underlying network protocols.
The Application Layer contains many protocols such as:
1. File Transfer Protocol (FTP)
2. Simple Mail Transfer Protocol ( SMTP)
3. Domain Name System (DNS)
4. Dynamic Host Configuration Protocol ( DHCP)

Let's take an example — if we want to send an email to another person, let's say we are using the outlook application to send an email, so the Outlook application will be using the SMTP will put that mail in an envelope and deliver it from source to the destination address.
here APplication layer will generate a raw datagram, so that SMTP can create a raw email message and that PDU is called Data.

Layer 6 — Presentation Layer

When an application layer protocol such as HTTP sends it raw data to the network, it is formatted for the lower layer to read and understand before sending it out on the network.
The Presentation Layer is responsible for the data formatting.
It is also responsible for the following functions —
1. Data Formatting
2. Data Compression
3. Data encryption and Decryption.

it encrypts the message so that the lower layer doesn't understand the actual message. This layer ensures that data should be formatted in such a way that lower layers can understand it and interpret it and perhaps proceed with adding the additional information before sending it out to the network.

Layer 5 — Session Layer

The Session layer is responsible for three main functions on the network.
1. Create or build a session between a sender and receiver.
2. Maintain the established session during the transmission of the message between sender and receiver.
3. Terminating a session when both parties indicate they no longer want to communicate with the other.

Layer 4 — Transport Layer

1. The Transport layer is responsible for moving datagrams between the upper layers (Application layer) onto the network itself.
2. At the Transport layer, the protocol Data Unit (PDU) is known as Segment.
3. At the application layer there are many applications(programs) that generate network traffic such as HTTP or SMTP at a time, when each application layer protocol sends its datagram onto the network, the transport layer has the responsibility of tracking these conversations as they occur.

There are two types of protocols that exist in the Transport protocol.
1. Transport Control Protocol ( TCP)
2. User Datagram Protocol ( UDP)

1. Transport Control Protocol ( TCP):-

a. TCP is a connection-oriented protocol that operates at the Transport Layer of both the OSI reference model and TCP/IP protocol stack.
b. It is designed to provide reliable transportation of the datagrams over a network.
c. It provides reassurance by initializing a TCP 3 — way handshake before communicating data between the sender and receiver.
d. It is very slow because of the ACK of each message.

TCP 3 — Way Handshake working.
If PC1 wants to send data to PC2, then before that they will create a connection with the help of a TCP 3-way handshake.
Firstly PC! sends a synchronization signal to PC1 and then PC2 will send its acknowledgment in the form of SYN/ACK form and then again PC1 will send the ACK signal to PC2. After this PC1 will start sending the data to the PC2. in this process, after each data, PC2 will send ACK to PC1 that PC2 received data. After ensuring this again PC1 will send some more data to PC2 and again wait for the ACK.

What is PC2 is not sending ACK signal to the PC1.
In this case, PC1 will send the same data again to PC2 after some time and wait for the ACK for some time. if not again it will repeat the same process. PC1 will repeat this process for some time, and if PC2 is not sending ACK after some repetitive data messages, then it will stop.

For every message sent by Sender, the Receiver must send the ACK back to the sender.

Diagram for the same.

2. User Datagram Protocol (UDP)

a. It is a connection-less protocol that operates at the Transport layer.
b. UDP doesn’t provide any guarantee or reassurance of the delivery of datagrams across a network.
c. Not all protocols at the Application layer uses TCP, there are many layer7 protocols that use the user datagram Protocol.
d. some examples of layer7 protocols are
Voice and video traffic, are time-sensitive data types, so can't wait for the ACK for each message.
e. It is very fast.

Layer 3 — Network Layer

1. It is responsible for the logical address of the end devices on the network and the encapsulation of the IP header which adds both source and destination IP addresses ( IPv4, IPv6) to the packet.
2. The Networking layer provides the functionality of directing the traffic flows on a network using routing protocols that operates using the Internet Protocol.
3. At this layer, the Router operates as they have the ability to read and understand IP addressing and contents of a packet.
4. The PDU for this layer is Packets.

Layer 2 — Data Link Layer

1. Data link layer is responsible for allowing the messages of the upper layers to access the network.
2. It also controls how data are placed onto the physical network(media) and handles error detection and flow control.
3. Within the Data link layer there are two sub-layers
a. Logical Link Control (LLC)
b. Media Access Control (MAC)

4. Switches operate at this layer as they are able to read and understand frames that contain MAC addresses.
5. PDU ( Protocol Data Unit) for this Layer is Frame.

Logical Link Layer

a.This layer encapsulates the packet received from the network layer into a frame by adding a layer2 header containing the source and destination media access control (MAC) address.
b. At the end of the frame, a trailer is added.
c. The trailer of a frame contains the File Check Sequence (FCS) and inside the FCS is the Cyclic Redundancy Check ( CRC) which is used for error detection on a network.

Media Access Control (MAC)

a. MAC address is made up of 48 bits and is presented in the format of hexadecimal values ranging from 0 to 9 and A — F.
b. Example of MAC address is 12:34:56:78:9A: BC. The first 24 bits are known as Organization Unique Identifier (OUI) which identifies the manufacturer of the Network Interface card (NIC) and the second 24 bits are assigned by the manufacturer to the Devices.
c. The MAC address is also as Burned In Address (BIA) since it is hardcoded onto the hardware and is not changeable.
d. Hackers have found ways to change the MAC address also of the device.

6. Once the Datalink layer finishes its task, now it will place the message as a frame onto the actual wire. The wire can be the wireless signal, network cable, or fiber optics cable.
Before putting the message on layer1, it cuts them into the smaller unit known as Bits.

Layer 1 — Physical Layer

1. At this layer, wireless signal, cables, etc. operates. At this layer, Protocol Data Unit (PDU) is known as Bits
2. Hubs operate at the physical layer since they only repeat a signal on the physical layer.

###############################################################

TCP/IP Model

1. Transmission Control Protocol/ Internet Protocol (TCP/IP) suite was developed by the US Department of Defence (DOD) and has been implemented in all networking devices since it is approved.
2. The protocol suite is maintained by Internet Engineering Task Force (IETF).
3. Unlike the OSI reference model, the TCP/IP protocol suite has 5 Layers.

Layers PDU
5. Application Data
4. Transport Segment
3. Internet Packet
2. Data-link Frame
1. Physical Bits

Comparison between OSI and TCP/IP

Explain TCP/IP with an Example.

--

--

Prabhjeetsingh

Talks about Cyber security, Ethical Hacking, Python, Java, Shell Scripting, Computer Networking and Automation - Web, Mobile and API