void icnVideoChunkingServer::OnInterest(std::shared_ptr<const ndn::Interest> interest) { // ndn::App::OnInterest(interest); // forward call to perform app-level tracing // // do nothing else (hijack interest) // NS_LOG_DEBUG("Do nothing for incoming interest for" << interest->getName()); ndn::App::OnInterest(interest); // std::cout << "Producer received interest " << interest->getName() << std::endl; // Note that Interests send out by the app will not be sent back to the app ! auto data = std::make_shared<ndn::Data>(interest->getName()); data->setFreshnessPeriod(ndn::time::seconds(1000)); this->total_bytes_served += 1000; data->setContent(std::make_shared< ::ndn::Buffer>(this->chunk_size)); ndn::StackHelper::getKeyChain().sign(*data); // Call trace (for logging purposes) m_transmittedDatas(data, this, m_face); m_face->onReceiveData(*data); // Call trace (for logging purposes) // printf("OnInterest\n"); }
// Callback that will be called when Interest arrives void CustomApp1::OnInterest(std::shared_ptr<const ndn::Interest> interest) { ndn::App::OnInterest(interest); NS_LOG_DEBUG("Received Interest packet for " << interest->getName()); // Note that Interests send out by the app will not be sent back to the app ! Name sender("/malicious"); auto data = std::make_shared<ndn::Data>(interest->getName()); data->setFreshnessPeriod(ndn::time::milliseconds(1000)); data->setContent(std::make_shared< ::ndn::Buffer>(1024)); ndn::StackHelper::getKeyChain().sign(*data); NS_LOG_DEBUG("Sending Data packet for " << data->getName()); // Call trace (for logging purposes) m_transmittedDatas(data, this, m_face); m_face->onReceiveData(*data); }