$ show pktgen/Pktgen-DPDK
Pktgen is a high-performance, scriptable packet generator built on top of DPDK. It generates wire-rate traffic with support for Ethernet, IPv4/IPv6, TCP/UDP, GRE, GTP-U, MPLS, VLAN, and other encapsulations. The application provides an interactive CLI with auto-complete, history, and environment variables, as well as Lua scripting for automation. It includes features like latency measurement, packet capture/replay, range-based packet field sweeping, random bitfield generation, and RFC 2544 throughput testing. The architecture is a monolithic DPDK application with modular libraries for CLI, Lua bindings, hash maps, vectors, plugins, and common utilities. It is designed for network testing, benchmarking, and research scenarios requiring precise traffic generation and measurement.
The LLM identified 5 files worth highlighting for reuse:
Generic command dispatch table using format tokens (%d, %s, %P, %|opt|opt|) for declarative argument parsing. This pattern is reusable in any CLI-driven DPDK application and provides a clean separation between command definition and handler invocation.
VT100 escape sequence state machine for terminal input handling. Implements cursor keys, function keys, and special characters. Self-contained and reusable for any interactive terminal application requiring raw mode input processing.
Open-addressing hash map with dynamic resizing, C11 _Generic macros for type-safe value/array storage, prefix-based keys, iteration, sorted dump, and optional allocation tracking. Fully reusable as a standalone generic hash map library.
Generic dlopen-based plugin loader with name/hash lookup, reference counting, and instance management. Supports up to 32 plugins with start/stop lifecycle. Reusable in any application needing runtime extensibility via shared objects.
Optimized one's-complement checksum implementation using an unrolled loop for IPv4/TCP/UDP header checksums. Self-contained and reusable for any network application requiring fast software checksum calculation.