NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
ndn-stack-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_STACK_HELPER_HPP
21 #define NDNSIM_HELPER_NDN_STACK_HELPER_HPP
22 
23 #include "ns3/ndnSIM/model/ndn-common.hpp"
24 
25 #include "ns3/ptr.h"
26 #include "ns3/object-factory.h"
27 #include "ns3/node.h"
28 #include "ns3/node-container.h"
29 
30 #include "ndn-face-container.hpp"
31 #include "ndn-fib-helper.hpp"
33 
34 namespace nfd {
35 namespace cs {
36 class Policy;
37 } // namespace cs
38 } // namespace nfd
39 
40 namespace ns3 {
41 
42 class Node;
43 
44 namespace ndn {
45 
46 class L3Protocol;
47 
56 class StackHelper : boost::noncopyable {
57 public:
61  StackHelper();
62 
66  virtual ~StackHelper();
67 
71  void
72  SetStackAttributes(const std::string& attr1 = "", const std::string& value1 = "",
73  const std::string& attr2 = "", const std::string& value2 = "",
74  const std::string& attr3 = "", const std::string& value3 = "",
75  const std::string& attr4 = "", const std::string& value4 = "");
76 
80  void
81  setCsSize(size_t maxSize);
82 
86  void
87  setPolicy(const std::string& policy);
88 
95  void
96  SetOldContentStore(const std::string& contentStoreClass, const std::string& attr1 = "",
97  const std::string& value1 = "", const std::string& attr2 = "",
98  const std::string& value2 = "", const std::string& attr3 = "",
99  const std::string& value3 = "", const std::string& attr4 = "",
100  const std::string& value4 = "");
101 
102  typedef Callback<shared_ptr<Face>, Ptr<Node>, Ptr<L3Protocol>, Ptr<NetDevice>>
104 
114  void
115  AddFaceCreateCallback(TypeId netDeviceType, FaceCreateCallback callback);
116 
125  void
126  UpdateFaceCreateCallback(TypeId netDeviceType, FaceCreateCallback callback);
127 
132  void
133  RemoveFaceCreateCallback(TypeId netDeviceType, FaceCreateCallback callback);
134 
146  Ptr<FaceContainer>
147  Install(const std::string& nodeName) const;
148 
160  Ptr<FaceContainer>
161  Install(Ptr<Node> node) const;
162 
175  Ptr<FaceContainer>
176  Install(const NodeContainer& c) const;
177 
184  Ptr<FaceContainer>
185  InstallAll() const;
186 
190  void
191  SetDefaultRoutes(bool needSet);
192 
193  static KeyChain&
194  getKeyChain();
195 
201  void
202  Update(Ptr<Node> node);
203 
209  void
210  Update(const NodeContainer& c);
211 
217  void
218  Update(const std::string& nodeName);
219 
223  void
224  UpdateAll();
225 
229  void
231 
232  // Cannot be disabled for now
233  // /**
234  // * \brief Disable Face Manager
235  // */
236  // void
237  // disableFaceManager();
238 
242  void
244 
248  void
250 
251 private:
252  shared_ptr<Face>
253  DefaultNetDeviceCallback(Ptr<Node> node, Ptr<L3Protocol> ndn, Ptr<NetDevice> netDevice) const;
254 
255  shared_ptr<Face>
256  PointToPointNetDeviceCallback(Ptr<Node> node, Ptr<L3Protocol> ndn,
257  Ptr<NetDevice> netDevice) const;
258  shared_ptr<Face>
259  createAndRegisterFace(Ptr<Node> node, Ptr<L3Protocol> ndn, Ptr<NetDevice> device) const;
260 
261  bool m_isRibManagerDisabled;
262  // bool m_isFaceManagerDisabled;
263  bool m_isForwarderStatusManagerDisabled;
264  bool m_isStrategyChoiceManagerDisabled;
265 
266 public:
267  void
269 
270 private:
271  ObjectFactory m_ndnFactory;
272  ObjectFactory m_contentStoreFactory;
273 
274  bool m_needSetDefaultRoutes;
275  size_t m_maxCsSize;
276 
277  typedef std::function<std::unique_ptr<nfd::cs::Policy>()> PolicyCreationCallback;
278  PolicyCreationCallback m_csPolicyCreationFunc;
279 
280  std::map<std::string, PolicyCreationCallback> m_csPolicies;
281 
282  typedef std::list<std::pair<TypeId, FaceCreateCallback>> NetDeviceCallbackList;
283  NetDeviceCallbackList m_netDeviceCallbacks;
284 };
285 
286 } // namespace ndn
287 } // namespace ns3
288 
289 #endif // NDNSIM_HELPER_NDN_STACK_HELPER_HPP
virtual ~StackHelper()
Destroy the NdnStackHelper.
Copyright (c) 2011-2015 Regents of the University of California.
void setPolicy(const std::string &policy)
Set the cache replacement policy for NFD&#39;s Content Store.
StackHelper()
Create a new NdnStackHelper with a default NDN_FLOODING forwarding stategy.
void RemoveFaceCreateCallback(TypeId netDeviceType, FaceCreateCallback callback)
Remove callback to create and configure instance of the face, based on supplied Ptr<Node> and Ptr<Net...
void setCsSize(size_t maxSize)
Set maximum size for NFD&#39;s Content Store (in number of packets)
void SetDefaultRoutes(bool needSet)
Set flag indicating necessity to install default routes in FIB.
void SetStackAttributes(const std::string &attr1="", const std::string &value1="", const std::string &attr2="", const std::string &value2="", const std::string &attr3="", const std::string &value3="", const std::string &attr4="", const std::string &value4="")
Set parameters of NdnL3Protocol.
void disableForwarderStatusManager()
Disable Forwarder Status Manager.
Ptr< FaceContainer > Install(const std::string &nodeName) const
Install Ndn stack on the node.
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
Callback< shared_ptr< Face >, Ptr< Node >, Ptr< L3Protocol >, Ptr< NetDevice > > FaceCreateCallback
Helper class to install NDN stack and configure its parameters.
Copyright (c) 2011-2015 Regents of the University of California.
void AddFaceCreateCallback(TypeId netDeviceType, FaceCreateCallback callback)
Add callback to create and configure instance of the face, based on supplied Ptr<Node> and Ptr<NetDev...
void disableRibManager()
Disable the RIB manager of NFD.
ndn L3Protocol
Copyright (c) 2011-2015 Regents of the University of California.
void SetOldContentStore(const std::string &contentStoreClass, const std::string &attr1="", const std::string &value1="", const std::string &attr2="", const std::string &value2="", const std::string &attr3="", const std::string &value3="", const std::string &attr4="", const std::string &value4="")
Set ndnSIM 1.0 content store implementation and its attributes.
Ptr< FaceContainer > InstallAll() const
Install Ndn stack on all nodes in the simulation.
void UpdateAll()
Update Ndn stack on all the nodes (Add faces for new devices)
static KeyChain & getKeyChain()
void UpdateFaceCreateCallback(TypeId netDeviceType, FaceCreateCallback callback)
Update callback to create and configure instance of the face, based on supplied Ptr<Node> and Ptr<Net...
void Update(Ptr< Node > node)
Update Ndn stack on a given node (Add faces for new devices)
ndn security v2 KeyChain
Definition: key-chain.cpp:70
void disableStrategyChoiceManager()
Disable Face Manager.