Have you ever wondered how you can chat with a person so far or voice or video call them so easily , Well let’s talk about network layers and how each of them help.
There are basically two models of network transmission stack :
- TCP/IP model
- OSI model
Both have a great theory but only TCP/IP is the only one that comes in handy in today’s internet.
The TCP/IP model is basically consist of 4 network stack:
- Data Link Layer : The Data is converted to Binary or they opposite in this layer .
- Network Layer : The stream of bits of data are gathered here and the shortest and most efficient route is found for the data packets to be transffered to the destination address.
- Transport Layer : This is where TCP or UDP is chosen based on the data being transferred through the network.This handles error detection and ordering when a the data packets are sent or recieved.
- Application Layer : Handles transferring data end to end.
Each of the layer has there work but lets understand about Transport Layer a bit more:
Transport layer is used to send data packets across the network along with the loads of data sent by other users around you.
So What Special does the Transport Layer does? It basically adds a layer to the data packets containing the IP headers , Ordering , Checksum
- IP headers : Headers contain the Source address , Destination address , MAC address of the network passed from and other metadata.
- Ordering : This layer assigns a special unique number to each of the data packets in a serial manner so that if a data packet reaches late they can be correctly ordered by the application layer.
- checksum : It is a method which to used to handle error and is used in error detection.
All these are handled by Transport layer but vary depending on what you are using TCP or UDP
TCP (Transmission Control Protocol):
TCP is a very reliable communication and is always safe to send data through this protocol. TCP uses almost all of the transport layer utilities along with the it’s own advantages(discussed later).
UDP (User Datagram Protocol):
UDP are very fast but uses some of the utilities in available in Transport layer.
TCP-Process:
TCP establishes the connection to the other end user using a 3-way handshake.
Once the connection is established and the network is set TCP starts sending data packets using that connection and everytime the reciever recieves a data packet it sends an acknowlodgement (ACK) to the sender once the ACK is recieved the sender sends another packet and the process goes on if in anytime the the reciever does not send a ACK then after a interval the sender sends the previous data packet again and the process goes on once this finishes the sender sends a finish(FIN) request to the reciever and the reciever sends a FIN then ACK to the sender and then sender send the FIN again to close down the connection.
This process is little slow but is reliable and no data loss is found , error handling is done using checksum to check if any data is lossed while transmission.
TCP also handles network congestion which is if the network is crowded or slow then it increases the time to send the data packets while if the network is fast it decreases the time of transmission of each packet and this is how it adjust according to the network speed.
TCP is widely used e.g. When you browse something on a HTTP server or in FTP ,TCP is used.
Basically it is used in every aspect unless it is not about real-time streaming of data. So you must be asking me if TCP is protocol so are HTTP and FTP why are they not doing something like this . The answer is simple HTTP and FTP and many other protocols are of application layer protocols they only help keep the data authentic and only to the end user(reciever).
UDP-process:
UDP doesn’t establish any connection to the reciever end it is connectionless. It start sending data packets(datagram) to the reciever address without any reliable connection , so , there is no single network used it send the data through multiple networks never thinking about ordering , it oonly think of how i can make the packets reach faster to the receiver rather than the quality.
A real life example would be video calling you must have notices that the quality of video calling is not as good even with fast internet connection it might loose some bits of data which may create a laggy interface to you.
UDP is generally used in fast data transferring like DNS search , DHCP , Live streaming etc.
UDP is faster in general compared to TCP but if you compare it yourself you wont see much difference unless a very large stream of data is being transffered.
Best Meme to understand TCP and UDP is :
This meme shows exactly what each of they mean , TCP is very gentle while UDP is careless.
This is my understanding of TCP and UDP . Would love to have your feedbacks.



Top comments (0)