Unit 2, Flow control

The finite state machine of “stop and wait”

Unit 2, Flow control_第1张图片
Sliding window可以填充满network pipe的capacity,比如bottleneck为10Mbps (Mega-bits per second), RTT(round trip time)为50ms,那么1s内能发送 1000/50 = 20次 rount trip,10Mbps/20 = 500Kbps, 每个Eternet frame大小为12bits,那么 500/12 ≈ 41 个 frame。每秒能发送约41个frame。
Unit 2, Flow control_第2张图片

The sliding window mechanism

Unit 2, Flow control_第3张图片
The sliding window allows a “window” of unacknowledged packets in flight. (这里对比的stop and wait, which only allows one packet in flight,是一个极大的浪费)。

先发过去了再说,可以到了buffer然后确认,ACK。

1. Sender side

Unit 2, Flow control_第4张图片

  • Sender端保留三个重要的变量,SWS, LAR, LSS
  • Sender可以send的segement sequence number一定要小于LAR + SWS。Last acknowledgment received在哪,发送的就不能超过这个number加上sliding window size. 这就是sliding window,小划窗的形象定义。
  • 在一个SWS内发送的几个segment,如果存在未ACK的,那么sliding window就会卡在那个segment停滞不前,LAR也会停留在那个numebr。

2. Receiver side

Unit 2, Flow control_第5张图片
也有三个变量:RWS, LAS, LSR, LAS-LSR ≤ RWS。

Last acceptable segment denotes the next segmente it can receive, e.g. RWS=5, LSR=3, it can receive 4,5,6,7,8, segment 10 will be discarded because the receiver cannot buffer it.

If received packet is < LAS, send ACK.
Note: Cumulative state.这里有个advance,rather than sending the ACKs for the data you received, send what is the end of the contiguous data you received, that is cumulative. E.g.
acknowledge 3, for every data before 3, not just 3.

例外:
TCP acks是next expected data, say last received is n, 那么tcp表示的是n+1. Should keep this in mind.

Unit 2, Flow control_第6张图片
RWS≤SWS,不然多余的buffer space就是浪费啊。

Go-back-N的意思是,因为Receiver window size是1,所以只能buffer当前segment,如果丢失,那么sender must retransmit the entire window.

TCP is a protocol using sliding window.
Unit 2, Flow control_第7张图片

对sliding window还有不懂的话,听听Sliding window Example
最后的部分。
Unit 2, Flow control_第8张图片
Receiver: ACK3
Sender: data 4, data 5

data4 lost

Receiver: ACK3 (cumulative ACKs)
But buffered data 5 becasue RWS=2,能保存5.
Sender: send data 4 again
Receiver: ACK5 (5 already buffered thanks to receive window)

P.s. 这里不发送ACK 4,becasue of the principle of cumulative state. Send what is the end of the contiguous data segments received.


P34 retransmission:

What kind of retransmission protocol to use?
Go-back-N v.s. selective repeat: a trade-off between conservative and optimistic

你可能感兴趣的:(网络)