Overview of the TRex Packet Builder
masterdpkt Python library to construct various packet headers.repository·master·Indexed 23 days ago
https://github.com/cisco-system-traffic-generator/trex-coreCore repository for the Cisco system traffic generator, including TRex Wireless for simulating Wireless APs and clients compatible with Cisco WLCs. The codebase also contains various external libraries and tools, such as Valijson (a C++11 JSON Schema validation library), jsonpickleJS for Python-to-Javascript object reconstruction, and a deck.js backend for AsciiDoc slide generation.
dpkt Python library to construct various packet headers.Scapy is a powerful Python-based interactive packet manipulation program and library. It allows you to forge or decode packets for a wide variety of protocols, send them on the wire, capture them, and store/read them using pcap files.
Key capabilities include:
hping, nmap, arpspoof, arping, tcpdump, and wireshark for many tasks.TRex is a high-performance traffic generator designed to outperform traditional tools like iperf, netperf, and Linux kernel pktgen. It leverages COTS x86/ARM servers and NICs (Intel, Mellanox, etc.) to provide both stateless and stateful traffic generation.
Key Capabilities:
jsonpickle is a Python library designed for the serialization and deserialization of complex Python objects to and from JSON.
Unlike standard Python JSON libraries (such as the built-in json module, simplejson, or demjson) which are limited to Python primitives with direct JSON equivalents (e.g., dict, list, str, int), jsonpickle can handle much more complex data structures. It is highly configurable and extendable, allowing users to select or add different JSON backends.
The Scapy RPC Server provides a way to build and modify network packets using a JSON-RPC 2.0 specification over ZMQ. It operates on a Request-Response basis and does not support batched commands. It is primarily used to translate Scapy-like packet definitions into binary payloads and structured JSON data.
Key characteristics:
The Packet Builder Language uses a YAML-based format to define packet structures for use in a GUI. This format allows for dynamic packet building, field manipulation, and protocol stacking.
Key Capabilities:
The TRex Stateless (STL) API allows users to control high-performance traffic generation. The API is structured around several core components:
Bird CFG Creator, PyBirdClient, and Bird Node components.The Stateless (STL) API is used for high-speed, simple packet generation where each packet is independent of the previous one. It provides two primary interfaces:
Refer to the specific stl_plugin_api or stl_ndr_bench documentation for implementation details.
dhcpsrv plugin allows you to run a DHCP server within the TRex Emulation (Emu) environment. This is part of the trex.emu.emu_plugins.emu_plugin_dhcpsrv module. It is used to provide DHCP services to emulated hosts during traffic generation or network emulation scenarios.The lockfile package provides a unified API for file locking across Unix (Linux, Mac) and Windows platforms. It abstracts away platform-specific mechanisms like fcntl.flock on Unix and msvcrt.locking on Windows.
linklockfile.LinkLockFile (based on the link(2) system call).mkdirlockfile.MkdirLockFile (based on the mkdir(2) system call).with statement support.from lockfile import LockFile
lock = LockFile("/some/file/or/other")
with lock:
print lock.path, 'is locked.'TRex performance monitoring has evolved from using hard-coded boundaries (which caused false positives) to a data-driven approach. The current recommended architecture involves sending performance results to an ElasticSearch database and analyzing them using Kibana, Grafana, and Pandas.
This solution enables:
The workflow typically involves:
The Advanced Stateful (ASTF) API is used for complex traffic scenarios that require maintaining state (e.g., TCP flows, handshake sequences). It provides two primary interfaces:
Refer to the specific astf_plugin_api or astf_ndr_bench documentation for implementation details.