28 #include <boost/random/uniform_int_distribution.hpp> 
   50                                   const Interest& interest,
 
   51                                   shared_ptr<fib::Entry> fibEntry,
 
   52                                   shared_ptr<pit::Entry> pitEntry)
 
   55   if (nexthops.size() == 0) {
 
   60   shared_ptr<PitEntryInfo> pitEntryInfo =
 
   62   bool isNewPitEntry = !pitEntry->hasUnexpiredOutRecords();
 
   67   shared_ptr<MeasurementsEntryInfo> measurementsEntryInfo =
 
   72   size_t nUpstreams = nexthops.size();
 
   74   shared_ptr<Face> bestFace = measurementsEntryInfo->getBestFace();
 
   75   if (static_cast<bool>(bestFace) && fibEntry->hasNextHop(bestFace) &&
 
   76       pitEntry->canForwardTo(*bestFace)) {
 
   78     deferFirst = measurementsEntryInfo->prediction;
 
   79     deferRange = time::microseconds((deferFirst.count() + 1) / 2);
 
   83       measurementsEntryInfo->prediction,
 
   88     this->
sendInterest(pitEntry, nexthops.begin()->getFace());
 
   92   shared_ptr<Face> previousFace = measurementsEntryInfo->previousFace.lock();
 
   93   if (static_cast<bool>(previousFace) && fibEntry->hasNextHop(previousFace) &&
 
   94       pitEntry->canForwardTo(*previousFace)) {
 
   99     pitEntryInfo->maxInterval = std::max(time::microseconds(1),
 
  100       time::microseconds((2 * deferRange.count() + nUpstreams - 1) / nUpstreams));
 
  106     pitEntryInfo->maxInterval = deferFirst;
 
  110          weak_ptr<pit::Entry>(pitEntry), weak_ptr<fib::Entry>(fibEntry)));
 
  116   shared_ptr<pit::Entry> pitEntry = pitEntryWeak.lock();
 
  117   if (!static_cast<bool>(pitEntry)) {
 
  120   shared_ptr<fib::Entry> fibEntry = fibEntryWeak.lock();
 
  121   if (!static_cast<bool>(fibEntry)) {
 
  125   shared_ptr<PitEntryInfo> pitEntryInfo = pitEntry->getStrategyInfo<
PitEntryInfo>();
 
  128   BOOST_ASSERT(static_cast<bool>(pitEntryInfo));
 
  130   shared_ptr<MeasurementsEntryInfo> measurementsEntryInfo =
 
  133   shared_ptr<Face> previousFace = measurementsEntryInfo->previousFace.lock();
 
  134   if (static_cast<bool>(previousFace) && fibEntry->hasNextHop(previousFace) &&
 
  135       pitEntry->canForwardTo(*previousFace)) {
 
  140   bool isForwarded = 
false;
 
  141   for (fib::NextHopList::const_iterator it = nexthops.begin(); it != nexthops.end(); ++it) {
 
  142     shared_ptr<Face> face = it->getFace();
 
  143     if (pitEntry->canForwardTo(*face)) {
 
  151     boost::random::uniform_int_distribution<time::nanoseconds::rep> dist(0,
 
  152       pitEntryInfo->maxInterval.count() - 1);
 
  153     time::nanoseconds deferNext = time::nanoseconds(dist(
getGlobalRng()));
 
  156          weak_ptr<pit::Entry>(pitEntry), weak_ptr<fib::Entry>(fibEntry)));
 
  163   shared_ptr<pit::Entry> pitEntry = pitEntryWeak.lock();
 
  164   if (!static_cast<bool>(pitEntry)) {
 
  167   shared_ptr<measurements::Entry> measurementsEntry = this->
getMeasurements().
get(*pitEntry);
 
  170     if (!static_cast<bool>(measurementsEntry)) {
 
  176     shared_ptr<MeasurementsEntryInfo> measurementsEntryInfo =
 
  178     measurementsEntryInfo->adjustPredictUp();
 
  186                                    const Face& inFace, 
const Data& data)
 
  188   if (pitEntry->getInRecords().empty()) {
 
  194   shared_ptr<measurements::Entry> measurementsEntry = this->
getMeasurements().
get(*pitEntry);
 
  197     if (!static_cast<bool>(measurementsEntry)) {
 
  203     shared_ptr<MeasurementsEntryInfo> measurementsEntryInfo =
 
  205     measurementsEntryInfo->updateBestFace(inFace);
 
  210   shared_ptr<PitEntryInfo> pitEntryInfo = pitEntry->getStrategyInfo<
PitEntryInfo>();
 
  211   if (static_cast<bool>(pitEntryInfo)) {
 
  216 shared_ptr<NccStrategy::MeasurementsEntryInfo>
 
  219   shared_ptr<measurements::Entry> measurementsEntry = this->
getMeasurements().
get(*entry);
 
  223 shared_ptr<NccStrategy::MeasurementsEntryInfo>
 
  227   if (static_cast<bool>(info)) {
 
  231   info = make_shared<MeasurementsEntryInfo>();
 
  232   entry->setStrategyInfo(info);
 
  235   if (static_cast<bool>(parentEntry)) {
 
  237     BOOST_ASSERT(static_cast<bool>(parentInfo));
 
  238     info->inheritFrom(*parentInfo);
 
  246                                                              time::microseconds(8192);
 
  248                                                              time::microseconds(127);
 
  250                                                              time::microseconds(160000);
 
  253   : prediction(INITIAL_PREDICTION)
 
  260   this->operator=(other);
 
  265   shared_ptr<Face> best = this->bestFace.lock();
 
  266   if (static_cast<bool>(best)) {
 
  269   this->bestFace = best = this->previousFace.lock();
 
  275   if (this->bestFace.expired()) {
 
  276     this->bestFace = 
const_cast<Face&
>(face).shared_from_this();
 
  279   shared_ptr<Face> bestFace = this->bestFace.lock();
 
  280   if (bestFace.get() == &face) {
 
  281     this->adjustPredictDown();
 
  284     this->previousFace = this->bestFace;
 
  285     this->bestFace = 
const_cast<Face&
>(face).shared_from_this();
 
  290 NccStrategy::MeasurementsEntryInfo::adjustPredictDown() {
 
  291   prediction = std::max(MIN_PREDICTION,
 
  292     time::microseconds(prediction.count() - (prediction.count() >> ADJUST_PREDICT_DOWN_SHIFT)));
 
  297   prediction = std::min(MAX_PREDICTION,
 
  298     time::microseconds(prediction.count() + (prediction.count() >> ADJUST_PREDICT_UP_SHIFT)));
 
  302 NccStrategy::MeasurementsEntryInfo::ageBestFace() {
 
  303   this->previousFace = this->bestFace;
 
  304   this->bestFace.reset();
 
static const time::microseconds DEFER_FIRST_WITHOUT_BEST_FACE
 
static const Name STRATEGY_NAME
 
virtual void afterReceiveInterest(const Face &inFace, const Interest &interest, shared_ptr< fib::Entry > fibEntry, shared_ptr< pit::Entry > pitEntry) 1
trigger after Interest is received 
 
StrategyInfo on measurements::Entry. 
 
shared_ptr< Face > getBestFace()
 
static const int UPDATE_MEASUREMENTS_N_LEVELS
 
void cancel(const EventId &eventId)
cancel a scheduled event 
 
static const time::microseconds DEFER_RANGE_WITHOUT_BEST_FACE
 
NccStrategy(Forwarder &forwarder, const Name &name=STRATEGY_NAME)
 
shared_ptr< measurements::Entry > get(const Name &name)
find or insert a Measurements entry for name 
 
shared_ptr< MeasurementsEntryInfo > getMeasurementsEntryInfo(shared_ptr< measurements::Entry > entry)
 
static const time::microseconds MIN_PREDICTION
 
virtual void beforeSatisfyInterest(shared_ptr< pit::Entry > pitEntry, const Face &inFace, const Data &data) 1
trigger before PIT entry is satisfied 
 
MeasurementsAccessor & getMeasurements()
 
void inheritFrom(const MeasurementsEntryInfo &other)
 
void doPropagate(weak_ptr< pit::Entry > pitEntryWeak, weak_ptr< fib::Entry > fibEntryWeak)
propagate to another upstream 
 
std::vector< fib::NextHop > NextHopList
 
void timeoutOnBestFace(weak_ptr< pit::Entry > pitEntryWeak)
best face did not reply within prediction 
 
static const time::nanoseconds MEASUREMENTS_LIFETIME
 
EventId schedule(const time::nanoseconds &after, const std::function< void()> &event)
schedule an event 
 
boost::random::mt19937 & getGlobalRng()
 
void rejectPendingInterest(shared_ptr< pit::Entry > pitEntry)
decide that a pending Interest cannot be forwarded 
 
StrategyInfo on pit::Entry. 
 
represents a forwarding strategy 
 
void extendLifetime(measurements::Entry &entry, const time::nanoseconds &lifetime)
extend lifetime of an entry 
 
static const time::microseconds INITIAL_PREDICTION
 
void sendInterest(shared_ptr< pit::Entry > pitEntry, shared_ptr< Face > outFace, bool wantNewNonce=false)
send Interest to outFace 
 
void updateBestFace(const Face &face)
 
static const time::microseconds MAX_PREDICTION
 
shared_ptr< measurements::Entry > getParent(const measurements::Entry &child)
find or insert a Measurements entry for child's parent