The TCP/IP Model and How it is different from OSI
Hello, everyone. I am back with a new blog.
This is the second part of my previous blog, “The OSI Model”. If you haven’t read it yet, check it out here: “https://medium.com/@shubh.varshney2103/the-osi-model-b1324bd3f63c?sharedUserId=shubh.varshney2103”.
(I recommend reading about the OSI model before reading this blog for better understanding.)
Now, let’s get to the point.
As I mentioned in my previous post, OSI is more like a theoretical model and TCP/IP is a practical model that is actually implemented in real-world scenarios.
So, we will understand the TCP/IP model while comparing it to the OSI model.
(Although we are comparing them, I will still explain each layer carefully.)
The TCP/IP Model
Here, TCP/IP stands for “Transmission Control Protocol” and “Internet Protocol”, respectively. Although TCP and IP are protocols of different layers of this model, we still call it the TCP/IP model. Isn’t it weird? Anyways, back to the topic.
People often get confused about the number of layers this model has — whether they are 4 or 5. To be honest, no one is wrong here because this model has two versions: the old version has 4 layers and the new one has 5 layers. Since we are modern people, we will learn about the new one.
Let’s begin.
The 5 layers that it consists of are:
- Physical Layer
- Data Link Layer
- Network Layer
- Transport Layer
- Application Layer
5. Application Layer
It is the top-most and closest-to-user layer in the model. It acts like an interface between user applications and the lower networking layers. Due to the smaller number of layers in TCP/IP, it combines three layers of the OSI model: the application, presentation, and session layers. Thus, it also combines the functionality of these layers.
Now, this layer has several responsibilities, and the main ones include:
- It takes care of data conversion while sending and receiving data because different applications use different kinds of data formats for providing services. Hence, it becomes important that both the sender and receiver process data in the required format.
- Manages sessions for successful communication, which also includes initiating communication and keeping it open long enough for a session.
- Provides encryption for secure communication and compression of data for smooth transmission.
It uses several kinds of protocols like HTTP, DNS, SMTP, and FTP, etc., for different purposes.
(Don’t worry, we will talk about many important protocols in detail in upcoming blogs.)
(If you think it is a brief explanation, then check out the OSI model blog and read about the 3 layers mentioned above. It is just the combination of them. In real-world scenarios, these things are done at a single stage and by the same software. Hence, we combine them here.)
4. Transport Layer
While the application layer just initiates a connection, the transport layer takes care of end-to-end communication. That means it checks whether the other device is listening or not and whether the connection is successfully established or not.
It has several different responsibilities, like ensuring the data reaches the correct application and choosing the correct port number for that (as every application uses a different port), breaking the data into small parts like segments or datagrams (depending on the protocol used). For data from different applications, it also uses two functions, i.e., “multiplexing” and “demultiplexing”, meaning combining data from different applications and separating data for different applications, respectively.
Not only that, it also checks for errors in segment transmission: loss of any segment, whether retransmission is required for any segment, and whether data is transferred completely without corruption. It also maintains the flow of data so that the receiver doesn’t get overwhelmed.
Get Shubh Varshney’s stories in your inbox
Join Medium for free to get updates from this writer.
This layer mainly uses 2 types of protocols for transmission:
1. TCP
TCP stands for Transmission Control Protocol. It is preferred when reliability and accuracy are more important than speed. It maintains the integrity of data better using something called checksums, which are placed in the header of the segment.
When we use TCP, first it ensures that a connection is established between the sender and receiver so that it can maintain a session throughout the communication. It checks whether any segment got lost; if any did, it resends it automatically.
As I mentioned before, I am using the word “segment” here for small data chunks. The reason is that TCP sees the data as a continuous stream of bytes. Hence, the order of pieces is important because segments are dependent on each other for data integrity.
Also, the word “segment” itself means “part of a whole”, which aligns with the idea behind it.
Example: exploring web pages, downloading files, sending emails, etc.
2. UDP
UDP stands for User Datagram Protocol. It is preferred when speed is more important than accuracy, but it is not considered reliable for several reasons: it can detect errors but does not correct them, it doesn’t care about the order of data sent, and it doesn’t resend lost data.
It avoids extra checks and tasks to perform; hence, it is faster than TCP. The word “datagram” is used here because it doesn’t think of data as a continuous stream; rather, it treats every datagram as a separate message independent of other datagrams.
The word “datagram” itself means a “self-contained” packet of data, which matches the idea behind it.
Example: live streaming, online gaming, video calls, etc.
3. Network Layer
This layer is responsible for the transfer of data from one network to another. It provides the IP header to the segment/datagram received from the transport layer. Generally, this layer doesn’t break down the packet (segment/datagram after getting the header) further in size, but if the MTU (maximum transmission unit) of the next network is smaller, then it will break down the packet further and, at the destination, it will reassemble it. However, reassembly of segments into the original form of data happens at the transport layer.
It also has a very important functionality known as routing, which means finding the best path from source to destination.
(We will cover the full working of a home router along with routing in a separate blog.)
2. Data Link Layer
While the network layer worries about sending data over different networks, this layer is responsible for transferring data within the same network to different devices. It encapsulates the data into frames for the required medium, whether it is Ethernet, fiber optics, or cables. Frames are also necessary to separate the data packets because when they get converted into a stream of bits in the next layer, it helps to identify when one packet is ending and another is starting.
While the network layer puts an IP address on the packet, the data link layer uses a MAC address for the identification of the physical device.
It also detects errors while transmitting packets, but errors are generally handled by protocols like TCP.
(We will talk about frames, headers, and the structure of data/IP packets in much more detail later.)
1. Physical Layer
After receiving the data in encapsulated frames, this layer converts them into a stream of bits, i.e., 0s and 1s. In this layer, it doesn’t matter what type of data it was; all types are treated in the same way.
Now, to send to other devices, it changes the bits into the required form: electrical signals for wires, light pulses for fiber, and radio waves for wireless communication.
(If you are thinking that if everything gets converted into bits, then how do other devices like routers know where to send it? It is true that all data gets transformed into bits, but bits have a defined structure of body as well as header. So, it reads the required set of bits and knows the destination IP address.)
OSI and TCP/IP Model side by side
Now you can visualize the comparison between the old and new TCP/IP model with the OSI model with the help of this image.
(I already explained the overall flow of data in the previous blog; it is the same here. Just remember the difference of the application layer between these two models.)
That’s it for today. I hope you like this blog, and don’t forget to leave reviews and suggestions in the comments.
If you find any mistakes, feel free to point them out in the comments. I will be back soon with a new blog.
Till then, “DO WHATEVER YOU WANT!!” ;)
(Source: GeeksforGeeks, IPCisco, and my brain. :)







