35 #include <ndn-cxx/ims/in-memory-storage-fifo.hpp>
36 #include <ndn-cxx/ims/in-memory-storage-persistent.hpp>
37 #include <ndn-cxx/security/key-chain.hpp>
38 #include <ndn-cxx/util/segmenter.hpp>
39 #include <ndn-cxx/util/segment-fetcher.hpp>
40 #include <ndn-cxx/util/signal.hpp>
41 #include <ndn-cxx/util/time.hpp>
43 #include <boost/multi_index_container.hpp>
44 #include <boost/multi_index/composite_key.hpp>
45 #include <boost/multi_index/hashed_index.hpp>
49 namespace bmi = boost::multi_index;
71 return m_lsdb.get<
byName>().find(std::make_tuple(router, lsaType)) != m_lsdb.end();
83 buildAndInstallOwnCoordinateLsa();
105 return m_isBuildAdjLsaScheduled;
118 return std::static_pointer_cast<T>(
findLsa(router, T::type()));
135 return std::hash<ndn::Name>{}(name);
143 return static_cast<int>(t);
151 std::shared_ptr<Lsa>,
158 bmi::const_mem_fun<Lsa, Lsa::Type, &Lsa::getType>
160 bmi::composite_key_hash<name_hash, enum_class_hash>
162 bmi::hashed_non_unique<
164 bmi::const_mem_fun<Lsa, Lsa::Type, &Lsa::getType>,
171 std::pair<LsaContainer::index<Lsdb::byType>::type::iterator,
172 LsaContainer::index<Lsdb::byType>::type::iterator>
175 return m_lsdb.get<
byType>().equal_range(T::type());
182 auto it = m_lsdb.get<byName>().find(std::make_tuple(router, lsaType));
183 return it != m_lsdb.end() ? *it :
nullptr;
187 incrementDataSentStats(
Lsa::Type lsaType)
201 incrementInterestRcvdStats(
Lsa::Type lsaType)
215 incrementInterestSentStats(
Lsa::Type lsaType)
234 isLsaNew(
const ndn::Name& originRouter,
Lsa::Type lsaType, uint64_t seqNo)
const
237 auto lsaPtr =
findLsa(originRouter, lsaType);
238 return lsaPtr ? lsaPtr->getSeqNo() < seqNo :
true;
242 installLsa(std::shared_ptr<Lsa> lsa);
253 removeLsa(
const ndn::Name& router,
Lsa::Type lsaType);
256 removeLsa(
const LsaContainer::index<Lsdb::byName>::type::iterator& lsaIt);
270 buildAndInstallOwnAdjLsa();
276 ndn::scheduler::EventId
277 scheduleLsaExpiration(std::shared_ptr<Lsa> lsa, ndn::time::seconds expTime);
283 expireOrRefreshLsa(std::shared_ptr<Lsa> lsa);
286 processInterestForLsa(
const ndn::Interest& interest,
const ndn::Name& originRouter,
290 expressInterest(
const ndn::Name& interestName, uint32_t timeoutCount, uint64_t incomingFaceId,
291 ndn::time::steady_clock::time_point deadline = DEFAULT_LSA_RETRIEVAL_DEADLINE);
308 onFetchLsaError(uint32_t errorCode,
const std::string& msg,
309 const ndn::Name& interestName, uint32_t retransmitNo,
310 const ndn::time::steady_clock::time_point& deadline,
311 ndn::Name lsaName, uint64_t seqNo);
320 afterFetchLsa(
const ndn::ConstBufferPtr& bufferPtr,
const ndn::Name& interestName);
323 emitSegmentValidatedSignal(
const ndn::Data& data)
328 ndn::time::system_clock::time_point
329 getLsaExpirationTimePoint()
const
338 std::list<ndn::Name>, std::list<ndn::Name>>;
343 ndn::Scheduler m_scheduler;
350 ndn::time::seconds m_lsaRefreshTime;
351 ndn::time::seconds m_adjLsaBuildInterval;
352 const ndn::Name& m_thisRouterPrefix;
356 std::map<ndn::Name, uint64_t> m_highestSeqNo;
360 ndn::signal::ScopedConnection m_onNewLsaConnection;
362 std::set<std::shared_ptr<ndn::SegmentFetcher>> m_fetchers;
363 ndn::Segmenter m_segmenter;
364 ndn::InMemoryStorageFifo m_segmentFifo;
366 bool m_isBuildAdjLsaScheduled;
367 int64_t m_adjBuildCount;
368 ndn::scheduler::ScopedEventId m_scheduledAdjLsaBuild;
370 ndn::InMemoryStoragePersistent m_lsaStorage;
372 static inline const ndn::time::steady_clock::time_point DEFAULT_LSA_RETRIEVAL_DEADLINE =
373 ndn::time::steady_clock::time_point::min();
A class to house all the configuration parameters for NLSR.
uint32_t getRouterDeadInterval() const
Represents a Link State Announcement (LSA).
const ndn::Name & getOriginRouter() const
std::shared_ptr< T > findLsa(const ndn::Name &router) const
ndn::signal::Signal< Lsdb, Statistics::PacketType > lsaIncrementSignal
bool doesLsaExist(const ndn::Name &router, Lsa::Type lsaType)
Returns whether the LSDB contains some LSA.
ndn::signal::Signal< Lsdb, std::shared_ptr< Lsa >, LsdbUpdate, std::list< ndn::Name >, std::list< ndn::Name > > AfterLsdbModified
std::pair< LsaContainer::index< Lsdb::byType >::type::iterator, LsaContainer::index< Lsdb::byType >::type::iterator > getLsdbIterator() const
void buildAndInstallOwnNameLsa()
Builds a name LSA for this router and then installs it into the LSDB.
boost::multi_index_container< std::shared_ptr< Lsa >, bmi::indexed_by< bmi::hashed_unique< bmi::tag< byName >, bmi::composite_key< Lsa, ExtractOriginRouter, bmi::const_mem_fun< Lsa, Lsa::Type, &Lsa::getType > >, bmi::composite_key_hash< name_hash, enum_class_hash > >, bmi::hashed_non_unique< bmi::tag< byType >, bmi::const_mem_fun< Lsa, Lsa::Type, &Lsa::getType >, enum_class_hash > > > LsaContainer
AfterLsdbModified onLsdbModified
void processInterest(const ndn::Name &name, const ndn::Interest &interest)
ndn::signal::Signal< Lsdb, ndn::Data > afterSegmentValidatedSignal
bool getIsBuildAdjLsaScheduled() const
void scheduleAdjLsaBuild()
Schedules a build of this router's LSA.
Lsdb(ndn::Face &face, ndn::KeyChain &keyChain, ConfParameter &confParam)
SyncLogicHandler & getSync()
@ SENT_COORD_LSA_INTEREST
NLSR-to-sync interaction point.
Copyright (c) 2014-2020, The University of Memphis, Regents of the University of California.
constexpr ndn::time::seconds GRACE_PERIOD
int operator()(T t) const
int operator()(const ndn::Name &name) const
#define PUBLIC_WITH_TESTS_ELSE_PRIVATE