Networking

/proc/net/udp 中的 rx_queue 值增長到 SO_RCVBUF 值的兩倍

  • May 11, 2017

當使用SO_RCVBUF10485760 時(這也是sysctlnet.core.rmem_max設置規定的目前限制,並且發送 UDP 數據包的速度比接收方能夠處理的速度快,rx_queue列中的列/proc/net/udp總是增長到幾乎正好是SO_RCVBUF.20972544大小的兩倍我能觀察到的最高值。

那麼沒有遵守 SO_RCVBUF嗎?還是 /proc/net/udp 的輸出錯誤?

我的系統:

uname -a
Linux mybox 4.3.0-1-amd64 #1 SMP Debian 4.3.3-5 (2016-01-04) x86_64 GNU/Linux

socket(7)手冊頁:

   SO_RCVBUF
          Sets or gets the maximum socket receive buffer in bytes.  The
          kernel doubles this value (to allow space for bookkeeping
          overhead) when it is set using setsockopt(2), and this doubled
          value is returned by getsockopt(2).  The default value is set
          by the /proc/sys/net/core/rmem_default file, and the maximum
          allowed value is set by the /proc/sys/net/core/rmem_max file.
          The minimum (doubled) value for this option is 256.

請注意,手冊頁表明核心會將指定的緩衝區值加倍以用於記賬成本。

引用自:https://serverfault.com/questions/758885