NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
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 
36 {
37 public:
38  static constexpr int
40  {
41  return 1020;
42  }
43 
44  explicit
45  PitInfo(const Duration& initialInterval)
46  : suppressionInterval(initialInterval)
47  {
48  }
49 
50 public:
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
nfd::fw::RetxSuppressionExponential::Duration
time::microseconds Duration
time granularity
Definition: retx-suppression-exponential.hpp:46
nfd::fw::RetxSuppressionExponential::incrementIntervalForOutRecord
void incrementIntervalForOutRecord(pit::OutRecord &outRecord)
Increment the suppression interval for out record.
Definition: retx-suppression-exponential.cpp:119
nfd::fw::RetxSuppressionExponential::PitInfo::PitInfo
PitInfo(const Duration &initialInterval)
Definition: retx-suppression-exponential.cpp:45
nfd::fw::RetxSuppressionExponential::DEFAULT_MAX_INTERVAL
static const Duration DEFAULT_MAX_INTERVAL
Definition: retx-suppression-exponential.hpp:78
nfd::pit::OutRecord
Contains information about an Interest toward an outgoing face.
Definition: pit-out-record.hpp:37
nfd::fw::RetxSuppressionExponential::PitInfo::getTypeId
static constexpr int getTypeId()
Definition: retx-suppression-exponential.cpp:39
ndn::time::steady_clock::now
static time_point now() noexcept
Definition: time.cpp:80
nfd::pit::Entry::getOutRecord
OutRecordCollection::iterator getOutRecord(const Face &face)
get the out-record for face
Definition: pit-entry.cpp:91
retx-suppression-exponential.hpp
nfd::pit::Entry::out_end
OutRecordCollection::iterator out_end()
Definition: pit-entry.hpp:190
nfd::fw::RetxSuppressionExponential::PitInfo
Definition: retx-suppression-exponential.cpp:36
nfd::fw::RetxSuppressionExponential::PitInfo::suppressionInterval
Duration suppressionInterval
if last transmission occurred within suppressionInterval, retransmission will be suppressed
Definition: retx-suppression-exponential.cpp:54
nfd::fw::RetxSuppressionResult
RetxSuppressionResult
Definition: retx-suppression.hpp:34
nfd
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
nfd::fw::RetxSuppressionExponential::decidePerPitEntry
RetxSuppressionResult decidePerPitEntry(pit::Entry &pitEntry)
determines whether Interest is a retransmission per pit entry and if so, whether it shall be forwarde...
Definition: retx-suppression-exponential.cpp:70
nfd::fw::StrategyInfo
contains arbitrary information forwarding strategy places on table entries
Definition: strategy-info.hpp:37
nfd::face::Face
generalization of a network interface
Definition: face.hpp:53
nfd::fw::RetxSuppressionExponential::RetxSuppressionExponential
RetxSuppressionExponential(const Duration &initialInterval=DEFAULT_INITIAL_INTERVAL, float multiplier=DEFAULT_MULTIPLIER, const Duration &maxInterval=DEFAULT_MAX_INTERVAL)
Definition: retx-suppression-exponential.cpp:57
nfd::pit::Entry
An Interest table entry.
Definition: pit-entry.hpp:59
nfd::fw::getLastOutgoing
time::steady_clock::TimePoint getLastOutgoing(const pit::Entry &pitEntry)
Definition: algorithm.cpp:119
nfd::fw::RetxSuppressionResult::FORWARD
@ FORWARD
Interest is retransmission and should be forwarded.
nfd::fw::hasPendingOutRecords
bool hasPendingOutRecords(const pit::Entry &pitEntry)
determine whether pitEntry has any pending out-records
Definition: algorithm.cpp:108
nfd::StrategyInfoHost::insertStrategyInfo
std::pair< T *, bool > insertStrategyInfo(A &&... args)
Insert a StrategyInfo item.
Definition: strategy-info-host.hpp:63
nfd::fw::RetxSuppressionExponential::DEFAULT_INITIAL_INTERVAL
static const Duration DEFAULT_INITIAL_INTERVAL
Definition: retx-suppression-exponential.hpp:73
nfd::fw::RetxSuppressionExponential::DEFAULT_MULTIPLIER
static const float DEFAULT_MULTIPLIER
Definition: retx-suppression-exponential.hpp:77
nfd::fw::RetxSuppressionResult::SUPPRESS
@ SUPPRESS
Interest is retransmission and should be suppressed.
nfd::fw::RetxSuppressionExponential::decidePerUpstream
RetxSuppressionResult decidePerUpstream(pit::Entry &pitEntry, Face &outFace)
determines whether Interest is a retransmission per upstream and if so, whether it shall be forwarded...
Definition: retx-suppression-exponential.cpp:95
nfd::fw::RetxSuppressionResult::NEW
@ NEW
Interest is new (not a retransmission)