40 , m_removeFaceInfoConn(this->beforeRemoveFace.connect(
47 const shared_ptr<pit::Entry>& pitEntry)
50 switch (suppressResult) {
52 this->afterReceiveNewInterest(inFace, interest, pitEntry);
55 this->afterReceiveRetxInterest(inFace, interest, pitEntry);
67 AccessStrategy::afterReceiveNewInterest(
const Face& inFace,
const Interest& interest,
68 const shared_ptr<pit::Entry>& pitEntry)
73 std::tie(miName, mi) = this->findPrefixMeasurements(*pitEntry);
78 " new-interest mi=" << miName);
81 bool isSentToLastNexthop = this->sendToLastNexthop(inFace, interest, pitEntry, *mi, fibEntry);
83 if (isSentToLastNexthop) {
89 " new-interest no-mi");
95 int nMulticastSent = this->multicast(inFace, interest, pitEntry, fibEntry);
97 if (nMulticastSent < 1) {
103 AccessStrategy::afterReceiveRetxInterest(
const Face& inFace,
const Interest& interest,
104 const shared_ptr<pit::Entry>& pitEntry)
108 this->multicast(inFace, interest, pitEntry, fibEntry);
112 AccessStrategy::sendToLastNexthop(
const Face& inFace,
const Interest& interest,
113 const shared_ptr<pit::Entry>& pitEntry, MtInfo& mi,
117 NFD_LOG_DEBUG(pitEntry->getInterest() <<
" no-last-nexthop");
121 if (mi.lastNexthop == inFace.
getId()) {
122 NFD_LOG_DEBUG(pitEntry->getInterest() <<
" last-nexthop-is-downstream");
127 if (outFace ==
nullptr || !fibEntry.
hasNextHop(*outFace)) {
128 NFD_LOG_DEBUG(pitEntry->getInterest() <<
" last-nexthop-gone");
133 NFD_LOG_DEBUG(pitEntry->getInterest() <<
" last-nexthop-violates-scope");
138 NFD_LOG_DEBUG(pitEntry->getInterest() <<
" interestTo " << mi.lastNexthop <<
139 " last-nexthop rto=" << time::duration_cast<time::microseconds>(rto).count());
144 PitInfo* pi = pitEntry->insertStrategyInfo<PitInfo>().first;
146 bind(&AccessStrategy::afterRtoTimeout,
this, weak_ptr<pit::Entry>(pitEntry),
147 inFace.
getId(), mi.lastNexthop));
153 AccessStrategy::afterRtoTimeout(weak_ptr<pit::Entry> pitWeak,
FaceId inFaceId,
FaceId firstOutFaceId)
155 shared_ptr<pit::Entry> pitEntry = pitWeak.lock();
156 BOOST_ASSERT(pitEntry !=
nullptr);
160 if (inFace ==
nullptr) {
161 NFD_LOG_DEBUG(pitEntry->getInterest() <<
" timeoutFrom " << firstOutFaceId <<
162 " inFace-gone " << inFaceId);
167 BOOST_ASSERT(inRecord != pitEntry->in_end());
172 const Interest& interest = inRecord->getInterest();
176 NFD_LOG_DEBUG(pitEntry->getInterest() <<
" timeoutFrom " << firstOutFaceId <<
177 " multicast-except " << firstOutFaceId);
178 this->multicast(*inFace, interest, pitEntry, fibEntry, firstOutFaceId);
182 AccessStrategy::multicast(
const Face& inFace,
const Interest& interest,
183 const shared_ptr<pit::Entry>& pitEntry,
const fib::Entry& fibEntry,
188 Face& outFace = nexthop.getFace();
189 if (&outFace == &inFace || outFace.
getId() == exceptFace ||
203 const Face& inFace,
const Data& data)
205 PitInfo* pi = pitEntry->getStrategyInfo<PitInfo>();
207 pi->rtoTimer.cancel();
210 if (!pitEntry->hasInRecords()) {
217 if (outRecord == pitEntry->out_end()) {
225 " rtt=" << time::duration_cast<time::microseconds>(rtt).count());
226 this->updateMeasurements(inFace, data, time::duration_cast<RttEstimator::Duration>(rtt));
230 AccessStrategy::updateMeasurements(
const Face& inFace,
const Data& data,
233 FaceInfo& fi = m_fit[inFace.
getId()];
234 fi.rtt.addMeasurement(rtt);
236 MtInfo* mi = this->addPrefixMeasurements(data);
237 if (mi->lastNexthop != inFace.
getId()) {
238 mi->lastNexthop = inFace.
getId();
242 mi->rtt.addMeasurement(rtt);
246 AccessStrategy::MtInfo::MtInfo()
248 , rtt(1, time::milliseconds(1), 0.1)
252 std::tuple<Name, AccessStrategy::MtInfo*>
253 AccessStrategy::findPrefixMeasurements(
const pit::Entry& pitEntry)
257 return std::make_tuple(
Name(),
nullptr);
261 BOOST_ASSERT(mi !=
nullptr);
264 return std::make_tuple(me->
getName(), mi);
267 AccessStrategy::MtInfo*
268 AccessStrategy::addPrefixMeasurements(
const Data& data)
277 BOOST_ASSERT(me !=
nullptr);
280 static const time::nanoseconds ME_LIFETIME = time::seconds(8);
286 AccessStrategy::FaceInfo::FaceInfo()
287 : rtt(1, time::milliseconds(1), 0.1)
292 AccessStrategy::removeFaceInfo(
const Face&
face)
294 m_fit.erase(face.
getId());
const Name & getName() const
time::microseconds Duration
PartialName getPrefix(ssize_t nComponents) const
Extract a prefix (PartialName) of the name, containing first nComponents components.
generalization of a network interface
AccessStrategy(Forwarder &forwarder, const Name &name=STRATEGY_NAME)
static time_point now() noexcept
const Name & getName() const
Get name of the Data packet.
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...
Face * getFace(FaceId id) const
Interest is retransmission and should be suppressed.
represents an Interest packet
#define NFD_LOG_DEBUG(expression)
static const Name STRATEGY_NAME
virtual void afterReceiveInterest(const Face &inFace, const Interest &interest, const shared_ptr< pit::Entry > &pitEntry) override
trigger after Interest is received
void extendLifetime(Entry &entry, const time::nanoseconds &lifetime)
extend lifetime of an entry
Entry * findLongestPrefixMatch(const Name &name, const EntryPredicate &pred=AnyEntry()) const
perform a longest prefix match for name
Interest is new (not a retransmission)
represents a Measurements entry
Table::const_iterator iterator
Copyright (c) 2011-2015 Regents of the University of California.
MeasurementsAccessor & getMeasurements()
NFD_REGISTER_STRATEGY(AccessStrategy)
void rejectPendingInterest(const shared_ptr< pit::Entry > &pitEntry)
decide that a pending Interest cannot be forwarded
Name abstraction to represent an absolute name.
std::pair< T *, bool > insertStrategyInfo(A &&... args)
insert a StrategyInfo item
represents a forwarding strategy
virtual void beforeSatisfyInterest(const shared_ptr< pit::Entry > &pitEntry, const Face &inFace, const Data &data) override
trigger before PIT entry is satisfied
Copyright (c) 2014-2016, Regents of the University of California, Arizona Board of Regents...
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.
Entry * get(const Name &name)
find or insert a Measurements entry for name
bool empty() const
Check if name is emtpy.
const NextHopList & getNextHops() const
Access Router Strategy version 1.
uint64_t FaceId
identifies a face
#define NFD_LOG_INIT(name)
void sendInterest(const shared_ptr< pit::Entry > &pitEntry, Face &outFace, const Interest &interest)
send Interest to outFace
bool wouldViolateScope(const Face &inFace, const Interest &interest, const Face &outFace)
determine whether forwarding the Interest in pitEntry to outFace would violate scope ...
const FaceId INVALID_FACEID
indicates an invalid FaceId
represents a nexthop record in FIB entry
bool hasNextHop(const Face &face) const
T * getStrategyInfo() const
get a StrategyInfo item