开发者

Optimal Buffer Size - TCP

开发者 https://www.devze.com 2023-03-19 05:04 出处:网络
If I\'m doing a 开发者_JAVA百科large transfer and I Flush() in 4KB increments, will the application send 2 full packets and a 3rd partial packet, or will it wait to fill until that 3rd packet is full?

If I'm doing a 开发者_JAVA百科large transfer and I Flush() in 4KB increments, will the application send 2 full packets and a 3rd partial packet, or will it wait to fill until that 3rd packet is full?

So my question is, should I be flushing in multiples of the packet payload size?

Thanks :-)


The application has no control on how the packets are transferred (I am assuming you are sending the file using a TCP socket). Thus, the packets are sent based on the window size of TCP. The window size is determined by different factors: MSS (maximum segment size), network state (is there congestion or not) and the speed of your recipient to process the packets.

However, Let us assume that 4096 bytes will be segmented into 1460(1), 1460(2), and 1176(3) (assuming MSS = 1460 and window size = MSS (fixed)). If Nagle algorithm is enabled, 1460(1) will be sent immediately because it is the first segment, 1460(2) will be sent immediately because = MSS and 1176(3) will be delayed until TCP receives the acknowledgment of previous segments.

0

精彩评论

暂无评论...
验证码 换一张
取 消