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-fib-helper.hpp"
32 
33 namespace nfd {
34 namespace cs {
35 class Policy;
36 } // namespace cs
37 } // namespace nfd
38 
39 namespace ns3 {
40 
41 class Node;
42 
43 namespace ndn {
44 
45 class L3Protocol;
46 
55 class StackHelper : boost::noncopyable {
56 public:
60  StackHelper();
61 
65  virtual ~StackHelper();
66 
70  void
71  SetStackAttributes(const std::string& attr1 = "", const std::string& value1 = "",
72  const std::string& attr2 = "", const std::string& value2 = "",
73  const std::string& attr3 = "", const std::string& value3 = "",
74  const std::string& attr4 = "", const std::string& value4 = "");
75 
79  void
80  setCsSize(size_t maxSize);
81 
85  void
86  setPolicy(const std::string& policy);
87 
94  void
95  SetOldContentStore(const std::string& contentStoreClass, const std::string& attr1 = "",
96  const std::string& value1 = "", const std::string& attr2 = "",
97  const std::string& value2 = "", const std::string& attr3 = "",
98  const std::string& value3 = "", const std::string& attr4 = "",
99  const std::string& value4 = "");
100 
101  typedef Callback<shared_ptr<Face>, Ptr<Node>, Ptr<L3Protocol>, Ptr<NetDevice>>
103 
113  void
114  AddFaceCreateCallback(TypeId netDeviceType, FaceCreateCallback callback);
115 
124  void
125  UpdateFaceCreateCallback(TypeId netDeviceType, FaceCreateCallback callback);
126 
131  void
132  RemoveFaceCreateCallback(TypeId netDeviceType, FaceCreateCallback callback);
133 
145  void
146  Install(const std::string& nodeName) const;
147 
159  void
160  Install(Ptr<Node> node) const;
161 
174  void
175  Install(const NodeContainer& c) const;
176 
183  void
184  InstallAll() const;
185 
189  void
190  SetDefaultRoutes(bool needSet);
191 
192  static KeyChain&
193  getKeyChain();
194 
200  void
201  Update(Ptr<Node> node);
202 
208  void
209  Update(const NodeContainer& c);
210 
216  void
217  Update(const std::string& nodeName);
218 
222  void
223  UpdateAll();
224 
228  void
230 
234  void
236 
240  static void
242 
243  static void
245 
246 private:
247  void
248  doInstall(Ptr<Node> node) const;
249 
250 private:
251  shared_ptr<Face>
252  DefaultNetDeviceCallback(Ptr<Node> node, Ptr<L3Protocol> ndn, Ptr<NetDevice> netDevice) const;
253 
254  shared_ptr<Face>
255  PointToPointNetDeviceCallback(Ptr<Node> node, Ptr<L3Protocol> ndn,
256  Ptr<NetDevice> netDevice) const;
257  shared_ptr<Face>
258  createAndRegisterFace(Ptr<Node> node, Ptr<L3Protocol> ndn, Ptr<NetDevice> device) const;
259 
260  bool m_isForwarderStatusManagerDisabled;
261  bool m_isStrategyChoiceManagerDisabled;
262 
263 public:
264  void
266 
267 private:
268  ObjectFactory m_ndnFactory;
269  ObjectFactory m_contentStoreFactory;
270 
271  bool m_needSetDefaultRoutes;
272  size_t m_maxCsSize;
273 
274  typedef std::function<std::unique_ptr<nfd::cs::Policy>()> PolicyCreationCallback;
275  PolicyCreationCallback m_csPolicyCreationFunc;
276 
277  std::map<std::string, PolicyCreationCallback> m_csPolicies;
278 
279  typedef std::list<std::pair<TypeId, FaceCreateCallback>> NetDeviceCallbackList;
280  NetDeviceCallbackList m_netDeviceCallbacks;
281 };
282 
283 } // namespace ndn
284 } // namespace ns3
285 
286 #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's Content Store.
StackHelper()
Create a new NdnStackHelper with a default NDN_FLOODING forwarding stategy.
static void ProcessWarmupEvents()
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's Content Store (in number of packets)
void SetDefaultRoutes(bool needSet)
Set flag indicating necessity to install default routes in FIB.
static void SetLinkDelayAsFaceMetric()
Set face metric of all faces connected through PointToPoint channel to channel latency.
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 InstallAll() const
Install Ndn stack on all nodes in the simulation.
void disableForwarderStatusManager()
Disable Forwarder Status Manager.
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
void Install(const std::string &nodeName) const
Install Ndn stack on the node.
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...
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.
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:69
void disableStrategyChoiceManager()
Disable Strategy Choice Manager.