ndnSIM helpers

Helpers are very important components of ndnSIM, especially for writing simulation scenarios. The following summarizes helpers and their basic usage.

NDN Stack Helpers

:ndnsim:`StackHelper` is used to install ndnSIM network stack on requested nodes, as well
to provide a simple way configure several important parameters of NDN simulation.

Example:

StackHelper ndnHelper;
NodeContainer nodes;
...
ndnHelper.Install(nodes);

Routing

All forwarding strategies require knowledge of where Interests can be forwarded (Forwarding Information Base).

Note

By default, all nodes have empty FIB. You need either to manually configure routes, use global routing controller, or (not recommended) enable default routes.

Manually routes (FIB Helper)

The :ndnsim:`FIB helper <FibHelper>` interacts with the FIB manager of NFD by sending special Interest commands to the manager in order to add/remove a next hop from FIB entries or add routes to the FIB manually (manual configuration of FIB).

Adding a route to the FIB manually:

Ptr<Node> node = ...     // some node
std::string prefix = ... // some prefix
Ptr<ndn::Face> face = ... // NDN face that belongs to the node and through which prefix is accessible
int32_t metric = ...     // some routing metric
FibHelper::AddRoute(node, prefix, face, metric);
:ndnsim:`FIB helper <FibHelper>` has few other AddRoute overloads that may be easier to
use. For example, when setting up manual routes between nodes connected with PointToPointNetDevice’s, it is simpler to use the overload that accepts two nodes (face will be automatically determined by the helper).

Automatic Shortest Path Routes (Global Routing Helper)

To simplify FIB management in large topologies, ndnSIM contains a global routing controller (:ndnsim:`helper <GlobalRoutingHelper>` and :ndnsim:`special interface <GlobalRouter>`), similar in spirit to Ipv4GlobalRoutingHelper.

There are several necessary steps, in order to take advantage of the global routing controller:

Forwarding Strategy

ndnSIM 2.0 exactly like NFD allows different namespaces to be associated with different forwarding strategies. By default, the following forwarding strategy configuration is defined:

Namespace Strategy Strategy Name
/ :nfd:`fw::BestRouteStrategy` /localhost/nfd/strategy/best-route
/localhost :nfd:`fw::MulticastStrategy` /localhost/nfd/strategy/multicast
/localhost/nfd :nfd:`fw::BestRouteStrategy` /localhost/nfd/strategy/best-route
/ndn/multicast :nfd:`fw::MulticastStrategy` /localhost/nfd/strategy/multicast

The :ndnsim:`Strategy Choice helper <StrategyChoiceHelper>` interacts with the Strategy Choice manager of NFD by sending special Interest commands to the manager in order to specify the desired per-name prefix forwarding strategy for one, more or all the nodes of a topology.

This helper should be used as follows:

StrategyChoiceHelper::Install(nodes, prefix, strategyName);

or (for a forwarding strategy to be installed in all the topology nodes):

StrategyChoiceHelper::InstallAll(prefix, strategyName);

Content Store

ndnSIM uses NFD’s content store implementation, maximum size of which can be controlled using :ndnsim:`StackHelper::setCsSize()`:

ndnHelper.setCsSize(<max-size-in-packets>);
...
ndnHelper.Install(nodes);

Note

Unless specified in the simulation scenario, default maximum size of the content store is 100 Data packets.

Note

In simulation scenarios it is possible to select one of the existing implementations of the content store or implement your own.

Application Helper

:ndnsim:`AppHelper` simplifies task of creating, configuring, and installing ndnSIM applications.

The basic usage of the :ndnsim:`AppHelper`:

  • Create helper for specific applications class:

    // Create helper for the consumer generating Interests with constant rate
    AppHelper consumerHelper("ns3::ndn::ConsumerCbr");
    
  • Assign prefix on which application operates (either generating Interests using this name or satisfying Interests for this name) using :ndnsim:`AppHelper::SetPrefix`:

    consumerHelper.SetPrefix(prefix);
    
  • Assign application-specific attributes using :ndnsim:`AppHelper::SetAttribute`:

    // Set frequency parameter
    consumerHelper.SetAttribute("Frequency", StringValue ("10")); // 10 interests a second
    
  • Install application on one or more nodes:

    NodeContainer nodes;
    ...
    consumerHelper.Install(nodes)