NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: 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; -*- */
27 #include "algorithm.hpp"
28 
29 namespace nfd {
30 namespace fw {
31 
33  time::milliseconds(1);
36  time::milliseconds(250);
37 
39 {
40 public:
41  static constexpr int
43  {
44  return 1020;
45  }
46 
47  explicit
48  PitInfo(const Duration& initialInterval)
49  : suppressionInterval(initialInterval)
50  {
51  }
52 
53 public:
58 };
59 
61  float multiplier,
62  const Duration& maxInterval)
63  : m_initialInterval(initialInterval)
64  , m_multiplier(multiplier)
65  , m_maxInterval(maxInterval)
66 {
67  BOOST_ASSERT(initialInterval > time::milliseconds::zero());
68  BOOST_ASSERT(multiplier >= 1.0);
69  BOOST_ASSERT(maxInterval >= initialInterval);
70 }
71 
73 RetxSuppressionExponential::decide(const Face& inFace, const Interest& interest,
74  pit::Entry& pitEntry) const
75 {
76  bool isNewPitEntry = !hasPendingOutRecords(pitEntry);
77  if (isNewPitEntry) {
78  return NEW;
79  }
80 
81  time::steady_clock::TimePoint lastOutgoing = this->getLastOutgoing(pitEntry);
83  time::steady_clock::Duration sinceLastOutgoing = now - lastOutgoing;
84 
85  PitInfo* pi = pitEntry.insertStrategyInfo<PitInfo>(m_initialInterval).first;
86  bool shouldSuppress = sinceLastOutgoing < pi->suppressionInterval;
87 
88  if (shouldSuppress) {
89  return SUPPRESS;
90  }
91 
92  pi->suppressionInterval = std::min(m_maxInterval,
93  time::duration_cast<Duration>(pi->suppressionInterval * m_multiplier));
94  return FORWARD;
95 }
96 
97 } // namespace fw
98 } // namespace nfd
time_point TimePoint
Definition: time.hpp:120
generalization of a network interface
Definition: face.hpp:67
static time_point now() noexcept
Definition: time.cpp:79
Duration suppressionInterval
if last transmission occurred within suppressionInterval, retransmission will be suppressed ...
Interest is retransmission and should be suppressed.
represents an Interest packet
Definition: interest.hpp:42
Interest is new (not a retransmission)
time::steady_clock::TimePoint getLastOutgoing(const pit::Entry &pitEntry) const
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
an Interest table entry
Definition: pit-entry.hpp:57
RetxSuppressionExponential(const Duration &initialInterval=DEFAULT_INITIAL_INTERVAL, float multiplier=DEFAULT_MULTIPLIER, const Duration &maxInterval=DEFAULT_MAX_INTERVAL)
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...
bool hasPendingOutRecords(const pit::Entry &pitEntry)
determine whether pitEntry has any pending out-records
Definition: algorithm.cpp:136
std::pair< T *, bool > insertStrategyInfo(A &&... args)
insert a StrategyInfo item
time::microseconds Duration
time granularity
Copyright (c) 2014-2016, Regents of the University of California, Arizona Board of Regents...
Interest is retransmission and should be forwarded.
contains arbitrary information forwarding strategy places on table entries