30 #include <ndn-cxx/util/random.hpp> 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();
91 rankedFaces.insert({info, &hopFace});
94 if (rankedFaces.empty()) {
99 return chooseFace(rankedFaces);
111 static std::uniform_int_distribution<> randDist(0, 5000);
112 auto interval = randDist(ndn::random::getRandomNumberEngine());
132 ProbingModule::chooseFace(
const FaceInfoFacePairSet& rankedFaces)
134 static std::uniform_real_distribution<> randDist;
135 double randomNumber = randDist(ndn::random::getRandomNumberEngine());
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;
177 m_probingInterval = time::milliseconds(probingInterval);
180 NDN_THROW(std::invalid_argument(
"Probing interval must be >= " +
FaceInfo * getFaceInfo(const fib::Entry &fibEntry, const Interest &interest, FaceId faceId)
static const time::nanoseconds RTT_NO_MEASUREMENT
void afterForwardingProbe(const fib::Entry &fibEntry, const Interest &interest)
bool isProbingDue() const
void scheduleProbe(const fib::Entry &fibEntry, time::milliseconds interval)
ProbingModule(AsfMeasurements &measurements)
NamespaceInfo * getNamespaceInfo(const Name &prefix)
static constexpr time::milliseconds DEFAULT_PROBING_INTERVAL
void setIsProbingDue(bool isProbingDue)
Scheduler & getScheduler()
Returns the global Scheduler instance for the calling thread.
static constexpr time::microseconds MEASUREMENTS_LIFETIME
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
time::nanoseconds getLastRtt() const
void setIsFirstProbeScheduled(bool isScheduled)
const Name & getPrefix() const
NamespaceInfo & getOrCreateNamespaceInfo(const fib::Entry &fibEntry, const Interest &interest)
bool isFirstProbeScheduled() const
generalization of a network interface
bool isProbingNeeded(const fib::Entry &fibEntry, const Interest &interest)
Stores strategy information about each face in this namespace.
This file contains common algorithms used by forwarding strategies.
const NextHopList & getNextHops() const
static constexpr time::milliseconds MIN_PROBING_INTERVAL
void setProbingInterval(size_t probingInterval)
Face * getFaceToProbe(const Face &inFace, const Interest &interest, const fib::Entry &fibEntry, const Face &faceUsed)
bool wouldViolateScope(const Face &inFace, const Interest &interest, const Face &outFace)
determine whether forwarding the Interest in pitEntry to outFace would violate scope ...
Strategy information for each face in a namespace.
Helper class to retrieve and create strategy measurements.