To use UDP multicast, each network interface needs to have a separate transport.
It's easiest to let NDNts automatically create transports on every network interface.
// UdpTransport.multicasts() attempts to create UDP multicast transports on every // network interface, skipping network interfaces where socket creation fails. constmulticasts = awaitUdpTransport.multicasts(); for (consttransportofmulticasts) { awaituseInL3Face(transport); }
Transports are normally used to construct L3Face objects (from @ndn/l3face package), which are in turned add to the Forwarder (from @ndn/fw package).
Each transport provides a createFace convenience function to construct a transport and add it to the forwarder.
See @ndn/ws-transport package documentation for a complete example of createFace function.
// UdpTransport.createFace() constructs a UDP unicast transport, and adds it to a forwarder. // First parameters allows setting L3Face attributes and NDNLP service options, or attaching // the face to a non-default Forwarder instance. This argument is required. // Subsequent parameters are same as the corresponding connect() function. // It returns a FwFace instance (from @ndn/fw package). constface = awaitUdpTransport.createFace({}, "ndnhub.ipv6.lip6.fr"); face.close(); // TcpTransport.createFace() and UnixTransport.createFace() behave similarly.
// UdpTransport.createMulticastFaces() constructs UDP multicast transports on every network // interface and adds them to a forwarder. constfaces = awaitUdpTransport.createMulticastFaces({}); for (constfaceoffaces) { face.close(); }
L3Face allows sending and receiving layer-3 packets on a transport.
L3Face does not provide Interest-Data matching logic, timeout scheduler, etc.
It is more like a forwarder's face.
This section presents the low-level details of how to use a "raw" transport with L3Face class.
asyncfunctionuseInL3Face(transport: Transport) {
// Transports are normally used in a network layer face. constface = newL3Face(transport);
// We want to know if something goes wrong. face.on("rxerror", (err) =>console.warn(err)); face.on("txerror", (err) =>console.warn(err));
@ndn/node-transport
This package is part of NDNts, Named Data Networking libraries for the modern web.
This package implements socket transports for Node.js environment.
Transport Types
There are three transport types:
The
connect()
function of each transport creates a transport.To use UDP multicast, each network interface needs to have a separate transport. It's easiest to let NDNts automatically create transports on every network interface.
How to Use a Transport
Transports are normally used to construct L3Face objects (from
@ndn/l3face
package), which are in turned add to the Forwarder (from@ndn/fw
package). Each transport provides acreateFace
convenience function to construct a transport and add it to the forwarder.See
@ndn/ws-transport
package documentation for a complete example ofcreateFace
function.L3Face Low-Level Details
L3Face allows sending and receiving layer-3 packets on a transport. L3Face does not provide Interest-Data matching logic, timeout scheduler, etc. It is more like a forwarder's face.
This section presents the low-level details of how to use a "raw" transport with
L3Face
class.