Options
All
  • Public
  • Public/Protected
  • All
Menu

@ndn/nfdmgmt

This package is part of NDNts, Named Data Networking libraries for the modern web.

This package enables interaction with NDN-DPDK high-speed forwarder. It can create faces for the NDNts application, and perform prefix registrations.

Currently, there are several limitations using this package:

  • Data plane uses UDP transport, which does not deliver the best performance.
  • Prefix registration replaces a FIB entry, and does not preserve other prefix registrations on the same prefix.
  • If the application crashes, the face would not be closed on NDN-DPDK side.
import { openFace } from "@ndn/dpdkmgmt";

// other imports for examples
import { Endpoint } from "@ndn/endpoint";
import { Forwarder } from "@ndn/fw";
import { Name, Interest, Data } from "@ndn/packet";
import { fromUtf8, toUtf8 } from "@ndn/tlv";
import { strict as assert } from "assert";
(async () => {

const gqlServer = process.env.DEMO_DPDKMGMT_GQLSERVER;
const localHost = process.env.DEMO_DPDKMGMT_LOCAL;
if (!gqlServer || !localHost) {
  console.log(`
To run @ndn/dpdkmgmt demo, set the following environment variables:
DEMO_DPDKMGMT_GQLSERVER= NDN-DPDK forwarder GraphQL server URI
DEMO_DPDKMGMT_LOCAL= IP address to reach local host from NDN-DPDK forwarder
`);
  return;
}

// Topology of this demo
//
// producer                      consumer
//    |                              |
//   fwP                            fwC
//    \---------- NDN-DPDK ----------/
//       uplinkP            uplinkC

// Create two logical forwarders, one as consumer and one as producer.
const fwC = Forwarder.create();
const fwP = Forwarder.create();

// Connect to NDN-DPDK.
const uplinkC = await openFace({
  fw: fwC,
  localHost,
  gqlServer,
});
uplinkC.addRoute(new Name("/"));
const uplinkP = await openFace({
  fw: fwP,
  localHost,
  gqlServer,
});
console.log(`uplinkC=${uplinkC}`, `uplinkP=${uplinkP}`);

// Start a producer.
const producer = new Endpoint({ fw: fwP }).produce("/P",
  async () => {
    console.log("producing");
    return new Data("/P", Data.FreshnessPeriod(1000), toUtf8("NDNts + NDN-DPDK"));
  });
await new Promise((r) => setTimeout(r, 500));

// Start a consumer, fetching Data from the producer via NFD.
const data = await new Endpoint({ fw: fwC }).consume(
  new Interest("/P", Interest.MustBeFresh),
);
const payloadText = fromUtf8(data.content);
console.log("received", `${data.name} ${payloadText}`);
assert.equal(payloadText, "NDNts + NDN-DPDK");

// Close faces.
producer.close();
await new Promise((r) => setTimeout(r, 500));
uplinkC.close();
uplinkP.close();
})();

Index

References

Classes

Interfaces

Functions

References

OpenFaceOptions

Re-exports OpenFaceOptions

openFace

Re-exports openFace

Functions

openFace

  • openFace(__namedParameters?: { attributes: Attributes; fw: Forwarder; gqlServer: string; localHost: string }): Promise<FwFace>
  • Parameters

    • Default value __namedParameters: { attributes: Attributes; fw: Forwarder; gqlServer: string; localHost: string } = {}
      • attributes: Attributes
      • fw: Forwarder
      • gqlServer: string
      • localHost: string

    Returns Promise<FwFace>

Legend

  • Namespace
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Type alias
  • Type alias with type parameter
  • Interface
  • Interface with type parameter
  • Class
  • Class with type parameter
  • Enumeration

Generated using TypeDoc