Skip to content

Commit 5dd1fa2

Browse files
committed
Add README
Add a README briefly explaining what this example does. Signed-off-by: Simon Sundberg <[email protected]>
1 parent 7f334a3 commit 5dd1fa2

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

netstacklat/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Netstacklat - Monitor latency within the network stack
2+
Netstacklat is a simple tool for monitoring latency within the Linux
3+
network stack for ingress traffic. The tool relies on the kernel time
4+
stamping received packets (`SOF_TIMESTAMPING_RX_SOFTWARE`),
5+
specifically setting `sk_buff->tstamp`, and then reports when packets
6+
arrive at various hooks relative to this timestamp, i.e. the time
7+
between the latency between the packet being timestamped and reaching
8+
the hook.
9+
10+
The tool is based on the following bpftrace script from Jesper
11+
Dangaard Brouer:
12+
```console
13+
sudo bpftrace -e '
14+
kfunc:tcp_v4_do_rcv,
15+
kfunc:tcp_data_queue,
16+
kfunc:udp_queue_rcv_one_skb
17+
{
18+
$tai_offset=37000000000;
19+
$now=nsecs(tai)-$tai_offset; @cnt[probe]=count(); @total[probe]=count();
20+
$ts=args->skb->tstamp; $delta=$now-(uint64)$ts;
21+
@hist_ns[probe]=hist($delta);
22+
@stats[probe]=stats($delta);
23+
//printf("now:%llu - ts:%llu = delta:%llu\n", $now, $ts, $delta);
24+
}
25+
interval:s:10 {time("\n%H:%M:%S\n");
26+
print(@cnt); clear(@cnt);
27+
print(@total);
28+
print(@stats);
29+
print(@hist_ns);
30+
}'
31+
```
32+
33+
The eBPF part of the tool (`netstacklat.bpf.c`) is designed to be
34+
compatible with
35+
[ebpf_exporter](https://github.com/cloudflare/ebpf_exporter), so that
36+
the data can easily be exported to Prometheus.

0 commit comments

Comments
 (0)