Why TCP Matters: A Deep Dive into Transport Layer Fundamentals
This article explains the essential concepts of TCP and UDP, covering the OSI layers, physical and data‑link networking, IP addressing, transport‑layer mechanisms such as sliding windows, congestion control, reliable transmission, connection establishment and termination, and compares the strengths and weaknesses of TCP versus UDP.
Introduction
Anyone working in IT inevitably deals with networks, and the most important protocol is TCP. After reading RFCs, Linux source code, and various frameworks, the author decided to share TCP knowledge.
OSI Model Overview
Network communication can be divided into logical layers. The lowest Physical Layer defines hardware connections (e.g., cables, voltage, frequency). Above it is the Data Link Layer , which uses MAC addresses for LAN communication.
Multiple computers are connected via switches to form a LAN (Ethernet). Each host has a unique, permanent MAC address. Communication within a LAN requires only the target MAC address.
Network Layer
The Network Layer introduces IP addresses, providing logical host‑to‑host communication. IP addresses act like postal addresses, allowing routers to forward packets across different LANs.
Transport Layer
The transport layer offers process‑level logical communication . It uses sockets (IP + port) to differentiate applications on the same host. TCP and UDP are the two main transport protocols.
TCP Overview
TCP adds a header (20 bytes fixed, 4 bytes optional) to the data stream, providing reliable, ordered, byte‑stream delivery. Key fields include source/destination ports, sequence number, acknowledgment number, window size, and flags (SYN, ACK, FIN, etc.).
TCP treats the application data as a byte stream, assigning sequence numbers to each byte and segmenting the stream into packets.
Data is read from the send buffer, numbered, and placed into TCP segments.
Segments are sent via the network layer.
The receiver reassembles bytes in order and delivers them to the application.
This design avoids large memory usage but makes the protocol unaware of the semantic meaning of the data, leading to issues such as packet loss, duplication, and reordering.
Reliable Transmission Mechanisms
TCP guarantees delivery using stop‑and‑wait , sliding window , timeout retransmission , cumulative ACK , selective ACK (SACK) , and ARQ strategies.
Stop‑and‑wait sends one segment and waits for an ACK before sending the next. This is simple but inefficient.
Continuous ARQ (also called sliding‑window) allows multiple unacknowledged segments to be in flight, improving throughput. The sender adjusts its window size based on the receiver’s advertised buffer.
When loss occurs, the sender may use Go‑Back‑N (retransmit from the missing segment) or Selective ACK (retransmit only the missing segment).
Flow Control and Congestion Control
Flow control prevents the sender from overwhelming the receiver’s buffer by using the window size field. Congestion control prevents the network from becoming overloaded. TCP employs four key algorithms: slow start , congestion avoidance , fast retransmit , and fast recovery .
Slow start doubles the congestion window each RTT until a loss is detected (timeout or three duplicate ACKs). Then the window is reduced (ssthresh) and grows linearly (congestion avoidance). Fast retransmit triggers after three duplicate ACKs, and fast recovery adjusts ssthresh and resumes linear growth.
Connection Management
TCP is connection‑oriented. Establishment uses a three‑way handshake (SYN, SYN‑ACK, ACK). Termination uses a four‑step handshake (FIN, ACK, FIN, ACK) with the TIME_WAIT state to ensure delayed packets are handled.
UDP Overview
UDP is a lightweight, connection‑less transport protocol. Its header contains only source port, destination port, length, and checksum. UDP provides no reliability, ordering, flow control, or congestion control, making it suitable for low‑latency or broadcast scenarios such as video streaming, DNS, and routing protocols.
Advantages: low overhead, high efficiency, broadcast capability.
Disadvantages: no guarantee of delivery, no congestion control.
Additional Topics
Other important concepts include packet fragmentation (splitting large data into smaller segments to avoid retransmitting huge payloads), routing (multiple paths increase fault tolerance), sticky packets and packet framing (application‑level solutions to delimit messages), security concerns such as SYN‑flood attacks, long‑lived connections, and the impact of malicious traffic on server resources.
Conclusion
Understanding TCP/UDP fundamentals, reliable transmission, congestion control, and connection management is crucial for designing robust networked applications and for performing effective system and network engineering.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Open Source Linux
Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
