Transmission Control Protocol (TCP)

TCP is a connection-based protocol layer that guarantees delivery of data to the destination.  The reliability and flow control of TCP requires that status information be sent with each datagram indicating sequence numbers and checksums.  So that TCP transmissions can recover from data that is damaged, lost, duplicated, or delivered out of order, each datagram is checked for its sequence number, and the data is verified against the checksum.  An acknowledgment (ACK) is then required from the recipient for each successful datagram received.  If an ACK is not received within a timeout period, the datagram is resent.

Unlike UDP, TCP does not reassemble fragmented datagrams into the original data packet.  It simply extracts the data portion of the datagram and adds it to the incoming data stream.  This can be problematic if a source has sent 20 bytes of data that is fragmented into two datagrams with 10 bytes each.  TCP will give the first 10 bytes to the client without waiting for the next 10 bytes to arrive.  UDP will give all 20 bytes of the data, or nothing.

 

See Also

The Internet Protocol (IP)

User Datagram Protocol (UDP)

Winsock

Request for Comments (RFC)

TCP clients and servers

Simple Mail Transfer Protocol (SMTP)

An ECHO client and server using TCP