<<TCP/IP详解>>卷1 的19.3节讲到"经受时延的确认":
在TCP用作交互式应用的时候, 比如远程登录, 为了减少报文传送, 接收方往往会等待200ms, 以便将前一个段的响应与本段的数据一块发送.请问, 难道TCP协议会判定当前是传送交互式的数据还是大块的数据, 然后作出是否要作200ms延时的决定? 感觉不可能.

解决方案 »

  1.   


    有一个Nagle算法,建议楼主看看RFC,或者<<TCP/IP详解>>卷1的第19章。
      

  2.   

    就是所谓的粘包控制,这样如果有多个数据需要发送的话,可以尽可能的合并到一个数据报发送
    不一定是缓冲满才发送,因为接收或者发送缓冲可能很大的
    每次能发送包大小应该是受MTU控制的,而且IPV4一个包最大也不能超过32K吧可以通过设置打开或者关闭这个功能,如果关闭的话,则数据将立即发送。
      

  3.   

    TCP的平滑窗口机制,Nagle算法,就是假如发送缓冲没满就等一下
      

  4.   


    "Delayed Acknowledgments
    As specified in RFC 1122: Requirements for Internet Hosts -- Communication Layers, Transmission Control Protocol (TCP) uses delayed acknowledgments (ACKs) to reduce the number of packets sent on the transmission media. In Windows Transmission Control Protocol/Internet Protocol (TCP/IP), the stack takes a common approach to implementing delayed ACKs. As data is received by TCP on a connection, the stack only sends an acknowledgment back if one of the following conditions is met:
    No ACK was sent for the previous segment received.
    A segment is received, but no other segment arrives within 200 milliseconds for that connection.
    In other words, an ACK is sent for every other TCP segment received on a connection, unless the delayed ACK timer expires after 200 milliseconds pass. 
    "以上的自己慢慢看吧,MSDN文档的东西。这个是可以通过修改注册表增加或降些这个等待时间的。
      

  5.   

    里边是有个200MS的定时器,使用Nagle来组包,如果接受端产生一个回应报文通知发送端没有接受空间了,发送端哪怕缓冲区已经满了,也不会启动发送