Skip to content
MikroTik RouterOS Docs

Traffic Generator

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=1400

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.

Traffic Generator uses three main components:

  1. Ports - Associate interfaces with TX/RX operations
  2. Packet Templates - Define packet structure (headers, IPs, ports)
  3. 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: Single command that starts, runs, and displays results interactively. Best for ad-hoc testing.

/tool/traffic-generator/quick interface=ether1 mbps=100

Persistent mode: Configure components separately, start/stop as needed, statistics stored for later analysis.

/tool/traffic-generator/start
# ... test runs in background ...
/tool/traffic-generator/stop

Associate interfaces with Traffic Generator before creating templates.

/tool/traffic-generator/port/add interface=ether1 name=port0
/tool/traffic-generator/port/print

Expected output:

Flags: X - DISABLED; D - DYNAMIC; I - INACTIVE
Columns: NAME, INTERFACE, FIRST-HEADER
# NAME INTERFACE FIRST-HEADER
0 port0 ether1 mac
/tool/traffic-generator/port/set port0 disabled=yes

Define what packets look like using templates. Each template specifies headers, addresses, and payload.

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=port0
/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=port0
/tool/traffic-generator/packet-template/print

When network topology changes, update automatically determined values:

/tool/traffic-generator/packet-template/set [find]

Running set without parameters triggers MAC address re-resolution.

Streams define traffic flows: which template to use, at what rate, and with what packet size.

/tool/traffic-generator/stream/add \
name=stream1 \
num=0 \
port=port0 \
tx-template=test-template \
mbps=500 \
packet-size=1400

Stream ID Requirement

Each stream must have a unique num value (0-15). This identifier tracks packets for statistics collection.

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-1500
/tool/traffic-generator/stream/print

Run an immediate test with inline parameters:

/tool/traffic-generator/quick interface=ether1 mbps=100 packet-size=1400 duration=30s

Output displays real-time statistics until the test completes.

/tool/traffic-generator/start
/tool/traffic-generator/stop
/tool/traffic-generator/print

Example 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: yes

When not using quick mode, statistics are stored for analysis.

/tool/traffic-generator/stats/stream/print

Example 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%
/tool/traffic-generator/stats/latency-distribution/print

Example output:

# LATENCY COUNT SHARE GRAPH
0 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% *******
/tool/traffic-generator/stats/port/print
/tool/traffic-generator/stats/stream/reset

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=60s

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=yes

R2 (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=yes

Traffic 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=30s

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=60s

Review latency distribution after test:

/tool/traffic-generator/stats/latency-distribution/print

Replay captured traffic from a PCAP file (RouterOS 7.21+):

/tool/traffic-generator/inject-pcap file=capture.pcapng interface=ether1

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
SettingDescription
latency-distribution-maxMaximum latency range for distribution buckets
measure-out-of-orderEnable OOO packet detection (CPU-intensive on multi-core)
stats-samples-to-keepNumber of sample records to retain
test-idIdentifier for distinguishing multiple tests
/system/device-mode/print

Look for traffic-gen in the enabled features.

/tool/traffic-generator/port/print

Expected: Ports listed without I (inactive) flag.

/tool/traffic-generator/packet-template/print detail

Check assumed-mac-dst has a valid MAC address, not 00:00:00:00:00:00.

/tool/traffic-generator/quick interface=ether1 mbps=10 duration=5s

Expected: Statistics display showing TX and RX counters incrementing.

SymptomCauseSolution
”traffic generator is disabled”Feature locked in device-modeEnable via /system/device-mode/update traffic-gen=yes with reset button
No RX packetsPackets not returningVerify routing, check topology, ensure return path exists
assumed-mac-dst is 00:00:00:00:00:00ARP not resolvedSet ip-gateway or verify destination is reachable
High packet lossInterface saturated or DUT overloadedReduce mbps/pps rate; check DUT CPU
Out-of-order not measuredDisabled by default on multi-coreEnable with measure-out-of-order=yes
Cannot capture generated packetsBy design limitationUse separate sniffer device on the wire
Template errorsInvalid header-stack combinationUDP requires IP; VLAN follows MAC only
Inconsistent resultsOther traffic on test pathIsolate test network; test during maintenance
/system/resource/print

High CPU (>90%) indicates the traffic generator or DUT is the bottleneck.

/ip/route/print where dst-address~"10.0.0"

Ensure routes exist for both source and destination networks.

/interface/ethernet/print stats

Look 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 num value (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 set on templates to refresh assumed values

Global Properties (/tool/traffic-generator)

Section titled “Global Properties (/tool/traffic-generator)”
PropertyTypeDefaultDescription
latency-distribution-maxtime100usMaximum latency range for distribution
measure-out-of-orderyes/noCPU-dependentEnable OOO detection
stats-samples-to-keepinteger100Statistics samples retained
test-idinteger [0..255]0Test identifier

Port Properties (/tool/traffic-generator/port)

Section titled “Port Properties (/tool/traffic-generator/port)”
PropertyTypeDefaultDescription
namestring-Port identifier
interfacestring-Associated interface
disabledyes/nonoDisable port

Packet Template Properties (/tool/traffic-generator/packet-template)

Section titled “Packet Template Properties (/tool/traffic-generator/packet-template)”
PropertyTypeDefaultDescription
namestring-Template identifier
header-stacklistipHeader sequence: mac, vlan, ip, udp, raw
portstring-Associated port
interfacestring-Direct interface (creates dynamic port)
ip-srcIP/Mask-Source IP address
ip-dstIP/Netmask-Destination IP address
ip-gatewayIP-Next-hop for routing
ip-ttlinteger [0..255]-Time-to-live
ip-dscpinteger [0..255]-DSCP value
ip-protocolprotocol-IP protocol
mac-srcMAC-Source MAC address
mac-dstMAC-Destination MAC address
udp-src-portinteger [0..65535]-Source UDP port
udp-dst-portinteger [0..65535]-Destination UDP port
vlan-idinteger-VLAN identifier
vlan-priorityinteger-VLAN priority
datauninitialized/specific-byte/incrementing/randomuninitializedPayload fill method
data-bytehex [0..FF]0Byte for specific-byte fill

Stream Properties (/tool/traffic-generator/stream)

Section titled “Stream Properties (/tool/traffic-generator/stream)”
PropertyTypeDefaultDescription
namestring-Stream identifier
numinteger [0..15]0Unique stream number
disabledyes/nonoDisable stream
portstring-Associated port
tx-templatestring-Packet template reference
mbpsinteger0Target rate in Mbps
ppsinteger0Target rate in packets/sec
packet-sizeinteger or range0Packet size (supports ranges like 64-1500)
ParameterTypeDescription
interfacestringInterface for quick test
mbpsintegerTarget rate in Mbps
ppsintegerTarget rate in packets/sec
packet-sizeintegerPacket size
durationtimeTest duration
tx-templatestringTemplate to use
streamstringStream to use
CommandDescription
quickRun interactive test with terminal output
startStart background test
stopStop running test
injectInject raw data into interface
inject-pcapInject from PCAP file (v7.21+)