Skip to main content

Command Palette

Search for a command to run...

Two Protocols that runs the Internet: TCP vs UDP explained simply

Updated
5 min read
Two Protocols that runs the Internet: TCP vs UDP explained simply

Did you ever wonder that how does server makes a response to client when client makes some requests. This responses travels through some protocols those 2 protocols are known as TCP & UDP. They are simply just 2 protocols that moves data from one application to another .They both are transport layer protocols.

why internet needs this protocols ?

imagine internet as a massive highway . IP is that system which guides cars (data packets ) to move from one computer to another. IP is very basic system it just dumps the data to another computer and does not care about the data is reached or crashed or being theft. That is why we need Transport layer protocols to handles what happens after the data reaches the device. Without them the internet would be chaotic.

What is TCP?

Transmission Control Protocol (TCP) is a transport layer protocol , It is a standard that defines how to establish and maintain a network conversation through which application program exchanges data. if IP is a address system then TCP is a guarantee delivery service.

How TCP works?

Assume when we call someone from phone,

  • we dial the number and say hello that is ( request connection )

  • then other person will say hello ( that’s acknowledge request)

  • you starts talking ( connection established)

That was a real life scenario how does 3 way handshake connection establishes. but now lets talk about how TCP do this, the process known as 3 way handshake :

Key Features of TCP:

  1. Reliability : very time TCP sends a packet, it starts a timer. If the receiver doesn't send back an acknowledgment (ACK) saying "I got it" before the timer runs out, TCP assumes the packet was lost and resends it automatically.

  2. Order / Sequence : Data packets often take different routes across the internet and arrive out of order (e.g., Packet 3 arrives before Packet 2).TCP numbers every packet. The receiver uses these numbers to put them back in the correct order before handing the data to the app.

  3. Flow control : TCP manages the speed of data. If the receiver is overwhelmed, it tells the sender to slow down.

  4. Error checking : If the data is bad, TCP discards it and asks for a fresh copy.

When is TCP used :

TCP is used in any application where accuracy is more important than speed. for example

  1. web browsing ( we don’t want website showing incomplete texts )

  2. emails

  3. file transfer

  4. Text messaging apps like WhatsApp

real world example for TCP are :

  • open a website

  • Log in to an account

  • Send an email

What is UDP ?

User Datagram Protocol (UDP) is a transport layer protocol which is used to send data quickly. There is no confirmation weather data reached or not , is is just like throwing data to IP address and we hope that it arrives , UDP does not wait for confirmation and instantly send other data. there is no 3 way handshake process in this protocol.

How does UDP works :

unlike TCP here there is no 3 way handshake connection , it simply just takes application data into small packets and attaches a very small header just to know where data is going and then it just sends data super quick.

Features of UDP:

  1. Unreliable : UDP is often called a "Best Effort" service. If a packet drops due to network congestion, UDP does not resend it. The data is simply lost forever.

  2. unordered : If you send Packet A, then Packet B, they might arrive as B then A.

  3. Lightweight and high speed

  4. no control flow

When is UDP used :

  • Online gaming

  • video streaming

  • DNS

real life scenario of UDP is video streaming platform like Netflix , jiohotstar, games etc .

Difference between TCP & UDP :

TCPUDP
It is ReliableIt is non Reliable
it is slow compared to UDPit is very fast
guarantees Data transferno guarantee
do retransmission if data didn’t delivered properlydoesn’t do any retransmission
Flow controlNo flow control
It follows order/sequencedoesn’t follow order

What is HTTP:

HTTP stands for HyperText Transfer Protocol. if TCP is delivery truck then HTTP is the order of delivering the packets . it defines the format and language that browsers and server talk to each other.

for eg: when we search google.com

  1. HTTP creates a specific message: "GET me the homepage."

  2. it hands this message to TCP to deliver it safely.

  3. The Server's TCP receives it and hands it to the Server's HTTP

  4. Server understands the message and sends back the website code (HTML).

Where does it fits :

  • application layer

  • transport layer

  • network layer

  • physical layer : actual wifi radio waves or ethernet cables.

Relationship between TCP and HTTP :

HTTP has almost exclusively used TCP. When you load a webpage, you need the HTML, CSS, and JavaScript to arrive perfectly. If a line of JavaScript is missing (packet loss), the button on the site won't work. Therefore, HTTP relies on TCP's reliability.


Thank you for reading . Have a happy learning journey. I hope this article added some value for your given precious time.