TCP

Giao thức

Định nghĩa

Transmission Control Protocol. Giao thức truyền tải đáng tin cậy, hướng kết nối, đảm bảo chuyển giao dữ liệu có thứ tự, kiểm tra lỗi thông qua bắt tay ba bước, xác nhận và truyền lại. Là nền tảng của HTTP, SSH và hầu hết các dịch vụ internet.

Reliable, Ordered Delivery

TCP (Transmission Control Protocol) is the transport-layer protocol that provides reliable, ordered, and error-checked delivery of data between applications. Before any data is exchanged, TCP establishes a connection through a three-way handshake: SYN, SYN-ACK, ACK. Each byte of data is numbered with a sequence number, and the receiver acknowledges receipt. Lost packets are detected and retransmitted automatically, ensuring the application receives a complete, ordered byte stream.

Flow Control and Congestion Control

TCP includes two interrelated mechanisms to prevent overwhelming receivers and networks. Flow control uses a receive window advertised by the receiver to tell the sender how much data it can buffer. Congestion control uses algorithms (Cubic, BBR, RENO) to estimate available BandwidthThe maximum data transfer rate of a network link, typically measured in bits per second (Mbps, Gbps). Bandwidth represents capacity, not actual speed; real-world transfer rates depend on latency, congestion, and protocol overhead. and adjust the sending rate dynamically, backing off when Packet LossThe percentage of data packets that fail to reach their destination, typically caused by network congestion, faulty hardware, or wireless interference. Even 1-2% packet loss can noticeably degrade voice and video quality. signals network congestion and probing for more capacity when the network is clear.

When to Use TCP vs. UDP

TCP's reliability guarantees make it ideal for applications where data integrity is essential: web (HTTPHypertext Transfer Protocol. The application-layer protocol for transmitting web pages, APIs, and other resources. HTTP defines methods (GET, POST, PUT, DELETE) and status codes for client-server communication./HTTPSHTTP Secure. The encrypted version of HTTP that uses TLS to protect data in transit between a browser and a web server. Identified by the padlock icon in browsers and the https:// URL scheme.), email (SMTPSimple Mail Transfer Protocol. The standard protocol for sending email between servers and from clients to servers (port 25/587). SMTP handles outbound delivery, while IMAP or POP3 handle retrieval., IMAPInternet Message Access Protocol. An email retrieval protocol that synchronizes messages between a server and multiple clients, keeping emails stored on the server. Supports folders, search, and partial message fetching.), file transfer (FTPFile Transfer Protocol. A standard protocol for transferring files between a client and server over TCP (ports 20/21). FTP transmits data in plaintext; SFTP (over SSH) and FTPS (over TLS) are secure alternatives., SSHSecure Shell. A cryptographic protocol for secure remote login, command execution, and file transfer over an unsecured network. SSH (port 22) replaced insecure protocols like Telnet and rlogin.), and database queries. The cost is LatencyThe time delay for a data packet to travel from source to destination, typically measured in milliseconds (ms). Lower latency is critical for real-time applications like video calls, gaming, and financial trading.: the handshake, acknowledgments, and retransmission delays add overhead. UDPUser Datagram Protocol. A connectionless transport protocol that sends datagrams without establishing a connection or guaranteeing delivery. Faster than TCP, it is preferred for real-time applications like DNS queries, VoIP, gaming, and streaming. is preferred when low latency matters more than guaranteed delivery, as in video calls, gaming, and DNS. HTTP/3 moves web traffic to QUIC (a UDP-based transport) precisely to get TCP-like reliability without TCP's head-of-line blocking.

Thuật ngữ liên quan

Thêm trong Giao thức