psync::Consumer Class Reference

Consumer logic to subscribe to producer's data. More...

#include <consumer.hpp>

Public Member Functions

 Consumer (const ndn::Name &syncPrefix, ndn::Face &face, const ReceiveHelloCallback &onReceiveHelloData, const UpdateCallback &onUpdate, unsigned int count, double false_positive, ndn::time::milliseconds helloInterestLifetime=HELLO_INTEREST_LIFETIME, ndn::time::milliseconds syncInterestLifetime=SYNC_INTEREST_LIFETIME)
 constructor More...
 
bool addSubscription (const ndn::Name &prefix)
 Add prefix to subscription list. More...
 
ndn::optional< uint64_t > getSeqNo (const ndn::Name &prefix) const
 
std::set< ndn::Name > getSubscriptionList () const
 
bool isSubscribed (const ndn::Name &prefix) const
 
void sendHelloInterest ()
 send hello interest /<sync-prefix>/hello/ More...
 
void sendSyncInterest ()
 send sync interest /<sync-prefix>/sync/<BF>/<producers-IBF> More...
 
void stop ()
 Stop segment fetcher to stop the sync and free resources. More...
 

Detailed Description

Consumer logic to subscribe to producer's data.

Application needs to call sendHelloInterest to get the subscription list in psync::ReceiveHelloCallback. It can then add the desired names using addSubscription. Finally application will call sendSyncInterest. If the application adds something later to the subscription list then it may call sendSyncInterest again for sending the next sync interest with updated IBF immediately to reduce any delay in sync data. Whenever there is new data UpdateCallback will be called to notify the application.

If consumer wakes up after a long time to sync, producer may not decode the differences with its old IBF successfully and send an application nack. Upon receiving the nack, consumer will send a hello again and inform the application via psync::ReceiveHelloCallback and psync::UpdateCallback.

Currently, fetching of the data needs to be handled by the application.

Definition at line 63 of file consumer.hpp.

Constructor & Destructor Documentation

◆ Consumer()

psync::Consumer::Consumer ( const ndn::Name &  syncPrefix,
ndn::Face &  face,
const ReceiveHelloCallback onReceiveHelloData,
const UpdateCallback onUpdate,
unsigned int  count,
double  false_positive = 0.001,
ndn::time::milliseconds  helloInterestLifetime = HELLO_INTEREST_LIFETIME,
ndn::time::milliseconds  syncInterestLifetime = SYNC_INTEREST_LIFETIME 
)

constructor

Parameters
syncPrefixsyncPrefix to send hello/sync interests to producer
faceapplication's face
onReceiveHelloDatacall back to give hello data back to application
onUpdatecall back to give sync data back to application
countbloom filter number of expected elements (subscriptions) in bloom filter
false_positivebloom filter false positive probability
helloInterestLifetimelifetime of hello interest
syncInterestLifetimelifetime of sync interest

Definition at line 32 of file consumer.cpp.

Member Function Documentation

◆ addSubscription()

bool psync::Consumer::addSubscription ( const ndn::Name &  prefix)

Add prefix to subscription list.

Parameters
prefixprefix to be added to the list
Returns
true if prefix is added, false if it is already present

Definition at line 57 of file consumer.cpp.

◆ getSeqNo()

ndn::optional<uint64_t> psync::Consumer::getSeqNo ( const ndn::Name &  prefix) const
inline

Definition at line 125 of file consumer.hpp.

◆ getSubscriptionList()

std::set<ndn::Name> psync::Consumer::getSubscriptionList ( ) const
inline

Definition at line 113 of file consumer.hpp.

◆ isSubscribed()

bool psync::Consumer::isSubscribed ( const ndn::Name &  prefix) const
inline

Definition at line 119 of file consumer.hpp.

◆ sendHelloInterest()

void psync::Consumer::sendHelloInterest ( )

send hello interest /<sync-prefix>/hello/

Should be called by the application whenever it wants to send a hello

Definition at line 85 of file consumer.cpp.

◆ sendSyncInterest()

void psync::Consumer::sendSyncInterest ( )

send sync interest /<sync-prefix>/sync/<BF>/<producers-IBF>

Should be called after subscription list is set or updated

Definition at line 160 of file consumer.cpp.

◆ stop()

void psync::Consumer::stop ( )

Stop segment fetcher to stop the sync and free resources.

Definition at line 69 of file consumer.cpp.