Вы находитесь на странице: 1из 46

Computer Networks

Part 6 : Transport Layer


Overview (1)

• IP
• UDP versus TCP
• UDP
• TCP
• TCP Segment
• Connection Establishment
• Connection Termination
• Reliable Transport
• Retransmission Timer
Overview (2)

• Timer Backoff Strategy


• Timer Granularity
• Flow Control
• Congestion Control
• Slow Start
• Congestion Avoidance
• Fast Retransmit/Recovery
• Acronyms
Internet Protocol (IP)

• Best Effort Service


• Datagrams
 delivered out-of-order
 lost
 duplicated
UDP versus TCP

• UDP & TCP


 same network layer (IP)
 provide totally different service
 unreliable - reliable
 connection-less - connection-oriented
UDP

• UDP merely passes on the service of IP

• UDP only adds a checksum


TCP

Reliable
transmitted data has to be confirmed by the receiving end,
TCP uses checksums, acknowledgements en timers

Connection-Oriented
connection establishment ➾ data transfer ➾ connection termination

Byte-stream Service
TCP assigns byte sequence numbers

Between 2 end systems


no broadcast facility
TCP Segment (1)


TCP Segment (2)

• Port Nrs identify sending and receiving application


• Seq Nr is position of 1st data byte in this segment,
relative to the start of the complete message
• Ack Nr is sequence nr expected by the receiver,

confirms correct receipt of all bytes up to Ack Nr-1


valid when ACK flag set
• Header Length is variable due to options field
• Reserved Field for future use
TCP Segment (3)

• 6 Flag Bits
 to indicate validity of other fields
 for connection control

 ACK flag ➾ acknowledgment nr


 URG Flag ➾ urgent pointer field
 PSH Flag receiver passes segment immediately to application
 RST Flag resets the connection
 SYN Flag indicate connection establishment, Seq Nr contains ISN
 FIN flag terminates the connection
TCP Segment (4)

• Window Size advertised by receiver,


gives the nr of bytes (starting from Ack Nr)
the receiver is willing to accept.
• Checksum for complete segment (header + data)
• Urgent Pointer is positive offset to be added to Seq Nr
points to end of urgent data
• Options (if any)
e.g. MSS at connection establishment
• Padding to maintain 32-bit boundary
Connection Establishment (1)
Three-way handshake
1 Client
 sends SYN with ISN
 option: MSS up to MTU - 40

otherwise: default = 536 bytes


2 Server
 responds with own SYN with ISN
 possibly MSS
 acks client’s SYN
3 Client acks Server’s SYN
Client- Server
Connection Establishment (2)
• Two ends perform active open
at same time

• Result is 1 connection
• Requires exchange of 4
segments

Collision Possibility
Connection Termination (1)
TCP connection is full-duplex
 each direction must be shut down
independently
 receipt of FIN means
• no more data flow in that direction
• but TCP can still send

Graceful Termination
Connection Termination (2)

Simultaneous Termination

Same nr of segments exchanged


Reliable Transport (1)

Mechanism:
• When sending a new segment:
• seqnr in header
= seqnr of 1st byte of data carried in the segment
• calculate checksum of header and data
• if retransmission timer free, set timer
Reliable Transport (2)

• When receiving a new segment:


• use checksum to verify correctness
if corrupted, discard segment
• use seqnr to check for duplicate and/or
out-of-order segment
• if correct, return ack, acknr = next expected seqnr
segment in-order ➾ acknr = seqnr + nr data bytes +1
segment out-of-order ➾seqnr of 1st missing data
Reliable Transport (3)

• When receiving a new ack:


• when new data acked, release timer
• if still unacked data, restart timer

• When retransmission timer expires:


• retransmit segment,
starting from 1st unacked data byte
Reliable Transport (4)

Example: 90 data bytes


MSS = 20, ISN = 3

44 24 4
4

64 44 24
4
24
Reliable Transport (5)
84 64 44
4
24 44

84 64
4

24 44 64

84
24
44 64

44
64 64
Reliable Transport (6)
64
64

64
64

Timer expires
64
64
Reliable Transport (7)

64
64

64
91
Reliable Transport (8)

• Remarks:
 1-1 correspondence between segments and the acks is
not necessary
 acks are cumulative :
problem of lost ack is solved by following ack
 value of Retransmission Timer is critical
Retransmission Timer (1)

• Based on RTT
• How is RTT estimated ?
 RTT value of segment is timed
 only one counter per connection
 no measurements on retransmitted segments
• Approach 1
 update: (M = RTT measurement & R = RTT estimator)
R= α R + (1- α) M, with α = 0.9 (a smoothing factor)
RTO = β R, with β = 2 (a delay variance factor)
Retransmission Timer (2)

• Approach 2: Algorithm of Jacobson


based on both mean and variance of RTT
 M = RTT measurement
A = smoothed RTT (estimation of the average)
D = smoothed mean deviation
g and h = gains set to res. 0.125 and 0.25
 update :
• Err = M-A
• A = A + g Err
• D = D + h ( |Err| - D)
• RTO = A + 4D
Timer Backoff Strategy

• For each retransmission:


the time-out value is doubled,
with an upper limit of 64 sec.

T1 T2 = 2 * T1

