NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
fib-updater.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26 #ifndef NFD_RIB_FIB_UPDATER_HPP
27 #define NFD_RIB_FIB_UPDATER_HPP
28 
29 #include "core/common.hpp"
30 #include "fib-update.hpp"
31 #include "rib.hpp"
32 #include "rib-update-batch.hpp"
33 
34 #include <ndn-cxx/mgmt/nfd/controller.hpp>
35 
36 namespace nfd {
37 namespace rib {
38 
41 class FibUpdater : noncopyable
42 {
43 public:
44  class Error : public std::runtime_error
45  {
46  public:
47  explicit
48  Error(const std::string& what)
49  : std::runtime_error(what)
50  {
51  }
52  };
53 
54 public:
55  typedef std::list<FibUpdate> FibUpdateList;
56 
57  typedef function<void(RibUpdateList inheritedRoutes)> FibUpdateSuccessCallback;
58  typedef function<void(uint32_t code, const std::string& error)> FibUpdateFailureCallback;
59 
60  FibUpdater(Rib& rib, ndn::nfd::Controller& controller);
61 
68  void
70  const FibUpdateSuccessCallback& onSuccess,
71  const FibUpdateFailureCallback& onFailure);
72 
77  void
78  computeUpdates(const RibUpdateBatch& batch);
79 
88  void
89  sendUpdates(const FibUpdateList& updates,
90  const FibUpdateSuccessCallback& onSuccess,
91  const FibUpdateFailureCallback& onFailure);
92 
96  void
97  sendUpdatesForBatchFaceId(const FibUpdateSuccessCallback& onSuccess,
98  const FibUpdateFailureCallback& onFailure);
99 
103  void
104  sendUpdatesForNonBatchFaceId(const FibUpdateSuccessCallback& onSuccess,
105  const FibUpdateFailureCallback& onFailure);
106 
112  void
113  sendAddNextHopUpdate(const FibUpdate& update,
114  const FibUpdateSuccessCallback& onSuccess,
115  const FibUpdateFailureCallback& onFailure,
116  uint32_t nTimeouts = 0);
117 
123  void
124  sendRemoveNextHopUpdate(const FibUpdate& update,
125  const FibUpdateSuccessCallback& onSuccess,
126  const FibUpdateFailureCallback& onFailure,
127  uint32_t nTimeouts = 0);
128 
129 private:
132  void
133  computeUpdatesForRegistration(const RibUpdate& update);
134 
137  void
138  computeUpdatesForUnregistration(const RibUpdate& update);
139 
152  void
153  onUpdateSuccess(const FibUpdate update,
154  const FibUpdateSuccessCallback& onSuccess,
155  const FibUpdateFailureCallback& onFailure);
156 
172  void
173  onUpdateError(const FibUpdate update,
174  const FibUpdateSuccessCallback& onSuccess,
175  const FibUpdateFailureCallback& onFailure,
176  const ndn::nfd::ControlResponse& response, uint32_t nTimeouts);
177 
178 private:
186  void
187  addFibUpdate(const FibUpdate update);
188 
191  void
192  addInheritedRoutes(const RibEntry& entry, const Rib::RouteSet& routesToAdd);
193 
197  void
198  addInheritedRoutes(const Name& name, const Rib::RouteSet& routesToAdd, const Route& ignore);
199 
202  void
203  removeInheritedRoutes(const RibEntry& entry, const Rib::RouteSet& routesToRemove);
204 
207  void
208  createFibUpdatesForNewRibEntry(const Name& name, const Route& route,
209  const Rib::RibEntryList& children);
210 
213  void
214  createFibUpdatesForNewRoute(const RibEntry& entry, const Route& route,
215  const bool captureWasTurnedOn);
216 
219  void
220  createFibUpdatesForUpdatedRoute(const RibEntry& entry, const Route& route,
221  const Route& existingRoute);
222 
225  void
226  createFibUpdatesForErasedRoute(const RibEntry& entry, const Route& route,
227  const bool captureWasTurnedOff);
228 
231  void
232  createFibUpdatesForErasedRibEntry(const RibEntry& entry);
233 
236  void
237  modifyChildrensInheritedRoutes(const Rib::RibEntryList& children,
238  const Rib::RouteSet& routesToAdd,
239  const Rib::RouteSet& routesToRemove);
240 
243  void
244  traverseSubTree(const RibEntry& entry, Rib::RouteSet routesToAdd, Rib::RouteSet routesToRemove);
245 
246 private:
249  void
250  addInheritedRoute(const Name& name, const Route& route);
251 
254  void
255  removeInheritedRoute(const Name& name, const Route& route);
256 
257 private:
258  const Rib& m_rib;
259  ndn::nfd::Controller& m_controller;
260  uint64_t m_batchFaceId;
261 
263  FibUpdateList m_updatesForBatchFaceId;
264  FibUpdateList m_updatesForNonBatchFaceId;
265 
269  RibUpdateList m_inheritedRoutes;
270 
271 private:
272  static const unsigned int MAX_NUM_TIMEOUTS;
273  static const uint32_t ERROR_FACE_NOT_FOUND;
274 };
275 
276 } // namespace rib
277 } // namespace nfd
278 
279 #endif // NFD_RIB_FIB_UPDATER_HPP
#define PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:40
FibUpdater(Rib &rib, ndn::nfd::Controller &controller)
Definition: fib-updater.cpp:42
represents the Routing Information Base
Definition: rib.hpp:59
function< void(RibUpdateList inheritedRoutes)> FibUpdateSuccessCallback
Definition: fib-updater.hpp:57
represents a collection of RibUpdates to be applied to a single FaceId
STL namespace.
computes FibUpdates based on updates to the RIB and sends them to NFD
Definition: fib-updater.hpp:41
std::list< FibUpdate > FibUpdateList
Definition: fib-updater.hpp:55
function< void(uint32_t code, const std::string &error)> FibUpdateFailureCallback
Definition: fib-updater.hpp:58
std::set< Route, RouteComparePredicate > RouteSet
Definition: rib.hpp:67
represents a FIB update
Definition: fib-update.hpp:37
std::list< shared_ptr< RibEntry > > RibEntryList
Definition: rib.hpp:62
std::list< RibUpdate > RibUpdateList
Error(const std::string &what)
Definition: fib-updater.hpp:48
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
represents a RIB entry, which contains one or more Routes with the same prefix
Definition: rib-entry.hpp:36
represents a route for a name prefix
Definition: route.hpp:39
NFD Management protocol client.
Definition: controller.hpp:50
Represents an absolute name.
Definition: name.hpp:42
ControlCommand response.
void computeAndSendFibUpdates(const RibUpdateBatch &batch, const FibUpdateSuccessCallback &onSuccess, const FibUpdateFailureCallback &onFailure)
computes FibUpdates using the provided RibUpdateBatch and then sends the updates to NFD&#39;s FIB ...
Definition: fib-updater.cpp:50