DTRACE_IP(4)
β¨ DTRACE_IP(4) β¨ β the Kernel Interfaces Manual one, bestie π
okay so. picture this: you're in the kernel, packets are flying everywhere, and you're just standing there like ποΈπποΈ. enter dtrace_ip, aka the girl who tells you everything about IPv4 and IPv6 events. this is the manual page for it, rewritten with love and zero cap. let's go π¦
πΈ NAME πΈ
dtrace_ip β a DTrace provider for tracing events related to the IPv4 and IPv6 protocols. yes she does both. versatile queen π
π SYNOPSIS π
ip:::receive(pktinfo_t *, csinfo_t *, ipinfo_t *, ifinfo_t *,
ipv4info_t *, ipv6info_t *);
ip:::send(pktinfo_t *, csinfo_t *, ipinfo_t *, ifinfo_t *, ipv4info_t *,
ipv6info_t *);
look at her. six arguments, no notes. π
π« DESCRIPTION π«
the DTrace ip provider lets you trace events inside the ip(4) and ip6(4) protocol implementations. two probes, two moods:
ip:::send()fires whenever the kernel is about to transmit an IP packet. it's giving "outbox" π€ip:::receive()fires whenever the kernel receives an IP packet. it's giving "inbox" π₯
the arguments to these probes let you pull detailed info about the IP headers of the packet in question, plus the network interface it was sent or received on. truly a full package.
now here's the plot twist π β unlike the dtrace_tcp(4) and dtrace_udp(4) providers, ip provider probes get triggered by forwarded packets. meaning: these probes fire on packets that are not destined to the local host. not everything is about you, bestie, and that's the whole point. π
π§ ARGUMENTS π§
π the pktinfo_t argument
currently unimplemented β she's here for compatibility with other implementations of this provider, and honestly? respect the hustle. her fields:
uintptr_t pkt_addrβ always set to0. every single time. iconic consistency.
π the csinfo_t argument
also currently unimplemented, also just here for compatibility with other implementations of this provider. her fields:
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.
π the ipinfo_t argument
this one's the main character π she holds the IP fields common to both IPv4 and IPv6 packets. her fields:
uint8_t ip_verβ IP version of the packet:4for IPv4 packets,6for IPv6 packets.uint32_t ip_plengthβ IP payload size. heads up: 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.
π the ifinfo_t argument
describes the outgoing and incoming interfaces for the packet in the ip:::send() and ip:::receive() probes respectively. her fields:
string if_nameβ the interface name.int8_t if_localβ a boolean value indicating whether or not the interface is a loopback interface.uintptr_t if_addrβ a pointer to thestruct ifnetwhich describes the interface. see theifnet(9)manual page.
π the ipv4info_t argument
contains the fields of the IP header for IPv4 packets. this argument is NULL for IPv6 packets. DTrace scripts should use the ip_ver() field in the ipinfo_t argument to determine whether to use this argument. her fields:
uint8_t ipv4_verβ IP version. this will always be4for IPv4 packets.uint8_t ipv4_ihlβ the IP header length, including options, in 32-bit words.uint8_t ipv4_tosβ IP type of service field.uint16_t ipv4_lengthβ the total packet length, including the header, in bytes.uint16_t ipv4_identβ identification field.uint8_t ipv4_flagsβ the IP flags.uint16_t ipv4_offsetβ the fragment offset of the packet.uint8_t ipv4_ttlβ time to live field.uint8_t ipv4_protocolβ next-level protocol ID.string ipv4_protostrβ a string containing the name of the encapsulated protocol. the protocol strings are defined in theprotocolarray in/usr/lib/dtrace/ip.d.uint16_t ipv4_checksumβ the IP checksum.ipaddr_t ipv4_srcβ IPv4 source address.ipaddr_t ipv4_dstβ IPv4 destination address.string ipv4_saddrβ a string representation of the source address.string ipv4_daddrβ a string representation of the destination address.ipha_t *ipv4_hdrβ a pointer to the raw IPv4 header.
π the ipv6info_t argument
contains the fields of the IP header for IPv6 packets. her fields are not set for IPv4 packets; and just like with the ipv4info_t argument, you should use the ip_ver() field to figure out whether this argument is valid. her fields:
uint8_t ipv6_verβ IP version. this will always be6for IPv6 packets.uint8_t ipv6_tclassβ the traffic class, used to set the differentiated services codepoint and extended congestion notification flags.uint32_t ipv6_flowβ the flow label of the packet.uint16_t ipv6_plenβ the IP payload size, including extension headers, in bytes.uint8_t ipv6_nexthdrβ an identifier for the type of the next header.string ipv6_nextstrβ a string representation of the type of the next header.uint8_t ipv6_hlimβ the hop limit.ip6_addr_t *ipv6_srcβ IPv6 source address.ip6_addr_t *ipv6_dstβ IPv6 destination address.string ipv6_saddrβ a string representation of the source address.string ipv6_daddrβ a string representation of the destination address.struct ip6_hdr *ipv6_hdrβ a pointer to the raw IPv6 header.
π¦ FILES π¦
/usr/lib/dtrace/ip.dβ DTrace type and translator definitions for theipprovider. this file is doing the lord's work fr fr π
π₯ EXAMPLES π₯
example one: this script counts received packets by remote host address. so simple. so powerful. she ate.
ip:::receive
{
@num[args[2]->ip_saddr] = count();
}
example two: this script prints some details of each IP packet as it's sent or received by the kernel. get you a script that does both π
#pragma D option quiet
#pragma D option switchrate=10Hz
dtrace:::BEGIN
{
printf(" %10s %30s %-30s %8s %6s\n", "DELTA(us)", "SOURCE",
"DEST", "INT", "BYTES");
last = timestamp;
}
ip:::send
{
this->elapsed = (timestamp - last) / 1000;
printf(" %10d %30s -> %-30s %8s %6d\n", this->elapsed,
args[2]->ip_saddr, args[2]->ip_daddr, args[3]->if_name,
args[2]->ip_plength);
last = timestamp;
}
ip:::receive
{
this->elapsed = (timestamp - last) / 1000;
printf(" %10d %30s <- %-30s %8s %6d\n", this->elapsed,
args[2]->ip_daddr, args[2]->ip_saddr, args[3]->if_name,
args[2]->ip_plength);
last = timestamp;
}
π COMPATIBILITY π
this provider is compatible with the ip providers found in Solaris and Darwin. she gets along with everybody, no drama. π€
β SEE ALSO β
dtrace(1), dtrace_tcp(4), dtrace_udp(4), ip(4), ip6(4), ifnet(9), SDT(9)
go read those next, bestie, iykyk π
π HISTORY π
the ip provider first appeared in FreeBSD 10.0. a true 2013-era legend. π«Ά
π AUTHORS π
this manual page was written by Mark Johnston <markj@FreeBSD.org>. thank you for your service, king π«‘
and that's the whole page!! this one came from the Debian crew and is dated September 14, 2015 β so yeah, it's been holding it down since before some of us could even read. mwah π go trace some packets, you absolute icon. πβ¨π¦π
π¦ 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