SkillPilotAI

pktmon

pktmon (Packet Monitor) is the in-box Windows tool for packet capture, drop detection and per-component counters. It is built into Windows 10 1809+ and Server 2019+ (C:\Windows\System32\PktMon.exe), needs an administrator prompt, and logs to an ETL file that converts to text or pcapng. On Linux/macOS tcpdump and tshark do this job.

130.1 Why is it used?

  • Capture on Windows without installing Wireshark/Npcap.
  • See a packet at every layer of the Windows stack, not just at the NIC.
  • Find which component dropped a packet and why (WFP drop, MTU mismatch, Filtered VLAN).
  • Collect ETW events (TCPIP, NDIS) together with packets in one log.

130.2 How it works

pktmon: an eye on every layer of the stack
  1. 1.Browser request enters the TCP/IP stack

  2. 2.Passes the WFP filter (Windows Firewall)

  3. 3.Then the Hyper-V vSwitch and filter drivers

  4. 4.NIC driver sends it out to the network

  5. 5.pktmon copies the packet at every one of these layers into PktMon.etl

  6. 6.So you see up to which layer the packet got

Drop reasons: where did the packet fall?
  1. 1.Request 1 is blocked by a firewall rule at WFP -> 'WFP drop'

  2. 2.Request 2 is dropped at the vSwitch -> 'MTU mismatch'

  3. 3.Request 3 is dropped at the NIC driver -> 'Filtered VLAN'

  4. 4.pktmon counters -t drop -r shows component + reason for each

130.3 Commands overview

  • pktmon help works in a normal prompt; driver commands need admin.
  • This was an office PC, so only read-only commands were run; capture outputs are the examples from the docs.
Output
$ pktmon helppktmon <command> [OPTIONS | help]    Advanced packet capture and event collection.Commands    filter     Manage packet filters.    list       List packet processing components.    start      Start packet capture, counters, and event collection.    stop       Stop data collection.    status     Query current status.    unload     Unload PktMon driver.    counters   Display current packet counters.    reset      Reset packet counters to zero.    etl2txt    Convert log file to text format.    etl2pcap   Convert log file to pcapng format.    hex2pkt    Decode packet in hexadecimal format.    help       Show help text for specific command.
CommandDoesAdmin?
filter add/list/removePacket filters (max 32; a packet must match all conditions of one filter)Yes
list [-a -i --json]Components with IDs (adapters; -a adds filter drivers, vSwitch)Yes
startCapture (-c), events (-t), logging (-f -s -m)Yes
stop / status / reset / unloadEnd + finalize ETL / query / zero counters / unload PktMon.sysYes
countersPer-component Tx/Rx counters, drops with reasonsYes
etl2txt (e2t) / etl2pcap (e2p)Convert the ETL log to text / pcapngNo (file only)
hex2pkt (hex, h2p)Decode a packet given as hexNo

130.4 pktmon filter

  • Add filters before capturing, otherwise the log is very noisy.
  • A packet is reported if it matches all conditions of at least one filter; up to 32 filters.
  • In a normal prompt the driver answers 'Access is denied' (exit code 5).
PowerShell
pktmon filter add -i 192.168.150.20 -t ICMPpktmon filter add Web -p 443pktmon filter add Syn -t TCP SYN -p 445pktmon filter listpktmon filter remove
Output
$ pktmon filter add help    Add a filter to control which packets are reported. For a packet to be    reported, it must match all conditions specified in at least one filter.    Up to 32 filters can be active at once.$ pktmon filter listFailed to communicate with the PktMon driver: Access is denied.[exit code 5]
Filter optionMatches
-m mac [mac2]Source/destination MAC
-v 100 / -d IPv4|IPv6|ARP|0x88CCVLAN ID / EtherType
-i ip [ip2] / -i 192.168.1.0/24Traffic between both IPs (any direction) / subnet
-p port [port2]Source/destination port
-t TCP|UDP|ICMP / -t TCP SYN ACK / -t 47Transport, TCP flags, IP protocol number
--dscp 46IP DSCP field
-b / -e [8472]Cluster heartbeat (UDP 3343) / inner headers of VXLAN, GRE

