zoukankan      html  css  js  c++  java
  • delayed ack与nagle's算法

    delayed ack和nagles算法都能减少tcp传输过程中的小数据包的问题

    tcpip卷二25章中提到tcp为每个连接建立7个定时器:

    1.connection established

    2.restransmission

    3.delayed ack(https://en.wikipedia.org/wiki/TCP_delayed_acknowledgment)

    4.persist

    5.keepalive

    6.fin_wait_2

    7.time_wait

    下面是wikipedia对nagle’s算法描述的url,

    https://en.wikipedia.org/wiki/Nagle%27s_algorithm

    最主要的应该就是这段代码:

    if there is new data to send
      if the window size >= MSS and available data is >= MSS
        send complete MSS segment now
      else
        if there is unconfirmed data still in the pipe
          enqueue data in the buffer until an acknowledge is received
        else
          send data immediately
        end if
      end if
    end if

    MSS(maximum segment size)

    (今天才知道这是两个概念,之前以为是一个意思呢O(∩_∩)O~),

    如果实际中就是小数据包很多而且实时要求很高的话,可以设置socket的tcp_nodelay选项来关闭nagles算法(nginx中就有此设置).(这里还有两个参数tcp_cork和tcp_quickack和本文有关系有时间可以研究一下这两个参数。)

  • 相关阅读:
    操作系統3-內存管理(請求分頁內存管理)
    c++对象的内存模式
    操作系統3-內存管理(虛擬存儲器)
    单词统计续
    团队冲刺八
    团队冲刺七
    团队冲刺六
    团队冲刺五
    关于文件读写的各种操作
    单词统计
  • 原文地址:https://www.cnblogs.com/WisWang/p/6055929.html
Copyright © 2011-2022 走看看