中文
English

TCP/IP Protocol Guide

2026-03-26

In today's highly interconnected world, whether browsing the web, sending emails, streaming videos, remotely monitoring industrial equipment, or collecting IoT data, all network communication relies on a core set of protocols—TCP/IP. As the foundation of the Internet, the TCP/IP protocol suite supports the interconnection of billions of devices worldwide. Understanding this protocol suite is essential for professionals working in network technology, industrial communication, and IoT development.

I. Overview of the TCP/IP Protocol Suite

TCP/IP is not a single protocol but a collection of protocols, named after its two most important components: the Transmission Control Protocol (TCP) and the Internet Protocol (IP). This protocol suite adopts a layered architecture, typically divided into four layers:

LayerFunctionMain Protocols
Application LayerProvides network services for user applicationsHTTP, FTP, SMTP, MQTT, Modbus TCP
Transport LayerProvides end-to-end communication servicesTCP, UDP
Network LayerHandles packet routing and forwardingIP, ICMP, ARP
Network Interface LayerManages physical network hardwareEthernet, Wi-Fi, 4G/5G

This layered design ensures clear separation of responsibilities, facilitating protocol design, implementation, and maintenance.

II. Internet Protocol (IP): The Internet's Addressing System

The IP protocol is responsible for sending data packets from source devices to destination devices, defining addressing methods and routing mechanisms on the network.

IP Addresses

Every device connected to a network is assigned a unique IP address, similar to a postal address. There are currently two main versions of the IP protocol:

  • IPv4: 32-bit addresses, typically expressed as four decimal numbers (e.g., 192.168.1.1), providing approximately 4.3 billion addresses. With the explosive growth of connected devices, IPv4 addresses have been largely exhausted.

  • IPv6: 128-bit addresses, expressed in hexadecimal notation, providing virtually unlimited address space to meet the addressing needs of the massive number of devices in the IoT era.

IP Packet Structure

The IP protocol encapsulates data into packets for transmission. An IP packet consists of a header and a data section:

  • Header: Contains key information such as source IP address, destination IP address, time-to-live (TTL), and protocol type

  • Data: Carries actual data from upper layers (such as TCP or UDP)

Routing and Forwarding

The IP protocol does not guarantee reliable packet delivery—it is only responsible for sending packets to the destination address. Packets may be lost, arrive out of order, or be duplicated during transmission. These reliability issues are handled by upper-layer protocols (such as TCP).

III. Transmission Control Protocol (TCP): Reliable Transport Service

TCP is the core protocol that provides reliable transmission on top of IP. It addresses the unreliability of the IP protocol, offering connection-oriented, reliable, and ordered byte-stream services to the application layer.

TCP Segment Header

The TCP segment header is the core structure of the TCP protocol, containing key information for controlling data transmission. The standard TCP header length is 20 bytes (without options) and can be extended to up to 60 bytes. Main fields include:

FieldLengthPurpose
Source Port16 bitsIdentifies the sending application
Destination Port16 bitsIdentifies the receiving application
Sequence Number32 bitsIdentifies the position of each byte in the data stream for ordering
Acknowledgment Number32 bitsIndicates the next expected byte, used to confirm received data
Data Offset4 bitsIndicates the length of the TCP header
Control Flags6 bitsContains SYN, ACK, FIN, RST, etc., used for connection management

Control Flags Explained

The six control flags in the TCP header are critical for connection management and data transmission:

  • SYN: Synchronization flag, used to synchronize sequence numbers when establishing a connection

  • ACK: Acknowledgment flag, indicates that the Acknowledgment Number field is valid

  • FIN: Finish flag, used to gracefully close a connection

  • RST: Reset flag, used to abruptly terminate a connection

  • PSH: Push flag, instructs the receiver to immediately deliver data to the application layer

  • URG: Urgent flag, indicates that the Urgent Pointer field is valid

Three-Way Handshake to Establish a Connection

TCP establishes a reliable connection through a "three-way handshake":

  1. First Handshake: The client sends a SYN packet to the server, indicating its initial sequence number

  2. Second Handshake: The server replies with a SYN-ACK packet, acknowledging receipt of the client's SYN and sending its own SYN

  3. Third Handshake: The client replies with an ACK packet, acknowledging receipt of the server's SYN

After the three-way handshake is completed, the connection is established and data transmission begins.

