0% found this document useful (0 votes)
6 views

7 Transmission Control Protocol (TCP)

TCP provides reliable, connection-oriented data transmission through a three-way handshake connection establishment process. It uses flow control and congestion control to regulate data transmission rates. Flow control is implemented through a sliding window mechanism, using a send window and receive window. Congestion control uses slow start, congestion avoidance, and congestion detection phases to dynamically adjust the congestion window size based on network conditions. TCP relies on timers for retransmission and persistence to ensure reliable data delivery.

Uploaded by

Yara Tarkhan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

7 Transmission Control Protocol (TCP)

TCP provides reliable, connection-oriented data transmission through a three-way handshake connection establishment process. It uses flow control and congestion control to regulate data transmission rates. Flow control is implemented through a sliding window mechanism, using a send window and receive window. Congestion control uses slow start, congestion avoidance, and congestion detection phases to dynamically adjust the congestion window size based on network conditions. TCP relies on timers for retransmission and persistence to ensure reliable data delivery.

Uploaded by

Yara Tarkhan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 52

Transmission Control Protocol

(TCP)

Chapter 15
TCP/IP Protocol Suite

2
TCP Services

 Process-to-process communication
 Stream delivery service
 Connection-oriented service
 Reliable service
 Error control
 Flow control
 Congestion control

3
Stream Delivery Service

 Buffering handles disparity between speed of


sending and receiving processes
 Segments created from the bytes in buffers

Segment N Segment 1
H H
Stream of bytes

4
TCP Segment Format

5
Control Field

6
TCP Checksum

 Checksum in TCP is mandatory

7
TCP Connection Establishment

 Three-way handshaking

Passive
Active open
open seq: 8000

UAPRS F
SYN
seq: 15000
Connection ack: 8001
opened nd: 5000
U A P R S F rw
SYN + ACK
seq: 8000
ack: 15001
UAPRS F
rwnd: 10000
ACK
See RFC 793
8
TCP Data Transfer

seq: 8001
Send
request ack: 15001
UAPRS F
Data Receive
bytes: 8001-9
000

Send seq: 9001


request ack: 15001
UAPRS F
Data Receive
bytes: 9001-1
0000

seq: 15001 Send


ack: 10001 request
UAPRSF
Data
17000
bytes: 15001-
seq: 10000
ack: 17001
UAPRS F
rwnd:10000

Connection Termination

9
Pushing Data and Urgent Data

 Pushing
 Send immediately, not to wait for window to fill
 Set push bit PSH
 Deliver as soon as possible, not to wait for data
 Urgent
 Insert urgent data at beginning of segment
 Set urgent bit URG
 Urgent pointer defines end of urgent data
 Inform receiving application to take action

10
TCP Connection Termination

 Three-way handshaking

See RFC 793


11
Half-Close

12
TCP Connection Reset: Denying a Connection

13
TCP Connection Reset: Aborting a Connection

14
Windows in TCP

 TCP uses two windows for each direction of


data transfer
 Send window
 Receive window

15
Send Window

 Closes when acknowledgement received


 Opens/shrinks when rwnd advertised by receiver 16
Receive Window

 Closes when more bytes arrive from sender


 Opens when more bytes pulled by process 17
Flow Control

 To avoid overwhelming receiver with data


 Implemented as sliding window
 Window size determined by receiver (rwnd)

Messages Flow control


are pushed
1 5 3 Messages
feedback are pulled

2
Segements are pushed
4
Flow control feedback

18
Example of Flow Control

19
Shrinking of Windows

 Receive window cannot shrink


 Send window can shrink
 To prevent shrinking of send window

20
Example of Flow Control

Last

New

21
Example of Flow Control

Last

New

22
Example of Flow Control

Last

New

23
Shrinking of Windows – Example

Send

 Sender sent bytes 206 to 214


 Sender received Ack=210, rwnd=4

210
Send
24
Window Shutdown

 Receiver can shut down window (rwnd=0)


 Sender stops sending data until new rwnd arrived
 Sender always sends 1-byte segment (probing) to
prevent deadlock

25
Silly Window Syndrome

 Sending very small segments caused by


 Sender creates data slowly
 Receiver consumes data slowly
 Inefficient use of network capacity

26
Solution to Syndrome Created by Sender

