Title: Selective Repeat
1Selective Repeat
- receiver individually acknowledges all correctly
received pkts - Buffers out-of-order packets
- sender only resends pkts for which ACK not
received - sender timer for each unACKed pkt
- sender window
- again limits seq s of sent, unACKed pkts
2Selective repeat sender, receiver windows
Send_base could lag rcv_base by as much as N
3Selective repeat Sender
Packets/ACK in the network Why?
Window N 4
95
99
snd_base 100 (sent, not yet acked)
- Assume No out-of-order
- Can Pkt 99 be in the network?
- Yes, may be there was a retransmission
- Can Pkt 95 be in the network?
- No.
- 95 cant be sent after sending 99.
- 99 has been acked
4Selective repeat Receiver
99
103
rcv_base 104 (not yet received)
Sender Window N 4
- Assume No out-of-order
- What is snd_base?
- Anywhere from 100 thru 104
- Which ACKs can be in the network?
- Anywhere from 96 thru 103
5Selective repeat
- pkt n in rcvbase, rcvbaseN-1
- send ACK(n)
- out-of-order buffer
- in-order deliver (also deliver buffered,
in-order pkts), advance window to next
not-yet-received pkt - pkt n in rcvbase-N,rcvbase-1
- ACK(n)
- otherwise
- ignore
- data from above
- if next available seq in window, send pkt
- timeout(n)
- resend pkt n, restart timer
- ACK(n) in sendbase,sendbaseN
- mark pkt n as received
- if n is smallest unACKed pkt, advance window base
to next unACKed seq
6Selective repeat in action
7Selective repeat dilemma
- Example
- seq s 0, 1, 2, 3
- window size3
- receiver sees no difference in two scenarios!
- incorrectly passes duplicate data as new in (a)
- Qs what relationship between seq size and
window size? - Ans num of seq numbers
- gt 2 X window size
- (Assuming no out-of-order)
8TCP Overview
- point-to-point
- one sender, one receiver
- reliable, in-order byte steam
- no message boundaries
- UDP is packet oriented
- pipelined
- TCP congestion and flow control set window size
- send receive buffers
- full duplex data
- bi-directional data flow in same connection
- MSS maximum segment size num of data bytes in a
TCP packet - connection-oriented
- handshaking (exchange of control msgs) inits
sender, receiver state before data exchange - flow controlled
- sender will not overwhelm receiver
9TCP 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 estab (setup,
teardown commands)
Internet checksum (as in UDP)
10TCP seq. s and ACKs
- Seq. s
- Sequence number of first byte
- ACKs
- seq of next byte expected from other side
- cumulative ACK
Host B
Host A
User types C
Seq42, ACK79, data C
host ACKs receipt of C, echoes back C
Seq79, ACK43, data C
host ACKs receipt of echoed C
Seq43, ACK80
11TCP 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 several recent measurements, not just
current SampleRTT
- Q how to set TCP timeout value?
- longer than RTT
- but RTT varies
- too short premature timeout
- unnecessary retransmissions
- too long slow reaction to segment loss
12TCP Round Trip Time and Timeout
EstimatedRTT (1- ?)EstimatedRTT ?SampleRTT
- Exponential weighted moving average
- influence of past sample decreases exponentially
fast - typical value ? 0.125
13Example RTT estimation
14TCP Round Trip Time and Timeout
- Setting the timeout
- EstimtedRTT plus safety margin
- large variation in EstimatedRTT -gt larger safety
margin - first estimate how much SampleRTT deviates from
EstimatedRTT
DevRTT (1-?)DevRTT ?SampleRTT-EstimatedRTT
(typically, ? 0.25)
Then set timeout interval
TimeoutInterval EstimatedRTT 4DevRTT
15TCP reliable data transfer
- Pipelined segments
- Cumulative ACKs
- Retransmissions are triggered by
- timeout events
- duplicate acks
- Initially consider simplified TCP sender
- ignore duplicate acks
- ignore flow control, congestion control