Skip to content

Tcpreplay

50 commands

Replays captured pcap traffic onto a network at chosen speeds — useful for testing IDS rules and network devices.

  • pcap
  • replay
  • testing

Install Tcpreplay

sudo apt install tcpreplay

General Information2

tcpreplay -V

Displays the version of tcpreplay installed and the compilation options used.

tcpreplay -h

Prints the help screen with a summary of available commands and flags.

Interface Selection1

tcpreplay --list-nics

Lists available network interfaces and their capture methods to verify hardware visibility.

Basic Replay2

tcpreplay -i eth0 capture.pcap

Replays packets from the specified pcap file onto the interface eth0 at the speed recorded in the file.

tcpreplay --intf1=wlan0 capture.pcap

Replays traffic onto a wireless interface using the long-form flag for clarity.

Replay Speed Control3

tcpreplay -i eth0 -t capture.pcap

Replays traffic at 'topspeed', ignoring packet timing to send as fast as the hardware allows.

tcpreplay -i eth0 -x 2.0 capture.pcap

Replays traffic at exactly 2.0 times the speed of the original capture speed.

tcpreplay -i eth0 -x 0.5 capture.pcap

Replays traffic in slow motion at half the original capture speed.

Link

Packet Rate Limiting1

tcpreplay -i eth0 -p 50 capture.pcap

Replays traffic at a constant rate of 50 packets per second, overriding original timing.

Bandwidth Limiting1

tcpreplay -i eth0 -M 10.0 capture.pcap

Limits the replay traffic throughput to 10.0 Megabits per second.

Preload and Caching2

tcpreplay -i eth0 -K capture.pcap

Preloads the entire pcap file into RAM before sending to improve performance and reduce disk I/O.

Link
tcpreplay -i eth0 --preload-pcap capture.pcap

Long-form command to load the file into memory before starting the replay.

Link

Looping and Continuous3

tcpreplay -i eth0 -l 0 capture.pcap

Replays the capture file in an infinite loop until manually stopped.

Link
tcpreplay -i eth0 --loop=5 capture.pcap

Replays the capture file exactly 5 times and then exits.

Link
tcpreplay -i eth0 -l 0 --loopdelay-ms=1000 capture.pcap

Loops infinitely with a 1000 millisecond (1 second) pause between each iteration.

Link

Stats and Reporting2

tcpreplay -i eth0 --stats=1 capture.pcap

Prints replay statistics to the console every 1 second during execution.

Link
tcpreplay -i eth0 -S capture.pcap

Wait for enter key before starting, then print statistics during replay.

Link

Packet Count Limiting1

tcpreplay -i eth0 -L 100 capture.pcap

Stops the replay immediately after sending the first 100 packets.

Link

Timing Preservation1

tcpreplay -i eth0 --duration=10 capture.pcap

Limits the total execution time to 10 seconds, regardless of how many packets are sent.

Link

Verbose and Debug2

tcpreplay -i eth0 -v capture.pcap

Enables verbose mode, printing decoded packet headers to STDOUT (similar to tcpdump) while replaying.

Link
tcpreplay -i eth0 -A "n,v,x" -v capture.pcap

Enables verbose mode using specific tcpdump args (numeric, verbose, hex) for the decoder.

Link

Quiet Output1

tcpreplay -i eth0 -q capture.pcap

Runs in quiet mode, suppressing non-error output (useful for scripts).

Link

Flow Modification3

tcpreplay -i eth0 --unique-ip capture.pcap

Modifies IP addresses per loop iteration to ensure each flow appears unique to network devices.

Link
tcpreplay -i eth0 --unique-ip-loops=5 capture.pcap

Loops traffic, modifying IP addresses to create unique flows for 5 iterations.

Link
tcpreplay -i eth0 --unique-ip --netmap capture.pcap

Combines unique IP generation with netmap detection for high-performance unique flow generation.

Link

Dual Interface Replay2

tcpreplay -i eth0 -I eth1 --cachefile=split.cache capture.pcap

Splits traffic between two interfaces (client/server) based on a tcpprep cache file.

Link
tcpreplay --intf1=eth0 --intf2=eth1 --cachefile=split.cache capture.pcap

