[[Networking]] [[TCP Flow, Error and Congestion Control]] [[TCP
Options]]
Overview
- Layer 4 protocol used to transport data
- One of the most common protocols
- Connection oriented
- Sending host numbers packets and sets a timer at send time
- Receiving host reorders and accounts for all of the packets
- Every time a packet is sent there is an acknowledgement (ACK)
- If a packets timer expires before the ACK is complete, it is
reset
- 20-60 Bytes in length (20 = default)
- Source port - 16 bits
- Destination port - 16 bits
- Sequence number - 32 bits
- Acknowledgement number - 32 bits
- Header Length - 4 bits
- Reserved, not used - 6 bits
- FLAGS there is alot of them - 6 bits
- Window size - 16 bits
- Checksum -16 bits
- Urgent pointer - 16 bits
Control Field
- A set amount of bits within the TCP header that control what happens
with it
- HLEN - Reserved bits - Flags
TCP Flags
- URG: Urgent pointer is valid
- ACK: Acknowledgement is valid
- PSH: Request for push up to next layer
- RST: Restart connection
- SYN: Initiates connection and sentimentalizes
numbers
- FIN: Connection is complete
3-Way Handshake
- SYN: Cannot carry data
- SYN + ACK: cannot carry data but consumes sequence
number
- ACK: Can carry data; if no data, consumes no
sequence number
- In order for a TCP connection, there must be a session
acknowledgement
- Essentially two one way connections communicating together
- Basic Steps
- Initiator sends an empty packet (SYN = 1)
- Recipient responds with SYN and ACK set to 1
- Initiator responds with ACK set to 1
- The connection is now made
- A bit more in depth (Ex: Host A and Host B)
- When handshake begins, Host A SYN is given a sequence number
- When Host B receives Host A’s packet, Host B sends a SYN/ACK with a
new SEQ# and an ACK number that is an increment of the original SYN
- Host A then sends back an ACK with an ACK# of the incremented ACK#
from Host B
- Each host basically acknowledges each others “unique” values. Each
SEQ# is tied to the other sides ACK#
Window Size & Sliding
Window
- Window size is just the amount of data that can be processed at a
time
- Both sides of the handshake have their own window size, however the
window size will only change when data is received by a host
- Host advertises its window size in TCP header
- This tells the other host the max buffer space available
- When data transfer starts host updates other host on available space
that can be taken
- Processed data sits in buffer and waits until it can be pushed up
the stack
- When the window is full, the recipient uses PSH flags to move
packets up a layer
- Once window is empty, more data can be received and process.
- In order to not become overwhelmed, window size will be set to 0
when buffer reaches capacity
Teardown Sequence
- When communication is complete, the connection needs to be
terminated in the same way that it was initiated.
- Initiator send a FIN flag
- Receiver replies with an ACK and a FIN back
- Initiator ACK’s the receivers FIN and the connection is closed