DTRACE_UDP(4)
π DTRACE_UDP π
okay bestie, so this is a page from the Kernel Interfaces Manual β section 4, the driver/kernel-interface girlies β and it's literally all about dtrace_udp, a DTrace provider for tracing events related to the UDP protocol. yes. we're doing packet girl summer. π¦
β¨ NAME β¨
dtrace_udp β a DTrace provider for tracing events related to the UDP protocol
πΈ SYNOPSIS πΈ
udp:::receive(pktinfo_t *, csinfo_t *, ipinfo_t *, udpsinfo_t *,
udpinfo_t *);
udp:::send(pktinfo_t *, csinfo_t *, ipinfo_t *, udpsinfo_t *,
udpinfo_t *);
π DESCRIPTION π
The DTrace udp provider lets you trace events inside the udp(4) protocol implementation. no cap.
udp:::send()β fires whenever the kernel is getting ready to transmit a UDP packet.udp:::receive()β fires whenever the kernel receives a UDP packet.
and now the plot twist π β receive() does not fire if any of these are true:
- the UDP header is incomplete
- the destination port is
0 - the length field is invalid
- the checksum is wrong
The arguments to these probes give you the detailed tea about the IP and UDP headers of the corresponding packet. π«Ά
π ARGUMENTS π
pktinfo_t β the placeholder bestie
This argument is currently unimplemented and is included for compatibility with other implementations of this provider. Its fields are:
uintptr_t pkt_addrβ Always set to0.
csinfo_t β also a placeholder, she's just here for the vibe
This argument is currently unimplemented and is included for compatibility with other implementations of this provider. Its fields are:
uintptr_t cs_addrβ Always set to0.uint64_t cs_cidβ A pointer to thestruct inpcbfor this packet, orNULL.pid_t cs_pidβ Always set to0.
ipinfo_t β the IP tea, IPv4 and IPv6 both
This argument contains IP fields common to both IPv4 and IPv6 packets. Its fields are:
uint8_t ip_verβ IP version of the packet,4for IPv4 packets and6for IPv6 packets.uint32_t ip_plengthβ IP payload size. This does not include the size of the IP header or IPv6 option headers.string ip_saddrβ IP source address.string ip_daddrβ IP destination address.
udpsinfo_t β the connection state, so iconic
This argument contains the state of the UDP connection associated with the packet. Its fields are:
uintptr_t udps_addrβ Pointer to thestruct inpcbcontaining the IP state for the associated socket.uint16_t udps_lportβ Local UDP port.uint16_t udps_rportβ Remote UDP port.string udps_laddrβ Local IPv4 or IPv6 address.string udps_raddrβ Remote IPv4 or IPv6 address.
udpinfo_t β the raw header, all fields in host order
This argument is the raw UDP header of the packet, with all fields in host order. Its fields are:
uint16_t udp_sportβ Source UDP port.uint16_t udp_dportβ Destination UDP port.uint16_t udp_lengthβ Length of the UDP header and payload, in bytes.uint16_t udp_checksumβ A checksum of the UDP header and payload, or0if no checksum was calculated.struct udphdr *udp_hdrβ A pointer to the raw UDP header.
π FILES π
/usr/lib/dtrace/udp.dβ DTrace type and translator definitions for theudpprovider.
π EXAMPLES π
count transmitted packets by destination port
The following script counts transmitted packets by destination port.
udp:::send
{
@num[args[4]->udp_dport] = count();
}
print some details of every UDP packet
This script will print some details of each UDP packet as it is sent or received by the kernel:
#pragma D option quiet
#pragma D option switchrate=10Hz
dtrace:::BEGIN
{
printf(" %10s %36s %-36s %6s\n", "DELTA(us)", "SOURCE",
"DEST", "BYTES");
last = timestamp;
}
udp:::send
{
this->elapsed = (timestamp - last) / 1000;
self->dest = strjoin(strjoin(args[2]->ip_daddr, ":"),
lltostr(args[4]->udp_dport));
printf(" %10d %30s:%-5d -> %-36s %6d\n", this->elapsed,
args[2]->ip_saddr, args[4]->udp_sport,
self->dest, args[4]->udp_length);
last = timestamp;
}
udp:::receive
{
this->elapsed = (timestamp - last) / 1000;
self->dest = strjoin(strjoin(args[2]->ip_saddr, ":"),
lltostr(args[4]->udp_sport));
printf(" %10d %30s:%-5d <- %-36s %6d\n", this->elapsed,
args[2]->ip_daddr, args[4]->udp_dport,
self->dest, args[4]->udp_length);
last = timestamp;
}
π COMPATIBILITY π
This provider is compatible with the udp provider in Solaris. π€
π SEE ALSO π
β HISTORY β
The udp provider first appeared in FreeBSD 10.0.
π«Ά AUTHORS π«Ά
This manual page was written by Mark Johnston <markj@FreeBSD.org>.
π and that's the whole page, bestie. written by Mark Johnston, living her truth on Debian, dated August 1, 2018. dtrace_udp(4) β she ate, no crumbs. periodt. π
β¨
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 2015 Mark Johnston <markj@FreeBSD.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms