$ show OpenCloudOS/nettrace
nettrace is a Linux network diagnostic tool based on eBPF that traces network packet lifecycle, performs fault diagnosis, and monitors network abnormalities. The architecture centers around a main CLI application (nettrace.c) that loads and attaches eBPF programs (primarily in src/progs/kprobe.c) to kernel functions and tracepoints. As packets traverse the network stack, eBPF programs capture event data sent to user space via perf buffers, where it's processed by analysis.c for diagnostic rule matching and formatted by output.c for display. Key features include basic packet tracing, diagnostic mode with automated problem identification, drop monitoring, socket tracking, and latency/RTT analysis. The tool relies on external dependencies like libbpf, libelf, and bpftool for eBPF program loading and compilation.
The LLM identified 1 files worth highlighting for reuse:
Provides bidirectional mapping between network protocol names and numeric values for both L3 (IPv4, IPv6, ARP, etc.) and L4 (TCP, UDP, ICMP, etc.) protocols. Implements efficient lookup functions with proper error handling. Demonstrates clean separation of interface and implementation with minimal dependencies (primarily standard headers), making it easily reusable in any network-related project with only trivial modifications like replacing Linux-specific type aliases with stdint.h equivalents.