NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
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
44
Ptr<L3Protocol> l3protocol = node->GetObject<
L3Protocol
>();
45
l3protocol->
injectInterest
(*command);
46
}
47
48
void
49
StrategyChoiceHelper::Install
(
const
NodeContainer& c,
const
Name
& namePrefix,
const
Name
& strategy)
50
{
51
for
(NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) {
52
Install
(*i, namePrefix, strategy);
53
}
54
}
55
56
void
57
StrategyChoiceHelper::Install
(Ptr<Node> node,
const
Name
& namePrefix,
const
Name
& strategy)
58
{
59
ControlParameters
parameters;
60
parameters.setName(namePrefix);
61
NS_LOG_DEBUG(
"Node ID: "
<< node->GetId() <<
" with forwarding strategy "
<< strategy);
62
parameters.setStrategy(strategy);
63
sendCommand(parameters, node);
64
}
65
66
void
67
StrategyChoiceHelper::InstallAll
(
const
Name
& namePrefix,
const
Name
& strategy)
68
{
69
Install
(NodeContainer::GetGlobal(), namePrefix, strategy);
70
}
71
72
}
// namespace ndn
73
74
}
// namespace ns
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-strategy-choice-helper.hpp:34
ns3::ndn::Name
Name
Definition:
ndn-common.cpp:25
ns3::ndn::StrategyChoiceHelper::Install
static void Install(Ptr< Node > node, const Name &namePrefix, const Name &strategy)
Install a built-in strategy strategy on node for namePrefix namespace.
Definition:
ndn-strategy-choice-helper.cpp:57
ndn-strategy-choice-helper.hpp
ns3
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
content-store-impl.cpp:38
ndn-stack-helper.hpp
ns3::ndn::L3Protocol
Implementation network-layer of NDN stack.
Definition:
ndn-l3-protocol.hpp:77
ns3::ndn::L3Protocol::injectInterest
void injectInterest(const Interest &interest)
Inject interest through internal Face.
Definition:
ndn-l3-protocol.cpp:246
ndn::tlv::nfd::ControlParameters
Definition:
tlv-nfd.hpp:35
ns3::ndn::StackHelper::getKeyChain
static KeyChain & getKeyChain()
Definition:
ndn-stack-helper.cpp:76
ns3::ndn::StrategyChoiceHelper::InstallAll
static void InstallAll(const Name &namePrefix, const Name &strategy)
Install a built-in strategy strategy on all nodes for namePrefix namespace.
Definition:
ndn-strategy-choice-helper.cpp:67
ndnSIM
helper
ndn-strategy-choice-helper.cpp
Generated on Sun Feb 25 2018 13:27:04 for ndnSIM by
1.8.14