NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
|
Overall ndnSIM 2.0 documentation |
Helpers are very important components of ndnSIM, especially for writing simulation scenarios. The following summarizes helpers and their basic usage.
Example:
StackHelper ndnHelper;
NodeContainer nodes;
...
ndnHelper.Install(nodes);
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.
The FIB helper 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);
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; ... 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()
GlobalRoutingHelper::CalculateRoutes();
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 |
---|---|---|
/ | fw::BestRouteStrategy | /localhost/nfd/strategy/best-route |
/localhost | fw::BroadcastStrategy | /localhost/nfd/strategy/broadcast |
/localhost/nfd | fw::BestRouteStrategy | /localhost/nfd/strategy/best-route |
/ndn/broadcast | fw::BroadcastStrategy | /localhost/nfd/strategy/broadcast |
The Strategy Choice helper 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);
ndnSIM uses NFD’s content store implementation, maximum size of which can be controlled using 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
NFD’s content store implementation takes full consideration of Interest selectors, however is not yet flexible when it comes to cache replacement policies. Feature to extend CS flexibility is currently in active development (refer to Issue #2219 on NFD Redmine) and for the time being, we have ported the old ndnSIM 1.0 content store implementations to the new code base. These implementations feature different cache replacement policies, but have very limited support for Interest selectors. If your scenario relies on proper selector processing, do not use these implementations as the simulation results most likely be incorrect.
To select old content store implementations, use SetOldContentStore() StackHelper method:
ndnHelper.SetOldContentStore("<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.
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 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)
Some scenarios require failing certain links between NDN nodes at certain times. NS-3 does not provide ability to actually “break” the link between nodes. However, it provides facility to set up a loss model to simulate packet drops in the channel. Using the properly set up loss model on both sides of the point-to-point link, it is possible to emulate link breakage.
To simplify these operations, ndnSIM includes ndn::LinkControlHelper that allows scheduling of link failures and failure recoveries:
#include "ns3/ndnSIM/helper/ndn-link-control-helper.hpp" ... Simulator::Schedule(Seconds(10.0), ndn::LinkControlHelper::FailLink, node1, node2); Simulator::Schedule(Seconds(15.0), ndn::LinkControlHelper::UpLink, node1, node2);
Usage of this helper is demonstrated in Simple scenario with link failures.