xref: /freebsd-src/share/man/man4/dtrace_tcp.4 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
14b4ad3a2SMark Johnston.\" Copyright (c) 2015 Mark Johnston <markj@FreeBSD.org>
24b4ad3a2SMark Johnston.\" All rights reserved.
34b4ad3a2SMark Johnston.\"
44b4ad3a2SMark Johnston.\" Redistribution and use in source and binary forms, with or without
54b4ad3a2SMark Johnston.\" modification, are permitted provided that the following conditions
64b4ad3a2SMark Johnston.\" are met:
74b4ad3a2SMark Johnston.\" 1. Redistributions of source code must retain the above copyright
84b4ad3a2SMark Johnston.\"    notice, this list of conditions and the following disclaimer.
94b4ad3a2SMark Johnston.\" 2. Redistributions in binary form must reproduce the above copyright
104b4ad3a2SMark Johnston.\"    notice, this list of conditions and the following disclaimer in the
114b4ad3a2SMark Johnston.\"    documentation and/or other materials provided with the distribution.
124b4ad3a2SMark Johnston.\"
134b4ad3a2SMark Johnston.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
144b4ad3a2SMark Johnston.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
154b4ad3a2SMark Johnston.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
164b4ad3a2SMark Johnston.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
174b4ad3a2SMark Johnston.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
184b4ad3a2SMark Johnston.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
194b4ad3a2SMark Johnston.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
204b4ad3a2SMark Johnston.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
214b4ad3a2SMark Johnston.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
224b4ad3a2SMark Johnston.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
234b4ad3a2SMark Johnston.\" SUCH DAMAGE.
244b4ad3a2SMark Johnston.\"
25*2176c9abSMichael Tuexen.Dd July 2, 2023
264b4ad3a2SMark Johnston.Dt DTRACE_TCP 4
274b4ad3a2SMark Johnston.Os
284b4ad3a2SMark Johnston.Sh NAME
294b4ad3a2SMark Johnston.Nm dtrace_tcp
304b4ad3a2SMark Johnston.Nd a DTrace provider for tracing events related to the
314b4ad3a2SMark Johnston.Xr tcp 4
324b4ad3a2SMark Johnstonprotocol
334b4ad3a2SMark Johnston.Sh SYNOPSIS
344b4ad3a2SMark Johnston.Fn tcp:::accept-established "pktinfo_t *" "csinfo_t *" "ipinfo_t *" \
354b4ad3a2SMark Johnston    "tcpsinfo_t *" "tcpinfo_t *"
364b4ad3a2SMark Johnston.Fn tcp:::accept-refused "pktinfo_t *" "csinfo_t *" "ipinfo_t *" \
374b4ad3a2SMark Johnston    "tcpsinfo_t *" "tcpinfo_t *"
384b4ad3a2SMark Johnston.Fn tcp:::connect-established "pktinfo_t *" "csinfo_t *" "ipinfo_t *" \
394b4ad3a2SMark Johnston    "tcpsinfo_t *" "tcpinfo_t *"
404b4ad3a2SMark Johnston.Fn tcp:::connect-refused "pktinfo_t *" "csinfo_t *" "ipinfo_t *" \
414b4ad3a2SMark Johnston    "tcpsinfo_t *" "tcpinfo_t *"
424b4ad3a2SMark Johnston.Fn tcp:::connect-request "pktinfo_t *" "csinfo_t *" "ipinfo_t *" \
434b4ad3a2SMark Johnston    "tcpsinfo_t *" "tcpinfo_t *"
444b4ad3a2SMark Johnston.Fn tcp:::receive "pktinfo_t *" "csinfo_t *" "ipinfo_t *" "tcpsinfo_t *" \
454b4ad3a2SMark Johnston    "tcpinfo_t *"
464b4ad3a2SMark Johnston.Fn tcp:::send "pktinfo_t *" "csinfo_t *" "ipinfo_t *" "tcpsinfo_t *" \
474b4ad3a2SMark Johnston    "tcpinfo_t *"
484b4ad3a2SMark Johnston.Fn tcp:::state-change "void *" "csinfo_t *" "void *" "tcpsinfo_t *" "void *" \
494b4ad3a2SMark Johnston    "tcplsinfo_t *"
500631830aSMichael Tuexen.Fn tcp:::siftr "siftrinfo_t *"
514b4ad3a2SMark Johnston.Sh DESCRIPTION
524b4ad3a2SMark JohnstonThe DTrace
534b4ad3a2SMark Johnston.Nm tcp
544b4ad3a2SMark Johnstonprovider allows users to trace events in the
554b4ad3a2SMark Johnston.Xr tcp 4
564b4ad3a2SMark Johnstonprotocol implementation.
574b4ad3a2SMark JohnstonThis provider is similar to the
584b4ad3a2SMark Johnston.Xr dtrace_ip 4
594b4ad3a2SMark Johnstonand
604b4ad3a2SMark Johnston.Xr dtrace_udp 4
614b4ad3a2SMark Johnstonproviders, but additionally contains probes corresponding to protocol events at
624b4ad3a2SMark Johnstona level higher than packet reception and transmission.
634b4ad3a2SMark JohnstonAll
644b4ad3a2SMark Johnston.Nm tcp
654b4ad3a2SMark Johnstonprobes except for
664b4ad3a2SMark Johnston.Fn tcp:::state-change
670631830aSMichael Tuexenand
680631830aSMichael Tuexen.Fn tcp:::siftr
694b4ad3a2SMark Johnstonhave the same number and type of arguments.
704b4ad3a2SMark JohnstonThe last three arguments are used to describe a TCP segment: the
714b4ad3a2SMark Johnston.Vt ipinfo_t
724b4ad3a2SMark Johnstonargument exposes the version-agnostic fields of the IP header, while the
734b4ad3a2SMark Johnston.Vt tcpinfo_t
744b4ad3a2SMark Johnstonargument exposes the TCP header, and the
754b4ad3a2SMark Johnston.Vt tcpsinfo_t
764b4ad3a2SMark Johnstonargument describes details of the corresponding TCP connection state, if any.
774b4ad3a2SMark JohnstonTheir fields are described in the ARGUMENTS section.
784b4ad3a2SMark Johnston.Pp
794b4ad3a2SMark JohnstonThe
804b4ad3a2SMark Johnston.Fn tcp:::accept-established
814b4ad3a2SMark Johnstonprobe fires when a remotely-initiated active TCP open succeeds.
824b4ad3a2SMark JohnstonAt this point the new connection is in the ESTABLISHED state, and the probe
834b4ad3a2SMark Johnstonarguments expose the headers associated with the final ACK of the three-way
844b4ad3a2SMark Johnstonhandshake.
854b4ad3a2SMark JohnstonThe
864b4ad3a2SMark Johnston.Fn tcp:::accept-refused
874b4ad3a2SMark Johnstonprobe fires when a SYN arrives on a port without a listening socket.
884b4ad3a2SMark JohnstonThe probe arguments expose the headers associated with the RST to be transmitted
894b4ad3a2SMark Johnstonto the remote host in response to the SYN segment.
904b4ad3a2SMark Johnston.Pp
914b4ad3a2SMark JohnstonThe
924b4ad3a2SMark Johnston.Fn tcp:::connect-established ,
934b4ad3a2SMark Johnston.Fn tcp:::connect-refused ,
944b4ad3a2SMark Johnstonand
954b4ad3a2SMark Johnston.Fn tcp:::connect-request
964b4ad3a2SMark Johnstonprobes are similar to the
974b4ad3a2SMark Johnston.Ql accept
984b4ad3a2SMark Johnstonprobes, except that they correspond to locally-initiated TCP connections.
994b4ad3a2SMark JohnstonThe
1004b4ad3a2SMark Johnston.Fn tcp:::connect-established
1014b4ad3a2SMark Johnstonprobe fires when the SYN-ACK segment of a three-way handshake is received from
1024b4ad3a2SMark Johnstonthe remote host and a final ACK is prepared for transmission.
1034b4ad3a2SMark JohnstonThis occurs immediately after the local connection state transitions from
1044b4ad3a2SMark JohnstonSYN-SENT to ESTABLISHED.
1054b4ad3a2SMark JohnstonThe probe arguments describe the headers associated with the received SYN-ACK
1064b4ad3a2SMark Johnstonsegment.
1074b4ad3a2SMark JohnstonThe
1084b4ad3a2SMark Johnston.Fn tcp:::connect-refused
1094b4ad3a2SMark Johnstonprobe fires when the local host receives a RST segment in response to a SYN
1104b4ad3a2SMark Johnstonsegment, indicating that the remote host refused to open a connection.
1114b4ad3a2SMark JohnstonThe probe arguments describe the IP and TCP headers associated with the received
1124b4ad3a2SMark JohnstonRST segment.
1134b4ad3a2SMark JohnstonThe
1144b4ad3a2SMark Johnston.Fn tcp:::connect-request
1154b4ad3a2SMark Johnstonprobe fires as the kernel prepares to transmit the initial SYN segment of a
1164b4ad3a2SMark Johnstonthree-way handshake.
1174b4ad3a2SMark Johnston.Pp
1184b4ad3a2SMark JohnstonThe
1194b4ad3a2SMark Johnston.Fn tcp:::send
1204b4ad3a2SMark Johnstonand
1214b4ad3a2SMark Johnston.Fn tcp:::receive
1224b4ad3a2SMark Johnstonprobes fire when the host sends or receives a TCP packet, respectively.
1234b4ad3a2SMark JohnstonAs with the
1244b4ad3a2SMark Johnston.Xr dtrace_udp 4
1254b4ad3a2SMark Johnstonprovider,
1264b4ad3a2SMark Johnston.Nm tcp
1274b4ad3a2SMark Johnstonprobes fire only for packets sent by or to the local host; forwarded packets are
1284b4ad3a2SMark Johnstonhandled in the IP layer and are only visible to the
1294b4ad3a2SMark Johnston.Xr dtrace_ip 4
1304b4ad3a2SMark Johnstonprovider.
1314b4ad3a2SMark Johnston.Pp
1324b4ad3a2SMark JohnstonThe
1334b4ad3a2SMark Johnston.Fn tcp:::state-change
1344b4ad3a2SMark Johnstonprobe fires upon local TCP connection state transitions.
1354b4ad3a2SMark JohnstonIts first, third and fifth arguments are currently always
1364b4ad3a2SMark Johnston.Dv NULL .
1374b4ad3a2SMark JohnstonIts last argument describes the from-state in the transition, and the to-state
1384b4ad3a2SMark Johnstoncan be obtained from
139e6c00555SDevin Teske.Dv args[3]->tcps_state .
1400631830aSMichael Tuexen.Pp
1410631830aSMichael TuexenThe
1420631830aSMichael Tuexen.Fn tcp:::siftr
1430631830aSMichael Tuexenprobe fires when a TCP segment is sent or received by the host.
1440631830aSMichael TuexenFor a detailed description see
1450631830aSMichael Tuexen.Xr siftr 4 .
1460631830aSMichael TuexenThe
1470631830aSMichael Tuexen.Vt siftrinfo_t
1480631830aSMichael Tuexenargument provides the information about the TCP connection.
1494b4ad3a2SMark Johnston.Sh ARGUMENTS
1504b4ad3a2SMark JohnstonThe
1514b4ad3a2SMark Johnston.Vt pktinfo_t
1524b4ad3a2SMark Johnstonargument is currently unimplemented and is included for compatibility with other
1534b4ad3a2SMark Johnstonimplementations of this provider.
1544b4ad3a2SMark JohnstonIts fields are:
1554b4ad3a2SMark Johnston.Bl -tag -width "uinptr_t pkt_addr" -offset indent
1564b4ad3a2SMark Johnston.It Vt uinptr_t pkt_addr
1574b4ad3a2SMark JohnstonAlways set to 0.
1584b4ad3a2SMark Johnston.El
1594b4ad3a2SMark Johnston.Pp
1604b4ad3a2SMark JohnstonThe
1614b4ad3a2SMark Johnston.Vt csinfo_t
1624b4ad3a2SMark Johnstonargument is currently unimplemented and is included for compatibility with other
1634b4ad3a2SMark Johnstonimplementations of this provider.
1644b4ad3a2SMark JohnstonIts fields are:
1654b4ad3a2SMark Johnston.Bl -tag -width "uintptr_t cs_addr" -offset indent
1664b4ad3a2SMark Johnston.It Vt uintptr_t cs_addr
1674b4ad3a2SMark JohnstonAlways set to 0.
1684b4ad3a2SMark Johnston.It Vt uint64_t cs_cid
1694b4ad3a2SMark JohnstonA pointer to the
1704b4ad3a2SMark Johnston.Vt struct inpcb
1714b4ad3a2SMark Johnstonfor this packet, or
1724b4ad3a2SMark Johnston.Dv NULL .
1734b4ad3a2SMark Johnston.It Vt pid_t cs_pid
1744b4ad3a2SMark JohnstonAlways set to 0.
1754b4ad3a2SMark Johnston.El
1764b4ad3a2SMark Johnston.Pp
1774b4ad3a2SMark JohnstonThe
1784b4ad3a2SMark Johnston.Vt ipinfo_t
1794b4ad3a2SMark Johnstontype is a version-agnostic representation of fields from an IP header.
1804b4ad3a2SMark JohnstonIts fields are described in the
1814b4ad3a2SMark Johnston.Xr dtrace_ip 4
1824b4ad3a2SMark Johnstonmanual page.
1834b4ad3a2SMark Johnston.Pp
1844b4ad3a2SMark JohnstonThe
1854b4ad3a2SMark Johnston.Vt tcpsinfo_t
1864b4ad3a2SMark Johnstontype is used to provide a stable representation of TCP connection state.
1874b4ad3a2SMark JohnstonSome
1884b4ad3a2SMark Johnston.Nm tcp
1894b4ad3a2SMark Johnstonprobes, such as
1904b4ad3a2SMark Johnston.Fn tcp:::accept-refused ,
1914b4ad3a2SMark Johnstonfire in a context where there is no TCP connection; this argument is
1924b4ad3a2SMark Johnston.Dv NULL
1934b4ad3a2SMark Johnstonin that case.
1944b4ad3a2SMark JohnstonIts fields are:
1954b4ad3a2SMark Johnston.Bl -tag -width "uint16_t tcps_lport" -offset indent
1964b4ad3a2SMark Johnston.It Vt uintptr_t tcps_addr
1974b4ad3a2SMark JohnstonThe address of the corresponding TCP control block.
1984b4ad3a2SMark JohnstonThis is currently a pointer to a
1994b4ad3a2SMark Johnston.Vt struct tcpcb .
2004b4ad3a2SMark Johnston.It Vt int tcps_local
2014b4ad3a2SMark JohnstonA boolean indicating whether the connection is local to the host.
2024b4ad3a2SMark JohnstonCurrently unimplemented and always set to -1.
2034b4ad3a2SMark Johnston.It Vt int tcps_active
2044b4ad3a2SMark JohnstonA boolean indicating whether the connection was initiated by the local host.
2054b4ad3a2SMark JohnstonCurrently unimplemented and always set to -1.
2064b4ad3a2SMark Johnston.It Vt uint16_t tcps_lport
2074b4ad3a2SMark JohnstonLocal TCP port.
2084b4ad3a2SMark Johnston.It Vt uint16_t tcps_rport
2094b4ad3a2SMark JohnstonRemote TCP port.
2104b4ad3a2SMark Johnston.It Vt string tcps_laddr
2114b4ad3a2SMark JohnstonLocal address.
2124b4ad3a2SMark Johnston.It Vt string tcps_raddr
2134b4ad3a2SMark JohnstonRemote address.
2144b4ad3a2SMark Johnston.It Vt int32_t tcps_state
2154b4ad3a2SMark JohnstonCurrent TCP state.
2164b4ad3a2SMark JohnstonThe valid TCP state values are given by the constants prefixed with
2174b4ad3a2SMark Johnston.Ql TCPS_
2184b4ad3a2SMark Johnstonin
2194b4ad3a2SMark Johnston.Pa /usr/lib/dtrace/tcp.d .
2204b4ad3a2SMark Johnston.It Vt uint32_t tcps_iss
2214b4ad3a2SMark JohnstonInitial send sequence number.
2224b4ad3a2SMark Johnston.It Vt uint32_t tcps_suna
2234b4ad3a2SMark JohnstonInitial sequence number of sent but unacknowledged data.
2244b4ad3a2SMark Johnston.It Vt uint32_t tcps_snxt
2254b4ad3a2SMark JohnstonNext sequence number for send.
2264b4ad3a2SMark Johnston.It Vt uint32_t tcps_rack
2274b4ad3a2SMark JohnstonSequence number of received and acknowledged data.
2284b4ad3a2SMark Johnston.It Vt uint32_t tcps_rnxt
2294b4ad3a2SMark JohnstonNext expected sequence number for receive.
2302dbc5931SHiren Panchasara.It Vt u_long tcps_swnd
2314b4ad3a2SMark JohnstonTCP send window size.
2324b4ad3a2SMark Johnston.It Vt int32_t tcps_snd_ws
2334b4ad3a2SMark JohnstonWindow scaling factor for the TCP send window.
2342dbc5931SHiren Panchasara.It Vt u_long tcps_rwnd
2354b4ad3a2SMark JohnstonTCP receive window size.
2364b4ad3a2SMark Johnston.It Vt int32_t tcps_rcv_ws
2374b4ad3a2SMark JohnstonWindow scaling factor for the TCP receive window.
2382dbc5931SHiren Panchasara.It Vt u_long tcps_cwnd
2394b4ad3a2SMark JohnstonTCP congestion window size.
2402dbc5931SHiren Panchasara.It Vt u_long tcps_cwnd_ssthresh
2414b4ad3a2SMark JohnstonCongestion window threshold at which slow start ends and congestion avoidance
2424b4ad3a2SMark Johnstonbegins.
2434b4ad3a2SMark Johnston.It Vt uint32_t tcps_sack_fack
2444b4ad3a2SMark JohnstonLast sequence number selectively acknowledged by the receiver.
2454b4ad3a2SMark Johnston.It Vt uint32_t tcps_sack_snxt
2464b4ad3a2SMark JohnstonNext selectively acknowledge sequence number at which to begin retransmitting.
2474b4ad3a2SMark Johnston.It Vt uint32_t tcps_rto
2484b4ad3a2SMark JohnstonRound-trip timeout, in milliseconds.
2494b4ad3a2SMark Johnston.It Vt uint32_t tcps_mss
2504b4ad3a2SMark JohnstonMaximum segment size.
2514b4ad3a2SMark Johnston.It Vt int tcps_retransmit
2524b4ad3a2SMark JohnstonA boolean indicating that the local sender is retransmitting data.
2534b4ad3a2SMark Johnston.It Vt int tcps_srtt
2544b4ad3a2SMark JohnstonSmoothed round-trip time.
2554b4ad3a2SMark Johnston.El
2564b4ad3a2SMark Johnston.Pp
2574b4ad3a2SMark JohnstonThe
2584b4ad3a2SMark Johnston.Vt tcpinfo_t
2594b4ad3a2SMark Johnstontype exposes the fields in a TCP segment header in host order.
2604b4ad3a2SMark JohnstonIts fields are:
2614b4ad3a2SMark Johnston.Bl -tag -width "struct tcphdr *tcp_hdr" -offset indent
2624b4ad3a2SMark Johnston.It Vt uint16_t tcp_sport
2634b4ad3a2SMark JohnstonSource TCP port.
2644b4ad3a2SMark Johnston.It Vt uint16_t tcp_dport
2654b4ad3a2SMark JohnstonDestination TCP port.
2664b4ad3a2SMark Johnston.It Vt uint32_t tcp_seq
2674b4ad3a2SMark JohnstonSequence number.
2684b4ad3a2SMark Johnston.It Vt uint32_t tcp_ack
2694b4ad3a2SMark JohnstonAcknowledgement number.
2704b4ad3a2SMark Johnston.It Vt uint8_t tcp_offset
2714b4ad3a2SMark JohnstonData offset, in bytes.
2724b4ad3a2SMark Johnston.It Vt uint8_t tcp_flags
2734b4ad3a2SMark JohnstonTCP flags.
2744b4ad3a2SMark Johnston.It Vt uint16_t tcp_window
2754b4ad3a2SMark JohnstonTCP window size.
2764b4ad3a2SMark Johnston.It Vt uint16_t tcp_checksum
2774b4ad3a2SMark JohnstonChecksum.
2784b4ad3a2SMark Johnston.It Vt uint16_t tcp_urgent
2794b4ad3a2SMark JohnstonUrgent data pointer.
2804b4ad3a2SMark Johnston.It Vt struct tcphdr *tcp_hdr
2814b4ad3a2SMark JohnstonA pointer to the raw TCP header.
2824b4ad3a2SMark Johnston.El
2834b4ad3a2SMark Johnston.Pp
2844b4ad3a2SMark JohnstonThe
2854b4ad3a2SMark Johnston.Vt tcplsinfo_t
2864b4ad3a2SMark Johnstontype is used by the
2874b4ad3a2SMark Johnston.Fn tcp:::state-change
2884b4ad3a2SMark Johnstonprobe to provide the from-state of a transition.
2894b4ad3a2SMark JohnstonIts fields are:
2904b4ad3a2SMark Johnston.Bl -tag -width "int32_t tcps_state" -offset indent
2914b4ad3a2SMark Johnston.It Vt int32_t tcps_state
2924b4ad3a2SMark JohnstonA TCP state.
2934b4ad3a2SMark JohnstonThe valid TCP state values are given by the constants prefixed with
2944b4ad3a2SMark Johnston.Ql TCPS_
2954b4ad3a2SMark Johnstonin
2964b4ad3a2SMark Johnston.Pa /usr/lib/dtrace/tcp.d .
2974b4ad3a2SMark Johnston.El
2980631830aSMichael Tuexen.Pp
2990631830aSMichael TuexenThe
3000631830aSMichael Tuexen.Vt siftrinfo_t
3010631830aSMichael Tuexentype is used by the
3020631830aSMichael Tuexen.Fn tcp:::siftr
3030631830aSMichael Tuexenprobe to provide the state of the TCP connection.
3040631830aSMichael TuexenIts fields are:
3050631830aSMichael Tuexen.Bl -tag -width "u_int sent_inflight_bytes" -offset indent
3060631830aSMichael Tuexen.It Vt uint8_t direction
3070631830aSMichael TuexenDirection of packet that triggered the log message.
3080631830aSMichael TuexenEither
3090631830aSMichael Tuexen.Qq 0
3100631830aSMichael Tuexenfor in, or
3110631830aSMichael Tuexen.Qq 1
3120631830aSMichael Tuexenfor out.
3130631830aSMichael Tuexen.It Vt uint8_t ipver
3140631830aSMichael TuexenThe version of the IP protocol being used.
3150631830aSMichael TuexenEither
3160631830aSMichael Tuexen.Qq 1
3170631830aSMichael Tuexenfor IPv4, or
3180631830aSMichael Tuexen.Qq 2
3190631830aSMichael Tuexenfor IPv6.
320*2176c9abSMichael Tuexen.It Vt uint16_t lport
3210631830aSMichael TuexenThe TCP port that the local host is communicating via.
322*2176c9abSMichael Tuexen.It Vt uint16_t rport
323*2176c9abSMichael TuexenThe TCP port that the remote host is communicating via.
324*2176c9abSMichael Tuexen.It Vt string laddr
325*2176c9abSMichael TuexenThe IPv4 or IPv6 address of the local host.
326*2176c9abSMichael Tuexen.It Vt string raddr
327*2176c9abSMichael TuexenThe IPv4 or IPv6 address of the remote host.
328cade9a8eSMichael Tuexen.It Vt uint32_t snd_cwnd
3290631830aSMichael TuexenThe current congestion window (CWND) for the flow, in bytes.
330cade9a8eSMichael Tuexen.It Vt uint32_t snd_wnd
3310631830aSMichael TuexenThe current sending window for the flow, in bytes.
3320631830aSMichael TuexenThe post scaled value is reported, except during the initial handshake (first
3330631830aSMichael Tuexenfew packets), during which time the unscaled value is reported.
334cade9a8eSMichael Tuexen.It Vt uint32_t rcv_wnd
3350631830aSMichael TuexenThe current receive window for the flow, in bytes.
3360631830aSMichael TuexenThe post scaled value is always reported.
337cade9a8eSMichael Tuexen.It Vt uint32_t t_flags2
338cade9a8eSMichael TuexenThe current value of the t_flags2 for the flow.
339cade9a8eSMichael Tuexen.It Vt uint32_t snd_ssthresh
3400631830aSMichael TuexenThe slow start threshold (SSTHRESH) for the flow, in bytes.
3410631830aSMichael Tuexen.It Vt int conn_state
3420631830aSMichael TuexenA TCP state.
3430631830aSMichael TuexenThe valid TCP state values are given by the constants prefixed with
3440631830aSMichael Tuexen.Ql TCPS_
3450631830aSMichael Tuexenin
3460631830aSMichael Tuexen.Pa /usr/lib/dtrace/tcp.d .
347*2176c9abSMichael Tuexen.It Vt uint32_t mss
348*2176c9abSMichael TuexenThe maximum segment size (MSS) for the flow, in bytes.
349643d0671SMichael Tuexen.It Vt uint32_t srtt
350643d0671SMichael TuexenThe current smoothed RTT (SRTT) for the flow in microseconds.
3510631830aSMichael Tuexen.It Vt u_char sack_enabled
3520631830aSMichael TuexenSACK enabled indicator. 1 if SACK enabled, 0 otherwise.
3530631830aSMichael Tuexen.It Vt u_char snd_scale
3540631830aSMichael TuexenThe current window scaling factor for the sending window.
3550631830aSMichael Tuexen.It Vt u_char rcv_scale
3560631830aSMichael TuexenThe current window scaling factor for the receiving window.
357*2176c9abSMichael Tuexen.It Vt u_int t_flags
3580631830aSMichael TuexenThe current value of the t_flags for the flow.
359643d0671SMichael Tuexen.It Vt uint32_t rto
360643d0671SMichael TuexenThe current retransmission timeout (RTO) for the flow in microseconds.
3610631830aSMichael TuexenDivide by HZ to get the timeout length in seconds.
3620631830aSMichael Tuexen.It Vt u_int snd_buf_hiwater
3630631830aSMichael TuexenThe current size of the socket send buffer in bytes.
3640631830aSMichael Tuexen.It Vt u_int snd_buf_cc
3650631830aSMichael TuexenThe current number of bytes in the socket send buffer.
3660631830aSMichael Tuexen.It Vt u_int rcv_buf_hiwater
3670631830aSMichael TuexenThe current size of the socket receive buffer in bytes.
3680631830aSMichael Tuexen.It Vt u_int rcv_buf_cc
3690631830aSMichael TuexenThe current number of bytes in the socket receive buffer.
3700631830aSMichael Tuexen.It Vt u_int sent_inflight_bytes
3710631830aSMichael TuexenThe current number of unacknowledged bytes in-flight.
3720631830aSMichael TuexenBytes acknowledged via SACK are not excluded from this count.
3730631830aSMichael Tuexen.It Vt int t_segqlen
3740631830aSMichael TuexenThe current number of segments in the reassembly queue.
3750631830aSMichael Tuexen.It Vt u_int flowid
3760631830aSMichael TuexenFlowid for the connection.
3770631830aSMichael TuexenA caveat: Zero '0' either represents a valid flowid or a default value when
3780631830aSMichael Tuexenthe flowid is not being set.
3790631830aSMichael Tuexen.It Vt u_int flowtype
3800631830aSMichael TuexenFlow type for the connection.
3810631830aSMichael TuexenFlowtype defines which protocol fields are hashed to produce the flowid.
3820631830aSMichael TuexenA complete listing is available in
3830631830aSMichael Tuexen.Pa /usr/include/sys/mbuf.h
3840631830aSMichael Tuexenunder
3850631830aSMichael Tuexen.Dv M_HASHTYPE_* .
3860631830aSMichael Tuexen.El
3874b4ad3a2SMark Johnston.Sh FILES
3880631830aSMichael Tuexen.Bl -tag -width "/usr/lib/dtrace/siftr.d" -compact
3894b4ad3a2SMark Johnston.It Pa /usr/lib/dtrace/tcp.d
3900631830aSMichael TuexenDTrace type and translator definitions for all the probes of the
3910631830aSMichael Tuexen.Nm tcp
3920631830aSMichael Tuexenprovider except the
3930631830aSMichael Tuexen.Nm siftr
3940631830aSMichael Tuexenprobe.
3950631830aSMichael Tuexen.It Pa /usr/lib/dtrace/siftr.d
3964b4ad3a2SMark JohnstonDTrace type and translator definitions for the
3970631830aSMichael Tuexen.Nm siftr
3980631830aSMichael Tuexenprobe of the
3994b4ad3a2SMark Johnston.Nm tcp
4004b4ad3a2SMark Johnstonprovider.
4014b4ad3a2SMark Johnston.El
4024b4ad3a2SMark Johnston.Sh EXAMPLES
4034b4ad3a2SMark JohnstonThe following script logs TCP segments in real time:
4044b4ad3a2SMark Johnston.Bd -literal -offset indent
4054b4ad3a2SMark Johnston#pragma D option quiet
4064b4ad3a2SMark Johnston#pragma D option switchrate=10hz
4074b4ad3a2SMark Johnston
4084b4ad3a2SMark Johnstondtrace:::BEGIN
4094b4ad3a2SMark Johnston{
410af1e9f5aSChristian Brueffer        printf(" %3s %15s:%-5s      %15s:%-5s %6s  %s\\n", "CPU",
4114b4ad3a2SMark Johnston            "LADDR", "LPORT", "RADDR", "RPORT", "BYTES", "FLAGS");
4124b4ad3a2SMark Johnston}
4134b4ad3a2SMark Johnston
4144b4ad3a2SMark Johnstontcp:::send
4154b4ad3a2SMark Johnston{
4164b4ad3a2SMark Johnston        this->length = args[2]->ip_plength - args[4]->tcp_offset;
4174b4ad3a2SMark Johnston        printf(" %3d %16s:%-5d -> %16s:%-5d %6d  (", cpu, args[2]->ip_saddr,
4184b4ad3a2SMark Johnston            args[4]->tcp_sport, args[2]->ip_daddr, args[4]->tcp_dport,
4194b4ad3a2SMark Johnston            this->length);
4204b4ad3a2SMark Johnston        printf("%s", args[4]->tcp_flags & TH_FIN ? "FIN|" : "");
4214b4ad3a2SMark Johnston        printf("%s", args[4]->tcp_flags & TH_SYN ? "SYN|" : "");
4224b4ad3a2SMark Johnston        printf("%s", args[4]->tcp_flags & TH_RST ? "RST|" : "");
4234b4ad3a2SMark Johnston        printf("%s", args[4]->tcp_flags & TH_PUSH ? "PUSH|" : "");
4244b4ad3a2SMark Johnston        printf("%s", args[4]->tcp_flags & TH_ACK ? "ACK|" : "");
4254b4ad3a2SMark Johnston        printf("%s", args[4]->tcp_flags & TH_URG ? "URG|" : "");
4264b4ad3a2SMark Johnston        printf("%s", args[4]->tcp_flags == 0 ? "null " : "");
42781b4bf08SMichael Tuexen        printf("\\b)\\n");
4284b4ad3a2SMark Johnston}
4294b4ad3a2SMark Johnston
4304b4ad3a2SMark Johnstontcp:::receive
4314b4ad3a2SMark Johnston{
4324b4ad3a2SMark Johnston        this->length = args[2]->ip_plength - args[4]->tcp_offset;
4334b4ad3a2SMark Johnston        printf(" %3d %16s:%-5d <- %16s:%-5d %6d  (", cpu,
4344b4ad3a2SMark Johnston            args[2]->ip_daddr, args[4]->tcp_dport, args[2]->ip_saddr,
4354b4ad3a2SMark Johnston            args[4]->tcp_sport, this->length);
4364b4ad3a2SMark Johnston        printf("%s", args[4]->tcp_flags & TH_FIN ? "FIN|" : "");
4374b4ad3a2SMark Johnston        printf("%s", args[4]->tcp_flags & TH_SYN ? "SYN|" : "");
4384b4ad3a2SMark Johnston        printf("%s", args[4]->tcp_flags & TH_RST ? "RST|" : "");
4394b4ad3a2SMark Johnston        printf("%s", args[4]->tcp_flags & TH_PUSH ? "PUSH|" : "");
4404b4ad3a2SMark Johnston        printf("%s", args[4]->tcp_flags & TH_ACK ? "ACK|" : "");
4414b4ad3a2SMark Johnston        printf("%s", args[4]->tcp_flags & TH_URG ? "URG|" : "");
4424b4ad3a2SMark Johnston        printf("%s", args[4]->tcp_flags == 0 ? "null " : "");
44381b4bf08SMichael Tuexen        printf("\\b)\\n");
4444b4ad3a2SMark Johnston}
4454b4ad3a2SMark Johnston.Ed
4464b4ad3a2SMark JohnstonThe following script logs TCP connection state changes as they occur:
4474b4ad3a2SMark Johnston.Bd -literal -offset indent
4484b4ad3a2SMark Johnston#pragma D option quiet
4494b4ad3a2SMark Johnston#pragma D option switchrate=25hz
4504b4ad3a2SMark Johnston
4514b4ad3a2SMark Johnstonint last[int];
4524b4ad3a2SMark Johnston
4534b4ad3a2SMark Johnstondtrace:::BEGIN
4544b4ad3a2SMark Johnston{
455af1e9f5aSChristian Brueffer        printf("   %12s %-20s    %-20s %s\\n",
4564b4ad3a2SMark Johnston            "DELTA(us)", "OLD", "NEW", "TIMESTAMP");
4574b4ad3a2SMark Johnston}
4584b4ad3a2SMark Johnston
4594b4ad3a2SMark Johnstontcp:::state-change
4604b4ad3a2SMark Johnston{
4614b4ad3a2SMark Johnston        this->elapsed = (timestamp - last[args[1]->cs_cid]) / 1000;
462af1e9f5aSChristian Brueffer        printf("   %12d %-20s -> %-20s %d\\n", this->elapsed,
4634b4ad3a2SMark Johnston            tcp_state_string[args[5]->tcps_state],
4644b4ad3a2SMark Johnston            tcp_state_string[args[3]->tcps_state], timestamp);
4654b4ad3a2SMark Johnston        last[args[1]->cs_cid] = timestamp;
4664b4ad3a2SMark Johnston}
4674b4ad3a2SMark Johnston
4684b4ad3a2SMark Johnstontcp:::state-change
4694b4ad3a2SMark Johnston/last[args[1]->cs_cid] == 0/
4704b4ad3a2SMark Johnston{
471af1e9f5aSChristian Brueffer        printf("   %12s %-20s -> %-20s %d\\n", "-",
4724b4ad3a2SMark Johnston            tcp_state_string[args[5]->tcps_state],
4734b4ad3a2SMark Johnston            tcp_state_string[args[3]->tcps_state], timestamp);
4744b4ad3a2SMark Johnston        last[args[1]->cs_cid] = timestamp;
4754b4ad3a2SMark Johnston}
4764b4ad3a2SMark Johnston.Ed
4770631830aSMichael TuexenThe following script uses the siftr probe to show the current value of CWND
4780631830aSMichael Tuexenand SSTHRESH when a packet is sent or received:
4790631830aSMichael Tuexen.Bd -literal -offset indent
4800631830aSMichael Tuexen#pragma D option quiet
4810631830aSMichael Tuexen#pragma D option switchrate=10hz
4820631830aSMichael Tuexen
4830631830aSMichael Tuexendtrace:::BEGIN
4840631830aSMichael Tuexen{
485*2176c9abSMichael Tuexen        printf(" %3s %16s:%-5s %16s:%-5s %10s %10s\\n",
486*2176c9abSMichael Tuexen            "DIR", "LADDR", "LPORT", "RADDR", "RPORT", "CWND", "SSTHRESH");
4870631830aSMichael Tuexen}
4880631830aSMichael Tuexen
4890631830aSMichael Tuexentcp:::siftr
4900631830aSMichael Tuexen{
491*2176c9abSMichael Tuexen        printf(" %3s %16s:%-5d %16s:%-5d %10u %10u\\n",
4920631830aSMichael Tuexen            siftr_dir_string[args[0]->direction],
493*2176c9abSMichael Tuexen            args[0]->laddr, args[0]->lport, args[0]->raddr, args[0]->rport,
4940631830aSMichael Tuexen            args[0]->snd_cwnd, args[0]->snd_ssthresh);
4950631830aSMichael Tuexen}
4960631830aSMichael Tuexen.Ed
4974b4ad3a2SMark Johnston.Sh COMPATIBILITY
4984b4ad3a2SMark JohnstonThis provider is compatible with the
4994b4ad3a2SMark Johnston.Nm tcp
5004b4ad3a2SMark Johnstonprovider in Solaris.
5014b4ad3a2SMark Johnston.Sh SEE ALSO
5024b4ad3a2SMark Johnston.Xr dtrace 1 ,
5034b4ad3a2SMark Johnston.Xr dtrace_ip 4 ,
5047bda9663SMichael Tuexen.Xr dtrace_sctp 4 ,
5054b4ad3a2SMark Johnston.Xr dtrace_udp 4 ,
5067bda9663SMichael Tuexen.Xr dtrace_udplite 4 ,
5070631830aSMichael Tuexen.Xr siftr 4 ,
5084b4ad3a2SMark Johnston.Xr tcp 4 ,
5094b4ad3a2SMark Johnston.Xr SDT 9
5104b4ad3a2SMark Johnston.Sh HISTORY
5114b4ad3a2SMark JohnstonThe
5124b4ad3a2SMark Johnston.Nm tcp
5134b4ad3a2SMark Johnstonprovider first appeared in
5144b4ad3a2SMark Johnston.Fx
5154b4ad3a2SMark Johnston10.0.
5164b4ad3a2SMark Johnston.Sh AUTHORS
5174b4ad3a2SMark JohnstonThis manual page was written by
5184b4ad3a2SMark Johnston.An Mark Johnston Aq Mt markj@FreeBSD.org .
5194b4ad3a2SMark Johnston.Sh BUGS
5204b4ad3a2SMark JohnstonThe
5214b4ad3a2SMark Johnston.Vt tcps_local
5224b4ad3a2SMark Johnstonand
5234b4ad3a2SMark Johnston.Vt tcps_active
5244b4ad3a2SMark Johnstonfields of
5254b4ad3a2SMark Johnston.Vt tcpsinfo_t
5264b4ad3a2SMark Johnstonare not filled in by the translator.
527