130.5 pktmon start: packet capture

  • -c turns on packet capture and counters; default is all components.
  • --comp nics captures only on network adapters; --comp 5 9 on chosen component IDs.
  • --type all|flow|drop picks which packets; --pkt-size 0 logs the full packet (default 128 bytes).
  • --flags is a hex event mask: default 0x032 in this build's help (some docs say 0x012); 0x010 = raw packet, 0x000 = counters only.
PowerShell
pktmon start -cpktmon start -c --comp nics -f https.etlpktmon start -c --comp 5 9 --type droppktmon start -c --pkt-size 0pktmon start --capture --counters-onlypktmon stop
Output
$ pktmon filter add Web -p 443$ pktmon start -c --comp nics -f https.etlLogging mode: Circular  Max file size: 512 MB$ pktmon stop

130.6 Event providers and logging

  • -t enables ETW events; -p provider name or GUID (repeat for several); -k keywords mask; -l level (default 4 = info).
  • -c -t together puts packets and TCPIP events in one log.
  • -f file name (default PktMon.etl), -s max size in MB (default 512).
PowerShell
pktmon start -t -p Microsoft-Windows-TCPIPpktmon start -t -p Microsoft-Windows-TCPIP -p Microsoft-Windows-NDISpktmon start -t -p Microsoft-Windows-TCPIP -k 0xFF -l 5pktmon start -c -t -p Microsoft-Windows-TCPIP -l 4
PowerShell
pktmon start -c -f C:\temp\capture.etlpktmon start -c -s 1024pktmon start -c -m circularpktmon start -c -m multi-filepktmon start -c -m memorypktmon start -c -m real-time
-m log modeBehaviour
circular (default)Fixed-size file (-s, default 512 MB); oldest events overwritten
multi-fileNo event limit; a new numbered file each time the log is full
memoryLike circular but kept in RAM; written to a file on stop
real-timeShows packets live on screen; no file; Ctrl+C to stop

130.7 stop, status, reset, unload

  • status shows whether a capture is running (-b adds ETW buffer info).
  • stop ends the capture and finalises the ETL file; reset zeroes the counters.
  • unload stops the PktMon driver service and deletes all state (counters, filters).
PowerShell
pktmon statuspktmon status -bpktmon stoppktmon resetpktmon reset -counterspktmon unload
Output
$ pktmon statusFailed to communicate with the PktMon driver: Access is denied.$ pktmon status -bFailed to communicate with the PktMon driver: Access is denied.[exit code 5]$ pktmon unload helppktmon unload    Stop the PktMon driver service and unload PktMon.sys. Effectively equivalent    to 'sc.exe stop PktMon'. Measurement (if active) will immediately stop, and    any state will be deleted (counters, filters, etc.).

130.8 counters and list

  • counters shows Tx/Rx per component; -t drop -r shows only drops with the latest reason.
  • -z shows zero counters, -i hidden components, --live refreshes, --json for scripts.
  • list shows component IDs (used in --comp and etl2pcap -c); -a adds filter drivers and the vSwitch.
PowerShell
pktmon counterspktmon counters -t drop -rpktmon counters -t flow -zpktmon counters -t all -ipktmon counters --live --refresh-rate 1pktmon counters --json
Output
$ pktmon counters -t drop -r        (example from the docs)Id Name                        Dir Packets Drop reason31 Windows Filtering Platform  Rx  42      WFP drop12 Intel(R) Ethernet I219-LM   Rx  3       Filtered VLAN18 Hyper-V Virtual Switch      Tx  7       MTU mismatch
PowerShell
pktmon listpktmon list -apktmon list -ipktmon list --json
Output
$ pktmon list helppktmon list [--all] [--include-hidden] [--json]    List networking components that can be monitored.-a, --all    Show all component types. Only network adapters are    displayed by default.-i, --include-hidden    Show components that are hidden by default.--json    Output in JSON format. Implies -i and -a.

130.9 etl2txt (e2t)

  • Converts the ETL to text; -o output file, -s statistics only.
  • Every packet has one snapshot per layer; the same PktGroupId means the same packet.
  • Drops start with 'drop' plus dropReason; the end of the log lists components and filters.
  • -v 1-3 verbose, -b brief, -x hex, -t timestamp, -e no Ethernet header, -m metadata, -p TMF dirs (WPP), -l VXLAN port.
