Пример #1
0
time::steady_clock::TimePoint
RetxSuppression::getLastOutgoing(const pit::Entry& pitEntry) const
{
  const pit::OutRecordCollection& outRecords = pitEntry.getOutRecords();
  pit::OutRecordCollection::const_iterator lastOutgoing = std::max_element(
      outRecords.begin(), outRecords.end(),
      [] (const pit::OutRecord& a, const pit::OutRecord& b) {
        return a.getLastRenewed() < b.getLastRenewed();
      });
  BOOST_ASSERT(lastOutgoing != outRecords.end()); // otherwise it's new PIT entry

  return lastOutgoing->getLastRenewed();
}
Пример #2
0
void
Forwarder::insertDeadNonceList(pit::Entry& pitEntry, bool isSatisfied,
                               const time::milliseconds& dataFreshnessPeriod,
                               Face* upstream)
{
  // need Dead Nonce List insert?
  bool needDnl = false;
  if (isSatisfied) {
    bool hasFreshnessPeriod = dataFreshnessPeriod >= time::milliseconds::zero();
    // Data never becomes stale if it doesn't have FreshnessPeriod field
    needDnl = static_cast<bool>(pitEntry.getInterest().getMustBeFresh()) &&
              (hasFreshnessPeriod && dataFreshnessPeriod < m_deadNonceList.getLifetime());
  }
  else {
    needDnl = true;
  }

  if (!needDnl) {
    return;
  }

  // Dead Nonce List insert
  if (upstream == 0) {
    // insert all outgoing Nonces
    const pit::OutRecordCollection& outRecords = pitEntry.getOutRecords();
    std::for_each(outRecords.begin(), outRecords.end(),
                  bind(&insertNonceToDnl, ref(m_deadNonceList), cref(pitEntry), _1));
  }
  else {
    // insert outgoing Nonce of a specific face
    pit::OutRecordCollection::const_iterator outRecord = pitEntry.getOutRecord(*upstream);
    if (outRecord != pitEntry.getOutRecords().end()) {
      m_deadNonceList.add(pitEntry.getName(), outRecord->getLastNonce());
    }
  }
}