DTRACE_UDP(4)
π DTRACE_UDP(4) β the Kernel Interfaces Manual glow-up β¨
Okay so bestie, this is the DTRACE_UDP(4) page from the Kernel Interfaces Manual, and it's literally all about the DTrace provider for tracing UDP stuff. Buckle up, we're getting into packet vibes. π¦
π NAME π
dtrace_udp β a DTrace provider for tracing events related to the UDP protocol. No cap, that's the whole name. π
β¨ 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 *);
Two probes, two moods: one for when packets come in, one for when they go out. Iconic. π
πΈ DESCRIPTION πΈ
The DTrace udp provider lets you trace events inside the udp(4) protocol implementation. Lowkey powerful.
- The
udp:::send()probe fires whenever the kernel is about to transmit a UDP packet. π - The
udp:::receive()probe fires whenever the kernel receives a UDP packet β unless the UDP header is incomplete, the destination port is0, the length field is invalid, or the checksum is wrong. So if any of those things are off, no probe for you, bestie. π
The arguments to these probes can be used to get detailed info about the IP and UDP headers of the corresponding packet. It's giving forensic girly. π
π§ ARGUMENTS π§
pktinfo_t β the compatibility cutie π«Ά
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. Literally always. Don't expect more. π
csinfo_t β also a compatibility moment π
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. Periodt.
ipinfo_t β the IP tea β
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,6for IPv6 packets.uint32_t ip_plengthβ IP payload size. This does not include the size of the IP header or IPv6 option headers. Important distinction, bestie.string ip_saddrβ IP source address.string ip_daddrβ IP destination address.
udpsinfo_t β the connection state check π¦
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, host order realness π
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. The whole vibe lives here. β¨
π₯ EXAMPLES π₯
The following script counts transmitted packets by destination port. Slay.
udp:::send
{
@num[args[4]->udp_dport] = count();
}
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;
}
No notes, it's perfect. π
π COMPATIBILITY π
This provider is compatible with the udp provider in Solaris. We love cross-platform solidarity. π€
β SEE ALSO β
Go read them, iykyk. π
π HISTORY π
The udp provider first appeared in FreeBSD 10.0. A classic. π
π AUTHORS π
This manual page was written by Mark Johnston <markj@FreeBSD.org>. Give him his flowers. π
And that's the whole page, bestie β written for Debian, dated August 1, 2018, under the DTRACE_UDP(4) name. Stay packet-positive! π β¨
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- Copyright (c) 2015 Mark Johnston <markj@FreeBSD.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms