What is Transmission Control Protocol (TCP)?

4 min

Security and speed are essential considerations when transmitting or receiving files across the Internet. However, perhaps the most important thing is ensuring that your email, photos, or files arrive intact. 

Frameworks like TCP ensure data integrity by breaking files down into small packets that are ordered by the receiver. This process ensures reliable, ordered, and error-checked data delivery between applications running on devices connected to a network.

If you’ve ever asked yourself the question, “What is TCP?” this article is for you.

Transmission Control Protocol (TCP) is a broadly used data transfer method. Its primary function is to help ensure reliable data transmission between devices on a network.

TCP operates at the transport layer of both the TCP/IP protocol and the OSI (Open Systems Interconnection) model —which we’ll get into in a later section. In both frameworks, the transport layer is responsible for delivering data from the source to the destination application.

In essence, TCP works with the Internet Protocol (IP) to define the rules governing how data sent over networks is: 

  • Packaged
  • Addressed
  • Transmitted
  • Routed
  • Received

The big reason for TCP’s reliability is that it establishes a connection between the receiver and sender before data transmission begins.

TCP ensures data transfers between clients and servers are efficient and consistent. Here are some of the more common ways that TCP is used day-to-day.

  • Web browsing: HTTP uses TCP to establish connections between websites and internet devices.
  • File transfers: FTP and SFTP both use TCP for file transfers.
  • Email: SMTP, POP, and IMAP all rely on TCP to deliver emails.
  • Remote administration: SSH and Telnet use TCP to control remote computers.
  • Database access: TCP provides database access across networks.
  • Virtual private networks: Many VPNs use TCP to create secure connections between  remote users and private networks
  • Peer-to-peer file sharing: Many P2P file-sharing systems employ TCP to send files.

The uses we’ve listed above are not exhaustive. However, it does clearly demonstrate the usefulness and flexibility of TCP.

Getting your head around TCP can be tricky for some. But if you break it down into stages, it’s much easier to understand.

Establishing a connection

TCP uses what is known as a three-way handshake to establish a connection between two devices before any data is sent.

Here’s how that looks.

  1. SYN: The client sends a packet with a synchronized flag set to the server.
  2. SYN-ACK: The server responds with a packet containing both SYN and ACK flags. This acknowledges the request.
  3. ACK: The client sends their own ACK packet back to the server.

The process here involves synchronizing the sequence number in which data packets are sent and establishing a connection between the devices.

Data transfer

Now that the two devices have established a connection, the data is ready to be transferred. 

  • Segmentation: TCP breaks the data into smaller packets called segments.
  • Sequencing: Each segment is assigned a sequence number to order the packets appropriately upon delivery.
  • Transmission: These segments are then sent to the network layer so they can be routed and delivered.
  • Reception: The receiving device (i.e., your computer) accepts the incoming segments.
  • Acknowledgement: Each time a segment is received, the receiving device sends an ACK to the sender to confirm they’ve got the segment.

Flow control

One problem that can occur when sending large amounts of data is overwhelming the receiver. TCP manages the rate of data transmission to prevent this issue. 

The two concepts you need to know here are:

  • Window Size: The receiver tells the sender how much data it can handle.
  • Sliding Window: As data is sent, the window size can slide open, meaning more data can be sent.

Error Handling and reliability

TCP contains several mechanisms that work to ensure data integrity.

  • Checksums: This mechanism is used to detect corrupted segments.
  • Retransmission: The sender retransmits the segment if an ACK is not received within a specified timeout.
  • Duplicate Detection: The receiver discards any duplicate segments it receives.
  • Out-of-Order Handling: TCP can reorder segments correctly if segments arrive out of sequence.

Congestion control

Data congestion is another potential issue when transmitting files. Here’s how TCP adapts to these issues.

  • Slow Start: As shown in the flow control section above, the window starts out small and increases as data is transmitted.
  • Congestion Avoidance: The transmission rate is adjusted based on network conditions.

Terminating the connection

Once the data transfer is complete, TCP will close the connection. Here is how the process works.

  • Either the sender or receiver can initiate the closure of the transfer by sending a FIN packet, which is short for Finish.
  • The other party then acknowledges the initiation of closure by sending an ACK packet, which is short for acknowledgment. 
  • After sending an ACK packet, the same party sends out their own FIN packet.
  • Finally, the other party acknowledges the second FIN packet.

The TCP/IP and OSI models are frameworks for understanding how data moves from one computer to another across a network. While they have some broad similarities, they are distinct methods. 

Let’s briefly overview both TCP/IP and OSI.

TCP/IP

TCP/IP is a framework that consists of four layers. They are:

  • Application
  • Transport
  • Internet
  • Link 

It’s the de facto model for practical network design. It has four layers, with some of them serving multiple functions. Overall, it’s very flexible and particularly amenable to new technologies.

OSI

  • Application
  • Presentation
  • Session
  • Transport
  • Network
  • Data Link
  • Physical

OSI has more layers than TCP/IP. As such, each layer has narrowly defined functions. OSI is a well-structured theoretical model. However, while it’s easy to grasp, the extra layers mean that it’s more complex to implement in real-world networking situations..

If you want to dig further read our article about OSI model vs TCP/IP model.

Optimized security and performance are the primary characteristics you want from a TCP data transfer. Here are a few best practices to help with the process.

  • Configure TCP to store corrupted or broken packets. Once new packets are permitted, these stored packets can fill in the gaps and reduce latency.
  • Implement powerful encryption methods like SSL/TLS to protect the data you transmit over TCP. This approach makes it far more difficult for bad actors to intercept or exploit any sensitive information you send.
  • Utilize firewalls to restrict incoming and outgoing traffic, reducing the risk of exploitation. Firewalls can be configured to allow only necessary traffic, creating an additional layer of security for your TCP connections.
  • Adjust the TCP window size based on your network conditions. Larger window size can enhance throughput on high-latency networks, but be cautious, as too large a window might lead to increased congestion and packet loss.
  • For services requiring frequent connections, such as websites, consider implementing TCP Fast Open. TFO reduces connection setup time by allowing data transmission during the initial handshake, potentially decreasing latency.

Further reading:

Share via Social Networks

You might also like…

Read more top posts in this category

Ready to get started with Domotz?

  • Powerful
  • Automated
  • Simple
  • Affordable
Start Your Free Trial Contact Sales