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)
40 bool shouldInstallNdnStack)
42 if (m_isTopologyInitialized) {
43 throw std::logic_error(
"Topology cannot be created twice");
46 PointToPointHelper p2p;
48 for (
auto&& clique : topology) {
49 for (
auto i = clique.begin(); i != clique.end(); ++i) {
50 auto node1 = getOrCreateNode(*i);
51 for (
auto j = i + 1; j != clique.end(); ++j) {
52 auto node2 = getOrCreateNode(*j);
54 auto link = p2p.Install(node1, node2);
55 links[*i][*j] = link.Get(0);
56 links[*j][*i] = link.Get(1);
61 if (shouldInstallNdnStack) {
64 m_isTopologyInitialized =
true;
82 for (
auto&& route : routes) {
84 getFace(route.node1, route.node2), route.metric);
91 for (
auto&& app : apps) {
93 for (
auto&& param : app.params) {
94 appHelper.
SetAttribute(param.first, StringValue(param.second));
97 installedApp.Start(Time(app.start));
98 installedApp.Stop(Time(app.end));
103 ScenarioHelper::getOrCreateNode(
const std::string& nodeName)
105 auto node = nodes.find(nodeName);
106 if (node == nodes.end()) {
107 std::tie(node, std::ignore) = nodes.insert(std::make_pair(nodeName, CreateObject<Node>()));
108 Names::Add(nodeName, node->second);
116 auto node = nodes.find(nodeName);
117 if (node != nodes.end()) {
121 throw std::invalid_argument(
"Node " + nodeName +
" does not exist");
128 return netDevice->GetNode()->GetObject<
L3Protocol>()->getFaceByNetDevice(netDevice);
134 auto i = links.find(node1);
135 if (i != links.end()) {
136 auto j = i->second.find(node2);
137 if (j != i->second.end()) {
142 throw std::invalid_argument(
"Link between " + node1 +
" and " + node2 +
" does not exist");