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;
38 class FaceTable;
40 typedef boost::property_tree::ptree ConfigSection;
41 namespace pit {
42 class Entry;
43 } // namespace pit
44 namespace cs {
45 class Policy;
46 } // namespace cs
47 namespace rib {
48 class Service;
49 }
50 } // namespace nfd
51 
52 namespace ns3 {
53 
54 class Packet;
55 class Node;
56 class Header;
57 
58 namespace ndn {
59 
81 class L3Protocol : boost::noncopyable, public Object {
82 public:
88  static TypeId
89  GetTypeId();
90 
91  static const uint16_t ETHERNET_FRAME_TYPE;
92  static const uint16_t IP_STACK_PORT;
93  // static const uint16_t IP_PROTOCOL_TYPE; ///< \brief IP protocol type of NDN
94 
98  L3Protocol();
99 
100  virtual ~L3Protocol();
101 
105  shared_ptr<nfd::Forwarder>
106  getForwarder();
107 
109  getFaceTable();
110 
114  shared_ptr<nfd::FibManager>
115  getFibManager();
116 
122 
124  getRibService();
125 
135  addFace(shared_ptr<Face> face);
136 
142  shared_ptr<Face>
143  getFaceById(nfd::FaceId face) const;
144 
145  // /**
146  // * \brief Remove face from ndn stack (remove callbacks)
147  // */
148  // virtual void
149  // removeFace(shared_ptr<Face> face);
150 
154  shared_ptr<Face>
155  getFaceByNetDevice(Ptr<NetDevice> netDevice) const;
156 
161  getConfig();
162 
166  void
167  injectInterest(const Interest& interest);
168 
169  typedef std::function<std::unique_ptr<nfd::cs::Policy>()> PolicyCreationCallback;
170 
174  void
176 
177 public: // Workaround for python bindings
178  static Ptr<L3Protocol>
179  getL3Protocol(Ptr<Object> node);
180 
181 public:
182  typedef void (*InterestTraceCallback)(const Interest&, const Face&);
183  typedef void (*DataTraceCallback)(const Data&, const Face&);
184 
185  typedef void (*SatisfiedInterestsCallback)(const nfd::pit::Entry& pitEntry, const Face& inFace, const Data& data);
186  typedef void (*TimedOutInterestsCallback)(const nfd::pit::Entry& pitEntry);
187 
188 protected:
189  virtual void
190  DoDispose(void);
191 
198  virtual void
200 
201 private:
202  void
203  initialize();
204 
205  void
206  initializeManagement();
207 
208  void
209  initializeRibManager();
210 
211 private:
212  class Impl;
213  std::unique_ptr<Impl> m_impl;
214 
215  // These objects are aggregated, but for optimization, get them here
216  Ptr<Node> m_node;
217 
218  TracedCallback<const Interest&, const Face&>
219  m_inInterests;
220  TracedCallback<const Interest&, const Face&>
221  m_outInterests;
222 
223  TracedCallback<const Data&, const Face&> m_outData;
224  TracedCallback<const Data&, const Face&> m_inData;
225 
226  TracedCallback<const lp::Nack&, const Face&> m_outNack;
227  TracedCallback<const lp::Nack&, const Face&> m_inNack;
228 
229  TracedCallback<const nfd::pit::Entry&, const Face&/*in face*/, const Data&> m_satisfiedInterests;
230  TracedCallback<const nfd::pit::Entry&> m_timedOutInterests;
231 };
232 
233 } // namespace ndn
234 } // namespace ns3
235 
236 #endif /* NDN_L3_PROTOCOL_H */
ns3::ndn::L3Protocol::IP_STACK_PORT
static const uint16_t IP_STACK_PORT
TCP/UDP port for NDN stack.
Definition: ndn-l3-protocol.hpp:92
ns3::ndn::L3Protocol::getForwarder
shared_ptr< nfd::Forwarder > getForwarder()
Get smart pointer to nfd::Forwarder installed on the node.
Definition: ndn-l3-protocol.cpp:328
ns3::ndn::L3Protocol::TimedOutInterestsCallback
void(* TimedOutInterestsCallback)(const nfd::pit::Entry &pitEntry)
Definition: ndn-l3-protocol.hpp:186
ns3::ndn::L3Protocol::DataTraceCallback
void(* DataTraceCallback)(const Data &, const Face &)
Definition: ndn-l3-protocol.hpp:183
ndn::tlv::Interest
@ Interest
Definition: tlv.hpp:65
ns3
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-app-link-service.cpp:32
nfd::cs::Policy
represents a CS replacement policy
Definition: cs-policy.hpp:39
ns3::ndn::L3Protocol::addFace
nfd::FaceId addFace(shared_ptr< Face > face)
Add face to NDN stack.
Definition: ndn-l3-protocol.cpp:396
ns3::ndn::L3Protocol::NotifyNewAggregate
virtual void NotifyNewAggregate()
This function will notify other components connected to the node that a new stack member is now conne...
Definition: ndn-l3-protocol.cpp:368
ns3::ndn::L3Protocol::GetTypeId
static TypeId GetTypeId()
Interface ID.
Definition: ndn-l3-protocol.cpp:71
ns3::ndn::L3Protocol::~L3Protocol
virtual ~L3Protocol()
Definition: ndn-l3-protocol.cpp:205
nfd::StrategyChoiceManager
Implements the Strategy Choice Management of NFD Management Protocol.
Definition: strategy-choice-manager.hpp:42
nfd::FibManager
FibManager
Definition: fib-manager.cpp:39
ns3::ndn::L3Protocol::PolicyCreationCallback
std::function< std::unique_ptr< nfd::cs::Policy >)> PolicyCreationCallback
Definition: ndn-l3-protocol.hpp:169
ns3::ndn::L3Protocol::setCsReplacementPolicy
void setCsReplacementPolicy(const PolicyCreationCallback &policy)
Set the replacement policy of NFD's CS.
Definition: ndn-l3-protocol.cpp:252
ns3::ndn::L3Protocol::getL3Protocol
static Ptr< L3Protocol > getL3Protocol(Ptr< Object > node)
Definition: ndn-l3-protocol.cpp:473
ns3::ndn::L3Protocol::getFaceByNetDevice
shared_ptr< Face > getFaceByNetDevice(Ptr< NetDevice > netDevice) const
Get face for NetDevice.
Definition: ndn-l3-protocol.cpp:459
nfd::rib::Service
initializes and executes NFD-RIB service thread
Definition: service.hpp:53
ns3::ndn::L3Protocol::DoDispose
virtual void DoDispose(void)
Do cleanup.
Definition: ndn-l3-protocol.cpp:381
ns3::ndn::L3Protocol::getRibService
::nfd::rib::Service & getRibService()
Definition: ndn-l3-protocol.cpp:352
ns3::ndn::L3Protocol::getConfig
nfd::ConfigSection & getConfig()
Get NFD config (boost::property_tree)
Definition: ndn-l3-protocol.cpp:358
nfd
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
ns3::ndn::L3Protocol::getFaceTable
nfd::FaceTable & getFaceTable()
Definition: ndn-l3-protocol.cpp:334
nfd::face::FaceId
uint64_t FaceId
Identifies a face.
Definition: face-common.hpp:44
nfd::FaceTable
container of all faces
Definition: face-table.hpp:39
nfd::pit::Entry
An Interest table entry.
Definition: pit-entry.hpp:59
ns3::ndn::L3Protocol::Impl
Definition: ndn-l3-protocol.cpp:112
ns3::ndn::L3Protocol::getFibManager
shared_ptr< nfd::FibManager > getFibManager()
Get smart pointer to nfd::FibManager, used by node's NFD.
Definition: ndn-l3-protocol.cpp:340
ns3::ndn::L3Protocol::InterestTraceCallback
void(* InterestTraceCallback)(const Interest &, const Face &)
Definition: ndn-l3-protocol.hpp:182
nfd::ConfigSection
boost::property_tree::ptree ConfigSection
a config file section
Definition: ndn-l3-protocol.hpp:39
Face
ndn Face
Definition: face-impl.hpp:41
ndn::tlv::Data
@ Data
Definition: tlv.hpp:66
nfd::FaceTable
FaceTable
Definition: face-table.cpp:37
ns3::ndn::L3Protocol::getFaceById
shared_ptr< Face > getFaceById(nfd::FaceId face) const
Get face by face ID.
Definition: ndn-l3-protocol.cpp:453
nfd::Forwarder
Forwarder
Definition: forwarder.cpp:41
nfd::StrategyChoiceManager
StrategyChoiceManager
Definition: strategy-choice-manager.cpp:35
ns3::ndn::L3Protocol
Implementation network-layer of NDN stack.
Definition: ndn-l3-protocol.hpp:81
ns3::ndn::L3Protocol::ETHERNET_FRAME_TYPE
static const uint16_t ETHERNET_FRAME_TYPE
Ethernet Frame Type of Ndn.
Definition: ndn-l3-protocol.hpp:91
ns3::ndn::L3Protocol::L3Protocol
L3Protocol()
Default constructor.
Definition: ndn-l3-protocol.cpp:199
ns3::ndn::L3Protocol::SatisfiedInterestsCallback
void(* SatisfiedInterestsCallback)(const nfd::pit::Entry &pitEntry, const Face &inFace, const Data &data)
Definition: ndn-l3-protocol.hpp:185
ns3::ndn::L3Protocol::getStrategyChoiceManager
nfd::StrategyChoiceManager & getStrategyChoiceManager()
Get nfd::StrategyChoiceManager, used by node's NFD.
Definition: ndn-l3-protocol.cpp:346
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-strategy-choice-helper.hpp:34
ns3::ndn::L3Protocol::injectInterest
void injectInterest(const Interest &interest)
Inject interest through internal Face.
Definition: ndn-l3-protocol.cpp:246