dpayne | 7b7e34a | 2018-01-18 09:34:20 -0800 | [diff] [blame] | 1 | .TH tcpconnlat 8 "2016-02-19" "USER COMMANDS" |
Brendan Gregg | afc9725 | 2016-02-19 16:07:36 -0800 | [diff] [blame] | 2 | .SH NAME |
dpayne | 7b7e34a | 2018-01-18 09:34:20 -0800 | [diff] [blame] | 3 | tcpconnlat \- Trace TCP active connection latency. Uses Linux eBPF/bcc. |
Brendan Gregg | afc9725 | 2016-02-19 16:07:36 -0800 | [diff] [blame] | 4 | .SH SYNOPSIS |
dpayne | fc50799 | 2018-01-18 14:09:28 -0800 | [diff] [blame] | 5 | .B tcpconnlat [\-h] [\-t] [\-p PID] [-v] [min_ms] |
Brendan Gregg | afc9725 | 2016-02-19 16:07:36 -0800 | [diff] [blame] | 6 | .SH DESCRIPTION |
| 7 | This tool traces active TCP connections |
| 8 | (eg, via a connect() syscall), and shows the latency (time) for the connection |
| 9 | as measured locally: the time from SYN sent to the response packet. |
| 10 | This is a useful performance metric that typically spans kernel TCP/IP |
| 11 | processing and the network round trip time (not application runtime). |
| 12 | |
| 13 | All connection attempts are traced, even if they ultimately fail (RST packet |
| 14 | in response). |
| 15 | |
| 16 | This tool works by use of kernel dynamic tracing of TCP/IP functions, and will |
| 17 | need updating to match any changes to these functions. This tool should be |
| 18 | updated in the future to use static tracepoints, once they are available. |
| 19 | |
| 20 | Since this uses BPF, only the root user can use this tool. |
| 21 | .SH REQUIREMENTS |
| 22 | CONFIG_BPF and bcc. |
| 23 | .SH OPTIONS |
| 24 | .TP |
| 25 | \-h |
| 26 | Print usage message. |
| 27 | .TP |
| 28 | \-t |
| 29 | Include a timestamp column. |
| 30 | .TP |
| 31 | \-p PID |
| 32 | Trace this process ID only (filtered in-kernel). |
dpayne | 7b7e34a | 2018-01-18 09:34:20 -0800 | [diff] [blame] | 33 | .TP |
dpayne | 7b7e34a | 2018-01-18 09:34:20 -0800 | [diff] [blame] | 34 | \-v |
| 35 | Print the resulting BPF program, for debugging purposes. |
dpayne | fc50799 | 2018-01-18 14:09:28 -0800 | [diff] [blame] | 36 | .TP |
dpayne | 8df98b7 | 2018-01-18 14:10:32 -0800 | [diff] [blame] | 37 | min_ms |
dpayne | fc50799 | 2018-01-18 14:09:28 -0800 | [diff] [blame] | 38 | Minimum duration to trace, in milliseconds. |
Brendan Gregg | afc9725 | 2016-02-19 16:07:36 -0800 | [diff] [blame] | 39 | .SH EXAMPLES |
| 40 | .TP |
| 41 | Trace all active TCP connections, and show connection latency (SYN->response round trip): |
| 42 | # |
dpayne | 7b7e34a | 2018-01-18 09:34:20 -0800 | [diff] [blame] | 43 | .B tcpconnlat |
Brendan Gregg | afc9725 | 2016-02-19 16:07:36 -0800 | [diff] [blame] | 44 | .TP |
| 45 | Include timestamps: |
| 46 | # |
dpayne | 7b7e34a | 2018-01-18 09:34:20 -0800 | [diff] [blame] | 47 | .B tcpconnlat \-t |
Brendan Gregg | afc9725 | 2016-02-19 16:07:36 -0800 | [diff] [blame] | 48 | .TP |
| 49 | Trace PID 181 only: |
| 50 | # |
dpayne | 7b7e34a | 2018-01-18 09:34:20 -0800 | [diff] [blame] | 51 | .B tcpconnlat \-p 181 |
| 52 | .TP |
| 53 | Trace connects with latency longer than 10 ms: |
| 54 | # |
dpayne | fc50799 | 2018-01-18 14:09:28 -0800 | [diff] [blame] | 55 | .B tcpconnlat 10 |
dpayne | 7b7e34a | 2018-01-18 09:34:20 -0800 | [diff] [blame] | 56 | .TP |
| 57 | Print the BPF program: |
| 58 | # |
| 59 | .B tcpconnlat \-v |
Brendan Gregg | afc9725 | 2016-02-19 16:07:36 -0800 | [diff] [blame] | 60 | .SH FIELDS |
| 61 | .TP |
| 62 | TIME(s) |
| 63 | Time of the response packet, in seconds. |
| 64 | .TP |
| 65 | PID |
| 66 | Process ID that initiated the connection. |
| 67 | .TP |
| 68 | COMM |
| 69 | Process name that initiated the connection. |
| 70 | .TP |
| 71 | IP |
| 72 | IP address family (4 or 6). |
| 73 | .TP |
| 74 | SADDR |
Mark Drayton | 11de298 | 2016-06-26 21:14:44 +0100 | [diff] [blame] | 75 | Source IP address. |
Brendan Gregg | afc9725 | 2016-02-19 16:07:36 -0800 | [diff] [blame] | 76 | .TP |
| 77 | DADDR |
Mark Drayton | 11de298 | 2016-06-26 21:14:44 +0100 | [diff] [blame] | 78 | Destination IP address. |
Brendan Gregg | afc9725 | 2016-02-19 16:07:36 -0800 | [diff] [blame] | 79 | .TP |
| 80 | DPORT |
| 81 | Destination port |
| 82 | .TP |
| 83 | LAT(ms) |
| 84 | The time from when a TCP connect was issued (measured in-kernel) to when a |
| 85 | response packet was received for this connection (can be SYN,ACK, or RST, etc). |
| 86 | This time spans kernel to kernel latency, involving kernel TCP/IP processing |
| 87 | and the network round trip in between. This typically does not include |
| 88 | time spent by the application processing the new connection. |
| 89 | .SH OVERHEAD |
| 90 | This traces the kernel tcp_v[46]_connect functions and prints output for each |
| 91 | event. As the rate of this is generally expected to be low (< 1000/s), the |
| 92 | overhead is also expected to be negligible. If you have an application that |
| 93 | is calling a high rate of connects()s, such as a proxy server, then test and |
| 94 | understand this overhead before use. |
| 95 | .SH SOURCE |
| 96 | This is from bcc. |
| 97 | .IP |
| 98 | https://github.com/iovisor/bcc |
| 99 | .PP |
| 100 | Also look in the bcc distribution for a companion _examples.txt file containing |
| 101 | example usage, output, and commentary for this tool. |
| 102 | .SH OS |
| 103 | Linux |
| 104 | .SH STABILITY |
| 105 | Unstable - in development. |
| 106 | .SH AUTHOR |
| 107 | Brendan Gregg |
| 108 | .SH SEE ALSO |
| 109 | tcpconnect(8), tcpaccept(8), funccount(8), tcpdump(8) |