Four-Way Handshake to Release a Connection

TCP connection termination follows a "four-way handshake" process:

  1. The active party sends a FIN packet, indicating it has finished sending data

  2. The passive party replies with an ACK, acknowledging receipt of the FIN

  3. The passive party sends a FIN packet, indicating it has also finished sending data

  4. The active party replies with an ACK, acknowledging receipt of the FIN

Reliable Transmission Mechanisms

Key mechanisms that enable TCP's reliable transmission include:

  • Sequence Numbers and Acknowledgments: Every byte sent has a sequence number; receivers use acknowledgment numbers to indicate which data has been received

  • Timeout Retransmission: If the sender does not receive an acknowledgment within a specified time, it retransmits the data

  • Flow Control: Uses the window field to inform the sender of its receiving capacity, preventing data loss due to excessive transmission speed

  • Congestion Control: Dynamically adjusts the sending rate based on network conditions to prevent network congestion

IV. TCP vs. UDP Comparison

In addition to TCP, the transport layer includes another important protocol—UDP (User Datagram Protocol). Each has distinct characteristics suited for different scenarios:

FeatureTCPUDP
Connection TypeConnection-orientedConnectionless
ReliabilityReliable, guarantees deliveryBest-effort, may lose packets
Data OrderingGuarantees orderNo guarantee of order
Flow ControlSupportedNot supported
Congestion ControlSupportedNot supported
Header Overhead20 bytes8 bytes
Typical ApplicationsWeb browsing, file transfer, industrial controlReal-time audio/video, DNS queries, SNMP

V. TCP/IP in Industrial Communication

In industrial automation and IoT, the TCP/IP protocol suite also plays a central role:

Modbus TCP

Modbus TCP encapsulates the classic Modbus RTU protocol over TCP/IP, enabling industrial equipment to communicate over Ethernet. Compared to traditional serial Modbus, Modbus TCP supports higher communication speeds and more flexible networking.

MQTT over TCP

MQTT is a lightweight IoT communication protocol based on TCP, widely used for data transmission between devices and cloud platforms. TCP's reliable transmission ensures accurate delivery of control commands and critical data.

Industrial Gateways and Protocol Conversion

Industrial gateways often use TCP/IP to achieve conversion between different protocols:

  • Converting Modbus RTU from serial devices to Modbus TCP

  • Encapsulating PLC data for upload to cloud platforms via TCP

  • Receiving cloud commands over TCP and delivering them to field devices

VI. Common TCP/IP Issues and Troubleshooting

Connection Timeout

Possible causes:

  • Target server not running or network unreachable

  • Firewall blocking the port

  • Route unreachable

Troubleshooting methods: Use ping to test network connectivity, use telnet or netcat to test port reachability

Connection Reset (RST)

Possible causes:

  • Target port not open

  • Application layer abnormally closed the connection

  • Firewall actively interrupted

Troubleshooting: Check server program status, confirm port is listening properly

Slow Data Transmission

Possible causes:

  • Network congestion or insufficient bandwidth

  • TCP window size set too small

  • Packet loss causing retransmissions

Troubleshooting: Use network monitoring tools to analyze traffic, check packet loss rate and latency

VII. Future Evolution of TCP/IP

IPv6 Adoption

With the explosive growth of IoT devices, IPv6 deployment is accelerating. IPv6 not only solves the address exhaustion problem but also offers better security and auto-configuration capabilities.

Next-Generation Transport Protocols

QUIC (Quick UDP Internet Connections) is emerging as a new protocol. Based on UDP but providing reliability similar to TCP, it solves TCP's head-of-line blocking problem and is used in HTTP/3.

Industrial Scenario Optimization

In industrial internet applications, the demand for low latency and high reliability is driving the development of technologies such as TSN (Time-Sensitive Networking), enabling TCP/IP to better support industrial real-time control scenarios.


The TCP/IP protocol suite is the foundation of the Internet era. Through its layered design, reliable transmission, and flexible addressing, it supports global data communication. From the early ARPANET to today's industrial internet, TCP/IP has evolved over decades, and its core design principles remain highly resilient. For network technology professionals, a deep understanding of TCP/IP is essential for network planning, troubleshooting, and system optimization. Whether building industrial IoT platforms or developing network applications, TCP/IP is fundamental knowledge that must be mastered.


share
Next:This is the last one
Prev:This is the first article