NS-3 based Named Data Networking (NDN) simulator
ndnSIM: NDN, CCN, CCNx, content centric networks
|
Overall ndnSIM documentation |
Helpers are very important components of ndnSIM, especially for writing simulation scenarios. The following summarizes helpers and their basic usage.
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:
ndn::StackHelper ndnHelper;
NodeContainer nodes;
...
ndnHelper.Install (nodes);
All forwarding strategies require knowledge of where Interests can be forwarded (Forwarding Information Base). Unlike IP routing, this knowledge may be imprecise, but without such knowledge forwarding strategies will not be able to make any decision and will drop any Interests.
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.
Routes can be configured manually using StackHelper::AddRoute() static methods of StackHelper.
These routes should be created after installing NDN stack on a node:
ndnHelper.Install (nodes); ... Ptr<Node> node = ... // FIB entry will be added to FIB on this 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 ndn::StackHelper::AddRoute (node, prefix, face, metric);
To simplify FIB management in large topologies, ndnSIM contains a global routing controller (helper and special interface), similar in spirit to Ipv4GlobalRoutingHelper.
There are several necessary steps, in order to take advantage of the global routing controller:
install special interfaces on nodes
NodeContainer nodes; ... ndn::GlobalRoutingHelper ndnGlobalRoutingHelper; ndnGlobalRoutingHelper.Install (nodes);
specify which node exports which prefix using GlobalRoutingHelper::AddOrigins()
Ptr<Node> producer; // producer node that exports prefix std::string prefix; // exported prefix ... ndnGlobalRoutingHelper.AddOrigins (prefix, producer);
calculate and install FIBs on every node using GlobalRoutingHelper::CalculateRoutes()
cdnGlobalRoutingHelper.CalculateRoutes ();
In simple topologies, like in examples, or when simulating broadcast environment, it is possible to set up default FIB entries using StackHelper::SetDefaultRoutes() call. More specifically, every installed NDN stack will have a FIB entry to / prefix, containing all available faces.
The following should be done before installing stack on a node:
ndnHelper.SetDefaultRoutes (true); ... ndnHelper.Install (nodes);
ndnSIM comes with several different in-memory content store implementations, featuring different cache replacement policies.
To select a particular content store and configure its capacity, use SetContentStore() helper method:
ndnHelper.SetContentStore ("<content store implementation>", ["<optional parameter>", "<optional parameter's value>" [, ...]]); ... ndnHelper.Install (nodes);
In simulation scenarios it is possible to select one of the existing implementations of the content store or implement your own.
The current version of ndnSIM provides templated realizations of PIT abstraction, allowing optional bounding the number of PIT entries and different replacement policies (i.e., perform different actions when limit on number of PIT entries is reached).
To select a particular PIT implementation and configure its policies, use SetPit() helper method:
persistent (default):
New entries will be rejected if PIT size reached its limit
ndnHelper.SetPit ("ns3::ndn::pit::Persistent", "MaxSize", "0"); ... ndnHelper.Install (nodes);
when PIT reaches its limit, random entry (could be the newly created one) will be removed from PIT;
ndnHelper.SetPit ("ns3::ndn::pit::Random", "MaxSize", "0"); ... ndnHelper.Install (nodes);
the least recently used entry (the oldest entry with minimum number of incoming faces) will be removed when PIT size reached its limit.
ndnHelper.SetPit ("ns3::ndn::pit::Lru", "MaxSize", "0"); ... ndnHelper.Install (nodes);
A desired forwarding strategy parameter need to be set before installing stack on a node.
To select a particular forwarding strategy implementation and configure its parameters, use SetForwardingStrategy() helper method:
ndnHelper.SetForwardingStrategy ("<forwarding strategy implementation>", ["<optional parameter>", "<optional parameter's value>" [, ...]]); ... ndnHelper.Install (nodes);
In simulation scenarios it is possible to select one of the existing implementations of the forwarding strategy or implement your own.
AppHelper simplifies task of creating, configuring, and installing ndnSIM applications.
The basic usage of the AppHelper:
Create helper for specific applications class:
// Create helper for the consumer generating Interests with constant rate ndn::AppHelper consumerHelper ("ns3::ndn::ConsumerCbr");
Assign prefix on which application operates (either generating Interests using this name or satisfying Interests for this name) using AppHelper::SetPrefix():
consumerHelper.SetPrefix (prefix);
Assign application-specific attributes using 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)
In simulation scenarios it is possible to select one of the existing applications or implement your own.