47 const shared_ptr<pit::Entry>& pitEntry)
51 if (nexthops.size() == 0) {
66 size_t nUpstreams = nexthops.size();
69 if (bestFace !=
nullptr && fibEntry.
hasNextHop(*bestFace) &&
74 deferRange = time::microseconds((deferFirst.count() + 1) / 2);
83 auto firstEligibleNexthop = std::find_if(nexthops.begin(), nexthops.end(),
85 Face& outFace = nexthop.getFace();
89 if (firstEligibleNexthop != nexthops.end()) {
90 this->
sendInterest(pitEntry, firstEligibleNexthop->getFace(), interest);
98 shared_ptr<Face> previousFace = meInfo.
previousFace.lock();
99 if (previousFace !=
nullptr && fibEntry.
hasNextHop(*previousFace) &&
105 if (nUpstreams > 0) {
106 pitEntryInfo->
maxInterval = std::max(time::microseconds(1),
107 time::microseconds((2 * deferRange.count() + nUpstreams - 1) / nUpstreams));
123 if (inFace ==
nullptr) {
126 shared_ptr<pit::Entry> pitEntry = pitEntryWeak.lock();
127 if (pitEntry ==
nullptr) {
130 pit::InRecordCollection::const_iterator inRecord = pitEntry->getInRecord(*inFace);
131 if (inRecord == pitEntry->in_end()) {
134 const Interest& interest = inRecord->getInterest();
140 BOOST_ASSERT(pitEntryInfo !=
nullptr);
144 shared_ptr<Face> previousFace = meInfo.
previousFace.lock();
145 if (previousFace !=
nullptr && fibEntry.
hasNextHop(*previousFace) &&
152 bool isForwarded =
false;
153 for (fib::NextHopList::const_iterator it = nexthops.begin(); it != nexthops.end(); ++it) {
164 std::uniform_int_distribution<time::nanoseconds::rep> dist(0, pitEntryInfo->
maxInterval.count() - 1);
165 time::nanoseconds deferNext = time::nanoseconds(dist(
getGlobalRng()));
174 shared_ptr<pit::Entry> pitEntry = pitEntryWeak.lock();
175 if (pitEntry ==
nullptr) {
181 if (measurementsEntry ==
nullptr) {
196 const Face& inFace,
const Data& data)
198 if (!pitEntry->hasInRecords()) {
207 if (measurementsEntry ==
nullptr) {
220 if (pitEntryInfo !=
nullptr) {
227 if (bestFace.get() == &inFace)
242 BOOST_ASSERT(entry !=
nullptr);
251 if (parentEntry !=
nullptr) {
264 : prediction(INITIAL_PREDICTION)
271 this->operator=(other);
277 shared_ptr<Face> best = this->
bestFace.lock();
278 if (best !=
nullptr) {
289 this->
bestFace =
const_cast<Face&
>(face).shared_from_this();
292 shared_ptr<Face>
bestFace = this->bestFace.lock();
293 if (bestFace.get() == &face) {
294 this->adjustPredictDown();
298 this->bestFace =
const_cast<Face&
>(face).shared_from_this();
303 NccStrategy::MeasurementsEntryInfo::adjustPredictDown()
317 NccStrategy::MeasurementsEntryInfo::ageBestFace()
static const time::microseconds DEFER_FIRST_WITHOUT_BEST_FACE
bool canForwardToLegacy(const pit::Entry &pitEntry, const Face &face)
decide whether Interest can be forwarded to face
static const Name STRATEGY_NAME
StrategyInfo on measurements::Entry.
void doPropagate(FaceId inFaceId, weak_ptr< pit::Entry > pitEntryWeak)
propagate to another upstream
shared_ptr< Face > getBestFace()
static const int UPDATE_MEASUREMENTS_N_LEVELS
generalization of a network interface
void cancel(const EventId &eventId)
cancel a scheduled event
static const time::microseconds DEFER_RANGE_WITHOUT_BEST_FACE
Face * getFace(FaceId id) const
time::microseconds maxInterval
maximum interval between forwarding to two nexthops except best and previous
represents an Interest packet
NccStrategy(Forwarder &forwarder, const Name &name=STRATEGY_NAME)
virtual void afterReceiveInterest(const Face &inFace, const Interest &interest, const shared_ptr< pit::Entry > &pitEntry) override
trigger after Interest is received
void extendLifetime(Entry &entry, const time::nanoseconds &lifetime)
extend lifetime of an entry
weak_ptr< Face > bestFace
static const time::microseconds MIN_PREDICTION
represents a Measurements entry
Copyright (c) 2011-2015 Regents of the University of California.
MeasurementsAccessor & getMeasurements()
void inheritFrom(const MeasurementsEntryInfo &other)
NFD_REGISTER_STRATEGY(AccessStrategy)
static const int ADJUST_PREDICT_DOWN_SHIFT
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
void rejectPendingInterest(const shared_ptr< pit::Entry > &pitEntry)
decide that a pending Interest cannot be forwarded
Name abstraction to represent an absolute name.
scheduler::EventId propagateTimer
timer for propagating to another face
bool hasPendingOutRecords(const pit::Entry &pitEntry)
determine whether pitEntry has any pending out-records
std::pair< T *, bool > insertStrategyInfo(A &&... args)
insert a StrategyInfo item
scheduler::EventId bestFaceTimeout
timer that expires when best face does not respond within predicted time
static const int ADJUST_PREDICT_UP_SHIFT
StrategyInfo on pit::Entry.
represents a forwarding strategy
MeasurementsEntryInfo & getMeasurementsEntryInfo(measurements::Entry *entry)
std::mt19937 & getGlobalRng()
Copyright (c) 2014-2016, Regents of the University of California, Arizona Board of Regents...
const fib::Entry & lookupFib(const pit::Entry &pitEntry) const
performs a FIB lookup, considering Link object if present
time::microseconds prediction
EventId schedule(const time::nanoseconds &after, const Scheduler::Event &event)
schedule an event
static const time::microseconds INITIAL_PREDICTION
Entry * get(const Name &name)
find or insert a Measurements entry for name
const NextHopList & getNextHops() const
uint64_t FaceId
identifies a face
void updateBestFace(const Face &face)
weak_ptr< Face > previousFace
virtual void beforeSatisfyInterest(const shared_ptr< pit::Entry > &pitEntry, const Face &inFace, const Data &data) override
trigger before PIT entry is satisfied
void sendInterest(const shared_ptr< pit::Entry > &pitEntry, Face &outFace, const Interest &interest)
send Interest to outFace
bool wouldViolateScope(const Face &inFace, const Interest &interest, const Face &outFace)
determine whether forwarding the Interest in pitEntry to outFace would violate scope ...
static const time::microseconds MAX_PREDICTION
Entry * getParent(const Entry &child)
find or insert a Measurements entry for child's parent
represents a nexthop record in FIB entry
virtual ~PitEntryInfo() override
bool hasNextHop(const Face &face) const