38 "ProbingModule::DEFAULT_PROBING_INTERVAL must be less than AsfMeasurements::MEASUREMENTS_LIFETIME");
41 : m_probingInterval(DEFAULT_PROBING_INTERVAL)
42 , m_measurements(measurements)
55 if (info ==
nullptr) {
72 FaceInfoFacePairSet rankedFaces(
73 [] (
const auto& pairLhs,
const auto& pairRhs) ->
bool {
86 Face& hopFace = hop.getFace();
102 rankedFaces.insert({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 auto& 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);
196 m_probingInterval = time::milliseconds(probingInterval);
199 BOOST_THROW_EXCEPTION(std::invalid_argument(
"Probing interval should be >= " bool isProbingDue() const
Declares the global pseudorandom number generator (PRNG) for NFD.
const Name & getPrefix() const
Helper class to retrieve and create strategy measurements.
generalization of a network interface
bool hasSrttMeasurement() const
ProbingModule(AsfMeasurements &measurements)
Represents an Interest packet.
stores stategy information about each face in this namespace
static constexpr time::milliseconds MIN_PROBING_INTERVAL
void setProbingInterval(size_t probingInterval)
bool isProbingNeeded(const fib::Entry &fibEntry, const Interest &interest)
Copyright (c) 2011-2015 Regents of the University of California.
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.
bool isFirstProbeScheduled() const
Face * getFaceToProbe(const Face &inFace, const Interest &interest, const fib::Entry &fibEntry, const Face &faceUsed)
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.
static constexpr time::milliseconds DEFAULT_PROBING_INTERVAL
EventId schedule(time::nanoseconds after, const EventCallback &event)
Schedule an event.
RttStats::Rtt getSrtt() const
void afterForwardingProbe(const fib::Entry &fibEntry, const Interest &interest)
FaceInfo * getFaceInfo(const fib::Entry &fibEntry, const Interest &interest, FaceId faceId)
std::string to_string(const V &v)
const NextHopList & getNextHops() const
bool wouldViolateScope(const Face &inFace, const Interest &interest, const Face &outFace)
determine whether forwarding the Interest in pitEntry to outFace would violate scope
represents a nexthop record in FIB entry