Timeout interval doubled


Packet
Transmitted Timeout occurs
before ack received,
packet retransmitted
Timer Granularity

• All timers (including RTT)


 are measured as a discrete value
 in multiples of a “tick”
 1 tick = 500 ms in many implementations
 smaller tick sizes in more recent implementations

• RTO is at least 2 clock ticks


Flow Control (1)

• Sliding window
Offered Window (advertised by receiver)
Usable Window

1 2 3 4 5 6 7 8 9 10 11 ...
Sent, Can send
not Acked ASAP
Send & Acked Can’t Send until window moves
Flow Control (2)

• Window size
 allowed number of unacked segments (expressed in bytes)
 advertised by the receiver based on buffer occupancy
 relative to acknr
 sender may transmit bytes in offered window
without waiting for acks
 ack moves window to the right

sliding window : flow control by the receiver


Flow Control : Example

1 2 3 4 5 6 7 8 9 10 11 ...

• ACK 6 with advertised window of 6 bytes

… 4 5 6 7 8 9 10 11 12 ...

• ACK 6 with advertised window of 8 bytes

… 5 6 7 8 9 10 11 12 13 14 ...
Flow Control (4)

• Window update
segment which doesn’t ack new data,
but contains a new window advertisement
• Window of 0
stops sender,
 until ack with non zero window arrives
 until window update
persist timer avoids waiting forever
if timer expires, window probe is transmitted
Congestion Control

• Consist of 4 algorithms :
 Slow Start
 Congestion Avoidance
 Fast Recovery
 Fast Retransmit
• Congestion Control
 flow control imposed by the sender
 to avoid overload in intermediate systems
Slow Start (1)

• Slow Start
 idea:
rate at which new segments should be injected into the network
=
rate at which the acks are returned by other side
 how :
• add congestion window, CWND
• sender can transmit up to the minimum of the congestion
window and the advertised window
Slow Start (2)

• Slow Start algorithm


 initially, CWND = 1 MSS
 increment window size by 1 MSS on each new ack

 slow start phase ends when window size reaches the

slow-start threshold SSThresh

• During Slow Start,


Window grows exponentially with time
Slow Start (3)
CWND = 1
1

2
CWND = 2
1 2

3 2

2
Slow Start (4)
CWND = 3
3 2 4

4
CWND = 4
3 5 4

6 5 4

3 4

7 6 5

3 4 5

Each RTT, CWND is doubled


Congestion Avoidance (1)

• Slow Start
- quickly attain max. transmission rates

• When max. capacity reached, losses occur


- indicates that CWND is too large

Therefor, Slow Start is implemented


together with Congestion Avoidance
Congestion Avoidance (2)

• Congestion Avoidance Algorithm


 when window size exceeds SSThresh
 on each new ack,
increment CWND with 1/CWND packets

• During Congestion Avoidance,


Window increases linearly with time
Congestion Avoidance (3)

• When Congestion occurs


(indicated by time-out or dupacks)

 SSThresh = max(2, current window/2 )


➥ min(CWND, advertised window)

 if congestion indicated by a time-out,


CWND = 1
Slow Start &Congestion Avoidance

25
After Time-out
CWND = 20
Congestion window

20
(segments)

15

10
SSThresh = 10
SSThresh = 8
5

0
0

15

22
12

20

25
Time (round trips)
Fast Retransmit/Recovery (1)

• Detects packet loss Using Dupacks


 Duplicate acks may be generated due to
• packet loss, or
• out-of-order packet delivery

 TCP sender assumes that a packet loss has


occurred if it receives 3 dupacks consecutively
➟ we don’t wait on time-out
& perform retransmission
Fast Retransmit/Recovery (2)

• When 3th dupack arrives,


 SSThresh = max(2, min(CWND, advertised window) /2 )
 retransmit the missing segment
 CWND = SSThresh + nr of dupacks
• When another dupack arrives,
 increment CWND with 1
 transmit new packet (if allowed)
• When new ack comes,
 CWND = SSThresh (enter congestion avoidance)
Fast Retransmit/Recovery (3)
After fast recovery
10
Advertised window
8
Window size (segments)

6
4
2
0
0 2 4 6 8 10 12 14
Time (round trips)
After fast retransmit and fast recovery, window size is reduced in half.
TCP Implementations (1)

• TCP Tahoe :
 Slow start
 Congestion avoidance
 Fast retransmit
• TCP Reno
 TCP Tahoe
 Fast recovery
TCP Implementations (2)
• TCP with SACK
 TCP Reno
 Selective acknowledgement
• TCP Vegas
 Better estimation of RTT
 New congestion avoidance (react on
throughput)
 Modified Slow Start
Acronyms
• ACK : Acknowledgment
• Ack Nr : Acknowledgment number in header of segment
• CWND : Congestion Window
• IP : Internet Protocol
• ISN : Initial Sequence Number
• MSS : Maximum Segment Size
• MTU : Maximum Transmission Unit
• RTO : Retransmission Time-Out value
• RTT : Round-Trip Time
• Seq Nr : Sequence number in header of segment
• SSThresh : Slow-Start Threshold
• TCP : Transmission Control Protocol
• UDP : User Datagram Protocol

Вам также может понравиться