33 class PitInfo final :
public StrategyInfo
58 : m_initialInterval(initialInterval)
59 , m_maxInterval(maxInterval)
60 , m_multiplier(multiplier)
62 if (m_initialInterval <= 0_ns) {
63 NDN_THROW(std::invalid_argument(
"Retx suppression initial interval must be > 0"));
65 if (m_maxInterval < m_initialInterval) {
66 NDN_THROW(std::invalid_argument(
"Retx suppression max interval must be >= initial interval"));
68 if (m_multiplier < 1.0f) {
69 NDN_THROW(std::invalid_argument(
"Retx suppression multiplier must be >= 1"));
82 auto now = time::steady_clock::now();
83 auto sinceLastOutgoing = now - lastOutgoing;
86 bool shouldSuppress = sinceLastOutgoing < pi->suppressionInterval;
92 pi->suppressionInterval = std::min(m_maxInterval,
93 time::duration_cast<Duration>(pi->suppressionInterval * m_multiplier));
103 if (outRecord == pitEntry.
out_end()) {
107 auto lastOutgoing = outRecord->getLastRenewed();
108 auto now = time::steady_clock::now();
109 auto sinceLastOutgoing = now - lastOutgoing;
112 PitInfo* pi = outRecord->insertStrategyInfo<PitInfo>(m_initialInterval).first;
113 bool shouldSuppress = sinceLastOutgoing < pi->suppressionInterval;
115 if (shouldSuppress) {
126 pi->suppressionInterval = std::min(m_maxInterval,
127 time::duration_cast<Duration>(pi->suppressionInterval * m_multiplier));
130 std::unique_ptr<RetxSuppressionExponential>
133 auto init = params.
getOrDefault<Duration::rep>(
"retx-suppression-initial",
135 auto max = params.
getOrDefault<Duration::rep>(
"retx-suppression-max",
137 auto mult = params.
getOrDefault<
float>(
"retx-suppression-multiplier",
140 return make_unique<RetxSuppressionExponential>(
Duration(init),
Duration(max), mult);
This file contains common algorithms used by forwarding strategies.
std::pair< T *, bool > insertStrategyInfo(A &&... args)
Insert a StrategyInfo item.
Generalization of a network interface.
time::milliseconds Duration
Time granularity.
static std::unique_ptr< RetxSuppressionExponential > construct(const StrategyParameters ¶ms)
void incrementIntervalForOutRecord(pit::OutRecord &outRecord)
Increment the suppression interval for an out-record.
static constexpr Duration DEFAULT_MAX_INTERVAL
static constexpr Duration DEFAULT_INITIAL_INTERVAL
RetxSuppressionResult decidePerUpstream(pit::Entry &pitEntry, Face &outFace)
Determines whether Interest is a retransmission per upstream and if so, whether it shall be forwarded...
RetxSuppressionResult decidePerPitEntry(pit::Entry &pitEntry)
Determines whether Interest is a retransmission per PIT entry and if so, whether it shall be forwarde...
static constexpr float DEFAULT_MULTIPLIER
RetxSuppressionExponential(Duration initialInterval=DEFAULT_INITIAL_INTERVAL, Duration maxInterval=DEFAULT_MAX_INTERVAL, float multiplier=DEFAULT_MULTIPLIER)
std::enable_if_t< std::is_signed_v< T >, T > getOrDefault(const key_type &key, const T &defaultVal) const
Represents an entry in the Interest table (PIT).
OutRecordCollection::iterator findOutRecord(const Face &face) noexcept
Get the out-record for face.
OutRecordCollection::iterator out_end() noexcept
Contains information about an Interest toward an outgoing face.
@ SUPPRESS
Interest is a retransmission and should be suppressed.
@ NEW
Interest is new (not a retransmission).
@ FORWARD
Interest is a retransmission and should be forwarded.
bool hasPendingOutRecords(const pit::Entry &pitEntry)
Determine whether pitEntry has any pending out-records.
time::steady_clock::time_point getLastOutgoing(const pit::Entry &pitEntry)
RetxSuppressionExponential::Duration suppressionInterval