I'm working on a software which connects to a Real Time data server (using TCP) and I have some connections dropping. My guess is that the clients do not read the data coming from the server fast enough. Therefore I would like to monitor my TCP sockets. For this I found the "ss" tool.
This tool allows to see the state of every socket – here's an example line of the output of the command ss -inm 'src *:50000'
ESTAB 0 0 184.7.60.2:50000 184.92.35.104:1105
mem:(r0,w0,f0,t0) sack rto:204 rtt:1.875/0.75 ato:40
My question is: what does the memory part mean?
Looking at the source code of the tool I found that the data is coming from a kernel structure (sock
in sock.h
). More precisely, it comes from the fields :
r = sk->sk_rmem_alloc
w = sk->sk_wmem_queued;
f = sk->sk_forward_alloc;
t = sk->sk_wmem_alloc;
Does somebody know what they mean? My guesses are:
rmem_alloc
: size of the inbound bufferwmem_alloc
: size of the outbound buffersk_forward_alloc
: ???sk->sk_wmem_queued
: ???
Here are my buffers sizes :
net.ipv4.tcp_rmem = 4096 87380 174760
net.ipv4.tcp_wmem = 4096 16384 131072
net.ipv4.tcp_mem = 786432 1048576 1572864
net.core.rmem_default = 110592
net.core.wmem_default = 110592
net.core.rmem_max = 1048576
net.core.wmem_max = 131071
Best Answer
sk_forward_alloc
is the forward allocated memory which is the total memory currently available in the socket's quota.sk_wmem_queued
is the amount of memory used by the socket send buffer queued in the transmit queue and are either not yet sent out or not yet acknowledged.You can learn more about TCP Memory Management in chapter 9 of TCP/IP Architecture, Design and Implementation in Linux By Sameer Seth, M. Ajaykumar Venkatesulu