retx-suppression-exponential.cpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014-2019, Regents of the University of California,
4  * Arizona Board of Regents,
5  * Colorado State University,
6  * University Pierre & Marie Curie, Sorbonne University,
7  * Washington University in St. Louis,
8  * Beijing Institute of Technology,
9  * The University of Memphis.
10  *
11  * This file is part of NFD (Named Data Networking Forwarding Daemon).
12  * See AUTHORS.md for complete list of NFD authors and contributors.
13  *
14  * NFD is free software: you can redistribute it and/or modify it under the terms
15  * of the GNU General Public License as published by the Free Software Foundation,
16  * either version 3 of the License, or (at your option) any later version.
17  *
18  * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
19  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
20  * PURPOSE. See the GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License along with
23  * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
24  */
25 
27 
28 namespace nfd {
29 namespace fw {
30 
34 
35 class RetxSuppressionExponential::PitInfo : public StrategyInfo
36 {
37 public:
38  static constexpr int
39  getTypeId()
40  {
41  return 1020;
42  }
43 
44  explicit
45  PitInfo(const Duration& initialInterval)
46  : suppressionInterval(initialInterval)
47  {
48  }
49 
50 public:
54  Duration suppressionInterval;
55 };
56 
58  float multiplier,
59  const Duration& maxInterval)
60  : m_initialInterval(initialInterval)
61  , m_multiplier(multiplier)
62  , m_maxInterval(maxInterval)
63 {
64  BOOST_ASSERT(initialInterval > 0_us);
65  BOOST_ASSERT(multiplier >= 1.0f);
66  BOOST_ASSERT(maxInterval >= initialInterval);
67 }
68 
71 {
72  bool isNewPitEntry = !hasPendingOutRecords(pitEntry);
73  if (isNewPitEntry) {
75  }
76 
77  auto lastOutgoing = getLastOutgoing(pitEntry);
78  auto now = time::steady_clock::now();
79  auto sinceLastOutgoing = now - lastOutgoing;
80 
81  PitInfo* pi = pitEntry.insertStrategyInfo<PitInfo>(m_initialInterval).first;
82  bool shouldSuppress = sinceLastOutgoing < pi->suppressionInterval;
83 
84  if (shouldSuppress) {
86  }
87 
88  pi->suppressionInterval = std::min(m_maxInterval,
89  time::duration_cast<Duration>(pi->suppressionInterval * m_multiplier));
90 
92 }
93 
96 {
97  // NEW if outRecord for the face does not exist
98  auto outRecord = pitEntry.getOutRecord(outFace);
99  if (outRecord == pitEntry.out_end()) {
101  }
102 
103  auto lastOutgoing = outRecord->getLastRenewed();
104  auto now = time::steady_clock::now();
105  auto sinceLastOutgoing = now - lastOutgoing;
106 
107  // insertStrategyInfo does not insert m_initialInterval again if it already exists
108  PitInfo* pi = outRecord->insertStrategyInfo<PitInfo>(m_initialInterval).first;
109  bool shouldSuppress = sinceLastOutgoing < pi->suppressionInterval;
110 
111  if (shouldSuppress) {
113  }
114 
116 }
117 
118 void
120 {
121  PitInfo* pi = outRecord.insertStrategyInfo<PitInfo>(m_initialInterval).first;
122  pi->suppressionInterval = std::min(m_maxInterval,
123  time::duration_cast<Duration>(pi->suppressionInterval * m_multiplier));
124 }
125 
126 } // namespace fw
127 } // namespace nfd
Interest is retransmission and should be forwarded.
OutRecordCollection::iterator getOutRecord(const Face &face)
get the out-record for face
Definition: pit-entry.cpp:91
void incrementIntervalForOutRecord(pit::OutRecord &outRecord)
Increment the suppression interval for out record.
std::pair< T *, bool > insertStrategyInfo(A &&... args)
Insert a StrategyInfo item.
Contains information about an Interest toward an outgoing face.
Interest is retransmission and should be suppressed.
RetxSuppressionResult decidePerUpstream(pit::Entry &pitEntry, Face &outFace)
determines whether Interest is a retransmission per upstream and if so, whether it shall be forwarded...
An Interest table entry.
Definition: pit-entry.hpp:58
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
Definition: algorithm.hpp:32
Interest is new (not a retransmission)
RetxSuppressionExponential(const Duration &initialInterval=DEFAULT_INITIAL_INTERVAL, float multiplier=DEFAULT_MULTIPLIER, const Duration &maxInterval=DEFAULT_MAX_INTERVAL)
generalization of a network interface
Definition: face.hpp:54
bool hasPendingOutRecords(const pit::Entry &pitEntry)
determine whether pitEntry has any pending out-records
Definition: algorithm.cpp:108
time::steady_clock::TimePoint getLastOutgoing(const pit::Entry &pitEntry)
Definition: algorithm.cpp:119
RetxSuppressionResult decidePerPitEntry(pit::Entry &pitEntry)
determines whether Interest is a retransmission per pit entry and if so, whether it shall be forwarde...
OutRecordCollection::iterator out_end()
Definition: pit-entry.hpp:190
time::microseconds Duration
time granularity