Using tcpcopy for Online Traffic Redirection in Performance Testing
This guide explains how to install, configure, and run tcpcopy and its companion intercept tool to redirect live traffic for realistic pressure testing, including command examples, parameter details, Jenkins integration, and common troubleshooting steps.
During performance testing, traditional load generators often produce uniform QPS that does not reflect real‑world traffic; using tcpcopy for online traffic redirection can simulate realistic load. This article introduces the usage of tcpcopy for online traffic redirection.
1. Installation
(1) Install tcpcopy on the target (online) machine (requires root):
git clone git://github.com/session-replay-tools/tcpcopy.git cd tcpcopy ./configure --pcap-capture --pcap-send make && make install # default install path: /usr/local/tcpcopy(2) Install intercept on the auxiliary machine:
git clone git://github.com/session-replay-tools/intercept.git cd intercept/ ./configure make && make install # default install path: /usr/local/intercept(3) Configure routing on the test machine (if the auxiliary and test machines are different):
route add -net 192.168.1.0 netmask 255.255.255.0 gw 172.16.1.24 dev eth02. Start the auxiliary server
intercept -i eth0 -F "tcp and src port 8080" -l /data/log/intercept.log -p 55555 -dParameters:
-i: network interface to listen on
-F: filter expression (enclose in quotes if it contains spaces)
-l: log file path
-p: listening port
-d: run as daemon
3. Start tcpcopy on the online server
tcpcopy -x 38001-TEST_IP:38001 -p 5555 -s AUX_IP -c 192.168.1.x -n 1 -r 100 -M 512 -l /data/log/tcpcopy.log -dKey parameters:
-x: server application port and destination IP:port
-c: replace source IP of packets with one from the provided list
-n: traffic replication factor
-r: percentage of traffic to copy
-M: MTU of sent packets (default 1500 bytes)
-m: memory limit for tcpcopy
-s: list of source IP:port pairs and intercept addresses
-t: timeout (default 120 s, increase for slow or long‑lived connections)
-p: intercept listening port
-l: error log file path
-d: run as daemon
4. Create a Jenkins job for one‑click redirection
Set up a Jenkins pipeline that starts intercept on the auxiliary machine, triggers tcpcopy on the online server, and automatically stops the services after the test completes.
5. Common issues and troubleshooting
"fd is null after session is created" – caused by incorrect routing configuration; ensure the route to the intercept machine is correct.
Test server cannot reach intercept – place both machines in the same subnet.
Test server receives no traffic – check for reverse filtering rules, disable firewalls, and use tcpdump to verify the three‑way handshake.
tcpcopy is simple to use, works well, and supports traffic redirection from multiple source machines by configuring additional intercept instances.
360 Quality & Efficiency
360 Quality & Efficiency focuses on seamlessly integrating quality and efficiency in R&D, sharing 360’s internal best practices with industry peers to foster collaboration among Chinese enterprises and drive greater efficiency value.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.