tree: a87ec674904718904ea39fd3cca28abeff8b22fe [path history] [tgz]
  1. examples/
  2. network-tun/

Fuchsia Network Tun

The network-tun package and the FIDL library allow for the creation of virtual interfaces to be added to the network stack, in a similar fashion to what TUN/TAP interfaces provide on other OSes.


To use it in your CFv2 tests, depend upon the network-tun v2 component from your test package, and include the manifest shard in your cml file in order to inject the manifest (recommended):

    include: [

To use it in legacy tests, depend upon the network-tun v1 component from your test package, and inject the manifest in your test's cmx file (deprecated):

   "injected-services": {
      "": "fuchsia-pkg://"

Using offers two types of backing protocols: a Device and a DevicePair. In other POSIX systems, when using tunctl or equivalent to create a virtual interface, that interface is directly installed into the kernel's networking stack. In Fuchsia, however, no assumptions are made about any Netstack capabilities being available, hence a virtual device is always comprised of two ends, one of which is meant to be installed into the Netstack and the other end is the equivalent of a TUN/TAP handle from other systems.

Device provides a handle to be offered to the Netstack and exposes FIDL methods to send and receive frames. It is easier to use and exposes more fine-tuned control over the interface, but it is less performant due to operation over FIDL.

DevicePair, in turn, offers a pair of instead, one of which can be held by the user and the other can be installed in Netstack. It requires a capable client to to operate the user end, but it is faster and provides better frame batching support. does not provide separate interfaces for the differences between the classical definitions of a TUN or TAP interface. The difference between an interface that will operate at the Ethernet or IP layers is achieved with FrameType configurations and informing the Netstack at which layer the device is operable.

See the rust example for a short walkthrough creating POSIX TAP-like or TUN-like interfaces with Device.