NS-3 based Named Data Networking (NDN) simulator
ndnSIM: NDN, CCN, CCNx, content centric networks
API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
ndn-stack-helper.h
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2 /*
3  * Copyright (c) 2011 UCLA
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
19  * Ilya Moiseenko <iliamo@cs.ucla.edu>
20  */
21 
22 #ifndef NDN_STACK_HELPER_H
23 #define NDN_STACK_HELPER_H
24 
25 #include "ns3/packet.h"
26 #include "ns3/ptr.h"
27 #include "ns3/object-factory.h"
28 #include "ns3/nstime.h"
29 
30 namespace ns3 {
31 
32 class Node;
33 
34 namespace ndn {
35 
36 class FaceContainer;
37 class Face;
38 class NetDeviceFace;
39 class L3Protocol;
40 
63 {
64 public:
68  StackHelper();
69 
73  virtual ~StackHelper ();
74 
78  void
79  SetStackAttributes (const std::string &attr1 = "", const std::string &value1 = "",
80  const std::string &attr2 = "", const std::string &value2 = "",
81  const std::string &attr3 = "", const std::string &value3 = "",
82  const std::string &attr4 = "", const std::string &value4 = "");
83 
84 
93  void
94  SetForwardingStrategy (const std::string &forwardingStrategyClass,
95  const std::string &attr1 = "", const std::string &value1 = "",
96  const std::string &attr2 = "", const std::string &value2 = "",
97  const std::string &attr3 = "", const std::string &value3 = "",
98  const std::string &attr4 = "", const std::string &value4 = "");
99 
104  void
105  SetContentStore (const std::string &contentStoreClass,
106  const std::string &attr1 = "", const std::string &value1 = "",
107  const std::string &attr2 = "", const std::string &value2 = "",
108  const std::string &attr3 = "", const std::string &value3 = "",
109  const std::string &attr4 = "", const std::string &value4 = "");
110 
115  void
116  SetPit (const std::string &pitClass,
117  const std::string &attr1 = "", const std::string &value1 = "",
118  const std::string &attr2 = "", const std::string &value2 = "",
119  const std::string &attr3 = "", const std::string &value3 = "",
120  const std::string &attr4 = "", const std::string &value4 = "");
121 
126  void
127  SetFib (const std::string &fibClass,
128  const std::string &attr1 = "", const std::string &value1 = "",
129  const std::string &attr2 = "", const std::string &value2 = "",
130  const std::string &attr3 = "", const std::string &value3 = "",
131  const std::string &attr4 = "", const std::string &value4 = "");
132 
133  typedef Callback< Ptr<NetDeviceFace>, Ptr<Node>, Ptr<L3Protocol>, Ptr<NetDevice> > NetDeviceFaceCreateCallback;
134 
145  void
146  AddNetDeviceFaceCreateCallback (TypeId netDeviceType, NetDeviceFaceCreateCallback callback);
147 
155  void
156  UpdateNetDeviceFaceCreateCallback (TypeId netDeviceType, NetDeviceFaceCreateCallback callback);
157 
161  void
162  RemoveNetDeviceFaceCreateCallback (TypeId netDeviceType, NetDeviceFaceCreateCallback callback);
163 
172  void
173  EnableLimits (bool enable = true, Time avgRtt=Seconds(0.1), uint32_t avgData=1100, uint32_t avgInterest=40);
174 
186  Ptr<FaceContainer>
187  Install (const std::string &nodeName) const;
188 
200  Ptr<FaceContainer>
201  Install (Ptr<Node> node) const;
202 
215  Ptr<FaceContainer>
216  Install (const NodeContainer &c) const;
217 
224  Ptr<FaceContainer>
225  InstallAll () const;
226 
235  static void
236  AddRoute (const std::string &nodeName, const std::string &prefix, uint32_t faceId, int32_t metric);
237 
246  static void
247  AddRoute (Ptr<Node> node, const std::string &prefix, uint32_t faceId, int32_t metric);
248 
257  static void
258  AddRoute (Ptr<Node> node, const std::string &prefix, Ptr<Face> face, int32_t metric);
259 
268  static void
269  AddRoute (Ptr<Node> node, const std::string &prefix, Ptr<Node> otherNode, int32_t metric);
270 
279  static void
280  AddRoute (const std::string &nodeName, const std::string &prefix, const std::string &otherNodeName, int32_t metric);
281 
285  void
286  SetDefaultRoutes (bool needSet);
287 
288 private:
289  Ptr<NetDeviceFace>
290  DefaultNetDeviceCallback (Ptr<Node> node, Ptr<L3Protocol> ndn, Ptr<NetDevice> netDevice) const;
291 
292  Ptr<NetDeviceFace>
293  PointToPointNetDeviceCallback (Ptr<Node> node, Ptr<L3Protocol> ndn, Ptr<NetDevice> netDevice) const;
294 
295 private:
296  StackHelper (const StackHelper &);
297  StackHelper &operator = (const StackHelper &o);
298 
299 private:
300  ObjectFactory m_ndnFactory;
301  ObjectFactory m_strategyFactory;
302  ObjectFactory m_contentStoreFactory;
303  ObjectFactory m_pitFactory;
304  ObjectFactory m_fibFactory;
305 
306  bool m_limitsEnabled;
307  Time m_avgRtt;
308  uint32_t m_avgDataSize;
309  uint32_t m_avgInterestSize;
310  bool m_needSetDefaultRoutes;
311 
312  typedef std::list< std::pair<TypeId, NetDeviceFaceCreateCallback> > NetDeviceCallbackList;
313  NetDeviceCallbackList m_netDeviceCallbacks;
314 };
315 
316 } // namespace ndn
317 } // namespace ns3
318 
319 #endif /* NDN_STACK_HELPER_H */
Adding Ndn functionality to existing Nodes.
void SetDefaultRoutes(bool needSet)
Set flag indicating necessity to install default routes in FIB.
StackHelper()
Create a new NdnStackHelper with a default NDN_FLOODING forwarding stategy.
void RemoveNetDeviceFaceCreateCallback(TypeId netDeviceType, NetDeviceFaceCreateCallback callback)
Remove callback to create and configure instance of the face, based on supplied Ptr and Ptr
void SetContentStore(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 content store class and its attributes.
Ptr< FaceContainer > InstallAll() const
Install Ndn stack on all nodes in the simulation.
void UpdateNetDeviceFaceCreateCallback(TypeId netDeviceType, NetDeviceFaceCreateCallback callback)
Update callback to create and configure instance of the face, based on supplied Ptr and Ptr
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 AddNetDeviceFaceCreateCallback(TypeId netDeviceType, NetDeviceFaceCreateCallback callback)
Add callback to create and configure instance of the face, based on supplied Ptr and Ptr
virtual ~StackHelper()
Destroy the NdnStackHelper.
static void AddRoute(const std::string &nodeName, const std::string &prefix, uint32_t faceId, int32_t metric)
Add forwarding entry to FIB.
void EnableLimits(bool enable=true, Time avgRtt=Seconds(0.1), uint32_t avgData=1100, uint32_t avgInterest=40)
Enable Interest limits (disabled by default)
void SetForwardingStrategy(const std::string &forwardingStrategyClass, 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 forwarding strategy class and its attributes.
void SetPit(const std::string &pitClass, 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 PIT class and its attributes.
Ptr< FaceContainer > Install(const std::string &nodeName) const
Install Ndn stack on the node.
void SetFib(const std::string &fibClass, 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 FIB class and its attributes.