TCP: Overview RFCs: 793, 1122, 1323, 2018, 2581 - PowerPoint PPT Presentation

1 / 27
About This Presentation
Title:

TCP: Overview RFCs: 793, 1122, 1323, 2018, 2581

Description:

long delay before resending lost packet. Detect lost segments via ... Enters 'timed wait' resend the final ACK in case it is lost. Connection closes after wait ... – PowerPoint PPT presentation

Number of Views:213
Avg rating:3.0/5.0
Slides: 28
Provided by: Kur481
Category:
Tags: tcp | overview | resend | rfcs

less

Transcript and Presenter's Notes

Title: TCP: Overview RFCs: 793, 1122, 1323, 2018, 2581


1
TCP Overview RFCs 793, 1122, 1323, 2018, 2581
  • reliable, in-order byte steam
  • no message boundaries
  • pipelined
  • TCP congestion and flow control set window size
  • full duplex data transfer
  • bi-directional data flow in same connection
  • A TCP is always point-to-point
  • one sender, one receiver
  • connection-oriented
  • Because handshaking take place. Handshaking
    (exchange of control msgs) initialize sender,
    receiver state before data exchange
  • send receive buffers
  • MSS maximum segment size

2
TCP segment structure
URG urgent data (generally not used)
counting by bytes of data (not segments!)
ACK ACK valid
PSH push data now (generally not used)
bytes rcvr willing to accept
RST, SYN, FIN connection setup and teardown
RFC 793, 1323
Internet checksum (as in UDP)
3
TCP Round Trip Time and Timeout
  • Q how to estimate RTT?
  • SampleRTT measured time from segment
    transmission until ACK receipt
  • ignore retransmissions
  • SampleRTT will vary, want estimated RTT
    smoother
  • average SampleRTT values
  • Q how to set TCP timeout value?
  • too short premature timeout
  • unnecessary retransmissions
  • too long slow reaction to segment loss
  • longer than RTT
  • but RTT varies

4
TCP Round Trip Time and Timeout
  • Setting the timeout
  • EstimtedRTT plus safety margin
  • large variation in EstimatedRTT -gt larger safety
    margin

5
TCP reliable data transfer
  • TCP creates reliable data transfer service on top
    of IPs unreliable service
  • Pipelined segments
  • Cumulative acks
  • Single retransmission timer
  • Retransmissions are triggered by
  • timeout events
  • duplicate acks
  • Initially consider simplified TCP sender
  • ignore duplicate acks
  • ignore flow control, congestion control

6
TCP sender events
  • data rcvd from app
  • create segment with seq NextSeqNum
  • start timer if not already running (think of
    timer as for oldest unacked segment)
  • expiration interval TimeOutInterval
  • timeout
  • retransmit not-yet-acked segment with smallest
    seq
  • restart timer
  • Ack(y) rcvd
  • If acknowledges previously unacked segments (y gt
    SendBase)
  • Set SendBase y
  • start timer if there are outstanding segments

7
TCP sender(simplified)
NextSeqNum InitialSeqNum
SendBase InitialSeqNum loop (forever)
switch(event) event
data received from application above
create TCP segment with sequence number
NextSeqNum if (timer currently
not running) start timer
pass segment to IP
NextSeqNum NextSeqNum length(data)
event timer timeout
retransmit not-yet-acknowledged segment with
smallest sequence number
start timer event ACK
received, with ACK field value of y
if (y gt SendBase)
SendBase y if (there are
currently not-yet-acknowledged segments)
start timer
/ end of loop forever /
  • Comment
  • SendBase-1 last
  • cumulatively acked byte
  • Example
  • SendBase 71y 73, so the rcvrwants 73 y
    gt SendBase?new
  • data (71,72) is acked

8
TCP retransmission scenarios
Host A
Host B
Seq92, 8 bytes data
Seq100, 20 bytes data
ACK100
ACK120
Seq92, 8 bytes data
Sendbase 100
SendBase 120
discard segment
ACK120
Seq92 timeout
SendBase 100
SendBase 120
premature timeout
9
TCP retransmission scenarios (more)
SendBase 120
10
TCP ACK generation RFC 1122, RFC 2581
TCP Receiver action Delayed ACK. Wait up to
500ms for another in-order segment. If no such
segment, send ACK Immediately send single
cumulative ACK, ACKing both in-order segments
Immediately send duplicate ACK, indicating
seq. of next expected byte Immediate send
ACK, provided that segment starts at lower end of
gap
Event at Receiver Arrival of in-order segment
with expected seq . All data up to expected seq
already ACKed Arrival of in-order segment
with expected seq . One other segment has ACK
pending Arrival of out-of-order
segment higher-than-expect seq. . Gap
detected Arrival of segment that partially or
completely fills gap
11
Fast Retransmit
  • Time-out period often relatively long
  • long delay before resending lost packet
  • Detect lost segments via duplicate ACKs.
  • Sender often sends many segments back-to-back
  • If a segment is lost, there will likely be many
    duplicate ACKs.
  • If sender receives 3 duplicate ACKs for the same
    data, it supposes that segment after ACKed data
    was lost
  • fast retransmit resend segment before timer
    expires

12
Fast retransmit algorithm
event ACK received, with ACK field value of y
if (y gt SendBase)
SendBase y
if (there are currently not-yet-acknowledged
segments) start
timer
else increment count
of dup ACKs received for y
if (count of dup ACKs received for y 3)
resend segment with
sequence number y

