NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
ndn-strategy-choice-helper.cpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
20
#include "
ndn-strategy-choice-helper.hpp
"
21
22
#include "ns3/log.h"
23
24
#include "
ndn-stack-helper.hpp
"
25
26
namespace
ns3 {
27
namespace
ndn {
28
29
NS_LOG_COMPONENT_DEFINE(
"ndn.StrategyChoiceHelper"
);
30
31
void
32
StrategyChoiceHelper::sendCommand(
const
ControlParameters& parameters, Ptr<Node> node)
33
{
34
NS_LOG_DEBUG(
"Strategy choice command was initialized"
);
35
Block encodedParameters(parameters.wireEncode());
36
37
Name
commandName(
"/localhost/nfd/strategy-choice"
);
38
commandName.append(
"set"
);
39
commandName.append(encodedParameters);
40
41
shared_ptr<Interest> command(make_shared<Interest>(commandName));
42
StackHelper::getKeyChain
().sign(*command);
43
Ptr<L3Protocol> L3protocol = node->GetObject<
L3Protocol
>();
44
auto
strategyChoiceManager = L3protocol->
getStrategyChoiceManager
();
45
strategyChoiceManager->onStrategyChoiceRequest(*command);
46
NS_LOG_DEBUG(
"Forwarding strategy installed in node "
<< node->GetId());
47
}
48
49
void
50
StrategyChoiceHelper::Install
(
const
NodeContainer& c,
const
Name
& namePrefix,
const
Name
& strategy)
51
{
52
for
(NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) {
53
Install
(*i, namePrefix, strategy);
54
}
55
}
56
57
void
58
StrategyChoiceHelper::Install
(Ptr<Node> node,
const
Name
& namePrefix,
const
Name
& strategy)
59
{
60
ControlParameters parameters;
61
parameters.setName(namePrefix);
62
NS_LOG_DEBUG(
"Node ID: "
<< node->GetId() <<
" with forwarding strategy "
<< strategy);
63
parameters.setStrategy(strategy);
64
sendCommand(parameters, node);
65
}
66
67
void
68
StrategyChoiceHelper::InstallAll
(
const
Name
& namePrefix,
const
Name
& strategy)
69
{
70
Install
(NodeContainer::GetGlobal(), namePrefix, strategy);
71
}
72
73
}
// namespace ndn
74
75
}
// namespace ns
ns3::ndn::Name
Name
Definition:
ndn-common.cpp:25
ndn-strategy-choice-helper.hpp
ndn-stack-helper.hpp
ns3::ndn::L3Protocol::getStrategyChoiceManager
shared_ptr< nfd::StrategyChoiceManager > getStrategyChoiceManager()
Get smart pointer to nfd::StrategyChoiceManager, used by node's NFD.
Definition:
ndn-l3-protocol.cpp:273
ns3::ndn::L3Protocol
Implementation network-layer of NDN stack.
Definition:
ndn-l3-protocol.hpp:75
ns3::ndn::StrategyChoiceHelper::Install
static void Install(const NodeContainer &c, const Name &namePrefix, const Name &strategy)
Definition:
ndn-strategy-choice-helper.cpp:50
ns3::ndn::StackHelper::getKeyChain
static KeyChain & getKeyChain()
Definition:
ndn-stack-helper.cpp:62
ns3::ndn::StrategyChoiceHelper::InstallAll
static void InstallAll(const Name &namePrefix, const Name &strategy)
Definition:
ndn-strategy-choice-helper.cpp:68
ndnSIM
helper
ndn-strategy-choice-helper.cpp
Generated on Wed Feb 18 2015 16:31:16 for ndnSIM by
1.8.7