PCAP Replay
Replays a previously recorded PCAP or PCAPNG capture as if it were a live device. Nothing is sent to a network: the driver connects, and the frames it "receives" come out of the file.
This is a debugging and development transport. It is what lets you work on a driver against a capture taken from a machine you cannot reach, and it pairs naturally with the audit-log - record once, then replay as often as you need.
Transport syntax
{path to the capture}
An absolute path names a file on disk. A path that matches a resource on the classpath is read from there instead and unpacked to a temporary file, which is how the drivers' own tests ship their captures alongside the code.
profinet:pcap-replay:///var/captures/line-3.pcapng?pcap-replay.speed-factor=1.0
| The three slashes are not a typo - two end the transport code, and the third begins the absolute path. |
The capture can also be named with the pcap-replay.pcap-file option instead; the address segment
wins if both name one.
Name |
Type |
Default Value |
Required |
Description |
Name |
PCAP Replay |
|||
Code |
|
|||
Maven Dependency |
<dependency> <groupId>org.apache.plc4x</groupId> <artifactId>plc4j-transports-pcap-replay</artifactId> <version>1.1.0</version> </dependency> |
|||
Config options: |
||||
|
STRING |
Path to the PCAP file to replay. Alternative to naming the capture in the address segment of the connection string, which takes precedence. |
||
|
STRING |
Local MAC address to simulate (acts as this device). |
||
|
STRING |
Remote MAC address to communicate with. |
||
|
INT |
0 |
EtherType / Protocol number to filter (e.g., 0x88B5 for PROFINET). |
|
|
DOUBLE |
0 |
Replay speed multiplier. 1.0 = real-time, 0.0 = as fast as possible, 2.0 = double speed. |
|
|
BOOLEAN |
false |
Loop the PCAP file when it reaches the end. |
|
|
BOOLEAN |
true |
Only replay packets from remote to local (simulates device responses). When false, replays all packets. |
|
|
BOOLEAN |
false |
Only replay packets from local to remote (simulates device requests). |
|
|
INT |
1500 |
Maximum frame size in bytes. |
|
|
INT |
0 |
Read timeout for blocking reads in milliseconds. |
|
|
INT |
1000 |
Buffer size for packet queue. |
|
|
BOOLEAN |
true |
Auto-detect MAC addresses from PCAP file based on first packet. |
|
|
BOOLEAN |
true |
Start replay automatically when transport is created. |
|
|
INT |
0 |
Filter by VLAN ID (0 means no VLAN filtering). |
|
Two options are worth knowing before the first run:
-
pcap-replay.speed-factordefaults to0, which replays the capture as fast as it can be read. Set it to1.0to reproduce the original timing - which is what you want when the bug you are chasing is a timing one. -
pcap-replay.only-incoming-packetsdefaults totrue, so by default only the frames the device sent are replayed and the driver’s own requests go nowhere. That is the right setting for standing in for a device.