37 "ProbingModule::DEFAULT_PROBING_INTERVAL must be less than AsfMeasurements::MEASUREMENTS_LIFETIME");
40 : m_probingInterval(DEFAULT_PROBING_INTERVAL)
41 , m_measurements(measurements)
54 if (info ==
nullptr) {
71 FaceInfoFacePairSet rankedFaces(
72 [] (FaceInfoFacePair pairLhs, FaceInfoFacePair pairRhs) ->
bool {
85 Face& hopFace = hop.getFace();
89 if (hopFace.getId() == inFace.getId() || hopFace.getId() == faceUsed.getId() ||
102 rankedFaces.insert(std::make_pair(info, &hopFace));
105 if (rankedFaces.empty()) {
110 return getFaceBasedOnProbability(rankedFaces);
122 uint64_t interval = getRandomNumber(0, 5000);
143 ProbingModule::getFaceBasedOnProbability(
const FaceInfoFacePairSet& rankedFaces)
145 double randomNumber = getRandomNumber(0, 1);
146 uint64_t rankSum = ((rankedFaces.size() + 1) * rankedFaces.size()) / 2;
151 for (
const FaceInfoFacePair pair : rankedFaces) {
152 double probability = getProbingProbability(rank++, rankSum, rankedFaces.size());
163 if (randomNumber <= offset + probability) {
168 offset += probability;
177 ProbingModule::getProbingProbability(uint64_t rank, uint64_t rankSum, uint64_t nFaces)
182 return static_cast<double>(nFaces + 1 - rank) / rankSum;
186 ProbingModule::getRandomNumber(
double start,
double end)
188 std::uniform_real_distribution<double> dist(start, end);
Declares the global pseudorandom number generator (PRNG) for NFD.
Helper class to retrieve and create strategy measurements.
boost::posix_time::time_duration milliseconds(long duration)
ProbingModule(AsfMeasurements &measurements)
RttStats::Rtt getSrtt() const
represents an Interest packet
stores stategy information about each face in this namespace
bool isProbingNeeded(const fib::Entry &fibEntry, const Interest &interest)
FaceInfo * getFaceInfo(const fib::Entry &fibEntry, const Interest &interest, const Face &face)
Copyright (c) 2011-2015 Regents of the University of California.
bool isProbingDue() const
void setHasFirstProbeBeenScheduled(bool hasBeenScheduled)
void setIsProbingDue(bool isProbingDue)
NamespaceInfo & getOrCreateNamespaceInfo(const fib::Entry &fibEntry, const Interest &interest)
static constexpr time::microseconds MEASUREMENTS_LIFETIME
void scheduleProbe(const fib::Entry &fibEntry, const time::milliseconds &interval)
Represents an absolute name.
Face * getFaceToProbe(const Face &inFace, const Interest &interest, const fib::Entry &fibEntry, const Face &faceUsed)
const NextHopList & getNextHops() const
Strategy information for each face in a namespace.
std::mt19937 & getGlobalRng()
NamespaceInfo * getNamespaceInfo(const Name &prefix)
This file contains common algorithms used by forwarding strategies.
EventId schedule(time::nanoseconds after, const EventCallback &event)
schedule an event
void afterForwardingProbe(const fib::Entry &fibEntry, const Interest &interest)
bool hasSrttMeasurement() const
static constexpr time::seconds DEFAULT_PROBING_INTERVAL
bool wouldViolateScope(const Face &inFace, const Interest &interest, const Face &outFace)
determine whether forwarding the Interest in pitEntry to outFace would violate scope ...
bool isFirstProbeScheduled() const
const Name & getPrefix() const
represents a nexthop record in FIB entry