Fundamentals 21 min read

Why TCP Beats UDP: Ports, Handshakes, and Flow Control Explained

This article explains the transport layer’s core protocols—TCP and UDP—detailing their functions, differences, port numbers, connection establishment, reliability mechanisms, flow and congestion control, and how applications use client‑server models to communicate over networks.

Open Source Linux
Open Source Linux
Open Source Linux
Why TCP Beats UDP: Ports, Handshakes, and Flow Control Explained

Initial Transport Layer

The transport layer establishes end‑to‑end connections between applications, providing reliable (TCP) or unreliable (UDP) communication services.

TCP is a connection‑oriented reliable protocol; UDP is connection‑less and unreliable.

IP packets contain a protocol number field (6 for TCP, 17 for UDP) to identify the transport protocol. Port numbers identify specific applications on a host, enabling multiplexing of network channels.

Frames (layer 2) and packets (layer 3) are unreliable, but TCP adds reliability through sequence control, retransmission, flow control, and congestion control.

Applications typically follow a client/server model: the server must be running to accept client requests.

Destination port numbers determine the service: port 22 → SSH, port 80 → HTTP.

TCP

TCP provides a reliable byte‑stream. Data sent in multiple 100‑byte chunks may be received as a single continuous stream.

Reliability mechanisms include ordered delivery, retransmission, flow control, congestion control, and window management.

UDP

UDP offers no reliability; the application must handle loss, ordering, and retransmission if needed. It is suitable for low‑latency or real‑time traffic such as DNS, video, or audio.

TCP vs UDP

TCP is reliable and connection‑oriented, suitable for data that must arrive intact. UDP is faster, connection‑less, and ideal for applications that can tolerate loss.

Port Numbers

Port numbers are 16‑bit values ranging from 0 to 65535. Well‑known ports (0‑1023) are assigned to standard services (e.g., HTTP, SSH). Registered ports (1024‑49151) are assigned by IANA. Dynamic ports (49152‑65535) are allocated by the operating system.

A communication flow is uniquely identified by the five‑tuple: source IP, destination IP, protocol number, source port, and destination port.

TCP Handshake

Three‑way handshake establishes a TCP connection: SYN, SYN‑ACK, ACK.

Three‑Way Handshake

Client sends SYN with sequence a.

Server replies with SYN‑ACK, sequence b, acknowledgment a+1.

Client sends ACK with sequence a+1 and acknowledgment b+1.

Four‑Way Termination

Client sends FIN with sequence p.

Server replies ACK ( p+1) and later sends its own FIN with sequence q.

Client replies ACK ( q+1) and closes the connection.

Window and Congestion Control

TCP uses a sliding window to send multiple segments before waiting for acknowledgments. The window size indicates how much data can be sent without acknowledgment.

Congestion control employs slow start, increasing the congestion window by one MSS per ACK until loss is detected.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

TCPReliabilityUDPtransport layerPort Numbers
Open Source Linux
Written by

Open Source Linux

Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.