$ show esnet/iperf
iperf3 is a mature, widely-deployed network bandwidth measurement tool developed by ESnet/LBNL. It measures maximum achievable throughput on IP networks using TCP, UDP, and SCTP, and provides detailed per-interval statistics including jitter, packet loss, retransmits, congestion window, and CPU utilization. The tool operates as a client-server application with a control channel for parameter exchange and data channels for bulk transfer, supporting parallel streams, reverse mode, bidirectional tests, and various pacing/affinity options. The codebase is written in C and built with GNU Autotools (autoconf, automake, libtool). It exposes a public library API (libiperf) that allows embedding iperf functionality into other programs, demonstrated by minimal examples in the examples/ directory. The architecture follows a protocol vtable pattern (struct protocol) for pluggable transport protocols, a callback system for test lifecycle events, and a timer subsystem for pacing and reporting intervals. JSON output is generated via a vendored cJSON library. Key strengths include its cross-platform support (Linux, FreeBSD, macOS, and others via #ifdef), extensive command-line options, and integration with perfSONAR for research and education networks. However, the codebase shows signs of organic growth: large monolithic files (iperf_api.c ~3000 lines), platform-specific #ifdef sprawl, manual release test scripts, and some unresolved TODOs. Security advisories have been issued for past vulnerabilities, and the authentication module uses OpenSSL RSA with multiple padding modes. Overall, iperf3 is a high-quality, production-grade tool with a few areas of technical debt.
The LLM identified 4 files worth highlighting for reuse:
Provides a portable network socket abstraction layer with functions like netdial(), netannounce(), create_socket(), timeout_connect(), Nread/Nrecv/Nwrite, Nsendfile, and GSO/GRO helpers. It handles IPv4/IPv6, TCP/UDP/SCTP, and includes select-based timeouts with soft/hard error conventions. This module is self-contained (depends only on system headers and net.h) and could be extracted for use in other network tools requiring reliable socket I/O with timeouts.
A timer library adapted from Jef Poskanzer's timers, providing a callback-based timer system with TimerClientData and TimerProc. It supports creating, running, and canceling timers with microsecond precision. The implementation uses a priority queue (heap) for efficient timer management. This is a self-contained, well-documented module that can be reused in any C project needing a lightweight timer scheduler.
Implements conversion and formatting of data rates and sizes (bits/bytes, K/M/G/T prefixes). Functions like unit_atof() parse human-readable strings (e.g., '10M', '1.5G') into numeric values, while unit_snprintf() formats numbers with appropriate units. The module is small, self-contained, and handles edge cases like fractional units and bit/byte ambiguity. It can be reused in any application that needs to parse or display network throughput or storage sizes.
Provides a portable high-resolution time abstraction using struct iperf_time. It wraps platform-specific monotonic clocks (clock_gettime on POSIX, mach_absolute_time on macOS, etc.) and offers functions for time arithmetic, comparison, and conversion to seconds/microseconds. The module is self-contained and can be extracted for any C project needing reliable monotonic timing without platform #ifdef pollution.