void MyMeasurementInfo::updateStoredNextHops(const fib::NextHopList& nexthops) { WeightedFaceSetByFaceId& facesById = weightedFaces.get<MyMeasurementInfo::ByFaceId>(); std::set<FaceId> nexthopFaceIds; for (fib::NextHopList::const_iterator i = nexthops.begin(); i != nexthops.end(); ++i) { const FaceId id = i->getFace()->getId(); if (facesById.find(id) == facesById.end()) { // new nexthop, add to set facesById.insert(WeightedFace(*i->getFace())); NFD_LOG_TRACE("added FaceId: " << id); } nexthopFaceIds.insert(id); } for (WeightedFaceSetByFaceId::const_iterator i = facesById.begin(); i != facesById.end(); ++i) { if (nexthopFaceIds.find(i->getId()) == nexthopFaceIds.end()) { NFD_LOG_TRACE("pruning FaceId: " << i->getId()); facesById.erase(i); } } }
/** \brief pick an eligible NextHop with earliest OutRecord * \note It is assumed that every nexthop has an OutRecord */ static inline fib::NextHopList::const_iterator congestion_FindEligibleNextHopWithEarliestOutRecord(const shared_ptr<pit::Entry>& pitEntry, const fib::NextHopList& nexthops, const Name& prefix, FaceId currentDownstream) { fib::NextHopList::const_iterator found = nexthops.end(); time::steady_clock::TimePoint earliestRenewed = time::steady_clock::TimePoint::max(); for (fib::NextHopList::const_iterator it = nexthops.begin(); it != nexthops.end(); ++it) { if (!congestion_Predicate_NextHop_eligible(pitEntry, *it, currentDownstream, prefix)) continue; pit::OutRecordCollection::const_iterator outRecord = pitEntry->getOutRecord(*it->getFace()); BOOST_ASSERT(outRecord != pitEntry->getOutRecords().end()); if (outRecord->getLastRenewed() < earliestRenewed) { found = it; earliestRenewed = outRecord->getLastRenewed(); } } return found; }
bool hasNextHopWithCost(const fib::NextHopList& nextHops, FaceId faceId, uint64_t cost) { for (fib::NextHopList::const_iterator i = nextHops.begin(); i != nextHops.end(); ++i) { if (i->getFace()->getId() == faceId && i->getCost() == cost) { return true; } } return false; }
static bool hasFaceForForwarding(const fib::NextHopList& nexthops, shared_ptr<pit::Entry>& pitEntry) { return std::find_if(nexthops.begin(), nexthops.end(), bind(&canForwardToNextHop, pitEntry, _1)) != nexthops.end(); }