NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
ncc-strategy.hpp
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 
26 #ifndef NFD_DAEMON_FW_NCC_STRATEGY_HPP
27 #define NFD_DAEMON_FW_NCC_STRATEGY_HPP
28 
29 #include "strategy.hpp"
30 
31 namespace nfd {
32 namespace fw {
33 
38 class NccStrategy : public Strategy
39 {
40 public:
41  explicit
42  NccStrategy(Forwarder& forwarder, const Name& name = getStrategyName());
43 
44  static const Name&
46 
47  void
48  afterReceiveInterest(const FaceEndpoint& ingress, const Interest& interest,
49  const shared_ptr<pit::Entry>& pitEntry) override;
50 
51  void
52  beforeSatisfyInterest(const shared_ptr<pit::Entry>& pitEntry,
53  const FaceEndpoint& ingress, const Data& data) override;
54 
58  {
59  public:
60  static constexpr int
62  {
63  return 1000;
64  }
65 
67 
68  void
69  inheritFrom(const MeasurementsEntryInfo& other);
70 
71  shared_ptr<Face>
72  getBestFace();
73 
74  void
75  updateBestFace(const Face& face);
76 
77  void
79 
80  private:
81  void
82  adjustPredictDown();
83 
84  void
85  ageBestFace();
86 
87  public:
88  weak_ptr<Face> bestFace;
89  weak_ptr<Face> previousFace;
90  time::microseconds prediction;
91 
92  static const time::microseconds INITIAL_PREDICTION;
93  static const time::microseconds MIN_PREDICTION;
94  static const int ADJUST_PREDICT_DOWN_SHIFT = 7;
95  static const time::microseconds MAX_PREDICTION;
96  static const int ADJUST_PREDICT_UP_SHIFT = 3;
97  };
98 
100  class PitEntryInfo : public StrategyInfo
101  {
102  public:
103  static constexpr int
105  {
106  return 1001;
107  }
108 
109  ~PitEntryInfo() override;
110 
111  public:
117  time::microseconds maxInterval;
118  };
119 
120 protected:
123 
125  getMeasurementsEntryInfo(const shared_ptr<pit::Entry>& entry);
126 
128  void
129  doPropagate(FaceId inFaceId, weak_ptr<pit::Entry> pitEntryWeak);
130 
132  void
133  timeoutOnBestFace(weak_ptr<pit::Entry> pitEntryWeak);
134 
135 protected:
136  static const time::microseconds DEFER_FIRST_WITHOUT_BEST_FACE;
137  static const time::microseconds DEFER_RANGE_WITHOUT_BEST_FACE;
138  static const int UPDATE_MEASUREMENTS_N_LEVELS = 2;
139  static const time::nanoseconds MEASUREMENTS_LIFETIME;
140 };
141 
142 } // namespace fw
143 } // namespace nfd
144 
145 #endif // NFD_DAEMON_FW_NCC_STRATEGY_HPP
nfd::fw::NccStrategy::MeasurementsEntryInfo
StrategyInfo on measurements::Entry.
Definition: ncc-strategy.hpp:58
nfd::fw::NccStrategy::MeasurementsEntryInfo::INITIAL_PREDICTION
static const time::microseconds INITIAL_PREDICTION
Definition: ncc-strategy.hpp:92
nfd::fw::NccStrategy::MeasurementsEntryInfo::MeasurementsEntryInfo
MeasurementsEntryInfo()
Definition: ncc-strategy.cpp:278
nfd::fw::NccStrategy::DEFER_RANGE_WITHOUT_BEST_FACE
static const time::microseconds DEFER_RANGE_WITHOUT_BEST_FACE
Definition: ncc-strategy.hpp:137
nfd::fw::NccStrategy::DEFER_FIRST_WITHOUT_BEST_FACE
static const time::microseconds DEFER_FIRST_WITHOUT_BEST_FACE
Definition: ncc-strategy.hpp:136
nfd::fw::NccStrategy::MeasurementsEntryInfo::adjustPredictUp
void adjustPredictUp()
Definition: ncc-strategy.cpp:325
nfd::fw::NccStrategy::MeasurementsEntryInfo::getBestFace
shared_ptr< Face > getBestFace()
Definition: ncc-strategy.cpp:290
nfd::fw::NccStrategy::MeasurementsEntryInfo::ADJUST_PREDICT_DOWN_SHIFT
static const int ADJUST_PREDICT_DOWN_SHIFT
Definition: ncc-strategy.hpp:94
nfd::fw::NccStrategy::MEASUREMENTS_LIFETIME
static const time::nanoseconds MEASUREMENTS_LIFETIME
Definition: ncc-strategy.hpp:139
nfd::fw::NccStrategy::doPropagate
void doPropagate(FaceId inFaceId, weak_ptr< pit::Entry > pitEntryWeak)
propagate to another upstream
Definition: ncc-strategy.cpp:136
nfd::fw::NccStrategy::MeasurementsEntryInfo::getTypeId
static constexpr int getTypeId()
Definition: ncc-strategy.hpp:61
nfd::fw::NccStrategy::PitEntryInfo::propagateTimer
scheduler::EventId propagateTimer
timer for propagating to another face
Definition: ncc-strategy.hpp:115
nfd::fw::NccStrategy::PitEntryInfo::~PitEntryInfo
~PitEntryInfo() override
Definition: ncc-strategy.cpp:338
nfd::fw::NccStrategy::MeasurementsEntryInfo::updateBestFace
void updateBestFace(const Face &face)
Definition: ncc-strategy.cpp:301
nfd::fw::NccStrategy::timeoutOnBestFace
void timeoutOnBestFace(weak_ptr< pit::Entry > pitEntryWeak)
best face did not reply within prediction
Definition: ncc-strategy.cpp:187
nfd::fw::NccStrategy::getStrategyName
static const Name & getStrategyName()
Definition: ncc-strategy.cpp:56
nfd::fw::NccStrategy::PitEntryInfo::getTypeId
static constexpr int getTypeId()
Definition: ncc-strategy.hpp:104
nfd::fw::NccStrategy::beforeSatisfyInterest
void beforeSatisfyInterest(const shared_ptr< pit::Entry > &pitEntry, const FaceEndpoint &ingress, const Data &data) override
trigger before PIT entry is satisfied
Definition: ncc-strategy.cpp:210
nfd::fw::NccStrategy::getMeasurementsEntryInfo
MeasurementsEntryInfo & getMeasurementsEntryInfo(measurements::Entry *entry)
Definition: ncc-strategy.cpp:255
nfd::fw::NccStrategy::PitEntryInfo
StrategyInfo on pit::Entry.
Definition: ncc-strategy.hpp:101
nfd::fw::NccStrategy::PitEntryInfo::maxInterval
time::microseconds maxInterval
maximum interval between forwarding to two nexthops except best and previous
Definition: ncc-strategy.hpp:117
nfd::fw::NccStrategy::UPDATE_MEASUREMENTS_N_LEVELS
static const int UPDATE_MEASUREMENTS_N_LEVELS
Definition: ncc-strategy.hpp:138
ndn::Name
Represents an absolute name.
Definition: name.hpp:44
ndn::scheduler::EventId
A handle for a scheduled event.
Definition: scheduler.hpp:59
nfd
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
nfd::fw::NccStrategy::MeasurementsEntryInfo::MIN_PREDICTION
static const time::microseconds MIN_PREDICTION
Definition: ncc-strategy.hpp:93
nfd::fw::StrategyInfo
contains arbitrary information forwarding strategy places on table entries
Definition: strategy-info.hpp:37
nfd::face::FaceId
uint64_t FaceId
Identifies a face.
Definition: face-common.hpp:44
nfd::face::Face
generalization of a network interface
Definition: face.hpp:53
nfd::fw::NccStrategy::NccStrategy
NccStrategy(Forwarder &forwarder, const Name &name=getStrategyName())
Definition: ncc-strategy.cpp:41
nfd::fw::NccStrategy
a forwarding strategy similar to CCNx 0.7.2
Definition: ncc-strategy.hpp:39
nfd::FaceEndpoint
Represents a face-endpoint pair in the forwarder.
Definition: face-endpoint.hpp:37
ndn::Interest
Represents an Interest packet.
Definition: interest.hpp:44
nfd::fw::NccStrategy::MeasurementsEntryInfo::ADJUST_PREDICT_UP_SHIFT
static const int ADJUST_PREDICT_UP_SHIFT
Definition: ncc-strategy.hpp:96
ndn::Data
Represents a Data packet.
Definition: data.hpp:36
nfd::fw::Strategy
represents a forwarding strategy
Definition: strategy.hpp:38
nfd::Forwarder
Main class of NFD's forwarding engine.
Definition: forwarder.hpp:52
nfd::fw::NccStrategy::MeasurementsEntryInfo::MAX_PREDICTION
static const time::microseconds MAX_PREDICTION
Definition: ncc-strategy.hpp:95
nfd::measurements::Entry
Represents a Measurements entry.
Definition: measurements-entry.hpp:42
strategy.hpp
ndn::name
Definition: name-component-types.hpp:33
nfd::fw::NccStrategy::PitEntryInfo::bestFaceTimeout
scheduler::EventId bestFaceTimeout
timer that expires when best face does not respond within predicted time
Definition: ncc-strategy.hpp:113
nfd::fw::NccStrategy::MeasurementsEntryInfo::previousFace
weak_ptr< Face > previousFace
Definition: ncc-strategy.hpp:89
PUBLIC_WITH_TESTS_ELSE_PROTECTED
#define PUBLIC_WITH_TESTS_ELSE_PROTECTED
Definition: common.hpp:40
nfd::fw::NccStrategy::MeasurementsEntryInfo::inheritFrom
void inheritFrom(const MeasurementsEntryInfo &other)
Definition: ncc-strategy.cpp:284
nfd::fw::NccStrategy::MeasurementsEntryInfo::bestFace
weak_ptr< Face > bestFace
Definition: ncc-strategy.hpp:88
nfd::fw::NccStrategy::MeasurementsEntryInfo::prediction
time::microseconds prediction
Definition: ncc-strategy.hpp:90
nfd::fw::NccStrategy::afterReceiveInterest
void afterReceiveInterest(const FaceEndpoint &ingress, const Interest &interest, const shared_ptr< pit::Entry > &pitEntry) override
trigger after Interest is received
Definition: ncc-strategy.cpp:63