Long-form command to split traffic bi-directionally between eth0 and eth1 using a cache.

Link

Advanced Timing5

tcpreplay -i eth0 -1 capture.pcap

Sends one packet at a time, waiting for a user keypress before sending the next.

Link
tcpreplay -i eth0 --timer=gtod capture.pcap

Uses the 'gettimeofday' system call for packet timing, which provides microsecond compatibility.

Link
tcpreplay -i eth0 --timer=nano capture.pcap

Uses the 'nanosleep' API for high-precision packet timing delays.

Link
tcpreplay -i eth0 --maxsleep=500 capture.pcap

Forces pauses between packets to never exceed 500 milliseconds, effectively compressing long idle gaps.

Link
tcpreplay -i eth0 --sleep-accel=2 capture.pcap

Reduces the amount of time slept by 2 microseconds per packet to compensate for system latency.

Link

IDS and IPS Testing1

tcpreplay -i eth0 -t -K --loop=0 capture.pcap

Stress tests an IDS by preloading the pcap and looping at maximum hardware speed.

Link

Red Team Simulation2

tcpreplay -i eth0 -p 1 -l 0 capture.pcap

Sends a 'Low and Slow' attack simulation by sending only 1 packet per second continuously.

Link
tcpreplay -i eth0 --unique-ip --mbps=500 capture.pcap

Simulates a DDoS attack or botnet by generating high bandwidth traffic with constantly changing IP addresses.

Link

Blue Team Detection1

tcpreplay -i eth0 -x 1.0 capture.pcap

Replays an attack capture at exactly real-time speed to verify if the SIEM/IDS triggers correctly.

Link

Network Troubleshooting1

tcpreplay -i eth0 -M 1000.0 -l 60 capture.pcap

Loads the link with 1Gbps of traffic for 60 loops to test throughput stability.

Link

MTU Handling2

tcpreplay -i eth0 --mtu=1500 capture.pcap

Specifies the Maximum Transmission Unit size to 1500 bytes for the replay interface.

Link
tcpreplay -i eth0 --mtu-trunc capture.pcap

Truncates packets that exceed the specified MTU size rather than skipping them.

Link

Error Handling2

tcpreplay -i eth0 --no-arg-check capture.pcap

Disables the validation of arguments, allowing execution even if settings seem conflicting.

Link
tcpreplay -i eth0 --skip-soft-errors capture.pcap

Continues replaying packets even if minor errors occur (e.g., failed to send a specific packet).

Link

Netmap/AF_XDP High Speed1

tcpreplay -i netmap:eth0 -t -K capture.pcap

Uses the netmap driver (if supported) for ultra-high-speed packet injection.

Link

Verbosity1

tcpreplay -i eth0 --verbose --decode="len=10" capture.pcap

Replays with verbose output but passes arguments to the decoder to limit length.

Link

Looping1

tcpreplay -i eth0 --loop=100 --loopdelay-ms=10 capture.pcap

Runs 100 loops with a very short 10ms gap between loops to maintain near-continuous pressure.

Link

Bandwidth1

tcpreplay -i eth0 --mbps=0.1 capture.pcap

Replays traffic at a very low rate of 100Kbps (0.1 Mbps) to test timeouts.

Link

PPS Control1

tcpreplay -i eth0 --pps=20000 capture.pcap

Injects packets at a high rate of 20,000 packets per second regardless of packet size.

Link

Timing1

tcpreplay -i eth0 --timer=rdtsc capture.pcap

Uses the CPU cycle counter (RDTSC) for the highest possible timing precision on supported CPUs.

Link

Packet Selection1

tcpreplay -i eth0 --limit=1 capture.pcap

Sends strictly the first packet of the capture file and then exits immediately.

Link

Performance Tuning1

tcpreplay -i eth0 --preload-pcap --quiet capture.pcap

A high-performance script-friendly mode that preloads data and suppresses output.

Link

Advanced Combined1

tcpreplay -i eth0 --mbps=100 --loop=0 --unique-ip --stats=5 capture.pcap

A complex scenario: infinite loop, unique IPs, 100Mbps limit, with stats printed every 5 seconds.

Link