tcpcong(8)

πŸ’– tcpcong(8) πŸ’–

✨ NAME ✨

okay so tcpcong is the tool that measures how long TCP sockets hang out in each congestion control state πŸ’… It's built on Linux eBPF/bcc, so it's giving low-level energy πŸ”₯

πŸŽ€ SYNOPSIS πŸŽ€

tcpcong [-h] [-T] [-L] [-R] [-u] [-d] [interval] [outputs]

πŸ¦‹ DESCRIPTION πŸ¦‹

bestie, this tool tracks how long TCP sockets spend in each congestion control status, then prints a summary of those durations plus the total number of state changes. ✨ Main character energy, fr fr.

It works by dynamically tracing the kernel functions that update TCP congestion control status. Those functions can change between kernel versions, so this tool will need updating to match kernel changes πŸ™ˆ

The traced functions only fire when the congestion state actually updates, so the overhead is lowkey tiny 🫢 It also stores the traced data in a BPF map to keep things light. Check the OVERHEAD section for the full tea β˜• And since this runs on BPF, only the root user can use it πŸ”

🧩 REQUIREMENTS 🧩

You need CONFIG_BPF enabled in your kernel, plus bcc installed 🌸

πŸ’… OPTIONS πŸ’…

  • -h β€” Pulls up the usage message πŸ“–
  • -T β€” Adds a timestamp column πŸ•°οΈ
  • -L β€” Lets you pick a local TCP port range 🎯
  • -R β€” Lets you pick a remote TCP port range 🌍
  • -u β€” Prints everything in microseconds πŸ”¬
  • -d β€” Shows the congestion status duration distribution as histograms πŸ“Š

πŸ“ EXAMPLES πŸ“

Show all TCP sockets' congestion status durations until you hit Ctrl-C πŸ›‘

# tcpcongestdura

Show all TCP sockets' congestion status durations every 1 second, 10 times πŸ”

# tcpcong 1 10

Show only local ports 3000-3006 every 1 second 🎯

# tcpcong -L 3000-3006 1

Show only remote ports 5000-5005 every 1 second 🌍

# tcpcong -R 5000-5005 1

Show 1 second summaries in microseconds, with timestamps ⏱️

# tcpcong -uT 1

Show all TCP sockets' congestion status durations as histograms πŸ“Š

# tcpcong -d

πŸ“‹ FIELDS πŸ“‹

  • LAddrPort β€” the local IP address and TCP socket port 🏠
  • RAddrPort β€” the remote IP address and TCP socket port 🌐
  • Open_us β€” total time spent in the open status, in microseconds 🌞
  • Dod_us β€” total time spent in the disorder status, in microseconds πŸŒ€
  • Rcov_us β€” total time spent in the recovery status, in microseconds 🩹
  • Cwr_us β€” total time spent in the cwr status, in microseconds 🌊
  • Los_us β€” total time spent in the loss status, in microseconds πŸ’”
  • Open_ms β€” total time spent in the open status, in milliseconds 🌞
  • Dod_ms β€” total time spent in the disorder status, in milliseconds πŸŒ€
  • Rcov_ms β€” total time spent in the recovery status, in milliseconds 🩹
  • Cwr_ms β€” total time spent in the cwr status, in milliseconds 🌊
  • Loss_ms β€” total time spent in the loss status, in milliseconds πŸ’”
  • Chgs β€” total number of status changes πŸ”„
  • usecs β€” the microsecond range for this bucket πŸ”¬
  • msecs β€” the millisecond range for this bucket ⏳
  • count β€” how many congestion statuses landed in this time range πŸ”’
  • distribution β€” an ASCII picture of the distribution (based on the count column) πŸ“Š

πŸŒ™ OVERHEAD πŸŒ™

This traces the kernel's TCP congestion status change functions. Those functions get called at a low rate per socket (under 10000 calls per second), so the overhead is expected to be negligible 🫧

⚠️ If your app is going to create thousands of TCP connections, test it and understand the overhead before you use this tool in production, bestie 😭

🌐 SOURCE 🌐

This comes from bcc 🐝

https://github.com/iovisor/bcc

Also check out the companion _examples.txt file in the bcc distribution. It has example usage, output, and commentary for this tool πŸ“š

πŸ’» OS πŸ’»

Linux 🐧

πŸ§ͺ STABILITY πŸ§ͺ

Unstable β€” it's still in development 🚧

πŸ‘©β€πŸ’» AUTHOR πŸ‘©β€πŸ’»

jacky gan πŸ’œ

πŸ”— SEE ALSO πŸ”—

tcpretrans(8), tcpconnect(8), tcptop(8), tcpdrop(8) 🧚


🌸 That's the tea, bestie: tcpcong(8) from the USER COMMANDS section, dated 2022-01-27 πŸ’–