NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
ndn-strategy-choice-helper.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
20 #ifndef NDNSIM_HELPER_NDN_STRATEGY_CHOICE_HELPER_HPP
21 #define NDNSIM_HELPER_NDN_STRATEGY_CHOICE_HELPER_HPP
22 
23 #include "ns3/ndnSIM/model/ndn-common.hpp"
24 
25 #include "ns3/node.h"
26 #include "ns3/ptr.h"
27 #include "ns3/node-container.h"
28 
29 #include "ns3/ndnSIM/model/ndn-l3-protocol.hpp"
30 #include "ns3/ndnSIM/NFD/daemon/mgmt/strategy-choice-manager.hpp"
31 #include "ns3/ndnSIM/NFD/daemon/fw/forwarder.hpp"
32 #include "ns3/ndnSIM/NFD/daemon/table/strategy-choice.hpp"
33 
34 namespace ndn {
35 namespace nfd {
36 class ControlParameters;
37 } // namespace nfd
38 } // namespace ndn
39 
40 namespace nfd {
41 namespace fw {
42 class Strategy;
43 } // namespace fw
44 } // namespace nfd
45 
46 
47 namespace ns3 {
48 namespace ndn {
49 
51 
61 {
62 public:
66  static void
67  Install(Ptr<Node> node, const Name& namePrefix, const Name& strategy);
68 
73  static void
74  Install(const NodeContainer& c, const Name& namePrefix, const Name& strategy);
75 
79  static void
80  InstallAll(const Name& namePrefix, const Name& strategy);
81 
86  template<class Strategy>
87  static void
88  Install(Ptr<Node> node, const Name& namePrefix);
89 
94  template<class Strategy>
95  static void
96  Install(const NodeContainer& c, const Name& namePrefix);
97 
102  template<class Strategy>
103  static void
104  InstallAll(const Name& namePrefix);
105 
106 private:
107  static void
108  sendCommand(const ControlParameters& parameters, Ptr<Node> node);
109 };
110 
111 template<class Strategy>
112 inline void
113 StrategyChoiceHelper::Install(Ptr<Node> node, const Name& namePrefix)
114 {
115  Ptr<L3Protocol> l3Protocol = node->GetObject<L3Protocol>();
116  NS_ASSERT(l3Protocol != nullptr);
117  NS_ASSERT(l3Protocol->getForwarder() != nullptr);
118 
119  if (!Strategy::canCreate(Strategy::getStrategyName())) {
120  Strategy::template registerType<Strategy>();
121  }
122 
123  Install(node, namePrefix, Strategy::getStrategyName());
124 }
125 
126 template<class Strategy>
127 inline void
128 StrategyChoiceHelper::Install(const NodeContainer& c, const Name& namePrefix)
129 {
130  for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) {
131  Install<Strategy>(*i, namePrefix);
132  }
133 }
134 
135 template<class Strategy>
136 inline void
137 StrategyChoiceHelper::InstallAll(const Name& namePrefix)
138 {
139  Install<Strategy>(NodeContainer::GetGlobal(), namePrefix);
140 }
141 
142 } // namespace ndn
143 } // namespace ns3
144 
145 #endif // NDNSIM_HELPER_NDN_STRATEGY_CHOICE_HELPER_HPP
Copyright (c) 2011-2015 Regents of the University of California.
represents parameters in a ControlCommand request or response
NFD Strategy Choice Helper (FIB) helper.
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:39
Copyright (c) 2011-2015 Regents of the University of California.
Implementation network-layer of NDN stack.
Represents a forwarding strategy.
Definition: strategy.hpp:38