What is Transmission Control Protocol (TCP)?
Transmission Control Protocol (TCP) is a communication protocol that establishes a reliable connection between devices, services, and applications across a network.
What is Transmission Control Protocol (TCP)?
Transmission Control Protocol (TCP) is a communication protocol for networks that focuses on the connection phase between devices, services, and applications. TCP establishes a connection between a data sender and a data receiver and translates data into a sequence of packets, ensuring the receiver can verify the sequence. TCP is part of the TCP/IP stack, where the Internet Protocol (IP) routes the data over a network. TCP is an essential protocol in everyday networking over the Internet and across the cloud.
How does TCP work?
Transmission Control Protocol (TCP) is a data transfer method that operates in the transport layer of the Internet protocol suite. Maintained by the Internet Engineering Task Force, TCP is in wide use by many applications, such as email services, peer-to-peer data streams, file transfer, and the Internet of Things. These applications use high-level protocols, such as hypertext transfer protocol secure (HTTPS), file transfer protocol (FTP), and secure sockets layer and transport layer security (SSL/TLS), on top of TCP.

Here are the key components of TCP.
Three-way handshake

In a TCP setup, the server and the clients can send and receive data. The server actively listens for incoming connections initiated by clients. Here is how a client, or sender, connects to a TCP server.
- The sender sends a SYN packet to the receiver.
- The receiver sends a SYN-ACK packet back to the sender.
- The sender sends an ACK packet to complete the connection.
After establishing the connection, both devices can exchange data across the network, including the Internet or a cloud network.
Data transmission
TCP breaks the original message into multiple smaller segments, assigns sequence numbers to each, and transmits them across the network. When a sender transfers data, it starts a countdown timer. During transmission, some TCP segments might use different paths to reach the destination.
When the data packets arrive at the destination, the receiver assembles them based on the numbered segments. Then, the receiver sends an ACK packet to the sender to indicate that it has successfully received the message in sequence. If the sender fails to receive an ACK after the transmission timer expires, it retransmits.
TCP uses several features to mitigate packet losses, network congestion, and data corruption.
Flow control
When exchanging data, the receiver provides the number of bytes it can accept in the window size through the TCP header. A TCP header is a special field that contains instructions on how to handle the TCP packet. This way, the sender can adjust the message size for the subsequent transmission to help prevent overwhelming the receiver.
Congestion control
TCP detects network congestion by tracking the ACK responses, packet loss, and transmission time out. If the receiver doesn’t respond within a specific duration, the sender assumes the network is congested and limits how much data it sends. Then, it monitors the network conditions and increases the amount of data it sends accordingly.
Error detection
TCP uses a checksum to detect data packet corruption during data delivery. A checksum is a number calculated from the data that a sender transmitted. When receiving the incoming data, the receiver calculates the checksum and compares it against the checksum in the received data packet. If the checksums do not match, the receiver discards the packet. The sender then retransmits the same data packet.
Connection end
Both sender and receiver can close a TCP connection. We share the sequence connection termination that a sender initiated.
- The sender sends a FIN packet to the receiver.
- The receiver sends an ACK followed by a FIN packet.
- The sender sends an ACK packet to close the connection.
What is the difference between TCP and UDP?
Both transmission control protocol (TCP) and user datagram protocol (UDP) are transport layer protocols that allow applications to exchange data. UDP is a connectionless protocol that doesn’t support orderly data transfer. Meanwhile, TCP is a connection-oriented protocol that provides reliable data transfer with orderly, sequenced data packets. UDP is faster, but doesn’t confirm delivery or reliable network connections. Meanwhile, TCP data packets require more time to transmit and are more accurate.
What are TCP ports?
TCP ports are used in conjunction with IP addresses to route internet traffic. TCP ports are a type of identifier that network devices use to deliver TCP traffic to the correct application. TCP ports range from 0 to 65535.
Each port number corresponds to a specific application or service. A TCP packet includes the source port and destination port. When processing a TCP packet, devices check the destination port to determine which application should receive the data.
What are some TCP best practices?
TCP implementation often requires adjustment to balance reliability, throughput, and latency. Here are some best practices in TCP implementation.
Timeout configuration
Consider network latency and round-trip time when setting TCP retransmission timeout. Occasionally, a traffic spike might cause a delay in TCP responses. Adjust the timeout based on changing traffic conditions, such as retransmission attempts, TCP latency, and resource usage.
Buffer size
A buffer is a temporary storage that devices can use for sending and receiving TCP data packets. When transmitting data, the device reads from a buffer. The buffer might become full if the sender fails to receive timely ACKs and remove sent data. Similarly, the receiving buffer can become full if the application doesn’t retrieve the stored information quickly enough. Allocate sufficient buffer size to help prevent transmission bottlenecks.
Connection pools
Connection pooling keeps TCP connections open even when they’re not in use. Applications can reuse the TCP connections instead of creating new ones. This is helpful for applications that have low tolerance to delays caused by handshakes when creating and closing the connection.
Selective acknowledgement
Selective acknowledgement is a method that helps devices handle missing packets more effectively. By default, a sender retransmits data packets that are assumed lost when the receiver doesn’t send an ACK.
In some cases, the sender might wait for an entire round trip before it manages to identify specific lost packets. With selective acknowledgement, the receiver informs the sender of the packets it has received earlier by adding an option field on the TCP header. That way, the sender can identify and retransmit missing packets instead of the entire message.
How can AWS support your TCP requirements?
Many AWS services support TCP connections or can help to manage your TCP connections across your networked cloud environment. Here are some services that can assist with TCP management:
- Amazon CloudWatch can monitor your TCP metrics across cloud resources, such as the number of current TCP connections, flow count, and errors in TCP connections.
- Elastic Load Balancing can balance incoming application TCP traffic across multiple targets and virtual appliances in one or more Availability Zones.
- AWS PrivateLink provides private connectivity between virtual private clouds (VPCs), supported services and resources, and your on-premises networks, without exposing your traffic to the public internet. AWS PrivateLink supports TCP connections.
- Amazon Virtual Private Cloud (VPC) with Amazon VPC Lattice allows you to simplify and automate service and resource connectivity. Use VPC Lattice to discover and securely connect services and resources across VPCs and accounts, including connections with TCP.
Get started with TCP networking on AWS by creating a free account today.
Browse all cloud computing concepts
Browse all cloud computing concepts content here:
Did you find what you were looking for today?
Let us know so we can improve the quality of the content on our pages