TCP Connection Basics

What is TCP?

Transmission Control Protocol (TCP) is the most widely used transmission protocol. It is the backbone of all Internet traffic. The idea behind TCP is to provide two communicating points (we can call them host A and host B) with a reliable, stream-oriented data link. "Stream-oriented" means that neither host A nor host B have to worry about how the data travels across the connection. Host A just puts the stream of bytes in and host B receives exactly the same stream of bytes on its side. It is the responsibility of TCP to split the data into packets for transmission through the network, retransmit lost packets, make sure there are no data overruns, etc.

TCP is strictly a "point-to-point" protocol: only two parties can engage in a connection and no third party can "join in."


TCP Connections

Before any data can be transmitted, one of the hosts has to establish a connection to another host. This is similar to placing a telephone call: one of the parties has to call the other end.

The host that takes the initiative to establish a connection is said to be opening an "outgoing connection" or "performing an active open." This is like dialing the telephone number of the desired party, only the number is the IP address of another host.

The host that accepts the "call" is said to be accepting an "incoming connection" or "performing a passive open." This is similar to picking up the phone when it starts ringing.

Once a connection has been established, both parties can "say something" (send data) at any time and TCP will make sure that all data sent on one end arrives to the other end.

TCP connections are expected to be closed (terminated) properly — there is a special exchange of messages between the hosts to let each other know that a connection is being terminated. This is called a "graceful disconnect." There is also a "reset" (abort), which is much simpler and is akin to hanging up abruptly. Finally, there is a "discard" way to end the connection in which a host simply "forgets" that there was a connection.

The TCP connection can be closed purposefully, or it can time out.

A TCP connection in progress is fully defined by four parameters: the IP address and the port number on host A, and the IP address and port number on host B. When the host is performing an active open, it has to "dial" not just the IP address of the target host, but also the port number on this host. Ports are not physical — they are just logical subdivisions of the IP address (65,536 ports per IP). If the IP is a telephone number of the whole office, then the port is an extension. The "calling" host is also calling not just from its IP address, but also from a specific port.

TiOS release V4 added support for Transport Layer Security (TLS), so it is now possible to use industry-standard encryption mechanisms for secure communications over the Internet.


TCP Connection Basics

What is TCP?

TCP Connections