Network Buffer Usage

buffercentos6linux-networkingnetworkingusage

I am facing some issues with my Application, and am curious to know the network buffer usage at any given moment.

I am using a CentOS 6 linux Machine.

I know the Default values are present in /proc/sys/net/core/

But i have not been successful in finding the current usage of the Buffers. If any one has any clue on how to find the current usage, please let me know.

Thanks in advance.

Best Answer

If you run ss or netstat the values Recv-Q and Send-Q produce this output.

I.E

$ ss -nt
State      Recv-Q Send-Q        Local Address:Port          Peer Address:Port 
ESTAB      203    0               192.168.1.2:36122       198.xxx.xxx.xxx:80    
CLOSE-WAIT 1      0               192.168.1.2:43870       140.xxx.xxx.xxx:80    

I have added a simple python program to demonstrate this.

#/usr/bin/python
from time import sleep
from socket import *
import subprocess

if __name__ == "__main__":
  sock = socket(AF_INET, SOCK_STREAM)
  sock.setsockopt(IPPROTO_TCP, TCP_CORK, 1)
  sock.connect(('www.google.com', 80))
  length = sock.send("GET / HTTP/1.1\r\nHost: www.google.com\r\n\r\n")
  sport = sock.getsockname()[1]
  print "Length of sent data: {0}".format(length)
  subprocess.call(["ss" ,"-nt", "sport", "=", ":{0}".format(sport)])
  sock.close()

Which produces

Length of sent data: 40
State      Recv-Q Send-Q        Local Address:Port          Peer Address:Port 
ESTAB      0      40              192.168.1.2:34259       173.194.41.180:80