39 , m_removeFaceInfoConn(this->beforeRemoveFace.connect(
51 shared_ptr<fib::Entry> fibEntry,
52 shared_ptr<pit::Entry> pitEntry)
55 switch (suppressResult) {
57 this->afterReceiveNewInterest(inFace, interest, fibEntry, pitEntry);
60 this->afterReceiveRetxInterest(inFace, interest, fibEntry, pitEntry);
72 AccessStrategy::afterReceiveNewInterest(
const Face& inFace,
74 shared_ptr<fib::Entry> fibEntry,
75 shared_ptr<pit::Entry> pitEntry)
78 shared_ptr<MtInfo> mi;
79 std::tie(miName, mi) = this->findPrefixMeasurements(*pitEntry);
84 " new-interest mi=" << miName);
87 bool isSentToLastNexthop = this->sendToLastNexthop(inFace, pitEntry, *mi, fibEntry);
89 if (isSentToLastNexthop) {
95 " new-interest no-mi");
101 this->multicast(pitEntry, fibEntry, {inFace.
getId()});
105 AccessStrategy::afterReceiveRetxInterest(
const Face& inFace,
107 shared_ptr<fib::Entry> fibEntry,
108 shared_ptr<pit::Entry> pitEntry)
111 this->multicast(pitEntry, fibEntry, {inFace.
getId()});
115 AccessStrategy::sendToLastNexthop(
const Face& inFace, shared_ptr<pit::Entry> pitEntry, MtInfo& mi,
116 shared_ptr<fib::Entry> fibEntry)
119 NFD_LOG_DEBUG(pitEntry->getInterest() <<
" no-last-nexthop");
123 if (mi.lastNexthop == inFace.
getId()) {
124 NFD_LOG_DEBUG(pitEntry->getInterest() <<
" last-nexthop-is-downstream");
128 shared_ptr<Face> face = this->
getFace(mi.lastNexthop);
129 if (face ==
nullptr || !fibEntry->hasNextHop(face)) {
130 NFD_LOG_DEBUG(pitEntry->getInterest() <<
" last-nexthop-gone");
134 if (pitEntry->violatesScope(*face)) {
135 NFD_LOG_DEBUG(pitEntry->getInterest() <<
" last-nexthop-violates-scope");
140 NFD_LOG_DEBUG(pitEntry->getInterest() <<
" interestTo " << mi.lastNexthop <<
141 " last-nexthop rto=" << time::duration_cast<time::microseconds>(rto).count());
146 shared_ptr<PitInfo> pi = pitEntry->getOrCreateStrategyInfo<PitInfo>();
148 bind(&AccessStrategy::afterRtoTimeout,
this, weak_ptr<pit::Entry>(pitEntry),
149 weak_ptr<fib::Entry>(fibEntry), inFace.
getId(), mi.lastNexthop));
155 AccessStrategy::afterRtoTimeout(weak_ptr<pit::Entry> pitWeak, weak_ptr<fib::Entry> fibWeak,
158 shared_ptr<pit::Entry> pitEntry = pitWeak.lock();
159 BOOST_ASSERT(pitEntry !=
nullptr);
162 shared_ptr<fib::Entry> fibEntry = fibWeak.lock();
163 if (fibEntry ==
nullptr) {
164 NFD_LOG_DEBUG(pitEntry->getInterest() <<
" timeoutFrom " << firstOutFace <<
" fib-gone");
168 NFD_LOG_DEBUG(pitEntry->getInterest() <<
" timeoutFrom " << firstOutFace <<
169 " multicast-except " << inFace <<
',' << firstOutFace);
170 this->multicast(pitEntry, fibEntry, {inFace, firstOutFace});
174 AccessStrategy::multicast(shared_ptr<pit::Entry> pitEntry, shared_ptr<fib::Entry> fibEntry,
175 std::unordered_set<FaceId> exceptFaces)
177 for (
const fib::NextHop& nexthop : fibEntry->getNextHops()) {
178 shared_ptr<Face> face = nexthop.getFace();
179 if (exceptFaces.count(face->getId()) > 0) {
182 NFD_LOG_DEBUG(pitEntry->getInterest() <<
" interestTo " << face->getId() <<
190 const Face& inFace,
const Data& data)
192 shared_ptr<PitInfo> pi = pitEntry->getStrategyInfo<PitInfo>();
194 pi->rtoTimer.cancel();
197 if (pitEntry->getInRecords().empty()) {
203 pit::OutRecordCollection::const_iterator outRecord = pitEntry->getOutRecord(inFace);
204 if (outRecord == pitEntry->getOutRecords().end()) {
212 " rtt=" << time::duration_cast<time::microseconds>(rtt).count());
213 this->updateMeasurements(inFace, data, time::duration_cast<RttEstimator::Duration>(rtt));
217 AccessStrategy::updateMeasurements(
const Face& inFace,
const Data& data,
220 FaceInfo& fi = m_fit[inFace.
getId()];
221 fi.rtt.addMeasurement(rtt);
223 shared_ptr<MtInfo> mi = this->addPrefixMeasurements(data);
224 if (mi->lastNexthop != inFace.
getId()) {
225 mi->lastNexthop = inFace.
getId();
229 mi->rtt.addMeasurement(rtt);
233 AccessStrategy::MtInfo::MtInfo()
235 , rtt(1, time::milliseconds(1), 0.1)
239 std::tuple<Name, shared_ptr<AccessStrategy::MtInfo>>
240 AccessStrategy::findPrefixMeasurements(
const pit::Entry& pitEntry)
244 return std::forward_as_tuple(
Name(),
nullptr);
247 shared_ptr<MtInfo> mi = me->getStrategyInfo<MtInfo>();
248 BOOST_ASSERT(mi !=
nullptr);
251 return std::forward_as_tuple(me->getName(), mi);
254 shared_ptr<AccessStrategy::MtInfo>
255 AccessStrategy::addPrefixMeasurements(
const Data& data)
257 shared_ptr<measurements::Entry> me;
264 BOOST_ASSERT(me !=
nullptr);
267 static const time::nanoseconds ME_LIFETIME = time::seconds(8);
270 return me->getOrCreateStrategyInfo<MtInfo>();
273 AccessStrategy::FaceInfo::FaceInfo()
274 : rtt(1, time::milliseconds(1), 0.1)
279 AccessStrategy::removeFaceInfo(shared_ptr<Face> face)
281 m_fit.erase(face->getId());
time::microseconds Duration
shared_ptr< measurements::Entry > findLongestPrefixMatch(const Name &name, const measurements::EntryPredicate &pred=measurements::AnyEntry()) const
perform a longest prefix match for name
#define NFD_LOG_DEBUG(expression)
virtual Result decide(const Face &inFace, const Interest &interest, pit::Entry &pitEntry) const 1
determines whether Interest is a retransmission, and if so, whether it shall be forwarded or suppress...
AccessStrategy(Forwarder &forwarder, const Name &name=STRATEGY_NAME)
static time_point now() noexcept
Interest is retransmission and should be suppressed.
represents an Interest packet
static const Name STRATEGY_NAME
shared_ptr< measurements::Entry > get(const Name &name)
find or insert a Measurements entry for name
virtual void afterReceiveInterest(const Face &inFace, const Interest &interest, shared_ptr< fib::Entry > fibEntry, shared_ptr< pit::Entry > pitEntry) 1
trigger after Interest is received
Interest is new (not a retransmission)
const Name & getName() const
Get name of the Data packet.
virtual ~AccessStrategy()
shared_ptr< Face > getFace(FaceId id)
MeasurementsAccessor & getMeasurements()
Copyright (c) 2011-2015 Regents of the University of California.
NFD_REGISTER_STRATEGY(AccessStrategy)
virtual void beforeSatisfyInterest(shared_ptr< pit::Entry > pitEntry, const Face &inFace, const Data &data) 1
trigger before PIT entry is satisfied
size_t size() const
Get the number of components.
EventId schedule(const time::nanoseconds &after, const std::function< void()> &event)
schedule an event
Name abstraction to represent an absolute name.
represents a forwarding strategy
void extendLifetime(measurements::Entry &entry, const time::nanoseconds &lifetime)
extend lifetime of an entry
#define NFD_LOG_INIT(name)
const FaceId INVALID_FACEID
indicates an invalid FaceId
Interest is retransmission and should be forwarded.
void sendInterest(shared_ptr< pit::Entry > pitEntry, shared_ptr< Face > outFace, bool wantNewNonce=false)
send Interest to outFace
PartialName getPrefix(ssize_t nComponents) const
Extract a prefix (PartialName) of the name, containing first nComponents components.
Access Router Strategy version 1.
represents a nexthop record in FIB entry