22 #include <ndn-cxx/util/logger.hpp> 23 #include <boost/algorithm/string.hpp> 35 const ndn::Name& syncPrefix,
36 const ndn::Name& userPrefix,
37 ndn::time::milliseconds syncReplyFreshness,
38 ndn::time::milliseconds helloReplyFreshness)
39 : m_iblt(expectedNumEntries)
40 , m_expectedNumEntries(expectedNumEntries)
41 , m_threshold(expectedNumEntries/2)
43 , m_scheduler(m_face.getIoService())
44 , m_syncPrefix(syncPrefix)
45 , m_userPrefix(userPrefix)
46 , m_syncReplyFreshness(syncReplyFreshness)
47 , m_helloReplyFreshness(helloReplyFreshness)
48 , m_segmentPublisher(m_face, m_keyChain)
49 , m_rng(ndn::random::getRandomNumberEngine())
71 uint64_t seqNo = it->second;
74 ndn::Name prefixWithSeq = ndn::Name(prefix).appendNumber(seqNo);
77 uint32_t hash = hashIt->second;
88 NDN_LOG_DEBUG(
"UpdateSeq: " << prefix <<
" " << seq);
96 NDN_LOG_WARN(
"Prefix not found in m_prefixes");
101 NDN_LOG_WARN(
"Update has lower/equal seq no for prefix, doing nothing!");
108 ndn::Name prefixWithSeq = ndn::Name(prefix).appendNumber(oldSeq);
111 uint32_t hash = hashIt->second;
120 ndn::Name prefixWithSeq = ndn::Name(prefix).appendNumber(seq);
130 NDN_LOG_DEBUG(
"Sending application nack");
131 ndn::Name dataName(name);
134 dataName.appendSegment(0);
135 ndn::Data data(dataName);
137 data.setContentType(ndn::tlv::ContentType_Nack);
138 data.setFinalBlock(dataName[-1]);
146 NDN_LOG_ERROR(
"ProduerBase::onRegisterFailed " << prefix <<
" " << msg);
147 BOOST_THROW_EXCEPTION(Error(msg));
void onRegisterFailed(const ndn::Name &prefix, const std::string &msg) const
Logs a message if setting an interest filter fails.
void sendApplicationNack(const ndn::Name &name)
Sends a data packet with content type nack.
void updateSeqNo(const ndn::Name &prefix, uint64_t seq)
Update m_prefixes and IBF with the given prefix and seq.
uint32_t murmurHash3(uint32_t nHashSeed, const std::vector< unsigned char > &vDataToHash)
bool addUserNode(const ndn::Name &prefix)
Adds a user node for synchronization.
void removeUserNode(const ndn::Name &prefix)
Remove the user node from synchronization.
void insert(uint32_t key)
ProducerBase(size_t expectedNumEntries, ndn::Face &face, const ndn::Name &syncPrefix, const ndn::Name &userPrefix, ndn::time::milliseconds syncReplyFreshness=SYNC_REPLY_FRESHNESS, ndn::time::milliseconds helloReplyFreshness=HELLO_REPLY_FRESHNESS)
constructor
std::map< uint32_t, ndn::Name > m_hash2prefix
std::map< ndn::Name, uint32_t > m_prefix2hash
ndn::time::milliseconds m_syncReplyFreshness
void appendToName(ndn::Name &name) const
Appends self to name.
Base class for PartialProducer and FullProducer.
std::map< ndn::Name, uint64_t > m_prefixes