Nagle’s Algorithm:
1. Send first segment even if it is only 1 byte
2. Accumulate data in output buffer and wait
until receiving acknowledgement or enough
data filled maximum-size segment
3. Repeat step 2 for rest of transmission

27
Solution to Syndrome Created by Receiver

 Clark’s Solution
 Send acknowledgement but announce
rwnd=0 until enough space for maximum-
size segment or half of receive buffer empty
 Delayed Acknowledgement
 Delay sending acknowledgement until decent
space available in incoming buffer
 Not delayed more than 500 ms

28
Congestion Control

 To avoid and detect congestion in network


 Sender’s window size determined by
 Receiver (rwnd)
 Congestion in network (cwnd)
 Actual window size = minimum (rwnd, cwnd)
 Based on three phases
 Slow start
 Congestion avoidance
 Congestion detection

29
Slow Start: Exponential Increase
 Sender starts with cwnd = 1 MSS (maximum segment size)
 cwnd size increases by 1 MSS for each acknowledged segment
 cwnd size increases exponentially until it reaches threshold

1
cwnd
RTT
2
cwnd

RTT
4
cwnd

RTT
8

cwnd 30
Congestion Avoidance: Additive Increase
 When cwnd size reaches threshold, congestion avoidance begins
 cwnd size increases by 1 MSS when whole window acknowledged
 cwnd size increases additively until congestion detected

31
Congestion Detection: Multiplicative Decrease

 Congestion detected by retransmission


 If congestion detected by time-out
 Set threshold to half current window size
 Set cwnd size to 1 MSS
 Start slow start phase
 If congestion detected by 3 duplicate ACKs
 Set threshold to half current window size
 Set cwnd size to threshold
 Start congestion avoidance phase

32
Congestion Example

Threshold = 1/2 window


cwnd = 1

Threshold = 1/2 window


cwnd = Threshold

33
TCP Timers

34
Retransmission Timer

 Value of retransmission time-out (RTO) based on:


 Smoothed RTT (round trip time)
 RTT Deviation
RTTD = (1 - β) RTTD + β . |RTTS – RTTM| (β = 1/4)
RTTS = (1 - α) RTTS + α . RTTM (α = 1/8)
RTO = RTTS + 4 . RTTD

 Karn’s Algorithm
 Do not consider RTT of retransmitted segment
 Do not update RTT until you send segment and receive ACK
 TCP uses exponential backoff strategy:
RTOnew = 2 x RTO

35
Retransmission Timer – Example

0.8125 4.875

See RFC 6298

36
Karn’s Algorithm – Example

0.8125 4.875

4.875 = 9.75

9.75

1.203 6.73

37
Persistence Timer

 To deal with zero-window-size advertisement


(deadlock)
 Set to value of retransmission time
 When time-out, TCP sends 1-byte probe segment
 If response not received, another probe sent and
timer doubled until 60s

38
Keepalive Timer

 To prevent long idle connection


 After time-out (2 hours)
 Server sends probe segment to client
 If no response after 10 probes (every 75s),
server terminates connection

39
TIME-WAIT Timer

 Used during connection termination


 If last ACK segment lost
 If duplicate segment from one connection appears in next one
 Twice maximum segment lifetime (MSL=30s - 60s)

40
TCP Options

41
End-of-Option (EOP) Option

42
No-Operation (NOP) Option

43
Maximum-Segment-Size (MSS) Option

 Each end defines MSS for segments it will receive


during connection (default = 536 bytes)
 Determined during connection establishment

44
Window-Scale-Factor Option

 To increase window size defined in TCP header


 Determined during connection establishment

new window size =


window size defined in header x 2window scale factor

45
Timestamp Option

 To measure round-trip time (RTT)


 Protection against wrapped sequence numbers (PAWS)
 Identity of segment defined as combination of
timestamp and sequence number

46
Timestamp Option – Measuring RTT

47
SACK-Permitted and SACK Options

 Allow receiver to send selective ACK (SACK)


 SACK-permitted exchanged during connection
establishment to use SACK during data transfer
 SACK includes list of
 Out-of-order segments
 Duplicate segments

48
SACK-Permitted and SACK Options

49
SACK Option – Reporting Out-of-Order

50
SACK Option – Reporting Out-of-Order and Duplicate

51
SACK Option – Reporting Duplicate of Out-of-Order

52

You might also like