/usr/lib/dtrace/ip.d
DTrace type and translator definitions for the ip provider.
A dtrace provider for tracing events related to the ipv4 and ipv6 protocols
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 *);
The DTrace ip provider allows users to trace events in the ip(4) and ip6(4) protocol implementations. The ip:::send() probe fires whenever the kernel prepares to transmit an IP packet, and the ip:::receive() probe fires whenever the kernel receives an IP packet. The arguments to these probes can be used to obtain detailed information about the IP headers of the corresponding packet, as well as the network interface on which the packet was sent or received. Unlike the dtrace_tcp(4) and dtrace_udp(4) providers, ip provider probes are triggered by forwarded packets. That is, the probes will fire on packets that are not destined to the local host.
The pktinfo_t argument is currently unimplemented and is included for compatibility with other implementations of this provider. Its fields are:
Always set to 0.
The csinfo_t argument is currently unimplemented and is included for compatibility with other implementations of this provider. Its fields are:
Always set to 0.
A pointer to the struct inpcb for this packet, or NULL.
Always set to 0.
The ipinfo_t argument contains IP fields common to both IPv4 and IPv6 packets. Its fields are:
IP version of the packet, 4 for IPv4 packets and 6 for IPv6 packets.
IP payload size. This does not include the size of the IP header or IPv6 option headers.
IP source address.
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. Its fields are:
The interface name.
A boolean value indicating whether or not the interface is a loopback interface.
A pointer to the struct ifnet which describes the interface. See the ifnet(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. Its fields are:
IP version. This will always be 4 for IPv4 packets.
The IP header length, including options, in 32-bit words.
IP type of service field.
The total packet length, including the header, in bytes.
Identification field.
The IP flags.
The fragment offset of the packet.
Time to live field.
Next-level protocol ID.
A string containing the name of the encapsulated protocol. The protocol strings are defined in the protocol array in /usr/lib/dtrace/ip.d
The IP checksum.
IPv4 source address.
IPv4 destination address.
A string representation of the source address.
A string representation of the destination address.
A pointer to the raw IPv4 header.
The ipv6info_t argument contains the fields of the IP header for IPv6 packets. Its fields are not set for IPv4 packets; as with the ipv4info_t argument, the ip_ver() field should be used to determine whether this argument is valid. Its fields are:
IP version. This will always be 6 for IPv6 packets.
The traffic class, used to set the differentiated services codepoint and extended congestion notification flags.
The flow label of the packet.
The IP payload size, including extension headers, in bytes.
An identifier for the type of the next header.
A string representation of the type of the next header.
The hop limit.
IPv6 source address.
IPv6 destination address.
A string representation of the source address.
A string representation of the destination address.
A pointer to the raw IPv6 header.
/usr/lib/dtrace/ip.d
DTrace type and translator definitions for the ip provider.
The following script counts received packets by remote host address.
ip:::receive
{
@num[args[2]->ip_saddr] = count();
}
This script will print some details of each IP packet as it is sent or received by the kernel:
#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;
}
This provider is compatible with the ip providers found in Solaris and Darwin.
25 releases since FreeBSD 11.0-RELEASE; the text changed 12 times.