CLOSE
Updated on 28 Feb, 202614 mins read 7 views

The Problem: Delivery Is Still Not Guaranteed

So far, we have learned:

  • Layer 1: moves bits
  • Layer 2: delivers frames locally
  • Layer 3: routes packets between networks

At this point, packets can travel across the world.

But a huge problem still exists.

Imagine Sending a Book Page by Page

You send a 500-page book by mail.

Each page travels independently.

What could go wrong?

  • Page arrive out of order
  • Some pages are lost
  • Some arrive twice
  • Some get damaged
  • Receiver doesn't know when book ends

This is exactly how IP works.

Reality of IP (Layer 3)

IP provides:

  • Addressing
  • Routing
  • Best-effort delivery

But IP does NOT guarantee:

  • Delivery
  • Order
  • No duplication
  • Reliability
  • Speed control

IP simply says:

“I will try my best.”

Applications need much more.

The Need for End-to-End Control

We need a system that ensures:

  • Data arrives completely
  • Data arrives correctly
  • Data arrives in order
  • Sender does not overwhelm receiver
  • Multiple apps share one connection safely

This responsibility belongs to:

The Tansport Layer (Layer 4)

What the Transport Layer Does

The transport layer provides:

Communication between applications, not just devices.

Layer 3: computer -> computer

Layer 4: application -> application

Example

Your laptop runs:

  • Browser
  • WhatsApp
  • Spotify
  • Email client

All using the Internet simultaneously.

How does data go to the correct application?

Transport layer solves this.

Ports – Talking to the Right Application

Transport layer introduces:

Port Numbers

Think of IP address as a building address.

Ports are apartment numbers.

Example Address

IP: 142.250.183.14
Port: 443

Meaning:

  • Device = Google server
  • Application = HTTPS web service

Common Ports

PortService
80HTTP
443HTTPS
25Email SMTP
53DNS
22SSH

Now routers deliver to device.

Transport layer delivers to correct program.

Segmentation – Breaking Data into Pieces

Applications send large data.

Transport layer splits it into segments.

Example:

Large File
   ↓
Segment 1
Segment 2
Segment 3
...

Each segment travels independently.

Later reassembled.

Two Different Philosophies

Transport layer offers TWO communication styles:

  1. TCP – Reliable
  2. UDP – Fast

They solve different problems.

TCP (Transmission Control Protocol)

TCP Philosophy

TCP says:

Reliability first.

It guarantees:

  • Ordered delivery
  • No data loss
  • Error recovery
  • Congestion control

TCP Connection – The Three-Way Handshake

Before sending data, TCP establishes a connection.

Step 1: SYN

Client -> Server:

“Can we talk?”

Step 2: SYN-ACK

Server -> Client:

“Yes, I am ready.”

Step 3: ACK

Client -> Server:

“Connection established.”

Connection ready.

Reliably Delivery

Every TCP segment has a sequence number.

Receiver sends acknowledgment (ACK):

Received up to byte 5000

If sender doesn't receive ACK:

Retransmit data.

Ordering Guarantee

Even if packets arrive:

3 → 1 → 2

TCP reorders them:

1 → 2 → 3

Application never sees disorder.

Flow Control

Receiver may be slow.

TCP asks:

“How much data can you handle?”

Receiver advertises a window size.

Prevents overload.

Congestion Control (Internet Safety System)

TCP monitors network congestion.

If packets drop:

  • Reduce sending speed
  • Gradually increase again

This prevents Internet collapse.

Where TCP Is Used

ApplicationWhy TCP
Web browsingAccuracy required
File downloadsNo corruption allowed
EmailMust be complete
SSHReliable control

UDP (User Datagram Protocol)

UDP Philosophy

UDP says:

Speed over reliability.

No connection.

No guarantees.

Just send.

UDP Characteristics

  • Very fast
  • Low overhead
  • No handshake
  • Minimal delay

But:

  • No retransmission
  • No ordering
  • No congestion control

UDP Analogy

TCP = phone call

UDP = shouting messages in a crowd

Where UDP Is Used

ApplicationWhy TCP
Web browsingAccuracy required
File downloadsNo corruption allowed
EmailMust be complete
SSHReliable control

TCP vs UDP Comparison

FeatureTCPUDP
ConnectionYesNo
ReliableYesNo
OrderedYesNo
SpeedSlowerFaster
OverheadHighLow
Use CaseAccuracyReal-time
Buy Me A Coffee

Leave a comment

Your email address will not be published. Required fields are marked *

Your experience on this site will be improved by allowing cookies Cookie Policy