コード例 #1
0
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 );
}
コード例 #2
0
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 );
}