NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
ndn-network-region-table-helper.cpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
20
#include "
ndn-network-region-table-helper.hpp
"
21
#include "ns3/ndnSIM/model/ndn-l3-protocol.hpp"
22
#include "ns3/ndnSIM/NFD/daemon/fw/forwarder.hpp"
23
24
namespace
ns3
{
25
namespace
ndn
{
26
27
NS_LOG_COMPONENT_DEFINE(
"ndn.NetworkRegionTableHelper"
);
28
29
void
30
NetworkRegionTableHelper::AddRegionName
(Ptr<Node> node,
const
Name
& region)
31
{
32
NS_LOG_LOGIC(
"Node ["
<< node->GetId() <<
"]$ RegionName "
<< region <<
" is added into NetworkRegionTable "
);
33
34
Ptr<L3Protocol> l3protocol = node->GetObject<
L3Protocol
>();
35
NS_ASSERT_MSG(l3protocol != 0,
"Ndn stack should be installed on the node"
);
36
37
node->GetObject<
L3Protocol
>()->getForwarder()->getNetworkRegionTable().insert(region);
38
}
39
40
void
41
NetworkRegionTableHelper::AddRegionName
(NodeContainer& nodes,
const
ndn::Name
& region)
42
{
43
for
(
auto
nodeIt = nodes.Begin(); nodeIt != nodes.End(); ++nodeIt) {
44
AddRegionName
(*nodeIt, region);
45
}
46
}
47
48
void
49
NetworkRegionTableHelper::AddRegionName
(Ptr<Node> node, std::initializer_list<Name> regions)
50
{
51
for
(
const
auto
& region : regions) {
52
AddRegionName
(node, region);
53
}
54
}
55
56
void
57
NetworkRegionTableHelper::AddRegionName
(
const
NodeContainer& nodes, std::initializer_list<Name> regions)
58
{
59
for
(
auto
nodeIt = nodes.begin(); nodeIt != nodes.End(); ++nodeIt) {
60
AddRegionName
(*nodeIt, regions);
61
}
62
}
63
64
void
65
NetworkRegionTableHelper::RemoveRegionName
(Ptr<Node> node,
const
Name
& region)
66
{
67
NS_LOG_LOGIC(
"Node ["
<< node->GetId() <<
"]$ RegionName "
<< region <<
" is removed from NetworkRegionTable "
);
68
69
Ptr<L3Protocol> l3protocol = node->GetObject<
L3Protocol
>();
70
NS_ASSERT_MSG(l3protocol != 0,
"Ndn stack should be installed on the node"
);
71
72
node->GetObject<
L3Protocol
>()->getForwarder()->getNetworkRegionTable().erase(region);
73
}
74
75
void
76
NetworkRegionTableHelper::RemoveRegionName
(
const
NodeContainer& nodes,
const
ndn::Name
®ion)
77
{
78
for
(
auto
nodeIt = nodes.begin(); nodeIt != nodes.End(); ++nodeIt) {
79
RemoveRegionName
(*nodeIt, region);
80
}
81
}
82
83
void
84
NetworkRegionTableHelper::RemoveRegionName
(Ptr<Node> node, std::initializer_list<Name> regions)
85
{
86
for
(
const
auto
& region : regions) {
87
RemoveRegionName
(node, region);
88
}
89
}
90
91
void
92
NetworkRegionTableHelper::RemoveRegionName
(
const
NodeContainer& nodes, std::initializer_list<Name> regions)
93
{
94
for
(
auto
nodeIt = nodes.begin(); nodeIt != nodes.End(); ++nodeIt) {
95
RemoveRegionName
(*nodeIt, regions);
96
}
97
}
98
99
void
100
NetworkRegionTableHelper::EmptyNetworkRegionTable
(Ptr<Node> node)
101
{
102
NS_LOG_LOGIC(
"Node ["
<< node->GetId() <<
"]$ NetworkRegionTable is cleared"
);
103
104
Ptr<L3Protocol> l3protocol = node->GetObject<
L3Protocol
>();
105
NS_ASSERT_MSG(l3protocol != 0,
"Ndn stack should be installed on the node"
);
106
107
node->GetObject<
L3Protocol
>()->getForwarder()->getNetworkRegionTable().clear();
108
}
109
110
void
111
NetworkRegionTableHelper::EmptyNetworkRegionTable
(
const
NodeContainer& nodes)
112
{
113
for
(
auto
nodeIt = nodes.begin(); nodeIt != nodes.End(); ++nodeIt) {
114
EmptyNetworkRegionTable
(*nodeIt);
115
}
116
}
117
118
}
// namespace ndn
119
}
// namespace ns3
ns3::ndn::NetworkRegionTableHelper::AddRegionName
static void AddRegionName(Ptr< Node > node, const Name ®ionName)
Definition:
ndn-network-region-table-helper.cpp:30
ns3
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-app-link-service.cpp:32
ndn::Name
Represents an absolute name.
Definition:
name.hpp:44
ns3::ndn::Name
Name
Definition:
ndn-common.cpp:25
ns3::ndn::NetworkRegionTableHelper::RemoveRegionName
static void RemoveRegionName(Ptr< Node > node, const Name ®ionName)
Definition:
ndn-network-region-table-helper.cpp:65
ns3::ndn::NetworkRegionTableHelper::EmptyNetworkRegionTable
static void EmptyNetworkRegionTable(Ptr< Node > node)
Definition:
ndn-network-region-table-helper.cpp:100
ndn-network-region-table-helper.hpp
ns3::ndn::L3Protocol
Implementation network-layer of NDN stack.
Definition:
ndn-l3-protocol.hpp:81
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-strategy-choice-helper.hpp:34
ndnSIM
helper
ndn-network-region-table-helper.cpp
Generated on Mon Jun 1 2020 22:32:14 for ndnSIM by
1.8.18