如何为每一轮频率打印序列号?

问题描述

@H_502_1@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);
}

有没有办法在第9行的每一轮频率上打印序列号?基本上,当我运行代码块时,应该给我轮数和序列号,例如第1-20轮为序列1,第21-40轮为序列2,依此类推。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)