]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/man/man4/dtrace_udp.4
MFC r336551:
[FreeBSD/FreeBSD.git] / share / man / man4 / dtrace_udp.4
1 .\" Copyright (c) 2015 Mark Johnston <markj@FreeBSD.org>
2 .\" All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\"
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 .\" SUCH DAMAGE.
24 .\"
25 .\" $FreeBSD$
26 .\"
27 .Dd July 20, 2018
28 .Dt DTRACE_UDP 4
29 .Os
30 .Sh NAME
31 .Nm dtrace_udp
32 .Nd a DTrace provider for tracing events related to the UDP protocol
33 .Sh SYNOPSIS
34 .Fn udp:::receive "pktinfo_t *" "csinfo_t *" "ipinfo_t *" "udpsinfo_t *" \
35     "udpinfo_t *"
36 .Fn udp:::send "pktinfo_t *" "csinfo_t *" "ipinfo_t *" "udpsinfo_t *" \
37     "udpinfo_t *"
38 .Sh DESCRIPTION
39 The DTrace
40 .Nm udp
41 provider allows users to trace events in the
42 .Xr udp 4
43 protocol implementation.
44 The
45 .Fn udp:::send
46 probe fires whenever the kernel prepares to transmit a UDP packet, and the
47 .Fn udp:::receive
48 probe fires whenever the kernel receives a UDP packet, unless
49 the UDP header is incomplete,
50 the destination port is 0,
51 the length field is invalid,
52 or the checksum is wrong.
53 The arguments to these probes can be used to obtain detailed information about
54 the IP and UDP headers of the corresponding packet.
55 .Sh ARGUMENTS
56 The
57 .Vt pktinfo_t
58 argument is currently unimplemented and is included for compatibility with other
59 implementations of this provider.
60 Its fields are:
61 .Bl -tag -width "uintptr_t pkt_addr" -offset indent
62 .It Vt uintptr_t pkt_addr
63 Always set to 0.
64 .El
65 .Pp
66 The
67 .Vt csinfo_t
68 argument is currently unimplemented and is included for compatibility with other
69 implementations of this provider.
70 Its fields are:
71 .Bl -tag -width "uintptr_t cs_addr" -offset indent
72 .It Vt uintptr_t cs_addr
73 Always set to 0.
74 .It Vt uint64_t cs_cid
75 A pointer to the
76 .Vt struct inpcb
77 for this packet, or
78 .Dv NULL .
79 .It Vt pid_t cs_pid
80 Always set to 0.
81 .El
82 .Pp
83 The
84 .Vt ipinfo_t
85 argument contains IP fields common to both IPv4 and IPv6 packets.
86 Its fields are:
87 .Bl -tag -width "uint32_t ip_plength" -offset indent
88 .It Vt uint8_t ip_ver
89 IP version of the packet, 4 for IPv4 packets and 6 for IPv6 packets.
90 .It Vt uint32_t ip_plength
91 IP payload size.
92 This does not include the size of the IP header or IPv6 option headers.
93 .It Vt string ip_saddr
94 IP source address.
95 .It Vt string ip_daddr
96 IP destination address.
97 .El
98 .Pp
99 The
100 .Vt udpsinfo_t
101 argument contains the state of the UDP connection associated with the packet.
102 Its fields are:
103 .Bl -tag -width "uintptr_t udps_addr" -offset indent
104 .It Vt uintptr_t udps_addr
105 Pointer to the
106 .Vt struct inpcb
107 containing the IP state for the associated socket.
108 .It Vt uint16_t udps_lport
109 Local UDP port.
110 .It Vt uint16_t udps_rport
111 Remote UDP port.
112 .It Vt string udps_laddr
113 Local IPv4 or IPv6 address.
114 .It Vt string udps_raddr
115 Remote IPv4 or IPv6 address.
116 .El
117 .Pp
118 The
119 .Vt udpinfo_t
120 argument is the raw UDP header of the packet, with all fields in host order.
121 Its fields are:
122 .Bl -tag -width "struct udphdr *udp_hdr" -offset indent
123 .It Vt uint16_t udp_sport
124 Source UDP port.
125 .It Vt uint16_t udp_dport
126 Destination UDP port.
127 .It Vt uint16_t udp_length
128 Length of the UDP header and payload, in bytes.
129 .It Vt uint16_t udp_checksum
130 A checksum of the UDP header and payload, or 0 if no checksum was calculated.
131 .It Vt struct udphdr *udp_hdr
132 A pointer to the raw UDP header.
133 .El
134 .Sh FILES
135 .Bl -tag -width "/usr/lib/dtrace/udp.d" -compact
136 .It Pa /usr/lib/dtrace/udp.d
137 DTrace type and translator definitions for the
138 .Nm udp
139 provider.
140 .El
141 .Sh EXAMPLES
142 The following script counts transmitted packets by destination port.
143 .Bd -literal -offset indent
144 udp:::send
145 {
146         @num[args[4]->udp_dport] = count();
147 }
148 .Ed
149 .Pp
150 This script will print some details of each UDP packet as it is sent or received
151 by the kernel:
152 .Bd -literal -offset indent
153 #pragma D option quiet
154 #pragma D option switchrate=10Hz
155
156 dtrace:::BEGIN
157 {
158         printf(" %10s %36s    %-36s %6s\\n", "DELTA(us)", "SOURCE",
159             "DEST", "BYTES");
160         last = timestamp;
161 }
162
163 udp:::send
164 {
165         this->elapsed = (timestamp - last) / 1000;
166         self->dest = strjoin(strjoin(args[2]->ip_daddr, ":"),
167              lltostr(args[4]->udp_dport));
168         printf(" %10d %30s:%-5d -> %-36s %6d\\n", this->elapsed,
169             args[2]->ip_saddr, args[4]->udp_sport,
170             self->dest, args[4]->udp_length);
171         last = timestamp;
172 }
173
174 udp:::receive
175 {
176         this->elapsed = (timestamp - last) / 1000;
177         self->dest = strjoin(strjoin(args[2]->ip_saddr, ":"),
178              lltostr(args[4]->udp_sport));
179         printf(" %10d %30s:%-5d <- %-36s %6d\\n", this->elapsed,
180             args[2]->ip_daddr, args[4]->udp_dport,
181             self->dest, args[4]->udp_length);
182         last = timestamp;
183 }
184 .Ed
185 .Sh COMPATIBILITY
186 This provider is compatible with the
187 .Nm udp
188 provider in Solaris.
189 .Sh SEE ALSO
190 .Xr dtrace 1 ,
191 .Xr dtrace_ip 4 ,
192 .Xr dtrace_tcp 4 ,
193 .Xr udp 4 ,
194 .Xr SDT 9
195 .Sh HISTORY
196 The
197 .Nm udp
198 provider first appeared in
199 .Fx
200 10.0.
201 .Sh AUTHORS
202 This manual page was written by
203 .An Mark Johnston Aq Mt markj@FreeBSD.org .