A capture taken on one network rarely has the addresses your lab DUT expects. Before you replay it, you need the frames to use the lab IP and MAC addresses, with checksums that still verify. Pcap Workbench Web Community 1.8.10 does that offline, from the Recipes tab, with two tools: NAT rewrite and MAC rewrite. Both replace the source and/or destination with a literal you type — they are not a CIDR map. On a request/reply capture you therefore rewrite each direction separately, using Selected packets / ranges.

The six-packet teaching file below is small enough that the Community 10-packet write cap does not get in the way. This article walks through a five-step recipe that maps documentation addresses onto a lab pair, then shows two leftovers the tools do not touch: the DNS A record and the ARP body.

Try it yourself in the browser Download the input PCAP

What is in the file

rewrite-lab-input.pcap is an Ethernet capture between two hosts in the documentation prefix 192.0.2.0/24 (RFC 5737). 192.0.2.10 (02:00:00:00:00:0a) talks to 192.0.2.20 (02:00:00:00:00:14), which also answers DNS on port 53. Timestamps start at 0.

No. Time (s) Protocol Length Content
10.000ICMP61Echo request, 192.0.2.10 → 192.0.2.20, seq 1
20.001ICMP61Echo reply, 192.0.2.20 → 192.0.2.10, seq 1
30.010DNS75Query 0x1234 A dut.lab.example, 53000 → 53
40.011DNS106Response 0x1234, A 192.0.2.20
50.100ICMP61Echo request, seq 2
60.200ARP42who-has 192.0.2.20 says 192.0.2.10, Ethernet dest broadcast

tshark 4.4 reports no expert warnings on this file, and the IP and UDP checksums verify as good. The web edition ships no demo captures, so this is the file the article publishes.

The intended lab mapping is:

Role Original IP / MAC Lab IP / MAC
Host (source of requests)192.0.2.10 / 02:00:00:00:00:0a198.51.100.10 / 02:00:00:00:aa:0a
DUT (replies, also DNS)192.0.2.20 / 02:00:00:00:00:14198.51.100.20 / 02:00:00:00:aa:14

Why you cannot rewrite every packet the same way

NAT rewrite replaces the IPv4 or IPv6 source and/or destination with the literals you type, on every selected packet of that IP version. It is not a prefix-preserving map (the kind tcprewrite --pnat does). Leave a field empty to keep it unchanged. The same is true of MAC rewrite for the Ethernet source and/or destination.

If you set New source IP to 198.51.100.10 and New destination IP to 198.51.100.20 with Packets left on All relevant packets, every IPv4 packet in this file becomes 198.51.100.10 → 198.51.100.20 — including the replies. In that check the tool reported rewritten packets: 5, skipped: 1. The skip is the ARP request, which has no IP header. The Ethernet addresses are also unchanged in that run, because NAT rewrite does not touch them.

A request/reply capture therefore needs Selected packets / ranges: one NAT step (and one MAC step) for the packets that originally went 10 → 20, and a second pair of steps that swap the lab addresses for the replies. That is the recipe below.

Try it yourself: rewrite both directions

These steps were run on the public Web Community 1.8.10 page at packetbuilder.net/pcap-workbench-web/.

  1. Open the page and wait until the status at the bottom right says Ready. The badge in the top right should read Web Community 1.8.10.
  2. In the Packet editor tab, click Open capture and choose rewrite-lab-input.pcap. The summary should read 6 of 6 packets shown. The list shows three ICMP rows at length 61, two DNS rows at 75 and 106, and an ARP row at 42. Select packet 1: Protocol view shows eth.src 02:00:00:00:00:0a, eth.dst 02:00:00:00:00:14, ip.src 192.0.2.10, and ip.dst 192.0.2.20.

Pcap Workbench Packet editor with rewrite-lab-input.pcap open. The summary reads 6 of 6 packets shown. Packet 1 is selected; Protocol view shows ip.src 192.0.2.10 and ip.dst 192.0.2.20.

  1. Open Recipes (the Recipes button in the toolbar, or the PCAP tools tab, which starts on the Recipes subtab). The hint on that page says tools are chained as a recipe and that each step writes an intermediate capture that the next step reads.
  2. Build the five steps below. For each one, choose the tool in the list, click + Add step, set Packets to Selected packets / ranges (that reveals the Packet numbers / ranges field; the help under it says Example: 1,3-7,12), and fill the addresses. Leave port fields and any unused MAC field empty.
Step Tool Packet numbers / ranges New source New destination
1NAT rewrite1,3,5198.51.100.10198.51.100.20
2NAT rewrite2,4198.51.100.20198.51.100.10
3MAC rewrite1,3,502:00:00:00:aa:0a02:00:00:00:aa:14
4MAC rewrite2,402:00:00:00:aa:1402:00:00:00:aa:0a
5MAC rewrite602:00:00:00:aa:0a(empty — keep broadcast)

Step 5 only changes the Ethernet source of the ARP request. Its destination stays ff:ff:ff:ff:ff:ff. The help under the MAC fields says “Empty = unchanged.”

Pcap Workbench Recipes tab with a five-step recipe: two NAT rewrite steps for packets 1,3,5 and 2,4, two MAC rewrite steps for the same ranges, and a fifth MAC rewrite of packet 6 that sets only the source MAC.

  1. Click the blue Run recipe button. Recipes use the capture that is open in the Packet editor; if none is open, the page asks you to open one first.

