Transmission Control Protocol (TCP) is a protocol of transmission geared toward reliability. It is defined in RFC793.
TCP offers reliability to a communication system that is inherently not reliable.
TCP must recover damaged, lost or un-ordered data.
This reliability makes TCP a great choice for many networked applications. However this reliability comes at a price: both in performance and complexity.
Data encapsulation and multiplexing is possible using…
TCP Segments are the Protocol Data Unit (PDU) of TCP: Segment Header and Segment Payload. In the Segment Header, the Source Port and Destination Port permit multiplexing.
TCP is a connection-oriented protocol. It won’t start sending application data until a connection has been established between application processes.
In order to establish a connection, TCP uses a Three-way Handshake:
Sender Receiver Sender send SYN Segments |\ | | \ | | \SYN | | \ | | \ | | \ | | \| Receiver receives SYN Segment, | /| Responds with SYN ACK Segment | SYN / | | ACK/ | | / | | / | | / | Receiver receives SYN ACK Segment, |/ | Responds with ACK Segment |\ | | \ | | \ACK | | \ | | \ | | \ | | \| Receiver receives ACK Segment, | | Connection is established! | | | |
Sender sends a SYN message (a TCP Segment with the
SYNflag set to
Upon receiving the SYN message, Receiver sends back a SYN ACK message (a TCP Segment with the
ACKflags set to
Upon receiving the SYN ACK, the sender then sends an ACK message (a TCP Segment with the
ACKflag set to
Sender can start sending application data right after sending the ACK message, but Receiver needs to receive the ACK before sending anything back. One reason is to be able to synchronise
SYN sequence numbers used during the connection.