TCP
Summary
TCP vs pipelined protocols
| Protocol | Timeout | Retransmit | Handle out-of-order |
|---|---|---|---|
| Go-Back-N | oldest unACKed packet | all unACKed, >=n | discard |
| Selective repeat | individual unACKed packets | one, n | buffer, discard only if too far |
| TCP | oldest unACKed packet | one, oldest unACKed packet | unspecified |
Timeout
- ideally,
timeout > RTT
the exponential weighted moving average(EWMA) encodes all the sampled RTTs into a single value
Concept
Transmission Control Protocol(TCP)
- connection-oriented, have to use source information to determine which socket to direct to
- reliable
- byte-stream, TCP divides the data into segments
- flow control
- congestion control
- full duplex - bi-directional data flow
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Source Port | Destination Port |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Sequence Number |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Acknowledgment Number |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Data | |U|A|P|R|S|F| |
| Offset| Reserved |R|C|S|S|Y|I| Window |
| | |G|K|H|T|N|N| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Checksum | Urgent Pointer |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Options (if offset > 5) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| data |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Sequence and acknowledgement numbers
- sequence: first byte in this segment’s data
- acknowledgement: next byte of data expected, receiver sends this as the cumulative ACK

- fast retransmission - if 3 duplicates ACKs are received, resend that segment immediately, without waiting for timeout
3-way handshake
- establishing a connection

- SYN flooding - send SYN, but not ACK
- SYN/ACK - send SYN-ACK packets that don’t belong to any session, server has to lookup everytime
Closing connection
- send signal to close
- wait for leftover data
