Skip to content

Commit

Permalink
add tcp congestion status duration statistic tool (iovisor#3899)
Browse files Browse the repository at this point in the history
add tcp congestion control status duration statistic tool, and it can be used to evaluate the networking and congestion algorithm performance.
  • Loading branch information
jackygam2001 authored Mar 24, 2022
1 parent 03e4948 commit a58c795
Show file tree
Hide file tree
Showing 5 changed files with 1,190 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ pair of .c and .py files, and some are directories of files.
- tools/[tcpsynbl](tools/tcpsynbl.py): Show TCP SYN backlog. [Examples](tools/tcpsynbl_example.txt).
- tools/[tcptop](tools/tcptop.py): Summarize TCP send/recv throughput by host. Top for TCP. [Examples](tools/tcptop_example.txt).
- tools/[tcptracer](tools/tcptracer.py): Trace TCP established connections (connect(), accept(), close()). [Examples](tools/tcptracer_example.txt).
- tools/[tcpcong](tools/tcpcong.py): Trace TCP socket congestion control status duration. [Examples](tools/tcpcong_example.txt).
- tools/[threadsnoop](tools/threadsnoop.py): List new thread creation. [Examples](tools/threadsnoop_example.txt).
- tools/[tplist](tools/tplist.py): Display kernel tracepoints or USDT probes and their formats. [Examples](tools/tplist_example.txt).
- tools/[trace](tools/trace.py): Trace arbitrary functions, with filters. [Examples](tools/trace_example.txt).
Expand Down
136 changes: 136 additions & 0 deletions man/man8/tcpcong.8
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
.TH tcpcong 8 "2022-01-27" "USER COMMANDS"
.SH NAME
tcpcong \- Measure tcp congestion state duration. Uses Linux eBPF/bcc.
.SH SYNOPSIS
.B tcpcong [\-h] [\-T] [\-L] [\-R] [\-u] [\-d] [interval] [outputs]
.SH DESCRIPTION
this tool measures tcp sockets congestion control status duration, and
prints a summary of tcp congestion state durations along with the number
of total state changes.

It uses dynamic tracing of kernel tcp congestion control status
updating functions, and will need to be updated to match kernel changes.

The traced functions are only called when there is congestion state update,
and therefore have low overhead. we also use BPF map to store traced data
to reduce overhead. See the OVERHEAD section for more details.
Since this uses BPF, only the root user can use this tool.
.SH REQUIREMENTS
CONFIG_BPF and bcc.
.SH OPTIONS
.TP
\-h
Print usage message.
.TP
\-T
Include a timestamp column.
.TP
\-L
Specify local tcp port range.
.TP
\-R
Specify remote tcp port range.
.TP
\-u
Output in microseconds.
.TP
\-d
Show congestion status duration distribution as histograms.
.SH EXAMPLES
.TP
Show all tcp sockets congestion status duration until Ctrl-C:
#
.B tcpcongestdura
.TP
Show all tcp sockets congestion status duration every 1 second and 10 times:
#
.B tcpcong 1 10
.TP
Show only local port 3000-3006 congestion status duration every 1 second:
#
.B tcpcong \-L 3000-3006 1
.TP
Show only remote port 5000-5005 congestion status duration every 1 second:
#
.B tcpcong \-R 5000-5005 1
.TP
Show 1 second summaries, printed in microseconds, with timestamps:
#
.B tcpcong \-uT 1
.TP
Show all tcp sockets congestion status duration as histograms:
#
.B tcpcong \-d
.SH FIELDS
.TP
LAddrPort
local ip address and tcp socket port.
.TP
RAddrPort
remote ip address and tcp socket port.
.TP
Open_us
Total duration in open status for microseconds.
.TP
Dod_us
Total duration in disorder status for microseconds.
.TP
Rcov_us
Total duration in recovery status for microseconds.
.TP
Cwr_us
Total duration in cwr status for microseconds.
.TP
Los_us
Total duration in loss status for microseconds.
.TP
Open_ms
Total duration in open status for milliseconds.
.TP
Dod_ms
Total duration in disorder status for milliseconds.
.TP
Rcov_ms
Total duration in recovery status for milliseconds.
.TP
Cwr_ms
Total duration in cwr status for milliseconds.
.TP
Loss_ms
Total duration in loss status for milliseconds.
.TP
Chgs
Total number of status change.
.TP
usecs
Range of microseconds for this bucket.
.TP
msecs
Range of milliseconds for this bucket.
.TP
count
Number of congestion status in this time range.
.TP
distribution
ASCII representation of the distribution (the count column).
.SH OVERHEAD
This traces the kernel tcp congestion status change functions.
As called rate per second of these functions per socket is low(<10000), the
overhead is also expected to be negligible. If you have an application that
will create thousands of tcp connections, then test and understand overhead
before use.
.SH SOURCE
This is from bcc.
.IP
https://github.com/iovisor/bcc
.PP
Also look in the bcc distribution for a companion _examples.txt file containing
example usage, output, and commentary for this tool.
.SH OS
Linux
.SH STABILITY
Unstable - in development.
.SH AUTHOR
jacky gan
.SH SEE ALSO
tcpretrans(8), tcpconnect(8), tcptop(8), tcpdrop(8)
3 changes: 3 additions & 0 deletions tests/python/test_tools_smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,9 @@ def test_tcpdrop(self):
def test_tcptop(self):
self.run_with_duration("tcptop.py 1 1")

def test_tcpcong(self):
self.run_with_duration("tcpcong.py 1 1")

def test_tplist(self):
self.run_with_duration("tplist.py -p %d" % os.getpid())

Expand Down
Loading

0 comments on commit a58c795

Please sign in to comment.