Explain TCP Operations
Protocol that ensures reliability in a transmission with minimum loss of packets
- Duties
- Assure packets maintain the right order
- Error Checking
- Delay is kept at an acceptable level
- Prevent possibility of packet duplication
- Ensure data received is consistent, in order, complete and smooth
- OSI – Transport Layer (4)
- Works before IP
- Data gets bundled inside of TCP packets before sending to IP which encapsulates into IP packets
TCP Segment Structure
- PDU – Protocol Data Unit
- Consists of Header and Data section
- Header – 10 mandatory fields
- Source port – 16 bits – ID’s sending port
- Destination Port – 16 bits – ID’s receiving port
- Sequence Number – 32 bits – used for 3 way handshake, SYN flag
- Acknowledgement Number – 32 bits
- Data offset – 4 bits –
- Reserved – 3 bits
- Flags – 9 bits (Control bits)
- Window Size – 16 bits – size of the receive window. Specifies number of window size units (bytes) sender on the segment is willing to receive
- Checksum (16 bits) – error checking of header and data
- Urgent point – 16 bits
- Options – Variable 0-320 bit divisible by 32
- Padding – Ensure TCP header ends and data begins on a 32 bit boundart. All zeros
- Header – 10 mandatory fields
Connection Establishment
- 3 way handshake – Attempt connection between client and server before sending data
- SYN – Active open is performed by the client to the server
- SYN-ACK – Responseto SYN from server to client
- ACK – Final response from client to server that SYN-ACK was received
- Full duplex communication is established
IPv4 PTMU
Determine the size of the network path between 2 IP hosts
- Goal is to avoid fragmentation
- Intended for routers. All modern OS’s use it on endpoints
Implementation
- Works by setting DF bit in outgoing IP headers
- Any device along path with smaller MTU sends ICMP – Fragmentation Needed (Type 3, Code 4)
- Process is continued until smallest MTU is found to send packets without fragmentation
IPv6 PMTU
Determine the size of the network path between 2 IP hosts
- Explicitly delegated to endpoints
- Routers do not support fragmentation
- ICMPv6 – Packet Too Big (Type 2)
MSS – Maximum Segment Size
- Largest amount of data (in bytes) a host can receive in a single TCP segment
- Does not count TCP or IP header
- Defined to be the relevant IP datagram minus 40
- Min MTU – 40 = MSS
- IPv4 hosts required to handle MSS of 536 (=576 – 20 – 20)
- IPv6 hosts required to handle 1220 (=1280 – 40 – 20)
- MSS specified as TCP option
- Send In SYN packet during TCP handshake
- MSS cannot be changed after connection is established
Latency
Time interval between point A and point B. Product of delay from physical distance packets traverse a medium
- Measured
- One-way – Time from source sending a packet to destination receiving the packet
- Round-trip Delay – Time from Source to Destination and Destination back to Source
- Ping can provide latency, but isn’t fully accurate as ICMP can be treated differently if traffic shaping is applied
- Accurate measurements can come from specific software
Windowing
TCP Windowing
- Amount of unacknowledged data that can be in transit at any given time
- Referred to as Window Size – 16 bit field in TCP header
Window Scaling
Bandwidth Delay Product
- Product of data links capacity, Bandwidth (bps) and RTD Time (RTT) (seconds)
- Measured in bits or bytes
- Max amount of data on the network at any given time.
- https://en.wikipedia.org/wiki/Bandwidth-delay_product
Global Synchronization
Can occur during periods of congestion because each sender will reduce their transmission rate at the same time when packet loss occurs
Simplest queuing technique
- Tail Drop – Allow queue to fil to max size and then discard any packets until there is space again
- Problem occurs when there is bursty traffic and the queue is full
- Full queue results in high latency
- Introduction of sudden burst of traffic may cause large number of established streams to lose packets simultaneously
- Recovery Mechanism
- TCP recovers from dropped packets which is interprets as congestion
- Senders reduce sending rate for period of time
- Known as slow start algorithm
- Tail drop is leading cause of the problem
- RED (Random Early Detection) and WRED (Weighted RED) reduce likeliness of global synchronization
Options
3 Types of TCP options
- Option-Kind – 1 byte
- Option-Length – 1 byte
- Option-Data – variable
Sent in the SYN packet