Addressing in the Transport Layer: Port Numbers

 

Addressing in the Transport Layer: Port Numbers

Introduction

One of the primary responsibilities of the Transport Layer is to provide process-to-process communication. While the Network Layer identifies the destination host (computer) using an IP address, the Transport Layer identifies the specific application process running on that host using a port number.

Thus, successful communication over the Internet requires both:

  • IP Address → Identifies the destination computer (host).
  • Port Number → Identifies the destination application (process).

Without port numbers, data would reach the destination computer but the operating system would not know which application should receive the data.


What is a Port Number?

A port number is a 16-bit integer assigned to a process (application) running on a host.

  • Size = 16 bits
  • Range = 0 to 65,535

Each process communicating through the transport layer is identified by a unique port number.

Port Number = 16 bits

0 ---------------------------------------- 65535

Why are Port Numbers Needed?

A computer can run multiple applications simultaneously.

For example:

  • Web Browser
  • Email Client
  • FTP Client
  • Video Streaming
  • Online Games

When data arrives at the computer, the operating system must determine which application should receive it.

The transport layer uses the destination port number to deliver the data to the correct process.


Example

Suppose a user opens:

  • Google Chrome
  • Outlook
  • FTP Client

All applications are connected to the Internet simultaneously.

                 Computer

        +----------------------+
        | Web Browser          |
        | Port 51000           |
        +----------------------+

        +----------------------+
        | Email Client         |
        | Port 52000           |
        +----------------------+

        +----------------------+
        | FTP Client           |
        | Port 53000           |
        +----------------------+

When a packet arrives,

  • Port 51000 → Web Browser
  • Port 52000 → Email Client
  • Port 53000 → FTP Client

Client and Server Port Numbers

Communication usually follows the client-server model.

Client --------------------------> Server

Both client and server require port numbers.

However, they use different types of ports.


Client Port Number (Ephemeral Port)

A client chooses a temporary port number, called an ephemeral port.

Characteristics

  • Assigned automatically by the operating system.
  • Temporary (short-lived).
  • Changes every time a connection is established.
  • Usually greater than 1023.

Example

Web Browser

Source Port = 52000

After communication ends, the port number is released.


Server Port Number (Well-Known Port)

Servers always use fixed (well-known) port numbers.

These port numbers are standardized so that every client knows where to connect.

Example

HTTP Server

Destination Port = 80

HTTPS Server

Destination Port = 443

DNS Server

Destination Port = 53

Since these port numbers never change, clients can easily locate the corresponding server.


Example of Client-Server Communication

Suppose Alice wants to access a web page.

Client (Alice)

IP Address : 192.168.1.10
Port       : 52000

        |
        | HTTP Request
        |
        V

Server

IP Address : 142.250.190.78
Port       : 80

The packet contains

Source IP        : 192.168.1.10
Destination IP   : 142.250.190.78

Source Port      : 52000
Destination Port : 80

The server sends the response back using the reverse addresses.


Example: Daytime Protocol



Client

Port = 52000 (Ephemeral)

Server

Port = 13 (Well-known)

Communication

Daytime Client                 Daytime Server

Port 52000  ---------------->  Port 13

The client uses a temporary port, whereas the server always listens on port 13.


IP Address vs Port Number



Both are required for communication but perform different functions.

FeatureIP AddressPort Number
Identifies        Host (Computer)    Process (Application)
Layer        Network Layer    Transport Layer
Size        32 bits (IPv4) / 128 bits (IPv6)    16 bits
Example        192.168.1.20    80
Used For        ost-to-host communication    Process-to-process communication

Analogy

Imagine sending a letter.

IP Address is like the building address.

Government Model Engineering College
Thrikkakara

Port Number is like the room number.

Computer Engineering Department
Room No. 203

The postal service first delivers the letter to the correct building (host), then to the correct room (process).


ICANN Port Number Ranges


The Internet Corporation for Assigned Names and Numbers (ICANN) classifies port numbers into three categories.



1. Well-Known Ports (0–1023)

  • Assigned and controlled by ICANN.
  • Reserved for standard services.
  • Used by servers.

Examples

PortService
20        FTP Data
21    FTP Control
22    SSH
23    TELNET
25    SMTP
53    DNS
69    TFTP
80    HTTP
110    POP3
143        IMAP
161    SNMP
162    SNMP Trap
443    HTTPS

2. Registered Ports (1024–49151)

  • Not assigned by default.
  • Can be registered with ICANN.
  • Used by user applications and proprietary services.

Examples

  • Database servers
  • Application servers
  • Enterprise software

3. Dynamic (Private/Ephemeral) Ports (49152–65535)

  • Not controlled by ICANN.
  • Assigned temporarily by the operating system.
  • Mainly used by client applications.

Example

Chrome Browser

Source Port = 52345

After communication finishes, the port is released.



Common Well-Known Port Numbers

ProtocolPort Number
FTP Data    20
FTP Control    21
SSH    22
TELNET    23
SMTP    25
DNS    53
DHCP Server    67
DHCP Client    68
TFTP    69
HTTP    80
POP3    110
IMAP    143
SNMP    161
SNMP Trap    162
HTTPS    443

Socket Address

A Socket Address uniquely identifies a process on a host.

It is the combination of:

Socket Address = IP Address + Port Number

Example

192.168.1.100 : 52000

or

142.250.190.78 : 80

Thus,

  • IP Address identifies the host.
  • Port Number identifies the process.

Together they uniquely identify an application running on the Internet.




Client and Server Socket Addresses

Communication requires two socket addresses.

Client Socket Address

(IP Address + Port Number)

192.168.1.10 : 52000


Server Socket Address

(IP Address + Port Number)

142.250.190.78 : 80

The transport layer uses both socket addresses to establish end-to-end communication.

Client Socket -------------------------> Server Socket

192.168.1.10:52000         142.250.190.78:80


Summary

  • The Transport Layer uses port numbers to provide process-to-process communication.
  • A port number is a 16-bit identifier (0–65,535) assigned to an application process.
  • Clients typically use ephemeral (temporary) port numbers, while servers use well-known (fixed) port numbers.
  • ICANN classifies ports into Well-Known (0–1023), Registered (1024–49151), and Dynamic/Private (49152–65535) ranges.
  • An IP address identifies the destination host, whereas a port number identifies the destination application.
  • A socket address is the combination of an IP address and a port number, and a communication session is uniquely identified by the client socket address and the server socket address.

Comments

Popular posts from this blog

Computer Networks PCCST501 Semester 5 KTU CS 2024 Scheme - Dr Binu V P

Introduction to Computer Networks

Introduction to Local Area Network (LAN)