The Result panel should show exit code 0 and a Download out.pcap link. The stdout is JSON from the Community runner. In this run it reported packets_in 6, packets_processed 6, community_limited false, packets_out 6, and these step results:

  • NAT rewrite: rewritten packets: 3, skipped: 0
  • NAT rewrite: rewritten packets: 2, skipped: 0
  • MAC rewrite: rewritten packets: 3
  • MAC rewrite: rewritten packets: 2
  • MAC rewrite: rewritten packets: 1

Pcap Workbench Result panel after the five-step rewrite recipe. Exit code 0, community_limited false, packets_processed 6, five rewritten-packets results, and a Download out.pcap link.

Open the downloaded file — or the published copy rewrite-lab-output.pcap — in the Packet editor. The summary is still 6 of 6 packets shown. Select packet 1: Protocol view now shows eth.src 02:00:00:00:aa:0a, eth.dst 02:00:00:00:aa:14, ip.src 198.51.100.10, and ip.dst 198.51.100.20. The IPv4 header checksum is 0x2648 (it was 0xf6ae on the input). The ICMP checksum stays 0x3730, which is expected: the ICMP checksum does not cover the IP addresses.

Packet editor opened on rewrite-lab-output.pcap. Packet 1 is selected. Protocol view shows eth.src 02:00:00:00:aa:0a, ip.src 198.51.100.10, ip.dst 198.51.100.20, and ip.checksum 0x2648.

What the tools leave alone

Select DNS packet 4 in the output. The IP addresses in the header are the lab pair (198.51.100.20 → 198.51.100.10), but dns.an.rdata is still 192.0.2.20. NAT rewrite changes the IP and (if you fill them) TCP/UDP ports; it does not edit DNS records, and the query name dut.lab.example is also unchanged.

Packet editor on the rewritten output, DNS packet 4 selected. Protocol view shows ip.src 198.51.100.20 and ip.dst 198.51.100.10, while dns.an.rdata is still 192.0.2.20.

Select ARP packet 6. eth.src is the new lab MAC 02:00:00:00:aa:0a and eth.dst is still broadcast. The ARP body is untouched: arp.src.hw_mac is still 02:00:00:00:00:0a, arp.src.proto_ipv4 is still 192.0.2.10, and arp.dst.proto_ipv4 is still 192.0.2.20. MAC rewrite only writes the Ethernet source and destination; NAT rewrite skips non-IP packets.

Packet editor on the rewritten output, ARP packet 6 selected. Ethernet source is 02:00:00:00:aa:0a and destination is still ff:ff:ff:ff:ff:ff, while arp.src.hw_mac is 02:00:00:00:00:0a and arp.src.proto_ipv4 is 192.0.2.10.

Those leftovers matter if you later replay the file: a resolver that honours the A record, or a stack that reads the ARP payload, still sees the original documentation addresses. Verify the output, including application payloads and ARP, before you send it. For a sanitize-and-share workflow rather than a lab remap, see anonymize a PCAP before you share it. Sending the rewritten file is a separate step; see replay a PCAP to a lab device.

Verify with tshark

On the published output, tshark 4.4 with IPv4 and UDP checksum checking reports status 1 (good) for every IP and UDP checksum. Packet 4 still lists A 192.0.2.20, and packet 6 still lists the original ARP addresses:

tshark -r rewrite-lab-output.pcap -T fields \
  -e frame.number -e eth.src -e eth.dst -e ip.src -e ip.dst \
  -e ip.checksum.status -e udp.checksum.status \
  -e dns.a -e arp.src.hw_mac -e arp.src.proto_ipv4 -e arp.dst.proto_ipv4 \
  -o ip.check_checksum:TRUE -o udp.check_checksum:TRUE

You can also open your downloaded out.pcap next to the published output in the Compare tab to confirm they match.

Editions and limits

Recipes that write a capture are subject to the Community 10-packet write cap. This teaching file has six packets, so the runner reported community_limited: false and processed the whole file. On a larger input, Community sees only the first 10 packets of each writing step. Compare, by contrast, is read-only and is not capped that way; see How to Compare Two PCAP Files.

The help under the IP fields says an empty value leaves that address unchanged, and that the literal is an IPv4 or IPv6 address. An IPv4 literal applies only to IPv4 packets: a side check with one IPv4 packet and one IPv6 packet reported rewritten packets: 1, skipped: 1, and the IPv6 addresses were left unchanged. The port fields, whose help says “0-65535, TCP/UDP only,” were left empty in the published recipe. A separate one-packet check that set New destination port to 5353 on the DNS query rewrote that UDP port and left a valid UDP checksum; TCP was not used in these files.

This walk-through was verified in the web edition. The same recipe tools are in the desktop app; that UI was not used here.

Related

Companion articles: How to Compare Two PCAP Files — open the published lab output next to your own recipe output and confirm they match — and How to Truncate and Split a PCAP like editcap.

Other Pcap Workbench guides in this series:

Earlier articles on related workflows: replay a PCAP to a lab device (the send step after this offline rewrite), anonymize a PCAP before you share it, edit a PCAP without breaking checksums, build a PCAP regression set with PASS/FAIL checks, and strip VLAN tags or decapsulate GTP-U.

Try it yourself in the browser Input PCAP Rewritten PCAP Input PCAPNG