Traffic Generator
Traffic Generator
Section titled “Traffic Generator”TL;DR (Quick Start)
Section titled “TL;DR (Quick Start)”For the impatient: generate test traffic through a device under test.
Configure port and run quick test:
/tool/traffic-generator/port/add interface=ether1 name=port0/tool/traffic-generator/quick interface=ether1 mbps=100 packet-size=1400Overview
Section titled “Overview”What this does: Traffic Generator creates and sends raw packets over network interfaces to evaluate Device Under Test (DUT) or System Under Test (SUT) performance. Unlike Bandwidth Test which measures point-to-point throughput, Traffic Generator creates customizable packets that traverse network paths and return for comprehensive metrics collection including latency distribution, jitter, packet loss, and out-of-order detection.
When to use this:
- Test router/firewall throughput capacity
- Measure latency and jitter through network paths
- Stress test network equipment before deployment
- Validate QoS configurations under load
- Test IPsec/VPN tunnel performance
- Evaluate switch fabric performance
- Detect packet loss and out-of-order issues
Prerequisites:
- RouterOS 6.0 or newer
- Traffic Generator feature enabled in device-mode
- Two or more interfaces for proper testing
- Understanding of network topology and routing
How it differs from Bandwidth Test:
- Generates raw packets with full control over headers
- Measures latency distribution, not just throughput
- Detects out-of-order packets
- Supports multiple streams with different configurations
- Packets can traverse complex paths (routed, tunneled, switched)
- Uses FastPath automatically when available
Security Restriction
Traffic Generator can be permanently disabled via /system/device-mode/update traffic-gen=no (requires physical reset button press). This prevents misuse for network attacks. Once disabled, re-enabling requires factory reset.
Packet Capture Limitation
Packets generated by Traffic Generator cannot be captured using packet sniffer, torch, or firewall rules on the outgoing interface of the generating router. This is by design.
Core Concepts
Section titled “Core Concepts”Architecture
Section titled “Architecture”Traffic Generator uses three main components:
- Ports - Associate interfaces with TX/RX operations
- Packet Templates - Define packet structure (headers, IPs, ports)
- Streams - Configure traffic flows with rate limits
┌──────────────┐ ┌──────────────┐ ┌──────────────┐│ PORTS │────▶│ TEMPLATES │────▶│ STREAMS ││ │ │ │ │ ││ interface │ │ headers │ │ rate (mbps) ││ assignment │ │ src/dst IP │ │ packet size ││ │ │ src/dst port │ │ template ref │└──────────────┘ └──────────────┘ └──────────────┘Quick Mode vs Persistent Mode
Section titled “Quick Mode vs Persistent Mode”Quick mode: Single command that starts, runs, and displays results interactively. Best for ad-hoc testing.
/tool/traffic-generator/quick interface=ether1 mbps=100Persistent mode: Configure components separately, start/stop as needed, statistics stored for later analysis.
/tool/traffic-generator/start# ... test runs in background .../tool/traffic-generator/stopPort Configuration
Section titled “Port Configuration”Associate interfaces with Traffic Generator before creating templates.
Add a Port
Section titled “Add a Port”/tool/traffic-generator/port/add interface=ether1 name=port0View Ports
Section titled “View Ports”/tool/traffic-generator/port/printExpected output:
Flags: X - DISABLED; D - DYNAMIC; I - INACTIVEColumns: NAME, INTERFACE, FIRST-HEADER# NAME INTERFACE FIRST-HEADER0 port0 ether1 macDisable a Port
Section titled “Disable a Port”/tool/traffic-generator/port/set port0 disabled=yesPacket Template Configuration
Section titled “Packet Template Configuration”Define what packets look like using templates. Each template specifies headers, addresses, and payload.
Basic Template
Section titled “Basic Template”Create a template for routed traffic:
/tool/traffic-generator/packet-template/add \ name=test-template \ header-stack=mac,ip,udp \ ip-src=192.168.1.100/32 \ ip-dst=10.0.0.100/32 \ ip-gateway=192.168.1.1 \ udp-src-port=12345 \ udp-dst-port=54321 \ port=port0Template with VLAN Tag
Section titled “Template with VLAN Tag”/tool/traffic-generator/packet-template/add \ name=vlan-template \ header-stack=mac,vlan,ip,udp \ vlan-id=100 \ ip-src=192.168.1.100/32 \ ip-dst=10.0.0.100/32 \ ip-gateway=192.168.1.1 \ port=port0View Templates
Section titled “View Templates”/tool/traffic-generator/packet-template/printUpdate Assumed MACs
Section titled “Update Assumed MACs”When network topology changes, update automatically determined values:
/tool/traffic-generator/packet-template/set [find]Running set without parameters triggers MAC address re-resolution.
Stream Configuration
Section titled “Stream Configuration”Streams define traffic flows: which template to use, at what rate, and with what packet size.
Create a Stream
Section titled “Create a Stream”/tool/traffic-generator/stream/add \ name=stream1 \ num=0 \ port=port0 \ tx-template=test-template \ mbps=500 \ packet-size=1400Stream ID Requirement
Each stream must have a unique num value (0-15). This identifier tracks packets for statistics collection.
Variable Packet Size
Section titled “Variable Packet Size”Test with random packet sizes in a range:
/tool/traffic-generator/stream/add \ name=variable-stream \ num=1 \ port=port0 \ tx-template=test-template \ mbps=100 \ packet-size=64-1500View Streams
Section titled “View Streams”/tool/traffic-generator/stream/printRunning Tests
Section titled “Running Tests”Quick Mode Test
Section titled “Quick Mode Test”Run an immediate test with inline parameters:
/tool/traffic-generator/quick interface=ether1 mbps=100 packet-size=1400 duration=30sOutput displays real-time statistics until the test completes.
Start Persistent Test
Section titled “Start Persistent Test”/tool/traffic-generator/startStop Test
Section titled “Stop Test”/tool/traffic-generator/stopCheck Running Status
Section titled “Check Running Status”/tool/traffic-generator/printExample output:
latency-distribution-max: 100us measure-out-of-order: no stats-samples-to-keep: 100 test-id: 0 latency-distribution-measure-interval: 1ms600us latency-distribution-samples: 16 running: yesStatistics Collection
Section titled “Statistics Collection”When not using quick mode, statistics are stored for analysis.
View Stream Statistics
Section titled “View Stream Statistics”/tool/traffic-generator/stats/stream/printExample output:
SEQ NUM TX-PACKET TX-RATE RX-PACKET RX-RATE LOST-PACKET LOST-RATE 0 0 1000000 500Mbps 999998 499.9Mbps 2 0.0002%TOT 0 1000000 500Mbps 999998 499.9Mbps 2 0.0002%View Latency Distribution
Section titled “View Latency Distribution”/tool/traffic-generator/stats/latency-distribution/printExample output:
# LATENCY COUNT SHARE GRAPH0 0-15.5us 0 0%1 15.5us-31us 1234 12.3% ************2 31us-46.5us 5678 56.8% ********************************************************3 46.5us-62us 2345 23.5% ***********************4 62us-77.5us 743 7.4% *******View Port Statistics
Section titled “View Port Statistics”/tool/traffic-generator/stats/port/printClear Statistics
Section titled “Clear Statistics”/tool/traffic-generator/stats/stream/resetCommon Scenarios
Section titled “Common Scenarios”Scenario: Test Router Forwarding Performance
Section titled “Scenario: Test Router Forwarding Performance”Set up two-port traffic flow to test packet forwarding:
Topology:
[Traffic Gen] ether1 ───▶ [DUT] ───▶ ether2 [Traffic Gen]Configuration:
# Create ports/tool/traffic-generator/port/add interface=ether1 name=port0/tool/traffic-generator/port/add interface=ether2 name=port1
# Create templates (traffic flows both directions)/tool/traffic-generator/packet-template/add \ name=to-dut \ header-stack=mac,ip,udp \ ip-src=192.168.1.100/32 \ ip-dst=192.168.2.100/32 \ ip-gateway=192.168.1.1 \ port=port0
/tool/traffic-generator/packet-template/add \ name=from-dut \ header-stack=mac,ip,udp \ ip-src=192.168.2.100/32 \ ip-dst=192.168.1.100/32 \ ip-gateway=192.168.2.1 \ port=port1
# Create bidirectional streams/tool/traffic-generator/stream/add name=outbound num=0 port=port0 \ tx-template=to-dut mbps=500 packet-size=1400/tool/traffic-generator/stream/add name=inbound num=1 port=port1 \ tx-template=from-dut mbps=500 packet-size=1400
# Run test/tool/traffic-generator/quick duration=60sScenario: Test IPsec Tunnel Performance
Section titled “Scenario: Test IPsec Tunnel Performance”Measure throughput through an encrypted tunnel.
R1 (Gateway 1):
/ip/address/add address=192.168.33.1/30 interface=ether1/ip/address/add address=1.1.1.2/24 interface=ether2
/ip/ipsec/peer/add address=192.168.33.2 secret=mypassword/ip/ipsec/policy/add sa-src-address=192.168.33.1 sa-dst-address=192.168.33.2 \ src-address=1.1.1.0/24 dst-address=2.2.2.0/24 tunnel=yesR2 (Gateway 2):
/ip/address/add address=192.168.33.2/30 interface=ether1/ip/address/add address=2.2.2.2/24 interface=ether2
/ip/ipsec/peer/add address=192.168.33.1 secret=mypassword/ip/ipsec/policy/add sa-src-address=192.168.33.2 sa-dst-address=192.168.33.1 \ src-address=2.2.2.0/24 dst-address=1.1.1.0/24 tunnel=yesTraffic Generator (connected to both gateway internal interfaces):
/tool/traffic-generator/port/add interface=ether2 name=port0/tool/traffic-generator/port/add interface=ether3 name=port1
/tool/traffic-generator/packet-template/add \ header-stack=mac,ip,udp \ ip-dst=2.2.2.1/32 ip-gateway=1.1.1.2 ip-src=1.1.1.1/32 \ name=tunnel-out port=port0
/tool/traffic-generator/packet-template/add \ header-stack=mac,ip,udp \ ip-dst=1.1.1.1/32 ip-gateway=2.2.2.2 ip-src=2.2.2.1/32 \ name=tunnel-in port=port1
/tool/traffic-generator/stream/add name=encrypted-out num=0 \ port=port0 tx-template=tunnel-out mbps=450 packet-size=1450/tool/traffic-generator/stream/add name=encrypted-in num=1 \ port=port1 tx-template=tunnel-in mbps=450 packet-size=1450
/tool/traffic-generator/quick duration=30sScenario: Latency Measurement
Section titled “Scenario: Latency Measurement”Test network latency with small packets at low rate:
/tool/traffic-generator/set latency-distribution-max=1ms measure-out-of-order=yes/tool/traffic-generator/quick interface=ether1 pps=1000 packet-size=64 duration=60sReview latency distribution after test:
/tool/traffic-generator/stats/latency-distribution/printScenario: Inject PCAP File
Section titled “Scenario: Inject PCAP File”Replay captured traffic from a PCAP file (RouterOS 7.21+):
/tool/traffic-generator/inject-pcap file=capture.pcapng interface=ether1Global Settings
Section titled “Global Settings”Configure global Traffic Generator behavior:
/tool/traffic-generator/set \ latency-distribution-max=100us \ measure-out-of-order=yes \ stats-samples-to-keep=1000 \ test-id=1| Setting | Description |
|---|---|
latency-distribution-max | Maximum latency range for distribution buckets |
measure-out-of-order | Enable OOO packet detection (CPU-intensive on multi-core) |
stats-samples-to-keep | Number of sample records to retain |
test-id | Identifier for distinguishing multiple tests |
Verification
Section titled “Verification”Check 1: Verify Feature Is Enabled
Section titled “Check 1: Verify Feature Is Enabled”/system/device-mode/printLook for traffic-gen in the enabled features.
Check 2: Verify Port Configuration
Section titled “Check 2: Verify Port Configuration”/tool/traffic-generator/port/printExpected: Ports listed without I (inactive) flag.
Check 3: Verify Template MAC Resolution
Section titled “Check 3: Verify Template MAC Resolution”/tool/traffic-generator/packet-template/print detailCheck assumed-mac-dst has a valid MAC address, not 00:00:00:00:00:00.
Check 4: Run Quick Test
Section titled “Check 4: Run Quick Test”/tool/traffic-generator/quick interface=ether1 mbps=10 duration=5sExpected: Statistics display showing TX and RX counters incrementing.
Troubleshooting
Section titled “Troubleshooting”| Symptom | Cause | Solution |
|---|---|---|
| ”traffic generator is disabled” | Feature locked in device-mode | Enable via /system/device-mode/update traffic-gen=yes with reset button |
| No RX packets | Packets not returning | Verify routing, check topology, ensure return path exists |
assumed-mac-dst is 00:00:00:00:00:00 | ARP not resolved | Set ip-gateway or verify destination is reachable |
| High packet loss | Interface saturated or DUT overloaded | Reduce mbps/pps rate; check DUT CPU |
| Out-of-order not measured | Disabled by default on multi-core | Enable with measure-out-of-order=yes |
| Cannot capture generated packets | By design limitation | Use separate sniffer device on the wire |
| Template errors | Invalid header-stack combination | UDP requires IP; VLAN follows MAC only |
| Inconsistent results | Other traffic on test path | Isolate test network; test during maintenance |
Debug: Check CPU During Test
Section titled “Debug: Check CPU During Test”/system/resource/printHigh CPU (>90%) indicates the traffic generator or DUT is the bottleneck.
Debug: Verify Routing Path
Section titled “Debug: Verify Routing Path”/ip/route/print where dst-address~"10.0.0"Ensure routes exist for both source and destination networks.
Debug: Check Interface Errors
Section titled “Debug: Check Interface Errors”/interface/ethernet/print statsLook for TX/RX errors, drops, or FCS errors.
Common Mistakes
- Forgetting return path - Traffic Generator needs packets to return for statistics; ensure bidirectional routing
- Using single interface - Proper testing requires at least two interfaces (TX and RX)
- Stream ID conflicts - Each stream must have a unique
numvalue (0-15) - Testing on production networks - Can saturate links; use isolated test networks
- Assuming packets reach firewall - Generated packets bypass local firewall on TX interface
- Not updating MACs after topology change - Run
seton templates to refresh assumed values
Related Topics
Section titled “Related Topics”Performance Testing
Section titled “Performance Testing”- Bandwidth Test - point-to-point throughput testing
- Speed Test - comprehensive performance testing
- Profile - CPU profiling for performance analysis
Traffic Analysis
Section titled “Traffic Analysis”- Torch - real-time traffic analysis
- Packet Sniffer - capture network traffic
- Traffic Monitor - interface statistics
Network Configuration
Section titled “Network Configuration”- Firewall Basics - allow generated traffic
- Simple Queues - test QoS configurations
Reference
Section titled “Reference”Global Properties (/tool/traffic-generator)
Section titled “Global Properties (/tool/traffic-generator)”| Property | Type | Default | Description |
|---|---|---|---|
latency-distribution-max | time | 100us | Maximum latency range for distribution |
measure-out-of-order | yes/no | CPU-dependent | Enable OOO detection |
stats-samples-to-keep | integer | 100 | Statistics samples retained |
test-id | integer [0..255] | 0 | Test identifier |
Port Properties (/tool/traffic-generator/port)
Section titled “Port Properties (/tool/traffic-generator/port)”| Property | Type | Default | Description |
|---|---|---|---|
name | string | - | Port identifier |
interface | string | - | Associated interface |
disabled | yes/no | no | Disable port |
Packet Template Properties (/tool/traffic-generator/packet-template)
Section titled “Packet Template Properties (/tool/traffic-generator/packet-template)”| Property | Type | Default | Description |
|---|---|---|---|
name | string | - | Template identifier |
header-stack | list | ip | Header sequence: mac, vlan, ip, udp, raw |
port | string | - | Associated port |
interface | string | - | Direct interface (creates dynamic port) |
ip-src | IP/Mask | - | Source IP address |
ip-dst | IP/Netmask | - | Destination IP address |
ip-gateway | IP | - | Next-hop for routing |
ip-ttl | integer [0..255] | - | Time-to-live |
ip-dscp | integer [0..255] | - | DSCP value |
ip-protocol | protocol | - | IP protocol |
mac-src | MAC | - | Source MAC address |
mac-dst | MAC | - | Destination MAC address |
udp-src-port | integer [0..65535] | - | Source UDP port |
udp-dst-port | integer [0..65535] | - | Destination UDP port |
vlan-id | integer | - | VLAN identifier |
vlan-priority | integer | - | VLAN priority |
data | uninitialized/specific-byte/incrementing/random | uninitialized | Payload fill method |
data-byte | hex [0..FF] | 0 | Byte for specific-byte fill |
Stream Properties (/tool/traffic-generator/stream)
Section titled “Stream Properties (/tool/traffic-generator/stream)”| Property | Type | Default | Description |
|---|---|---|---|
name | string | - | Stream identifier |
num | integer [0..15] | 0 | Unique stream number |
disabled | yes/no | no | Disable stream |
port | string | - | Associated port |
tx-template | string | - | Packet template reference |
mbps | integer | 0 | Target rate in Mbps |
pps | integer | 0 | Target rate in packets/sec |
packet-size | integer or range | 0 | Packet size (supports ranges like 64-1500) |
Quick Mode Parameters
Section titled “Quick Mode Parameters”| Parameter | Type | Description |
|---|---|---|
interface | string | Interface for quick test |
mbps | integer | Target rate in Mbps |
pps | integer | Target rate in packets/sec |
packet-size | integer | Packet size |
duration | time | Test duration |
tx-template | string | Template to use |
stream | string | Stream to use |
Commands
Section titled “Commands”| Command | Description |
|---|---|
quick | Run interactive test with terminal output |
start | Start background test |
stop | Stop running test |
inject | Inject raw data into interface |
inject-pcap | Inject from PCAP file (v7.21+) |