TCP
Intro
- Transmission control protocol
- Requires a connection to be set up first (handshakes)
- Delivers messages (also called “segments”) reliably and in order.
- Detects errors and can fix them
- Handles volumes of traffic by modulating the amount of data.
- Examples: HTTP, e-mail, file transfers
Responsibilites
- Send data at an appropriate transmission rate (to avoid congestion or inefficiency).
- Segment data.
- End-to-end flow control.
- This means not overwhelming the receiver.
- Identify and re-transmit messages that weren't delivered
- Identify when messages arrive out of order and reassemble them.
Examples
- File transfer
- SSH
- Email
- Web browsing
Features
- Connection-oriented. It creates a long-term connection between hosts.
- Full-duplex, which means that both hosts can send eachother messages at the same time.
- Point-to-point. Broadcasting and multi-casting is not possible with TCP - there are exactly two endpoints.
- Error control. TCP both detects and fixes errors.
- Flow control. TCP adjusts the amount of data being sent based on the receiver's stated capacity to process it.
- Congestion control. TCP has built-in congestion control mechanisms.
This is much more complicated than the UDP case, so see TCP Segment Header.
Three-way handshake
This is how connections are established. They use the sequence number, acknowledgement number, and SYN flag. (See the header section for definitions).
Client initial message
The client sends a TCP message with:
- the SYN flag set
- the sequence number set to a random value
This is often called the SYN segment.
Server response
Upon receiving this message, the server replies with:
- the SYN flag set
- the sequence number set to a random value
- the ACK flag set
- The acknowledgement number is set to the client's sequence number + 1.
This is often called a SYN+ACK segment.
Client acknowledgement
- ACK flag set
- Sequence number = previous client sequence number + 1.
- Acknowledgement number = server sequence number + 1.
