Tracing the netstack

TODO( Improve ergonomics of enabling tracing on the system netstack.

You can enable tracing for the netstack by swapping out the network realm package included in your build for the network realm that has tracing enabled. You can do this by adding these lines to the file in your current build directory.

legacy_base_package_labels -= [ "//src/connectivity/network" ]
legacy_base_package_labels += [ "//src/connectivity/network:network-with-tracing" ]

How to run a trace

You can use the ffx trace subcommand (see docs) to run a trace on a running Fuchsia system (e.g. an emulator, smart display, or NUC) that is connected to your development host machine. For example:

ffx trace start --categories net,kernel:sched --duration 10

This will record a trace of all categories in the kernel:sched and net categories. (kernel:sched includes detailed scheduler information, and net includes all events emitted by the netstack.) You might want to record this trace while doing something that exercises the netstack on the Fuchsia device; for example, running iperf3.

How to view the trace results

When you run ffx trace, it will produce a trace file that is viewable in Perfetto.