24 #include "ns3/ndnSIM/model/ndn-l3-protocol.hpp" 26 #include "ns3/names.h" 27 #include "ns3/point-to-point-helper.h" 28 #include "ns3/string.h" 34 : m_isTopologyInitialized(false)
41 if (m_isTopologyInitialized) {
42 throw std::logic_error(
"Topology cannot be created twice");
45 PointToPointHelper p2p;
47 for (
auto&& clique : topology) {
48 for (
auto i = clique.begin(); i != clique.end(); ++i) {
49 auto node1 = getOrCreateNode(*i);
50 for (
auto j = i + 1; j != clique.end(); ++j) {
51 auto node2 = getOrCreateNode(*j);
53 auto link = p2p.Install(node1, node2);
54 links[*i][*j] = link.Get(0);
55 links[*j][*i] = link.Get(1);
61 m_isTopologyInitialized =
true;
91 for (
auto&& route : routes) {
93 getFace(route.node1, route.node2), route.metric);
100 for (
auto&& app : apps) {
102 for (
auto&& param : app.params) {
103 appHelper.
SetAttribute(param.first, StringValue(param.second));
106 installedApp.Start(Time(app.start));
107 installedApp.Stop(Time(app.end));
112 ScenarioHelper::getOrCreateNode(
const std::string& nodeName)
114 auto node = nodes.find(nodeName);
115 if (node == nodes.end()) {
116 std::tie(node, std::ignore) = nodes.insert(std::make_pair(nodeName, CreateObject<Node>()));
117 Names::Add(nodeName, node->second);
125 auto node = nodes.find(nodeName);
126 if (node != nodes.end()) {
130 throw std::invalid_argument(
"Node " + nodeName +
" does not exist");
136 auto i = links.find(node1);
137 if (i != links.end()) {
138 auto j = i->second.find(node2);
139 if (j != i->second.end()) {
140 return j->second->GetNode()->GetObject<
L3Protocol>()->getFaceByNetDevice(j->second);
144 throw std::invalid_argument(
"Link between " + node1 +
" and " + node2 +
" does not exist");
void disableFaceManager()
Disable Face Manager.
Copyright (c) 2011-2015 Regents of the University of California.
void SetAttribute(std::string name, const AttributeValue &value)
Helper function used to set the underlying application attributes.
Ptr< Node > getNode(const std::string &nodeName)
Get node.
void disableRibManager()
Disable RIB Manager.
static void AddRoute(Ptr< Node > node, const Name &prefix, shared_ptr< Face > face, int32_t metric)
Add forwarding entry to FIB.
shared_ptr< Face > getFace(const std::string &node1, const std::string &node2)
Get face on the node1 pointing towards node2.
void disableFaceManager()
Disable Face Manager.
ApplicationContainer Install(NodeContainer c)
Install an ns3::NdnConsumer on each node of the input container configured with all the attributes se...
void disableStatusServer()
Disable Status Server.
Ptr< FaceContainer > InstallAll() const
Install Ndn stack on all nodes in the simulation.
Copyright (c) 2011-2015 Regents of the University of California.
void disableRibManager()
Disable the RIB manager of NFD.
Implementation network-layer of NDN stack.
void createTopology(std::initializer_list< std::initializer_list< std::string >> topology)
Create topology.
void disableStatusServer()
Disable Status Server.
void addRoutes(std::initializer_list< RouteInfo > routes)
Create routes between topology nodes.
void disableStrategyChoiceManager()
Disable Strategy Choice Manager.
void addApps(std::initializer_list< AppInfo > apps)
Create and install application on nodes.
A helper to make it easier to instantiate an ns3::ndn::App applications on a set of nodes...
void disableStrategyChoiceManager()
Disable Strategy Choice Manager.