Repository navigation
Traffic Generator
The traffic generator is in charge of periodically creating simulated IP packets for both uplink and downlink transmission directions. It is up to the emulator's users to decide and implement their own traffic generators. We built a base class for the traffic generator instance from which other custom traffic models can override the base methods. There is a higher level class which can select the model from all the implemented traffic generator classes inheriting from the base class. There is one traffic generator instance per UE.
Simple traffic generator model in which the only parameters to be determined are:
- Target UL Throughput.
- Target DL Throughput.
- IP packet size.
With this information, the traffic generator creates, in each time step, as many packets as necessary according to the selected target throughput. We included random variability around the target throughput following a uniform distribution when stochastic behavior is enabled. In each time step, the emulator generates as many UL or DL bits as required to fulfill the target data rate configured by the user.
In this implementation, the generator reads the packets to be generated from a simple .txt file. Each line in the file contains a timestamp and the payload size:
0.001 1200
0.003 800
0.004 1200
A file is necessary for each transmission direction. The emulator reads line by line in synchronization with the internal clock and according to the timestamps. Once a line is read, the corresponding payload is added to the IP buffers.
When the end of the trace file is reached, the generator resets the file and continues, shifting the timestamps so that traffic can keep being generated for longer simulations.
The following configuration parameters can be defined by the user for each group of UEs:
[UE]
# ...
traffic_type: 1
ul_traffic_file: data/XR_traffic/960_sensors_real.txt
dl_traffic_file: data/XR_traffic/960_offloading_real.txt
delay: 0.002
ul_target: 5.0
dl_target: 5.0
var_perc: 0.0
pkt_size: 12000
Which define:
-
traffic_type: selected traffic generator model. Use0for the simple constant model and1for the file-based generator. -
ul_traffic_file: file from which read the packets iftraffic_typeis1, for UL transmission direction. -
dl_traffic_file: file from which read the packets iftraffic_typeis1, for DL transmission direction. -
delay: optional start delay applied to trace-driven traffic. -
ul_target/dl_target: target throughput for UL and DL respectively, in Mbps. -
var_perc: size of the generated random variability. It is ignored whenrandom_vis false. -
pkt_size: virtual IP packet size in bits.
Besides the configured models, traffic can be handed to a UE while the emulator runs. It is the runtime twin of the file driven generator: instead of reading pairs of instant and bytes from a trace, the list is dictated by a client through the control channel (Runtime Control).
{"id":1,"cmds":[{"target":"ue/0","set":{"dl.inject_bytes":200000}}]}Those 200 kB are packetized into pkt_size packets on the next step and queued like any
other traffic. Three things to keep in mind:
-
It adds, it does not replace. A UE can have its configured generator running and
receive injected bursts on top. A UE with
dl_target: 0and only injection is a purely client driven source. - The pacing is the client's. The emulator applies no rate ceiling of its own: it queues whatever it is given, as soon as it is given. How much and how often is the client's decision, which is where the backlog actually lives.
-
inject_bytesis the one incremental knob. Sending it twice injects twice. Its read returns the cumulative total, so a client that retries after a timeout can compare what it meant to inject with what the emulator says it received.describeflags it with"incremental": true.
pkt_delay_budget_s defaults to 0.35 s and packets older than that are discarded before
reaching the air. Handing over 10 MB in one go on a 20 Mbps link means four seconds of
transfer, so most of it evaporates. Two ways out, and they combine:
- Inject in chunks sized so that each one clears within the budget, looking at what is still pending. This is the recommended practice and it is what "the client manages the backlog" means in practice.
-
Raise
pkt_delay_budget_s, which is a knob, when what you want to study is precisely a bulk transfer.
get on a UE returns a state block, per direction, with cumulative counters the
client diffs between two reads:
| Field | Meaning |
|---|---|
injected_bytes_total |
what the emulator says it received |
pending_bytes, pending_packets
|
still queued |
oldest_age_s |
age of the oldest packet; margin against the budget |
delivered_bytes_total |
what made it over the air |
expired_bytes_total |
discarded by the delay budget: you are overfeeding |
dropped_bytes_total |
discarded by the AQM or by exhausted retransmissions |
ce_packets_total |
ECN CE marks, for L4S clients |
latency_s |
recent IP latency |
The split between expired and dropped is what makes the reading actionable: the first
says the client is pushing more than the budget allows, the second says the radio is
struggling. Through the API the same block is at GET /ue/{id}/state under state.
The repository includes XR traffic traces prepared to be used directly by the emulator:
data/XR_traffic/
These files were generated from the XR traffic dataset described in the dataset README and can be used with traffic_type: 1. The original PCAP files are not included in the repository; the prepared traces are enough for emulator runs.
The scripts/trafficGenerator.py script generates synthetic traffic traces from statistical models for frame sizes, inter-frame times and inter-packet times. It writes both the generated .txt trace and a small configuration summary.
The scripts/pcapTrafficParser.py script parses a PCAP file and extracts packet timestamps and sizes for selected ports and protocol. It requires Scapy and supports TCP or UDP traces.
Typical Python dependencies for these scripts are:
pip install scipy numpy pandas matplotlib scapy