bool EdgeStrategy::filterOutgoingData ( const nfd::Face& face, const ndn::Interest& interest, ndn::Data& data, ns3::Time& delay ) { auto in_face = getFaceTable().get( data.getIncomingFaceId() ); bool coming_from_network = !in_face->isEdge(); bool going_to_network = !face.isEdge(); // if the data is coming from and leaving to // the same network then we don't need to do // anything special if( coming_from_network == going_to_network ) { return RouterStrategy::filterOutgoingData ( face, interest, data, delay ); } // if the data is coming into the network then // we just change its current network if( going_to_network ) { BOOST_ASSERT( data.getCurrentNetwork() == ndn::RouteTracker::EXIT_NETWORK ); tracers::edge->data_entered( data ); data.setCurrentNetwork( ndn::RouteTracker::INTERNET_NETWORK ); return RouterStrategy::filterOutgoingData ( face, interest, data, delay ); } // if the data is leaving the network then we change // its current network if( coming_from_network ) { BOOST_ASSERT( data.getCurrentNetwork() == ndn::RouteTracker::INTERNET_NETWORK ); tracers::edge->data_left( data ); data.setCurrentNetwork( ndn::RouteTracker::ENTRY_NETWORK ); return RouterStrategy::filterOutgoingData ( face, interest, data, delay ); } // this should never happen BOOST_ASSERT( false ); return true; }
void EdgeStrategy::onDataDenied ( const ndn::Data& data, const ndn::Interest& interest, ns3::Time& delay, const std::string& why ) { // if the denied data isn't leaving the network // then we just do the normal router stuff auto in_face = getFaceTable().get( data.getIncomingFaceId() ); auto out_face = getFaceTable().get( interest.getIncomingFaceId() ); bool coming_from_network = !in_face->isEdge(); bool going_to_network = !out_face->isEdge(); if( coming_from_network == going_to_network ) { RouterStrategy::onDataDenied( data, interest, delay, why ); return; } if( going_to_network ) { BOOST_ASSERT( data.getCurrentNetwork() == ndn::RouteTracker::INTERNET_NETWORK ); RouterStrategy::onDataDenied( data, interest, delay, why ); return; } // if the data is denied then we add the // tag used to retrieve it to the negative // cache; however we only want to do this // when the data is leaving the internet // and going into the client network // and the data's access level > 0 BOOST_ASSERT( data.getCurrentNetwork() == ndn::RouteTracker::ENTRY_NETWORK ); if( data.getAccessLevel() > 0 ) { BOOST_ASSERT( interest.hasAuthTag() ); tracers::edge->bloom_insert ( interest.getAuthTag(), s_edge_bloom_delay ); delay += s_edge_bloom_delay; m_negative_cache.insert( interest.getAuthTag() ); } // do whatever a normal router would do RouterStrategy::onDataDenied( data, interest, delay, why ); }
void EdgeStrategy::onDataSatisfied ( const ndn::Data& data, const ndn::Interest& interest, ns3::Time& delay ) { // if the satisfied data isn't leaving the network // then we just do the normal router stuff auto in_face = getFaceTable().get( data.getIncomingFaceId() ); auto out_face = getFaceTable().get( interest.getIncomingFaceId() ); bool coming_from_network = !in_face->isEdge(); bool going_to_network = !out_face->isEdge(); if( coming_from_network == going_to_network ) { RouterStrategy::onDataSatisfied( data, interest, delay ); return; } if( going_to_network ) { BOOST_ASSERT( data.getCurrentNetwork() == ndn::RouteTracker::INTERNET_NETWORK ); RouterStrategy::onDataSatisfied( data, interest, delay ); return; } // if the data is satisfied then we add it to // the positive cache if it isn't marked with // the no recache flag and if its access level > 0 BOOST_ASSERT( data.getCurrentNetwork() == ndn::RouteTracker::ENTRY_NETWORK ); if( !data.getNoReCacheFlag() && data.getAccessLevel() > 0 ) { BOOST_ASSERT( interest.hasAuthTag() ); tracers::edge->bloom_insert ( interest.getAuthTag(), s_edge_bloom_delay ); delay += s_edge_bloom_delay; m_positive_cache.insert( interest.getAuthTag() ); } RouterStrategy::onDataSatisfied( data, interest, delay ); }