|This documentation is for the TIP (development tree) of NNG and may represent unreleased changes or functionality that is experimental, and is subject to change before release. The latest released version is v1.7.2. See the documentation for v1.7.2 for the most up-to-date information.
nng_zerotier - ZeroTier transport
The zt transport provides communication support for NNG applications over a ZeroTier network, using a Virtual Layer 2 packet facility.
This transport is experimental.
To utilize it at present, the library must be built with support, and linked
against a suitable
Further information about building with this support are in the build
documentation included with the distribution.
libzerotiercore library at present is covered under different
license terms than the rest of NNG. Please be careful to review
and adhere to the licensing terms.
|The ZeroTier transport can take a long time to establish an initial connection — up to even a minute in extreme cases, while the network topology is configured. Consequently, this transport is not recommended for use cases involving short-lived programs, but is better for long-running programs such as background daemons or agents.
While ZeroTier makes use of the host’s IP stack (and UDP in particular), this transport does not use or require an IP stack on the virtual network; thereby mitigating any considerations about IP address management.
This service uses Ethernet type 901 to transport packets. Network rules must permit this Ethernet type to pass in order to have a functional network.
|This document assumes that the reader is familiar with ZeroTier concepts and administration.
Depending upon how the library was built, it may be necessary to
register the transport by calling
returns zero on success, or an nng error value if the transport
cannot be initialized for any reason.
This transport uses URIs using the scheme
zt://, followed by a node
number (ten hexadecimal digits) followed by a
. delimited, and then
a network address (sixteen hexadecimal digits), followed by a colon (
and service or port number (decimal value,
up to 24-bits).
For example, the URI
that node fedcba9876 on network 0123456789abcdef is listening on port 999.
The special value
* can be used in lieu of a node number to represent
the node’s own node number.
Listeners may use port 0 to indicate that a suitable port
number be selected automatically.
Applications using this must determine the selected port number using the
By default this transport creates an "ephemeral" node, and used the
same ephemeral node for any additional endpoints created.
As this node is ephemeral, the keys associated with it and all associated data
are located in memory and are discarded upon application termination.
If a persistent node is desired, please see the
It is possible for a single application to join multiple networks using the same node, or using separate nodes.
A ZeroTier node can be in one of the following states, which can be obtained
The ZeroTier network is up. This is the only state where it is possible to communicate with peers, and the only state where the network name (
NNG_OPT_ZT_NETWORK_NAME) is available.
The ZeroTier node is still configuring, network services are not available.
The node does not have permission to join the ZeroTier network.
The ZeroTier network is not found.
Some other ZeroTier error has occurred; the network is not available.
The node is running obsolete software; the network is not available.
The network is in an unknown state. This should not happen, as it indicates that the ZeroTier software is reporting an unexpected status. The network is most likely not available.
The following transport options are available:
(string) This option represents the home directory, where the transport can store (and reuse) persistent state, such as key materials, node identity, and federation membership. This option must be set before the ZeroTier transport is first used. If this value is empty, then an ephemeral ZeroTier node is created, and no persistent state is used. The default is to use an ephemeral node.
If this option is set to different values on different sockets, dialers, or listeners, then separate nodes will be created. It is perfectly valid for an application to have multiple node identities in this fashion.
uint64_t) The 64-bit ZeroTier network number (native byte order).
uint64_t) The ZeroTier 40-bit node address (native byte order).
int) The ZeroTier network status. See Network Status for an explanation of this option.
(string) The name of the network as established by the ZeroTier network administrator.
nng_duration) The time to wait between sending connection attempts, only used with dialers. The default is 500 msec.
int) The maximum number of attempts to try to establish a connection before reporting a timeout, and is only used with dialers. The default is 240, which results in a 2 minute timeout if
NNG_OPT_ZT_CONN_TIMEis at its default of 500. If the value is set to 0, then connection attempts will keep retrying forever.
nng_duration) If no traffic has been received from the ZeroTier peer after this period of time, then a ping message is sent to check if the peer is still alive.
int) If this number of consecutive ping requests are sent to the peer with no response (and no other intervening traffic), then the peer is assumed to be dead and the connection is closed.
size_t) The ZeroTier virtual network MTU (read-only) as configured on the network; this is the Virtual Layer 2 MTU. The headers used by this transport and the protocols consume some of this for each message sent over the network. (The transport uses 20-bytes of this, and each protocol may consume additional space, typically not more than 16-bytes.)
uint64_t) Write-only array of two
uint64_tvalues, indicating the ID of a ZeroTier <em>moon</em>, and the node ID of the root server for that moon. (The ID may be zero if the moon ID is the same as its root server ID, which is conventional.)
uint64_t) Write-only option indicating the moon ID to deorbit. If the node is not already orbiting the moon, then this has no effect.