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和本文有关系有时间可以研究一下这两个参数。)

  • 相关阅读:
    06.04 html
    汉企第一天
    Django之ajax
    Diango之图书管理系统编辑
    Django之模型层&ORM操作
    Django 之模板层
    Django之 路由层
    Django之ORM简单操作(一)
    迭代器、可迭代对象、迭代器对象、生成器、生成器对象、枚举对象
    装饰器
  • 原文地址:https://www.cnblogs.com/WisWang/p/6055929.html
Copyright © 2011-2022 走看看