37 const time::milliseconds AsfStrategy::RETX_SUPPRESSION_INITIAL(10);
38 const time::milliseconds AsfStrategy::RETX_SUPPRESSION_MAX(250);
44 , m_measurements(getMeasurements())
45 , m_probing(m_measurements)
46 , m_retxSuppression(RETX_SUPPRESSION_INITIAL,
54 const shared_ptr<pit::Entry>& pitEntry)
59 switch (suppressResult) {
71 if (nexthops.size() == 0) {
72 sendNoRouteNack(inFace, interest, pitEntry);
77 Face* faceToUse = getBestFaceForForwarding(fibEntry, interest, inFace);
79 if (faceToUse ==
nullptr) {
80 sendNoRouteNack(inFace, interest, pitEntry);
85 forwardInterest(interest, fibEntry, pitEntry, *faceToUse);
91 if (faceToProbe !=
nullptr) {
93 <<
" to FaceId: " << faceToProbe->
getId());
95 bool wantNewNonce =
true;
96 forwardInterest(interest, fibEntry, pitEntry, *faceToProbe, wantNewNonce);
104 const Face& inFace,
const Data& data)
108 if (namespaceInfo ==
nullptr) {
109 NFD_LOG_TRACE(
"Could not find measurements entry for " << pitEntry->getName());
127 const shared_ptr<pit::Entry>& pitEntry)
130 onTimeout(pitEntry->getName(), inFace.
getId());
137 AsfStrategy::forwardInterest(
const Interest& interest,
139 const shared_ptr<pit::Entry>& pitEntry,
156 <<
" FaceId: " << outFace.
getId()
157 <<
" in " << time::duration_cast<time::milliseconds>(timeout) <<
" ms");
160 bind(&AsfStrategy::onTimeout,
this, interest.
getName(), outFace.
getId()));
179 static const RttStats::Rtt SORTING_RTT_TIMEOUT = time::microseconds::max();
180 static const RttStats::Rtt SORTING_RTT_NO_MEASUREMENT = SORTING_RTT_TIMEOUT / 2;
183 return SORTING_RTT_TIMEOUT.count();
186 return SORTING_RTT_NO_MEASUREMENT.count();
189 return stats.
srtt.count();
194 AsfStrategy::getBestFaceForForwarding(
const fib::Entry& fibEntry,
const Interest& interest,
199 typedef std::function<bool(const FaceStats&, const FaceStats&)> FaceStatsPredicate;
200 typedef std::set<FaceStats, FaceStatsPredicate> FaceStatsSet;
202 FaceStatsSet rankedFaces(
208 if (lhsValue < rhsValue) {
211 else if (lhsValue == rhsValue) {
220 Face& hopFace = hop.getFace();
226 FaceInfo* info = m_measurements.getFaceInfo(fibEntry, interest, hopFace);
228 if (info ==
nullptr) {
234 rankedFaces.insert(stats);
238 rankedFaces.insert(stats);
244 if (it != rankedFaces.end()) {
255 NFD_LOG_TRACE(
"FaceId: " << faceId <<
" for " << interestName <<
" has timed-out");
257 NamespaceInfo* namespaceInfo = m_measurements.getNamespaceInfo(interestName);
259 if (namespaceInfo ==
nullptr) {
260 NFD_LOG_TRACE(
"FibEntry for " << interestName <<
" has been removed since timeout scheduling");
266 if (it == namespaceInfo->
end()) {
267 it = namespaceInfo->
insert(faceId);
275 AsfStrategy::sendNoRouteNack(
const Face& inFace,
const Interest& interest,
276 const shared_ptr<pit::Entry>& pitEntry)
281 nackHeader.
setReason(lp::NackReason::NO_ROUTE);
282 this->
sendNack(pitEntry, inFace, nackHeader);
virtual void beforeSatisfyInterest(const shared_ptr< pit::Entry > &pitEntry, const Face &inFace, const Data &data) override
trigger before PIT entry is satisfied
time::microseconds Duration
const Name & getPrefix() const
AsfStrategy(Forwarder &forwarder, const Name &name=STRATEGY_NAME)
FaceInfo & getOrCreateFaceInfo(const fib::Entry &fibEntry, const Interest &interest, const Face &face)
void recordRtt(const shared_ptr< pit::Entry > &pitEntry, const Face &inFace)
generalization of a network interface
void extendFaceInfoLifetime(FaceInfo &info, const Face &face)
RttEstimator::Duration computeRto() const
void sendNack(const shared_ptr< pit::Entry > &pitEntry, const Face &outFace, const lp::NackHeader &header)
send Nack to outFace
const Name & getName() const
Get name of the Data packet.
NFD_REGISTER_STRATEGY(AsfStrategy)
Interest is retransmission and should be suppressed.
represents an Interest packet
#define NFD_LOG_DEBUG(expression)
stores stategy information about each face in this namespace
static const Rtt RTT_TIMEOUT
void cancelTimeoutEvent(const Name &prefix)
FaceInfoTable::iterator end()
Interest is new (not a retransmission)
represents a Network Nack
NackReason getReason() const
Table::const_iterator iterator
std::shared_ptr< ns3::EventId > EventId
bool isProbingNeeded(const fib::Entry &fibEntry, const Interest &interest)
#define NFD_LOG_TRACE(expression)
Copyright (c) 2011-2015 Regents of the University of California.
FaceInfoTable::iterator find(nfd::face::FaceId faceId)
FaceInfo & get(nfd::face::FaceId faceId)
std::vector< fib::NextHop > NextHopList
NamespaceInfo & getOrCreateNamespaceInfo(const fib::Entry &fibEntry, const Interest &interest)
static const Rtt RTT_NO_MEASUREMENT
void rejectPendingInterest(const shared_ptr< pit::Entry > &pitEntry)
decide that a pending Interest cannot be forwarded
static const Name STRATEGY_NAME
virtual Result decide(const Face &inFace, const Interest &interest, pit::Entry &pitEntry) const override
determines whether Interest is a retransmission, and if so, whether it shall be forwarded or suppress...
RttStats::Rtt getRtt() const
Name abstraction to represent an absolute name.
void setTimeoutEvent(const scheduler::EventId &id, const Name &interestName)
Face * getFaceToProbe(const Face &inFace, const Interest &interest, const fib::Entry &fibEntry, const Face &faceUsed)
Strategy information for each face in a namespace.
represents a forwarding strategy
const FaceInfoTable::iterator insert(nfd::face::FaceId faceId)
virtual void afterReceiveNack(const Face &inFace, const lp::Nack &nack, const shared_ptr< pit::Entry > &pitEntry) override
trigger after Nack is received
virtual void afterReceiveInterest(const Face &inFace, const Interest &interest, const shared_ptr< pit::Entry > &pitEntry) override
trigger after Interest is received
NamespaceInfo * getNamespaceInfo(const Name &prefix)
const fib::Entry & lookupFib(const pit::Entry &pitEntry) const
performs a FIB lookup, considering Link object if present
EventId schedule(const time::nanoseconds &after, const Scheduler::Event &event)
schedule an event
Interest is retransmission and should be forwarded.
RttStats::Rtt getSrtt() const
void recordTimeout(const Name &interestName)
void afterForwardingProbe(const fib::Entry &fibEntry, const Interest &interest)
const NextHopList & getNextHops() const
double getValueForSorting(const FaceStats &stats)
uint64_t FaceId
identifies a face
#define NFD_LOG_INIT(name)
a retransmission suppression decision algorithm that suppresses retransmissions using exponential bac...
void sendInterest(const shared_ptr< pit::Entry > &pitEntry, Face &outFace, const Interest &interest)
send Interest to outFace
Adaptive SRTT-based Forwarding Strategy.
bool isTimeoutScheduled() const
const Interest & getInterest() const
time::duration< double, boost::micro > Rtt
const Name & getName() const
represents a nexthop record in FIB entry