PowerShell
pktmon etl2txt PktMon.etlpktmon etl2txt PktMon.etl -o capture.txtpktmon etl2txt PktMon.etl -spktmon etl2txt PktMon.etl -v 3 -x -o out.txtpktmon etl2txt PktMon.etl -b -tpktmon etl2txt PktMon.etl -m -p C:\tmfpktmon e2t PktMon.etl -e -l 8472

130.10 etl2pcap (e2p) and hex2pkt

  • etl2pcap writes pcapng for Wireshark; drops are excluded by default (-d for a drops file); -c for one component.
  • The drop reason is lost in pcapng: use counters -r or etl2txt for reasons.
  • hex2pkt decodes a hex packet offline without admin; -t IP or -t HTTP decodes from that layer; aliases hex, h2p.
PowerShell
pktmon etl2pcap PktMon.etlpktmon etl2pcap PktMon.etl -o capture.pcapngpktmon etl2pcap PktMon.etl -d -o drops.pcapngpktmon etl2pcap PktMon.etl -c 5 -o nic5.pcapngpktmon e2p PktMon.etl
Output
# a small pcapng of 3 pings from the Docker lab, to show what a pcapng looks like$ capinfos -t -c ping.pcapngFile type:           Wireshark/... - pcapngNumber of packets:   6$ tshark -r ping.pcapng    1 0.000000000 192.168.150.10 → 192.168.150.20 ICMP 98 Echo (ping) request  id=0x9d25, seq=1/256, ttl=64    2 0.000059427 192.168.150.20 → 192.168.150.10 ICMP 98 Echo (ping) reply    id=0x9d25, seq=1/256, ttl=64 (request in 1)
PowerShell
pktmon hex2pkt 02000000001402000000000A0800...pktmon hex2pkt -t IP 450000241234...pktmon hex2pkt -t HTTP 474554202F20...pktmon hex 02-00-00-00-00-14-02-00-00-00-00-0A-08-00
Output
$ pktmon hex2pkt 0200000000140200...6B746D6F6E212102-00-00-00-00-0A > 02-00-00-00-00-14, ethertype IPv4 (0x0800), length 50: (tos 0x0, ttl 64, id 4660, offset 0, flags [none], proto ICMP (1), length 36)    192.168.150.10 > 192.168.150.20: ICMP echo request, id 1, seq 1, length 16$ pktmon hex2pkt -t IP 4500002412340000...ip: (tos 0x0, ttl 64, id 4660, offset 0, flags [none], proto ICMP (1), length 36)    192.168.150.10 > 192.168.150.20: ICMP echo request, id 1, seq 1, length 16$ pktmon hex2pkt -t HTTP 474554202F20...HTTP, length: 37	GET / HTTP/1.1	Host: example.com$ pktmon hex 02-00-00-00-00-14-02-00-00-00-00-0A-08-0002-00-00-00-00-0A > 02-00-00-00-00-14, ethertype IPv4 (0x0800), length 14:  [|ip]

130.11 Comparison: pktmon vs Wireshark/Npcap vs tcpdump

PointpktmonWireshark + Npcaptcpdump
PlatformWindows 10 1809+ / Server 2019+, in-boxWindows/macOS/Linux, install neededLinux/macOS
Sees inside the stackYes, every componentNo, at the adapterNo, at the interface
Drop reasonsYes (counters -r, etl2txt)NoNo
File formatETL -> text / pcapngpcapngpcap
Analysis UINone (use Wireshark on the pcapng)Full GUIText decode

130.12 Common mistakes

  • Running driver commands in a non-admin prompt: 'Access is denied'.
  • Capturing with no filter: huge, noisy logs.
  • Expecting drop reasons in the pcapng: they are lost; use counters or etl2txt.
  • Forgetting stop/unload: the capture keeps running and filters stay active.

130.13 Interview tips

  • Packet drop on a Windows server: pktmon list -a -> filter add -> start -c (--type drop) -> reproduce -> counters -t drop -r -> stop -> etl2pcap -> unload.
  • HTTPS fails now and then: pktmon filter add -p 443; pktmon start -c --type drop; then pktmon counters -t drop -r.
  • pktmon captures in-box; Wireshark is only needed for analysis.
  • Same PktGroupId across snapshots = one packet seen at several layers.