NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
auto-prefix-propagator.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26 #ifndef NFD_RIB_AUTO_PREFIX_PROPAGATOR_HPP
27 #define NFD_RIB_AUTO_PREFIX_PROPAGATOR_HPP
28 
29 #include "rib.hpp"
30 #include "core/config-file.hpp"
31 #include "propagated-entry.hpp"
32 
33 #include <ndn-cxx/security/key-chain.hpp>
34 #include <ndn-cxx/mgmt/nfd/controller.hpp>
35 #include <ndn-cxx/mgmt/nfd/control-command.hpp>
36 #include <ndn-cxx/mgmt/nfd/control-parameters.hpp>
37 #include <ndn-cxx/mgmt/nfd/command-options.hpp>
38 #include <ndn-cxx/util/signal.hpp>
39 
40 namespace nfd {
41 namespace rib {
42 
76 class AutoPrefixPropagator : noncopyable
77 {
78 public:
79  class Error : public std::runtime_error
80  {
81  public:
82  explicit
83  Error(const std::string& what)
84  : std::runtime_error(what)
85  {
86  }
87  };
88 
90  ndn::KeyChain& keyChain,
91  Rib& rib);
97  void
98  loadConfig(const ConfigSection& configSection);
99 
103  void
104  enable();
105 
109  void
110  disable();
111 
122  typedef std::unordered_map<Name, PropagatedEntry> PropagatedEntryList;
123  typedef PropagatedEntryList::iterator PropagatedEntryIt;
124 
131  struct PrefixPropagationParameters
132  {
133  bool isValid;
134  ndn::nfd::ControlParameters parameters;
135  ndn::nfd::CommandOptions options;
136  };
137 
151  PrefixPropagationParameters
152  getPrefixPropagationParameters(const Name& localRibPrefix);
153 
162  bool
163  doesCurrentPropagatedPrefixWork(const Name& prefix);
164 
178  void
179  redoPropagation(PropagatedEntryIt entryIt,
180  const ndn::nfd::ControlParameters& parameters,
181  const ndn::nfd::CommandOptions& options,
182  time::seconds retryWaitTime);
183 
184 private:
204  void
205  advertise(const ndn::nfd::ControlParameters& parameters,
206  const ndn::nfd::CommandOptions& options,
207  time::seconds retryWaitTime);
208 
216  void
217  withdraw(const ndn::nfd::ControlParameters& parameters,
218  const ndn::nfd::CommandOptions& options,
219  time::seconds retryWaitTime);
220 
230  void
231  afterInsertRibEntry(const Name& prefix);
232 
243  void
244  afterEraseRibEntry(const Name& prefix);
245 
246 PUBLIC_WITH_TESTS_ELSE_PRIVATE: // PropagatedEntry state changes
255  void
256  afterRibInsert(const ndn::nfd::ControlParameters& parameters,
257  const ndn::nfd::CommandOptions& options);
258 
267  void
268  afterRibErase(const ndn::nfd::ControlParameters& parameters,
269  const ndn::nfd::CommandOptions& options);
270 
278  void
279  afterHubConnect();
280 
288  void
289  afterHubDisconnect();
290 
310  void
311  afterPropagateSucceed(const ndn::nfd::ControlParameters& parameters,
312  const ndn::nfd::CommandOptions& options,
313  const scheduler::EventCallback& refreshEvent);
314 
329  void
330  afterPropagateFail(const ndn::nfd::ControlResponse& response,
331  const ndn::nfd::ControlParameters& parameters,
332  const ndn::nfd::CommandOptions& options,
333  time::seconds retryWaitTime,
334  const scheduler::EventCallback& retryEvent);
335 
350  void
351  afterRevokeSucceed(const ndn::nfd::ControlParameters& parameters,
352  const ndn::nfd::CommandOptions& options,
353  time::seconds retryWaitTime);
354 
362  void
363  afterRevokeFail(const ndn::nfd::ControlResponse& response,
364  const ndn::nfd::ControlParameters& parameters,
365  const ndn::nfd::CommandOptions& options);
366 
377  void
378  onRefreshTimer(const ndn::nfd::ControlParameters& parameters,
379  const ndn::nfd::CommandOptions& options);
380 
392  void
393  onRetryTimer(const ndn::nfd::ControlParameters& parameters,
394  const ndn::nfd::CommandOptions& options,
395  time::seconds retryWaitTime);
396 
398  ndn::nfd::Controller& m_nfdController;
399  ndn::KeyChain& m_keyChain;
400  Rib& m_rib;
401  ndn::util::signal::ScopedConnection m_afterInsertConnection;
402  ndn::util::signal::ScopedConnection m_afterEraseConnection;
403  ndn::nfd::ControlParameters m_controlParameters;
404  ndn::nfd::CommandOptions m_commandOptions;
405  time::seconds m_refreshInterval;
406  time::seconds m_baseRetryWait;
407  time::seconds m_maxRetryWait;
408  bool m_hasConnectedHub;
409  PropagatedEntryList m_propagatedEntries;
410 };
411 
412 } // namespace rib
413 } // namespace nfd
414 
415 #endif // NFD_RIB_AUTO_PREFIX_PROPAGATOR_HPP
#define PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:40
function< void()> EventCallback
Definition: scheduler.hpp:46
represents the Routing Information Base
Definition: rib.hpp:59
The interface of signing key management.
Definition: key-chain.hpp:46
represents parameters in a ControlCommand request or response
Rib
Copyright (c) 2014-2017, Regents of the University of California, Arizona Board of Regents...
Definition: rib.cpp:31
STL namespace.
void disable()
disable automatic prefix propagation
Table::const_iterator iterator
Definition: cs-internal.hpp:41
contains options for ControlCommand execution
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
void loadConfig(const ConfigSection &configSection)
load the "auto_prefix_propagate" section from config file
disconnects a Connection automatically upon destruction
NFD Management protocol client.
Definition: controller.hpp:50
boost::property_tree::ptree ConfigSection
a config file section
Represents an absolute name.
Definition: name.hpp:42
void enable()
enable automatic prefix propagation
AutoPrefixPropagator(ndn::nfd::Controller &controller, ndn::KeyChain &keyChain, Rib &rib)
ControlCommand response.
provides automatic prefix propagation feature