Updated on 12 Jun, 202620 mins read 23 views

The Fundamental Requirement of Communication

Imagine two people want to talk over the phone.

For communication to happen, each person must know:

  1. Who they want to call
  2. How to reach them

Computers work the same way.

For one computer to communicate with another, it needs:

Identity + Location

On the Internet, this location is represented by an IP address.

What Is an IP Address?

An IP address is the network address of a device.

Think of it like a home address.

Example:

House Address: 777 Chahal street, KKR

A courier uses that address to deliver a package.

Similarly:

IP Address: 142.250.193.78

allows network packets to reach a device.

Without an address, nobody knows where to send data.

Why Computers Need Addresses

Suppose Alice wants to send data to bob.

Without addresses:

Alice
  |
  |-----> ????

Where should the data go?

The network has no idea.

Addresses solve this problem.

Alice
  |
  |-----> 142.250.193.78

Now the network knows the destination.

IPv4 Addresses

Most addresses are written like:

192.168.1.10

Each section:

0 - 255

Example:

10.0.0.5
172.16.10.25
8.8.8.8
1.1.1.1

The IPv4 Limitation

IPv4 supports approximately:

4.3 billion addresses

Years ago this seemed enormous.

Today we have:

  • laptops
  • phones
  • tablets
  • smart TVs
  • IoT devices

Billions of devices.

Eventually the world began running out of IPv4 addresses.

This led to one of the most important networking inventions: NAT

We will cover this shortly.

Public and Private Networks

Not every IP address is visible on the Internet.

There are two major categories:

Public IP

Visible globally.

Anyone on the Internet can potentially reach it.

Example:

49.37.220.12

Private IP

Used inside local networks.

Examples:

192.168.x.x
10.x.x.x
172.16.x.x - 172.31.x.x

Private addresses cannot be reached directly from the Internet.

The outside Internet cannot directly see them.

What Is a Router?

A router connects different network together.

You home router connects:

Home Network
        |
        |
     Router
        |
        |
Internet

Think of it as a traffic manager.

It decides:

Where packets should go

The Problem Appears

Suppose Laptop:

192.168.1.10

tries to access Google

Google receives:

Request from 192.168.1.10

Problem:

Millions of homes use:

192.168.1.10

Google cannot uniquely identify the device.

This is where NAT enters.

Understanding NAT

NAT means Network Address Translation

One of the most important concepts in WebRTC.

Many WebRTC problems exist solely because NAT exists.

Why NAT Was Invented

The world didn't have enough IPv4 addresses.

Instead of giving every device a public address:

Laptop
Phone
TV
Tablet

all devices share a single public address.

Example:

Public IP: 49.37.220.12

Home Network Example:

Inside:

Laptop = 192.168.1.10
Phone = 192.168.1.11
TV = 192.168.1.12
Outside:

49.37.220.12

Everybody appears as:

49.37.220.12

to the Internet.

How NAT Works

When your laptop sends:

Hello Google

the router rewrites the packet.

Before:

Source: 192.168.1.10

After:

49.37.220.12

Google thinks the request came from:

49.37.220.12

not:

192.168.1.10

NAT Translation Table

Router maintains a table.

Example:

192.168.1.10 -> Port 50000
192.168.1.11 -> Port 50001
192.168.1.12 -> Port 50002

When response return:

49.37.220.12:5000

Router knows:

Send to Laptop

NAT Solved One Problem

It allowed billions of devices to share a small number of public addresses.

But it create a new problem, which is the Inbound Connection Problem

The Inbound Connection Problem

Imagine:

Alice: 192.168.1.10

behind a router.

Bob wants to connect directly.

Bob sends:

Connect to 192.168.1.10

Impossible.

Why?

Because:

192.168.1.10

exists only inside Alice's network.

The Internet cannot see it.

Why This Matters For WebRTC

Peer-to-Peer communication requires:

Alice <-> Bob

But if both are hidden behind NAT:

Alice Router
        |
     Internet
        |
Bob Router

Neither knows how to directly reach the other.

This becomes WebRTC's biggest challenge.

Ports

An IP identifies the machine.

But one machine runs many applications.

Example:

Chrome
Zoom
Spotify
VS code
Discord

If a packet arrives, who should receive it?

The answer is: Ports

IP addresss and Port together uniquely identify a service.

Socket

Combining:

IP Address + Port

creates: Socket

Example:

49.37.220.12:443

A socket is an endpoint for communication.

Transport Protocols

Now we know: IP Address + Port

But how should data travel?

Two major options exist:

TCP
UDP

TCP: Transmission Control Protocol

Designed for reliability.

Guarantees:

  • delivery
  • ordering
  • retransmission

Example:

Suppose:

Packet 1
Packet 2
Packet 3

sent.

If Packet 2 disappear:

TCP waits.

Packet 1 ✓
Packet 2 ❌
Packet 3 ✓

TCP requests retransmission.

Only then continues.

Reliable.

Why TCP Is Great

Perfect for:

  • websites
  • APIs
  • Databases
  • file downloads

Because correctness matters more than speed.

Why TCP Is Bad For Real-Time Media

Suppose, Video frame 100 lost.

TCP says:

Wait

Retransmit.

During this wait:

Frame 101
Frame 102
Frame 103

cannot be delivered properly.

Video freezes.

UDP: User Datagram Protocol

UDP says:

Send packet
Forget packet

No guarantees.

No retransmissions.

No ordering.

Example:

Packet 1 ✓
Packet 2 ❌
Packet 3 ✓

UDP continues.

No waiting.

Why UDP Is Perfect For Real-Time Media

Imagine a live conversation.

Would you rather:

Option A:

Miss one word

or

Option B:

Freezes conversation for 3 seconds.

Most people choose A.

This is why video calls prefer UDP.

TCP vs UDP

FeatureTCPUDP
ReliableYesNo
OrderedYesNo
RetransmissionYesNo
LatencyHigherLower
Video CallsPoor ChoiceExcellent Choice
File DownloadExcellentPoor Choice

Firewalls

One more obstacle.

Organizations often deploy:

Firewalls

to control traffic.

Firewall rules may:

Allow
Block
Inspect

network packets.

Many WebRTC failures happen because:

Firewall Blocks Traffic
Buy Me A Coffee

Leave a comment

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