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