TCP

Transmission Control Protocol (TCP) is a foundational network protocol. It provides ordered and error-checked communication in chunks between a server and a client.

Contents

  1. TCP
    1. Design


Design

TCP packets are ordered because they are sent with a sequential number, and a client or server will wait for specifically numbered packet to proceed. A timeout causes the packet to be re-sent.

To start a TCP connection, a server must listen on a TCP port. A client sends a SYN with a random number A; that is the starting value for numbering the packets that will be sent to the client.

The server replies, sending a SYN+ACK numbered with A+1 and also with a random number B. This is the server's starting value.

The client replies, sending a ACK numbered with B+1.

Packets are now sent over a two-way TCP connection. A receiver sends ACKs to confirm receipt of a well-formed packet; if no ACK is received within a timeout period, the sender knows that a packet (and furthermore which packet) was lost and needs to be re-sent.

The timeout period is determined by the time elapsed during the SYN -> SYN-ACK -> ACK negotiation, as this represents the time taken for a roundtrip between server and client. The timeout period is then calculable on both ends of the connection, without requiring system clocks to match.

A checksum is included in the TCP packet to ensure correctness of communications.


CategoryRicottone

Protocols/TCP (last edited 2023-01-09 02:48:38 by DominicRicottone)