What is a TCP window update?
来源:互联网 发布:苹果mac系统如何更新 编辑:程序博客网 时间:2024/06/05 05:18
http://stackoverflow.com/questions/1466307/what-is-a-tcp-window-update
TCP windows are used for flow control between the peers on a connection. With each ACK packet, a host will send a "window size" field. This field says how many bytes of data that host can receive before it's full. The sender is not supposed to send more than that amount of data.
The window might get full if the client isn't receiving data fast enough. In other words, the TCP buffers can fill up while the application is off doing something other than reading from it's socket. When that happens, the client would send an ACK packet with the "window full" bit set. At that point, the server is supposed to stop sending data. Any packets sent to a machine with a full window willnot be acknowledged. (This will cause a badly behaved sender to retransmit. A well-behaved sender will just buffer the outgoing data. If the buffer on the sending side fills up too, then the sending app will block when it tries to write more data to the socket!)
This is a TCP stall. It can happen for a lot of reasons, but ultimately it just means the sender is transmitting faster than the receiver is reading.
Once the app on the receiving end gets back around to reading from the socket, it will drain some of the buffered data, which frees up some space. The receiver will then send a "window update" packet to tell the sender how much data it can transmit. The sender starts transmitting it's buffered data and traffic should flow normally.
Of course, you can get repeated stalls if the receiver is consistently slow.
I've worded this as if the sender and receiver are different, but in reality, both peers are exchanging window updates with every ACK packet, and either side can have it's window fill up.
The overall message is that you don't need to send window update packets directly. It would actually be a bad idea to spoof one up.
Regarding the exception you're seeing... it's not likely to be either caused or prevented by the window update packet. However, if the client is not reading fast enough, you might be losing data. In your server, you should check the return value from your Socket.write() calls. It could be less than the number of bytes you're trying to write. This happens if the sender's transmit buffer gets full, which can happen during a TCP stall. You might be losing bytes.
For example, if you're trying to write 8192 bytes with each call to write, but one of the calls returns 5691, then you need to send the remaining 2501 bytes on the next call. Otherwise, the client won't see the remainder of that 8K block and your file will be shorter on the client side than on the server side.
- What is a TCP window update?
- Windows SDK:What is a top-level window?
- What is TCP/IP?
- In TCP networking, what is a FIN_WAIT state?
- What Program is Listening on a Specific TCP Port(Unix)
- What is a UUID?
- what is a lawyer
- What Is a Desision?
- What Is A Framework?
- what is a TFT?
- What is a THINKER?
- What is a disagreement
- What is a Closure?
- What is a Region?
- what is a map
- What is a FOURCC?
- What is a Program?
- what is a process?
- magento 全页缓存
- web.xml深入了解——各种标签
- 宅男程序员给老婆的计算机课程
- 解决VS断点无效,源代码与原始版本不同的问题
- java.lang.AbstractMethodError: gnu.xml.dom.DomElement.getTextContent()Ljava/lang/String;
- What is a TCP window update?
- C#方法重载(overload)
- perf使用1
- hibernate知识文档
- sql server 2005更改数据的登录用户名与访问权限
- 《基于C/S模式的android手机与PC机通信系统的开发》项目
- 数据库的备份与还原
- OpenTLD 未完成 - 虎头
- JAVA学习网站