tcpsubnet(8)

πŸ“¦ version 0.36.1, in alpine 3.24, nixpkgs unstable, opensuse-leap 16.0

✨ tcpsubnet ✨

tcpsubnet is a manual page for a tool that summarizes and aggregates IPv4 TCP traffic by subnet πŸ’–

πŸ“ NAME

okay so tcpsubnet is the tool that summarizes and aggregates IPv4 TCP traffic by subnet πŸ¦‹

🧾 SYNOPSIS

tcpsubnet [-h] [-v] [-J] [-f FORMAT] [-i INTERVAL] [subnets]

πŸ’­ DESCRIPTION

bestie, this tool summarizes and aggregates IPv4 TCP sent to the subnets you pass in as an argument, then prints to stdout on a fixed interval ✨

It uses dynamic tracing of kernel TCP send/receive functions, so it's giving "kernel-aware" energy, but it will need updating whenever the kernel changes πŸ”₯

The traced data gets summarized in-kernel with a BPF map to keep overhead low πŸ’…. Still, at very high TCP event rates, the overhead may be measurable. Check the OVERHEAD section for the tea β˜•

Since this uses BPF, only the root user can use this tool. No root, no tcpsubnet πŸ™ˆ

πŸ› οΈ REQUIREMENTS

You'll need CONFIG_BPF and bcc 🧚

πŸŽ€ OPTIONS

  • -h β€” Prints the USAGE message 🌸
  • -v β€” Runs in verbose mode. It outputs the subnet evaluation and the BPF program πŸ”
  • -J β€” Formats the output as JSON πŸ’œ
  • -i β€” Sets the interval between updates, in seconds. The default is 1 ⏰
  • -f β€” Formats the output units. Supported values are bkmBKM. When you use kmKM, the output gets rounded to floor πŸ“
  • subnets β€” A comma separated list of subnets. Traffic gets sorted into these subnets, and order matters πŸ‘‘ The default is 127.0.0.1/32,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,0.0.0.0/0

🌈 EXAMPLES

Summarize TCP traffic by the default subnets:

# tcpsubnet

Summarize all TCP traffic:

# tcpsubnet 0.0.0.0/0

Summarize all TCP traffic and output in JSON and Kb:

# tcpsubnet -J -fk 0.0.0.0/0

πŸ”Ž FIELDS

Here's what you'll see in the output πŸ‘€

  • Standard output, left hand column β€” Subnet
  • Standard output, right hand column β€” Aggregate traffic in the units you passed as an argument
  • JSON output, date β€” The current date, formatted in the system locale
  • JSON output, time β€” The current time, formatted in the system locale
  • JSON output, entries β€” A map of subnets to aggregates. Values are in the format you passed to -f

🐒 OVERHEAD

Okay this part is important, so listen up 🫢 This traces all tcp_sendmsg function calls in the TCP/IP stack, and it summarizes data in-kernel to keep the overhead down. In a simple iperf test (v2.0.5) with the default values, throughput dropped by about 5%. Over 10 runs without tcpsubnet running, the average throughput was 32.42Gb/s. With tcpsubnet enabled, it was 31.26Gb/s πŸ“‰

This is not meant to be used as a long running service. Use it for troubleshooting or for a controlled interval. As always, try it out in a test environment first πŸ™ˆ

πŸ“¦ SOURCE

This one's from bcc πŸ’–

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

πŸ’» OS

Linux 🐧

πŸ§ͺ STABILITY

Unstable, still in development 🚧

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

Rodrigo Manyari 🌟

πŸ’‘ INSPIRATION

tcptop(8) by Brendan Gregg πŸ¦‹

πŸ”— SEE ALSO

netlink(7) 🫢


Man page vibes check: this one's from the USER COMMANDS section and dated 2018-03-01. Stay iconic, stay root-approved, and go tcpsubnet your little heart out πŸ’…βœ¨πŸŽ€