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 will not 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 the TCP Window Thing? • Why have a TCP window? • How do I set the TCP window in my application? o For most OS's o Unicos o AIX • Setting the TCP window size under Unicos • How big do I ...
FrequentlyAsked Questions 1. What are the different types...49. What is a free-boundary problem and what is the optimal-stopping time for an American option? 220 50. What are low discrepancy numbers? 225
The term business analyst is still synonymous with a career in the IT industry, but the most successful and valuable analysts are those who understand the “business” rather than those who understand...
What is a Matroid, James Oxley 精简介扫什么是拟阵(独立性泛化),拟阵的多个等价定义,拟阵的域表示,可图拟阵等等。
1. What is the IP address and TCP port number used by the client computer (source) that is transferring the file to gaia.cs.umass.edu? To answer this question, it’s probably easiest to select an ...
“What bugs live in the cloud? A study of 3000+ issues in cloud system” 论文ppt
What bugs in the cloud?A Study of 3000+ Issues in Cloud Systems
高中What's really green?课件设计.pptx
WHAT IS A MATROID? JAMES OXLEY Abstract. Matroids were introduced by Whitney in 1935 to try to capture abstractly the essence of dependence. Whitney’s definition embraces a surprising diversity of ...
This is a classic explanation on "what is a quant". Very good reading for the "want-to-be".
What is Nucleus C++ FILE? Nucleus C++ FILE is a C++ class interface into Nucleus FILE, a FAT16/FAT32 TM compatible file system specifically designed to work in embedded systems in conjunction with the...
Is Parallel Programming Hard, And, If So, What Can You Do About It?
有关遗传算法的论文,是英文的,可以作为翻译用
Q4) What is 77 level used for ? A4) Elementary level item. Cannot be subdivisions of other items (cannot be qualified), nor can they be subdivided themselves. Q5) What is 88 level used for ? A5) For ...
36. What is the Attach Window activity used for? 37. What happens if you put a Breakpoint on a Click activity and start the workflow in Debug mode? 38. What should you use to scrape tables from a ...
what is seen and what is not seen 一部很不错的书。
讲解如何写测试用例的文章
This chapter answers the question “What is a .NET Compact Framework application?” in two ways: by studying the details of a simple, but complete, Compact Framework Windows application. Along the ...
知识图谱的定义,概念的演化历史,知识图谱的特点与最新发展
What is a Weekly Report_ A Weekly Report is a structured journal