40 "ProbingModule::DEFAULT_PROBING_INTERVAL must be less than AsfMeasurements::MEASUREMENTS_LIFETIME");
43 : m_probingInterval(DEFAULT_PROBING_INTERVAL)
44 , m_measurements(measurements)
56 if (info ==
nullptr) {
70 FaceInfoFacePairSet rankedFaces;
75 Face& hopFace = hop.getFace();
79 if (hopFace.getId() == inFace.getId() || hopFace.getId() == faceUsed.getId() ||
91 rankedFaces.insert({
info, &hopFace});
94 if (rankedFaces.empty()) {
99 return chooseFace(rankedFaces);
111 static std::uniform_int_distribution<> randDist(0, 5000);
132 ProbingModule::chooseFace(
const FaceInfoFacePairSet& rankedFaces)
134 static std::uniform_real_distribution<> randDist;
136 uint64_t rankSum = (rankedFaces.size() + 1) * rankedFaces.size() / 2;
141 for (
const auto& pair : rankedFaces) {
142 double probability = getProbingProbability(rank++, rankSum, rankedFaces.size());
153 if (randomNumber <= offset + probability) {
157 offset += probability;
165 ProbingModule::getProbingProbability(uint64_t rank, uint64_t rankSum, uint64_t nFaces)
170 return static_cast<double>(nFaces + 1 - rank) / rankSum;
180 NDN_THROW(std::invalid_argument(
"Probing interval must be >= " +
bool isProbingDue() const
const Name & getPrefix() const
Helper class to retrieve and create strategy measurements.
void afterForwardingProbe(const fib::Entry &fibEntry, const Name &interestName)
std::string to_string(const T &val)
bool isProbingNeeded(const fib::Entry &fibEntry, const Name &interestName)
ProbingModule(AsfMeasurements &measurements)
Represents an Interest packet.
Stores strategy information about each face in this namespace.
static constexpr time::milliseconds MIN_PROBING_INTERVAL
void setProbingInterval(size_t probingInterval)
time::nanoseconds getLastRtt() const
Scheduler & getScheduler()
Returns the global Scheduler instance for the calling thread.
FaceInfo * getFaceInfo(const fib::Entry &fibEntry, const Name &interestName, FaceId faceId)
void setIsFirstProbeScheduled(bool isScheduled)
NamespaceInfo & getOrCreateNamespaceInfo(const fib::Entry &fibEntry, const Name &prefix)
Copyright (c) 2011-2015 Regents of the University of California.
RandomNumberEngine & getRandomNumberEngine()
Returns a reference to a thread-local instance of a properly seeded PRNG.
void setIsProbingDue(bool isProbingDue)
static constexpr time::microseconds MEASUREMENTS_LIFETIME
Represents an absolute name.
bool isFirstProbeScheduled() const
Face * getFaceToProbe(const Face &inFace, const Interest &interest, const fib::Entry &fibEntry, const Face &faceUsed)
void scheduleProbe(const fib::Entry &fibEntry, time::milliseconds interval)
Strategy information for each face in a namespace.
NamespaceInfo * getNamespaceInfo(const Name &prefix)
This file contains common algorithms used by forwarding strategies.
static constexpr time::milliseconds DEFAULT_PROBING_INTERVAL
const Name & getName() const noexcept
#define NDN_CXX_UNREACHABLE
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 ...
static const time::nanoseconds RTT_NO_MEASUREMENT
boost::chrono::milliseconds milliseconds