Alex Reece
Alex Reece

Reputation: 2026

How do I observe TCP connection variables for a process on Linux?

I have a distributed application where I can load a large batch of data into it. Unfortunately, my application isn't able push data over the network as fast as I'd expect: if I scp over the file, the network bandwidth (as reported by dstat --net) is ~120Mb/s, whereas my application only pushes ~80Mb/s.

How do I observe the TCP connection variables for the sockets used by my process to figure out where the bottleneck is? In particular, I would love to measure:

Upvotes: 0

Views: 754

Answers (1)

Alex Reece
Alex Reece

Reputation: 2026

  • cwnd size I can see via cat /proc/net/tcp (its the second to last column).
  • I can see the current count of outstanding bytes in the socket send / receive buffers by looking at /proc/net/tcp or netstat --tcp, although that doesn't also show me the max send buffer size.
  • TCP retransmissions are harder, but this gets pretty close: https://github.com/brendangregg/perf-tools/blob/master/net/tcpretrans

Upvotes: 1

Related Questions