O que o net.ipv4.tcp_app_win faz?

4

Eu não consigo entender por que essas variáveis coexistem no Linux. As informações do man tcp dizem (Ubuntu 12.04):

Para tcp_adv_win_scale:

tcp_adv_win_scale (integer; default: 2; since Linux 2.4)

          Count   buffering   overhead  as  bytes/2^tcp_adv_win_scale,  if
          tcp_adv_win_scale    is    greater    than    0;    or    bytes-
          bytes/2^(-tcp_adv_win_scale),  if tcp_adv_win_scale is less than
          or equal to zero.

          The socket receive buffer space is shared between  the  applica‐
          tion  and  kernel.   TCP maintains part of the buffer as the TCP
          window, this is the size of the receive window advertised to the
          other  end.   The rest of the space is used as the "application"
          buffer, used to isolate the network from scheduling and applica‐
          tion  latencies.   The  tcp_adv_win_scale  default  value  of  2
          implies that the space used for the application  buffer  is  one
          fourth that of the total.

E para tcp_app_win:

tcp_app_win (integer; default: 31; since Linux 2.4)
              This  variable  defines  how  many  bytes  of the TCP window are
              reserved for buffering overhead.

              A maximum of (window/2^tcp_app_win, mss) bytes in the window are
              reserved  for the application buffer.  A value of 0 implies that
              no amount is reserved.

Então, não tenho certeza de entender o que tcp_app_win exatamente muda. Parece-me que ambas as variáveis podem ser usadas para ajustar o buffer de aplicação TCP, portanto não há necessidade de alterá-las entre si. Estou correto?

    
por javag87 12.10.2013 / 17:56

1 resposta

2

Eu encontrei esta informação que fala sobre tcp_adv_win_scale . A página é intitulada: ajuste do desempenho do TCP - como ajustar o linux .

trecho

TCP performance is limited by latency and window size (and overhead, which reduces the effective window size) by window_size/RTT (this is how much data that can be "in transit" over the link at any given moment).

To get the actual transfer speeds possible you have to divide the resulting window by the latency (in seconds):

The overhead is: window/2^tcp_adv_win_scale (tcp_adv_win_scale default is 2)

So for linux default parameters for the recieve window (tcp_rmem): 87380 - (87380 / 2^2) = 65536.

Given a transatlantic link (150 ms RTT), the maximum performance ends up at: 65536/0.150 = 436906 bytes/s or about 400 kbyte/s, which is really slow today.

With the increased default size: (873800 - 873800/2^2)/0.150 = 4369000 bytes/s, or about 4Mbytes/s, which is resonable for a modern network. And note that this is the default, if the sender is configured with a larger window size it will happily scale up to 10 times this (8738000*0.75/0.150 = ~40Mbytes/s), pretty good for a modern network.

2.6.17 and later have resonably good defaults values, and actually tune the window size up to the max allowed, if the other side supports it. So since then most of this guide is not needed. For good long-haul throughput the maxiumum value might need to be increased though.

Eu pude seguir isso, mas não entendi muito bem a relação entre essas duas variáveis, se é que existe alguma.

Eu só entendia marginalmente o que isso estava tentando explicar. No núcleo, parece que esse parâmetro para dimensionar a quantidade de espaço em buffer deve ser usado para TCP e para o aplicativo.

Pesquisando um pouco mais, encontrei essas explicações que faziam mais sentido. A página foi intitulada: Ipsysctl tutorial 1.0.4 - Capítulo 3. Referência de variável IPv4 .

trecho

3.3.2. tcp_adv_win_scale

This variable is used to tell the kernel how much of the socket buffer space should be used for TCP window size, and how much to save for an application buffer. If tcp_adv_win_scale is negative, the following equation is used to calculate the buffer overhead for window scaling:

Where bytes are the amount of bytes in the window. If the tcp_adv_win_scale value is positive, the following equation is used to calculate the buffer overhead:

The tcp_adv_win_scale variable takes an integer value and is per default set to 2. This in turn means that the application buffer is 1/4th of the total buffer space specified in the tcp_rmem variable.

3.3.3. tcp_app_win

This variable tells the kernel how many bytes to reserve for a specific TCP window in the TCP sockets memory buffer where the specific TCP window is transfered in. This value is used in a calculation that specifies how much of the buffer space to reserve that looks as the following:

ss of formula

As you may understand from the above calculation, the larger this value gets, the smaller will the buffer space be for the specific window. The only exception to this calculation is 0, which tells the kernel to reserve no space for this specific connection. The default value for this variable is 31 and should in general be a good value. Do not change this value unless you know what you are doing.

Com base nessas explicações, soa como o primeiro parâmetro, tcp_adv_win_scale está controlando a divisão do espaço do buffer de soquete em termos de como ela é dividida para uso da janela TCP vs. buffer de aplicativo.

Considerando que o segundo parâmetro, tcp_app_win , está especificando o número de bytes a serem reservados para o buffer de aplicativo mencionado na descrição tcp_adv_win_scale .

    
por 13.10.2013 / 04:25