a duplicate ACK for already ACKed segment
fast retransmit
13
TCP Flow Control
  • receive side of TCP connection has a receive
    buffer
  • speed-matching service matching the send rate to
    the receiving apps drain rate
  • app process may be slow at reading from buffer

14
TCP Flow control how it works
  • Rcvr advertises spare room by including value of
    RcvWindow in segments
  • Sender limits unACKed data to RcvWindow
  • LastByteSent-LastByteAcked lt RcvWindow
    guarantees receive buffer doesnt overflow
  • (Suppose TCP receiver discards out-of-order
    segments)
  • spare room in buffer
  • RcvWindow
  • RcvBuffer-LastByteRcvd - LastByteRead

15
TCP Connection Management
  • Three way handshake
  • Step 1 client host sends TCP SYN segment to
    server
  • specifies initial seq
  • no data
  • Step 2 server host receives SYN, replies with
    SYNACK segment
  • server allocates buffers, variables
  • specifies server initial seq.
  • Step 3 client receives SYNACK, allocate buffers
    and variables, replies with ACK segment, which
    may contain data
  • Recall TCP sender, receiver establish
    connection before exchanging data segments
  • initialize TCP variables
  • seq. s
  • buffers, flow control info (e.g. RcvWindow)
  • client connection initiator
  • server contacted by client

16
TCP Connection Management Three way handshake
client
server
Connection request
SYN1, seqclient_ins
Connection granted
SYN1, seqserver_ins, Ackclient_ins1
ACK
SYN0, seqclient_ins1, Ackserver_ins1
17
TCP Connection Management (cont.)
  • Closing a connection
  • client closes socket
  • Step 1 client end system sends TCP FIN control
    segment to server, FIN bit set to 1
  • Step 2 server receives FIN, replies with ACK.
    Closes connection, sends FIN.

client
server
closing
FIN
ACK
closing
FIN
ACK
timed wait
closed
closed
18
TCP Connection Management (cont.)
  • Step 3 client receives FIN, replies with ACK.
  • Enters timed wait resend the final ACK in case
    it is lost
  • Connection closes after wait
  • Step 4 server receives ACK. Connection closed.

client
server
closing
FIN
ACK
closing
FIN
ACK
timed wait
closed
closed
19
Principles of Congestion Control
  • Congestion
  • informally too many sources sending too much
    data too fast for network to handle
  • different from flow control!
  • manifestations
  • lost packets (buffer overflow at routers)
  • long delays (queueing in router buffers)

20
Causes/costs of congestion scenario 2
  • Case 1 send a packet only when a buffer is free
  • Case 2 perfect retransmission only when loss
  • Case 3 retransmission of delayed (not lost)
    packet makes larger (than case 2) for
    same

C/2
C/3
C/4
R/2
R/2
R/2
  • costs of congestion
  • more work performed by sender (retransmissions)
  • unneeded retransmissions (due to large delay)

21
TCP Congestion Control
  • end-end control (no network assistance)
  • sender limits transmission rate
  • LastByteSent-LastByteAcked
  • ? minCongWin, RcvWindow)
  • Roughly,
  • CongWin is dynamic, function of perceived network
    congestion
  • How does sender perceive congestion?
  • loss event timeout or 3 duplicate acks
  • TCP sender reduces rate (CongWin) after loss
    event
  • three mechanisms
  • AIMD
  • slow start
  • reaction to timeout events

22
TCP AIMD
  • additive increase
  • increase CongWin by 1 MSS every RTT in the
    absence of loss events probing
  • also called congestion avoidance
  • multiplicative decrease cut CongWin in half
    after loss event

Long-lived TCP connection
23
TCP Slow Start
  • When connection begins, increase rate
    exponentially fast until first loss event
  • When connection begins, CongWin 1 MSS
  • Example MSS 500 bytes RTT 200 msec
  • initial rate 20 kbps
  • available bandwidth may be gtgt MSS/RTT
  • desirable to quickly ramp up to respectable rate

24
TCP Slow Start (more)
  • When connection begins, increase rate
    exponentially until first loss event
  • double CongWin every RTT
  • done by incrementing CongWin by one MSS for every
    ACK received
  • Summary initial rate is slow but ramps up
    exponentially fast

25
Refinement
Philosophy
  • After 3 dup ACKs
  • CongWin is cut in half
  • window then grows linearly
  • But after timeout event
  • CongWin instead set to 1 MSS
  • window then grows exponentially
  • to a threshold, then grows linearly
  • Implementation At loss event, threshold is set
    to 1/2 of CongWin just before loss event
  • 3 dup ACKs indicates network capable of
    delivering some segments
  • timeout before 3 dup ACKs is more alarming

26
Summary TCP Congestion Control
  • When CongWin is below Threshold, sender in
    slow-start phase, window grows exponentially.
  • When CongWin is above Threshold, sender is in
    congestion-avoidance phase, window grows
    linearly.
  • When a triple duplicate ACK occurs, Threshold set
    to CongWin/2 and CongWin set to Threshold.
  • When timeout occurs, Threshold set to CongWin/2
    and CongWin is set to 1 MSS.

Triple duplicate ACK
27
Summary
  • principles behind transport layer services
  • multiplexing, demultiplexing
  • reliable data transfer
  • flow control
  • congestion control
  • instantiation and implementation in the Internet
  • UDP
  • TCP
Write a Comment
User Comments (0)
About PowerShow.com