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.
分享到:
相关推荐
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 ...
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 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 ...
本书详细介绍了数学的各个分支。对于有需要了解数学方法的程序员有很大的帮助。
What If I’m a Perl Course Instructor? 4 What Does “Perl” Stand For? 4 Why Did Larry Create Perl? 5 Why Didn’t Larry Just Use Some Other Language? 5 Is Perl Easy or Hard? 6 How Did Perl Get to Be ...
What Is Computer Science
What? It’s a chair. It’s a chair. It’s a chair. Chair. Chair." 通过以上步骤,孩子们不仅学会了英语对话,还通过各种互动活动体验了英语学习的乐趣,为他们的英语基础打下了坚实的基础。此外,教师应时刻...
》(*What is Mathematics?*)是一本享誉全球的数学科普著作,由理查德·科朗(Richard Courant)与赫伯特·罗宾斯(Herbert Robbins)共同编写,并在第二版中加入了伊恩·斯图尔特(Ian Stewart)的新章节。本书自...
36 What is deflation?
What Knowledge Is Important to a Software Professional?——by Timothy C.Lethbridge 作者来自University of Ottawa,这篇文章影响很大,非常值得软件工程专业人士研读。
(a) filling in skeleton tables of the database with examples of what is to be retrieved (b) placing SQL keywords, such as select, under the column names they want to retrieve (c) typing a ...
【接力版三年级下册小学英语 Lesson 6 "What colour is it?" 教案】主要围绕小学英语中的颜色和物品名称的教学展开,旨在帮助学生掌握基本的英语词汇和句型,提高他们的听说能力和语言运用能力。 一、教材内容分析 ...
Transient Voltage Suppressors (TVS’s) are devices used to protect vulnerable circuits from electrical overstress such as that caused by electrostatic ...of the transient to a nondestructive level.
However, the choice of what context the logging statements to place is consistent to a fair degree. Conclusion: Both the inconsistency in density and log level and the convergence of context have ...
《ChatGPT在做什么...以及为什么它有效》 这本书由斯蒂芬·沃尔夫勒姆(Stephen Wolfram)撰写,探讨了ChatGPT的工作原理及其为何能成功运作。沃尔夫勒姆是计算科学领域的权威,他的公司Wolfram Media出版了这本书...
什么是神经网络进化__What_is_Neuro-Evolution_
An optimization problem is almost any problem that is, or can be, formulated as a question starting with “What is the best ... ?” For instance, • What is the best route to get from home to work? •...