46 NDN_THROW(std::invalid_argument(
"NccStrategy does not accept parameters"));
58 static Name strategyName(
"/localhost/nfd/strategy/ncc/%FD%01");
64 const shared_ptr<pit::Entry>& pitEntry)
68 if (nexthops.size() == 0) {
83 size_t nUpstreams = nexthops.size();
86 if (bestFace !=
nullptr && fibEntry.
hasNextHop(*bestFace) &&
91 deferRange = time::microseconds((deferFirst.count() + 1) / 2);
99 auto firstEligibleNexthop = std::find_if(nexthops.begin(), nexthops.end(),
101 Face& outFace = nexthop.getFace();
102 return !wouldViolateScope(ingress.face, interest, outFace) &&
103 canForwardToLegacy(*pitEntry, outFace);
105 if (firstEligibleNexthop != nexthops.end()) {
114 shared_ptr<Face> previousFace = meInfo.
previousFace.lock();
115 if (previousFace !=
nullptr && fibEntry.
hasNextHop(*previousFace) &&
121 if (nUpstreams > 0) {
123 time::microseconds((2 * deferRange.count() + nUpstreams - 1) / nUpstreams));
139 if (inFace ==
nullptr) {
142 shared_ptr<pit::Entry> pitEntry = pitEntryWeak.lock();
143 if (pitEntry ==
nullptr) {
146 auto inRecord = pitEntry->getInRecord(*inFace);
147 if (inRecord == pitEntry->in_end()) {
150 const Interest& interest = inRecord->getInterest();
156 BOOST_ASSERT(pitEntryInfo !=
nullptr);
160 shared_ptr<Face> previousFace = meInfo.
previousFace.lock();
161 if (previousFace !=
nullptr && fibEntry.
hasNextHop(*previousFace) &&
167 bool isForwarded =
false;
168 for (
const auto& nexthop : fibEntry.
getNextHops()) {
169 Face& face = nexthop.getFace();
179 std::uniform_int_distribution<time::nanoseconds::rep> dist(0, pitEntryInfo->
maxInterval.count() - 1);
189 shared_ptr<pit::Entry> pitEntry = pitEntryWeak.lock();
190 if (pitEntry ==
nullptr) {
196 if (measurementsEntry ==
nullptr) {
213 if (!pitEntry->hasInRecords()) {
222 if (measurementsEntry ==
nullptr) {
235 if (pitEntryInfo !=
nullptr) {
242 if (bestFace.get() == &ingress.
face)
257 BOOST_ASSERT(entry !=
nullptr);
266 if (parentEntry !=
nullptr) {
279 : prediction(INITIAL_PREDICTION)
286 this->operator=(other);
292 shared_ptr<Face> best = this->bestFace.lock();
293 if (best !=
nullptr) {
296 this->bestFace = best = this->previousFace.lock();
303 if (this->bestFace.expired()) {
304 this->bestFace =
const_cast<Face&
>(face).shared_from_this();
307 shared_ptr<Face> bestFace = this->bestFace.lock();
308 if (bestFace.get() == &face) {
309 this->adjustPredictDown();
312 this->previousFace = this->bestFace;
313 this->bestFace =
const_cast<Face&
>(face).shared_from_this();
318 NccStrategy::MeasurementsEntryInfo::adjustPredictDown()
320 prediction = std::max(MIN_PREDICTION,
321 time::microseconds(prediction.count() - (prediction.count() >> ADJUST_PREDICT_DOWN_SHIFT)));
327 prediction = std::min(MAX_PREDICTION,
328 time::microseconds(prediction.count() + (prediction.count() >> ADJUST_PREDICT_UP_SHIFT)));
332 NccStrategy::MeasurementsEntryInfo::ageBestFace()
334 this->previousFace = this->bestFace;
335 this->bestFace.reset();
340 bestFaceTimeout.cancel();
341 propagateTimer.cancel();