[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
一般来说我们希望数据传输得快一些,但如果发送得过快,可能会导致接收方来不及接收,造成数据丢失。
所谓流量控制,就是让发送方的发送速率不要太快,让接收方来得及接收。利用滑动窗口
机制可以很方便地在TCP连接上实现对发送方的流量控制。下面用一个例子来进行说明。
A和B之间已经建立了TCP连接,A的发送窗口大小为400字节,每一段的大小为100字节。A开始逐段向B发送数据,当发送第3段数据时,发生了丢失。
此时,A收到了来自B的确认报文,确认已经收到了前两段的内容,并将接收窗口调整为300字节。
收到确认报文后,A的发送窗口向前移动两段,前两段的数据可以删除掉。此时窗口内有201-500号字节数据。发送窗口继续逐段发送第4段和第5段数据,而当发送完第5段数据后,就不可以再发送新数据了。
这时,第2段的重传计时器超时了,第2段被重新发送。收到这些数据后,主机B对501号以前的数据进行累计确认,并将接收窗口调整为100。
发送窗口继续前移,并调整窗口大小为100字节。A继续发送第6段数据,B接收到后发过来一条确认报文,并调整窗口大小为0。
收到确认报文后,A的发送窗口前移,并将大小调整为0。此时,A就会启动持续计时器,如果B在计时时间内没有发送过来调整接收窗口的报文,或者发送过来的报文丢失了,A就会发送零窗口探测报文。
B接收到探测报文后,就会对其进行确认,并通告自己的接收窗口大小。如果仍然是0的话,A的持续计时器就会重启;而如果不是0的话,A就会调整发送窗口的大小,开始传送报文。