Skip to main content

Command Palette

Search for a command to run...

What is TCP and UDP?

Published
4 min read

TCP (Transmission control protocol) and UDP (User datagram protocol) are transport protocol layer (OSI 4 layer) responsible to send data packets across the internet to identify a network using source/destination port number, enabling to delivery data from one system to another specific system, utilize checksum for data integrity.


This is the basic definition of TCP and UDP. Now let’s move one-by-one their works.

What does TCP do?

As we discussed TCP (Transmission control protocol) is a transport protocol layer which is responsible to send data packets across the internet. it is connection-oriented network protocol which ensures of reliability send data to receiver without loosing packets. Because it checks continuously data packets while transfer data TCP is more reliable than UDP”.

What does TCP make differ from UDP?

  1. Reliable : It gives guarantee to send data properly to the destination.

  2. Order data : While sending data sometimes happen packets could be misplaced and then at the end client does not receive actual. To prevent this misplaced problem TCP ensures client receive actual data without lost and misplaced packets(data).

  3. 3 way handshake : The most important part of TCP. TCP does not make directly connection to server without it’s permission before sending data to client and receiving from server to build a connection it’s important to building the connection between server and client. Let’s see step-by-step:

  • SYN : First client initiate the connection with sending SYN flag 1 and sequence no. to verify data start with this sequence no.

  • SYN-ACK : Server receive it and SYN-ACK set to 1 then server say I send data with a this sequence no. it could be anything and the ACK (client sequence + 1). It means server verify client request and send signal.

  • ACK : Client receive the request and set ACK which by server.

In this 3 way handshake SYN means ‘connection start’ and ACK means ‘receive the request‘.

Where does TCP use?

Most of the time for sending data TCP is used commonly. But some specific area TCP require like Email, message, File transfer, etc. ”where content is more important”.


Now, let’s move to the UDP server.

What does UDP do?

UDP (User datagram protocol) is transport protocol layer which also help to transfer data across the internet with ensuring packet loss and disordering data. It is a less reliable but “It’s faster that TCP and also lightweight”.

Key features:

  1. Connectionless : Without handshaking sends data which reduce the latency because building 3 way handshake is a time taken process which UDP does not follow.

  2. Effortless-service: It does not acknowledge the data loss and retransmit the data.

  3. Speed : UDP is superfast because when it destination/source address to it directly send without permission or asking other server is ready or not? It just send data and in between sometime server could response or some packet are loss.

Where does UDP use?

The use cases of it where speed is more important than content like video streaming, video gaming, DNS lookup, etc.


There is little bit confusion between HTTP and TCP or UDP protocols. most of the time people think HTTP is a part of transport protocol but it’s totally wrong.

HTTP is application level and the TCP and UDP transport level. HTTP decide what will go to server and how? and transporting work TCP and UDP do.

In this diagram can see where HTTP locate application layer and at 4 transport (TCP or UDP) layer and between TCP and UDP which one should be choose this selection done by server most of time.

Conclusion:

In the last TCP and UDP both are transport level protocol TCP is reliable, secure, less speed and on the other hand UDP is less reliable, fast speed , less secure. HTTP is in application layer not transport layer. HTTP defines how does data send and where does it go?

Thank you for reading this blog I hope you found this useful and get something new from it.