Packet Capture on Fuchsia

Packet capture is a fundamental tool for developing, debugging, and testing networking.

Fuchsia provides target-side packet capturing capabilities via the net CLI tool (part of net-cli).

Running the ffx net capture plugin on the host

Warning: Host Tool Deprecation (fx sniff): fx sniff which is a host-side script that wraps running tcpdump on the target is a deprecated workflow. The new net capture CLI tool currently only supports rolling packet captures and does not yet support streamed mode, but unless streaming packet captures to see the output in real time is necessary, the newer net capture should be preferred as it provides better ergonomics.

The ffx net capture host plugin allows managing rolling captures directly from your development host.

Start a rolling capture

[host] $ ffx net capture start-rolling name:lo

You can optionally specify a packet filter using standard pcap-filter syntax, just like for tcpdump or tshark. See the help string for other arguments that the start command takes or the README for more examples.

The default, minimum, and maximum buffer sizes are defined in FIDL, and the resulting rolling packet capture will contain as many of the most recently captured packets that fit the negotiated buffer size. The --snap-len argument can also be used so that only the first N bytes of each packet is captured instead of the entire packet, which can help fit more packets into the capture since the contents of the payload is often not relevant.

Stop and download a rolling capture

[host] $ ffx net capture stop-rolling

This stops the capture, downloads the accumulated packet capture directly to your development host, and prints the path on the host where the pcapng file has been saved.

Running the net binary on the target directly

In order to run the net tool on the target directly, ensure //src/connectivity/network/net-cli is included in your build.

Usage is otherwise virtually identical to the ffx plugin.

[target] $ net capture start-rolling name:lo
[target] $ net capture stop-rolling

Running tcpdump on the target directly

Ensure that //third_party/tcpdump is included in your build so that tcpdump can be run on the target directly.

Reference: fx workflow packet signatures

There are many different kinds of services running between the Fuchsia development host and the target. Those are usually invoked by fx commands. Most of times, you are not interested in those packets generated by the fx workflows. The following table lists noteworthy signatures.

UseSignatureReference
fx shellport 22devshell/shell
SSDPport 1900UPnP discovery traffic
zxdb (legacy)port 2345Legacy raw TCP debug agent connection
mDNSport 5353Dynamic target discovery
Package Serverport 8083docs/packages.md
Loggerport 33337NETBOOT_DEBUGLOG_PORT_SERVER
Loggerport 33338NETBOOT_DEBUGLOG_PORT_ACK
Bootserverport 33330NETBOOT_PORT_SERVER
Bootserverport 33331NETBOOT_PORT_ADVERT
Bootserverport 33332NETBOOT_PORT_CMD_START
Bootserverport 33339NETBOOT_PORT_CMD_END
Bootserverport 33340NETBOOT_PORT_TFTP_OUTGOING
Bootserverport 33341NETBOOT_PORT_TFTP_INCOMING
target netsvc addrfe80::xxxx:xxff:fexx:xxxx%XXfx device-finder list --netboot
host link-local addrfe80::xxxx:xxxx:xxxx:xxxx%XXfx device-finder list --ipv4=false --local
target netstack addrfe80::xxxx:xxxx:xxxx:xxxx%XXfx get-device-addr