TCP Sliding Window

本文详细介绍了TCP滑动窗口的概念及其工作原理。首先探讨了快速发送方与缓慢接收方之间的场景,接着解释了滑动窗口如何帮助管理未确认的数据及根据接收方窗口大小调整发送策略。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Sliding window is an interesting concept. In terms of TCP, receiver’s window represents the amount of data that the receiver is willing to accept.

In this article, we will cover TCP sliding window concept and aspects related to it.

Quick Sender, Slow Receiver

Before learning the sliding window concept, lets first discuss a scenario where sender is quick to send data while receiver is a bit slow to accept it. Suppose sender sends three data segments (seg1, seg2 and seg3) each of 4096 bytes and starts waiting for the acknowledgement from the receiver.

Now, if these 3 segments fill up all the TCP buffers of the receiver then receiver will advertise a window size of 0. The window size zero means that receiver cannot accept any more data at this moment. Whenever buffers are available, a non zero window size would be advertised by the receiver.

TCP Sliding Window

The process described in last section is good on receiver’s part but sender has to maintain a window on its side too. This window covers unacknowledged data and the data it can send keeping in mind the window size advertised by the receiver.

Following figure should give you an idea about how a sliding window looks like :

In the figure shown above :

  • The available window advertised by the receiver is 6. This means that receiver can accept 6 bytes as of now.

  • The window at sender side covers bytes ranging from 13 to 18 (I.e. 6 bytes in total).

  • Out of this range, 13-15 are the bytes which have been sent but no acknowledgement is yet received for them.

  • Bytes 16-18 are the bytes that sender can send as soon as possible.

  • If sender starts receiving acknowledgement for bytes 13 to 15, the left end of the window starts closing in.

  • The right end starts opening up as more and more window size is advertised by the receiver.

  • This window slides towards right depending upon how fast receiver consumes data and sends acknowledgement and hence known as sliding window.

On a related note, it is also helpful for you to understand how TCP attacks andARP cache poisoning works.

Some more points related to sliding windows :

  • The receiver can send acknowledgement even before its window fills up completely.

  • The left edge of the window can move towards right.

  • Neither left edge should move towards left nor right edge should move towards left.


转载于:https://my.oschina.net/robinyao/blog/530563

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值