PortDock

Capturing PLC traffic with Wireshark or pktmon: port mirroring, admin rights, switch limits

Save HMI–PLC Modbus TCP or MC traffic with Wireshark or the built-in pktmon: why a switch hides it, port mirroring, taps, admin rights, pktmon commands.

Tools for this guideTCP Windows program · freeModbus Master Windows program · freeIndustrial pcap Analyzer web · no installModbus Frame Decoder web · no install

When device communication drops or slows down now and then, saving the packets to a file (.pcapng) lets you look at response times, missing replies and exception codes calmly afterwards. This guide is about recording your own equipment's traffic for monitoring, testing and troubleshooting. On a company network, get permission from whoever runs it first.

1. Where can you capture — the switch limit

Ethernet today is almost always switched. A switch forwards unicast frames only to the port where that address lives, so a laptop on the same switch running Wireshark will not see traffic between the HMI and the PLC (Wireshark wiki). It sees only its own traffic and broadcasts.

Capture whereWhat you seeWhat you need
The communicating PC itself (your program ⇄ device)That PC's trafficWireshark or pktmon on that PC, admin rights
A managed switch mirror port (SPAN)A copy of the chosen ports' trafficAccess to the switch settings, a mirror port at least as fast as the monitored port
A network tapBoth directions of that cableA tap, and a short break in the cable to insert it
An old (repeater) hubEverything on the hubA hub — full-duplex links drop to half duplex, which affects performance
PortDock TCP «Relay»TCP connections you route through this PCPoint the HMI at this PC; no admin rights or driver

A mirror port slower than the monitored port loses packets, and heavy traffic can cause capture loss too (Wireshark wiki). So a request that looks unanswered in a capture may in fact have been answered.

2. Capturing with Wireshark

3. Without installing anything — the built-in pktmon

pktmon is built into Windows from Windows 10 2004 (build 19041). Run it from an elevated prompt (PowerShell «Run as administrator»); without admin rights it stops with an «Access is denied» error about the PktMon driver.

pktmon filter add -p 502
pktmon start --capture --comp nics --pkt-size 0
(wait until the problem happens)
pktmon stop
pktmon etl2pcap PktMon.etl --out plc.pcapng
pktmon filter remove

4. Setting up switch mirroring

5. PortDock TCP relay — no mirror port or driver

If the HMI (or a PC program) connects to the PLC's address, change only the HMI's target to «this PC's IP:port» and run PortDock TCP in «Relay» mode: the PC passes the bytes through unchanged and logs both directions. No driver or mirror port is needed, and installing and running it needs no admin rights. For another PC or the HMI to connect to this PC, though, the Windows Firewall prompt that appears the first time the relay listens may need administrator approval; and since you change a device setting, use it on a test setup or during maintenance. With «Save as pcap» on, the relay writes only to the file you choose and sends nothing out.

6. Looking at the file

Open it in Wireshark, or drop it on the PortDock web tool «Industrial pcap Analyzer» to get Modbus TCP and MC 3E/4E request/response pairs, response times (min, median, 95%, max), missing replies and exception/end codes per connection and device. The file is processed only in that browser and never uploaded. How to read the results is in «Reading Modbus response times from a capture».

A pcap file also holds other traffic on the same network (web, file sharing …) and IP and MAC addresses. Before sending one to someone, export only the ports they need.

Wireshark is a trademark of the Wireshark Foundation; PortDock is not affiliated with Wireshark or Microsoft.

Sources

Published 2026-10-31