DTRACE_IP(4)
π DTRACE_IP π
okay so bestie, welcome to the dtrace_ip page β that's the DTrace provider for tracing all the stuff that goes down with the IPv4 and IPv6 protocols, no cap β¨
πΈ NAME πΈ
dtrace_ip β a DTrace provider for tracing events related to the IPv4 and IPv6 protocols. that's it, that's the whole vibe π¦
β¨ 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 *);
π DESCRIPTION π
So the DTrace ip provider lets you trace events inside the ip(4) and ip6(4) protocol implementations. literally iconic.
ip:::send()β this probe fires whenever the kernel gets ready to transmit an IP packet, slay π₯ip:::receive()β this one fires whenever the kernel receives an IP packet π
The arguments to these probes give you detailed info about the IP headers of the packet in question, plus the network interface it was sent or received on. the way that's so useful π«Ά
okay important caveat bestie: unlike thedtrace_tcp(4)anddtrace_udp(4)providers,ipprovider probes are triggered by forwarded packets. that means the probes will fire on packets that are not destined to the local host. yes really. don't come for me, that's just how it is π
π ARGUMENTS π
π§ pktinfo_t
This argument is currently unimplemented and is only included for compatibility with other implementations of this provider. its fields are:
uintptr_t pkt_addrβ always set to0.
π csinfo_t
Also currently unimplemented, also just there 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
This one has the IP fields that are 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 the IPv6 option headers.string ip_saddrβ IP source address.string ip_daddrβ IP destination address.
π ifinfo_t
Describes the outgoing and incoming interfaces for the packet in the ip:::send() and ip:::receive() probes respectively. its fields are:
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, iykyk.
π ipv4info_t
Contains the fields of the IP header for IPv4 packets. this argument is NULL for IPv6 packets, so heads up π β DTrace scripts should use the ip_ver() field in the ipinfo_t argument to figure out whether to use this argument. its fields are:
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.
π ipv6info_t
Contains the fields of the IP header for IPv6 packets. its fields are not set for IPv4 packets β and same as with the ipv4info_t argument, use the ip_ver() field to determine whether this argument is valid. its fields are:
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. literally the moment π
π₯ EXAMPLES π₯
okay so this first script counts received packets by remote host address. eat:
ip:::receive
{
@num[args[2]->ip_saddr] = count();
}
and this script prints some details of each IP packet as it's sent or received by the kernel. main character script fr fr:
#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. bestie behaviour honestly π«Ά
β SEE ALSO β
dtrace(1), dtrace_tcp(4), dtrace_udp(4), ip(4), ip6(4), ifnet(9), SDT(9)
πΈ HISTORY πΈ
The ip provider first appeared in FreeBSD 10.0. a classic, an icon, a legend π
π AUTHORS π
This manual page was written by Mark Johnston <markj@FreeBSD.org>. thank you king π«‘
and that's the whole page bestie β¨ this one came from the Debian gang, dated September 14, 2015, and it's the DTRACE_IP(4) kernel interfaces manual β go forth and trace those packets π
ππ¦
π¦ 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