NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
ndn-l3-protocol.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
20 #ifndef NDN_L3_PROTOCOL_H
21 #define NDN_L3_PROTOCOL_H
22 
23 #include "ns3/ndnSIM/model/ndn-common.hpp"
24 
25 #include <list>
26 #include <vector>
27 
28 #include "ns3/ptr.h"
29 #include "ns3/net-device.h"
30 #include "ns3/nstime.h"
31 #include "ns3/traced-callback.h"
32 
33 #include <boost/property_tree/ptree_fwd.hpp>
34 
35 namespace nfd {
36 class Forwarder;
37 class FibManager;
39 typedef boost::property_tree::ptree ConfigSection;
40 namespace pit {
41 class Entry;
42 } // namespace pit
43 namespace cs {
44 class Policy;
45 } // namespace cs
46 namespace rib {
47 class Service;
48 }
49 } // namespace nfd
50 
51 namespace ns3 {
52 
53 class Packet;
54 class Node;
55 class Header;
56 
57 namespace ndn {
58 
80 class L3Protocol : boost::noncopyable, public Object {
81 public:
87  static TypeId
88  GetTypeId();
89 
90  static const uint16_t ETHERNET_FRAME_TYPE;
91  static const uint16_t IP_STACK_PORT;
92  // static const uint16_t IP_PROTOCOL_TYPE; ///< \brief IP protocol type of NDN
93 
97  L3Protocol();
98 
99  virtual ~L3Protocol();
100 
104  shared_ptr<nfd::Forwarder>
105  getForwarder();
106 
110  shared_ptr<nfd::FibManager>
111  getFibManager();
112 
118 
120  getRibService();
121 
131  addFace(shared_ptr<Face> face);
132 
138  shared_ptr<Face>
139  getFaceById(nfd::FaceId face) const;
140 
141  // /**
142  // * \brief Remove face from ndn stack (remove callbacks)
143  // */
144  // virtual void
145  // removeFace(shared_ptr<Face> face);
146 
150  shared_ptr<Face>
151  getFaceByNetDevice(Ptr<NetDevice> netDevice) const;
152 
157  getConfig();
158 
162  void
163  injectInterest(const Interest& interest);
164 
165  typedef std::function<std::unique_ptr<nfd::cs::Policy>()> PolicyCreationCallback;
166 
170  void
172 
173 public: // Workaround for python bindings
174  static Ptr<L3Protocol>
175  getL3Protocol(Ptr<Object> node);
176 
177 public:
178  typedef void (*InterestTraceCallback)(const Interest&, const Face&);
179  typedef void (*DataTraceCallback)(const Data&, const Face&);
180 
181  typedef void (*SatisfiedInterestsCallback)(const nfd::pit::Entry& pitEntry, const Face& inFace, const Data& data);
182  typedef void (*TimedOutInterestsCallback)(const nfd::pit::Entry& pitEntry);
183 
184 protected:
185  virtual void
186  DoDispose(void);
187 
194  virtual void
196 
197 private:
198  void
199  initialize();
200 
201  void
202  initializeManagement();
203 
204  void
205  initializeRibManager();
206 
207 private:
208  class Impl;
209  std::unique_ptr<Impl> m_impl;
210 
211  // These objects are aggregated, but for optimization, get them here
212  Ptr<Node> m_node;
213 
214  TracedCallback<const Interest&, const Face&>
215  m_inInterests;
216  TracedCallback<const Interest&, const Face&>
217  m_outInterests;
218 
219  TracedCallback<const Data&, const Face&> m_outData;
220  TracedCallback<const Data&, const Face&> m_inData;
221 
222  TracedCallback<const lp::Nack&, const Face&> m_outNack;
223  TracedCallback<const lp::Nack&, const Face&> m_inNack;
224 
225  TracedCallback<const nfd::pit::Entry&, const Face&/*in face*/, const Data&> m_satisfiedInterests;
226  TracedCallback<const nfd::pit::Entry&> m_timedOutInterests;
227 };
228 
229 } // namespace ndn
230 } // namespace ns3
231 
232 #endif /* NDN_L3_PROTOCOL_H */
static const uint16_t IP_STACK_PORT
TCP/UDP port for NDN stack.
Copyright (c) 2011-2015 Regents of the University of California.
shared_ptr< nfd::Forwarder > getForwarder()
Get smart pointer to nfd::Forwarder installed on the node.
static const uint16_t ETHERNET_FRAME_TYPE
Ethernet Frame Type of Ndn.
initializes and executes NFD-RIB service thread
Definition: service.hpp:51
implement the Strategy Choice Management of NFD Management Protocol.
nfd::ConfigSection & getConfig()
Get NFD config (boost::property_tree)
void(* InterestTraceCallback)(const Interest &, const Face &)
std::function< std::unique_ptr< nfd::cs::Policy >)> PolicyCreationCallback
void(* DataTraceCallback)(const Data &, const Face &)
shared_ptr< nfd::FibManager > getFibManager()
Get smart pointer to nfd::FibManager, used by node's NFD.
virtual void NotifyNewAggregate()
This function will notify other components connected to the node that a new stack member is now conne...
FibManager
Definition: fib-manager.cpp:38
shared_ptr< Face > getFaceByNetDevice(Ptr< NetDevice > netDevice) const
Remove face from ndn stack (remove callbacks)
static TypeId GetTypeId()
Interface ID.
represents a CS replacement policy
Definition: cs-policy.hpp:39
ndn Face
Definition: face-impl.hpp:42
::nfd::rib::Service & getRibService()
void setCsReplacementPolicy(const PolicyCreationCallback &policy)
Set the replacement policy of NFD's CS.
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
an Interest table entry
Definition: pit-entry.hpp:59
nfd::FaceId addFace(shared_ptr< Face > face)
Add face to NDN stack.
Copyright (c) 2011-2015 Regents of the University of California.
void(* TimedOutInterestsCallback)(const nfd::pit::Entry &pitEntry)
boost::property_tree::ptree ConfigSection
a config file section
L3Protocol()
Default constructor.
Forwarder
Definition: forwarder.cpp:40
void(* SatisfiedInterestsCallback)(const nfd::pit::Entry &pitEntry, const Face &inFace, const Data &data)
Implementation network-layer of NDN stack.
static Ptr< L3Protocol > getL3Protocol(Ptr< Object > node)
virtual void DoDispose(void)
Do cleanup.
nfd::StrategyChoiceManager & getStrategyChoiceManager()
Get nfd::StrategyChoiceManager, used by node's NFD.
void injectInterest(const Interest &interest)
Inject interest through internal Face.
uint64_t FaceId
identifies a face
Definition: face.hpp:39
shared_ptr< Face > getFaceById(nfd::FaceId face) const
Get face by face ID.