How to print sequence number for each round of frequency?

82 Views Asked by At
void
ProducerNew2::OnInterest(std::shared_ptr<const ndn::Interest> interest)
{
  ndn::App::OnInterest(interest);
  //  auto milliseconds = ndn::time::steady_clock::now();

  auto now = boost::chrono::steady_clock::now().time_since_epoch();
  auto timeSinceEpoch = boost::chrono::duration_cast<boost::chrono::seconds> 
  (now).count();
  auto current_round = int(double(timeSinceEpoch)/15); //change the freq
  here


 //auto since_epoch = milliseconds.time_since_epoch();
 //auto secs = boost::chrono::duration_cast<nanoseconds> 
 (since_epoch).count();
 //  auto nanos = std::chrono::duration_cast<nanoseconds> 
 (milliseconds.time_since_epoch()).count();
//  ndn::time::milliseconds milliseconds = 
::ndn::time::duration_cast<::ndn::time::milliseconds> (now.time_since_epoch()); 
NS_LOG_DEBUG("Current time"<< now);
NS_LOG_DEBUG("Current time"<< timeSinceEpoch);
NS_LOG_DEBUG("Current round"<< current_round);

//  static const std::string content("hello world");
std::string content = {0};
content = boost::lexical_cast<std::string>(current_round);
NS_LOG_DEBUG("Content"<< content << "length" << content.length());

auto data = std::make_shared<ndn::Data>(interest->getName());
data->setFreshnessPeriod(ndn::time::milliseconds(1000));
data->setContent(reinterpret_cast<const uint8_t*>(content.data()), 
content.length());
//  data->setContent(reinterpret_cast<const uint8_t*>(content.data()), 
content.size());
ndn::StackHelper::getKeyChain().sign(*data);

NS_LOG_DEBUG("Sending Data packet for " << data->getName());
m_transmittedDatas(data, this, m_face);
m_appLink->onReceiveData(*data);
}

Is there any way to print the sequence number for each round of frequency on line 9? Basically, when I run the block of code it is supposed to give me the round number as well as the sequence number, e.g. rounds 1-20 would be sequence 1, rounds 21-40 would be sequence 2 and so forth.

0

There are 0 best solutions below