]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/man/man4/dtrace_udp.4
Import tzdata 2018c
[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 April 18, 2015
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.
49 The arguments to these probes can be used to obtain detailed information about
50 the IP and UDP headers of the corresponding packet.
51 .Sh ARGUMENTS
52 The
53 .Vt pktinfo_t
54 argument is currently unimplemented and is included for compatibility with other
55 implementations of this provider.
56 Its fields are:
57 .Bl -tag -width "uintptr_t pkt_addr" -offset indent
58 .It Vt uintptr_t pkt_addr
59 Always set to 0.
60 .El
61 .Pp
62 The
63 .Vt csinfo_t
64 argument is currently unimplemented and is included for compatibility with other
65 implementations of this provider.
66 Its fields are:
67 .Bl -tag -width "uintptr_t cs_addr" -offset indent
68 .It Vt uintptr_t cs_addr
69 Always set to 0.
70 .It Vt uint64_t cs_cid
71 A pointer to the
72 .Vt struct inpcb
73 for this packet, or
74 .Dv NULL .
75 .It Vt pid_t cs_pid
76 Always set to 0.
77 .El
78 .Pp
79 The
80 .Vt ipinfo_t
81 argument contains IP fields common to both IPv4 and IPv6 packets.
82 Its fields are:
83 .Bl -tag -width "uint32_t ip_plength" -offset indent
84 .It Vt uint8_t ip_ver
85 IP version of the packet, 4 for IPv4 packets and 6 for IPv6 packets.
86 .It Vt uint32_t ip_plength
87 IP payload size.
88 This does not include the size of the IP header or IPv6 option headers.
89 .It Vt string ip_saddr
90 IP source address.
91 .It Vt string ip_daddr
92 IP destination address.
93 .El
94 .Pp
95 The
96 .Vt udpsinfo_t
97 argument contains the state of the UDP connection associated with the packet.
98 Its fields are:
99 .Bl -tag -width "uintptr_t udps_addr" -offset indent
100 .It Vt uintptr_t udps_addr
101 Pointer to the
102 .Vt struct inpcb
103 containing the IP state for the associated socket.
104 .It Vt uint16_t udps_lport
105 Local UDP port.
106 .It Vt uint16_t udps_rport
107 Remote UDP port.
108 .It Vt string udps_laddr
109 Local IPv4 or IPv6 address.
110 .It Vt string udps_raddr
111 Remote IPv4 or IPv6 address.
112 .El
113 .Pp
114 The
115 .Vt udpinfo_t
116 argument is the raw UDP header of the packet, with all fields in host order.
117 Its fields are:
118 .Bl -tag -width "struct udphdr *udp_hdr" -offset indent
119 .It Vt uint16_t udp_sport
120 Source UDP port.
121 .It Vt uint16_t udp_dport
122 Destination UDP port.
123 .It Vt uint16_t udp_length
124 Length of the UDP header and payload, in bytes.
125 .It Vt uint16_t udp_checksum
126 A checksum of the UDP header and payload, or 0 if no checksum was calculated.
127 .It Vt struct udphdr *udp_hdr
128 A pointer to the raw UDP header.
129 .El
130 .Sh FILES
131 .Bl -tag -width "/usr/lib/dtrace/udp.d" -compact
132 .It Pa /usr/lib/dtrace/udp.d
133 DTrace type and translator definitions for the
134 .Nm udp
135 provider.
136 .El
137 .Sh EXAMPLES
138 The following script counts transmitted packets by destination port.
139 .Bd -literal -offset indent
140 udp:::send
141 {
142         @num[args[4]->udp_dport] = count();
143 }
144 .Ed
145 .Pp
146 This script will print some details of each UDP packet as it is sent or received
147 by the kernel:
148 .Bd -literal -offset indent
149 #pragma D option quiet
150 #pragma D option switchrate=10Hz
151
152 dtrace:::BEGIN
153 {
154         printf(" %10s %36s    %-36s %6s\\n", "DELTA(us)", "SOURCE",
155             "DEST", "BYTES");
156         last = timestamp;
157 }
158
159 udp:::send
160 {
161         this->elapsed = (timestamp - last) / 1000;
162         self->dest = strjoin(strjoin(args[2]->ip_daddr, ":"),
163              lltostr(args[4]->udp_dport));
164         printf(" %10d %30s:%-5d -> %-36s %6d\\n", this->elapsed,
165             args[2]->ip_saddr, args[4]->udp_sport,
166             self->dest, args[4]->udp_length);
167         last = timestamp;
168 }
169
170 udp:::receive
171 {
172         this->elapsed = (timestamp - last) / 1000;
173         self->dest = strjoin(strjoin(args[2]->ip_saddr, ":"),
174              lltostr(args[4]->udp_sport));
175         printf(" %10d %30s:%-5d <- %-36s %6d\\n", this->elapsed,
176             args[2]->ip_daddr, args[4]->udp_dport,
177             self->dest, args[4]->udp_length);
178         last = timestamp;
179 }
180 .Ed
181 .Sh COMPATIBILITY
182 This provider is compatible with the
183 .Nm udp
184 provider in Solaris.
185 .Sh SEE ALSO
186 .Xr dtrace 1 ,
187 .Xr dtrace_ip 4 ,
188 .Xr dtrace_tcp 4 ,
189 .Xr udp 4 ,
190 .Xr SDT 9
191 .Sh HISTORY
192 The
193 .Nm udp
194 provider first appeared in
195 .Fx
196 10.0.
197 .Sh AUTHORS
198 This manual page was written by
199 .An Mark Johnston Aq Mt markj@FreeBSD.org .