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-2020, 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 
36 class NccStrategy : public Strategy
37 {
38 public:
39  explicit
40  NccStrategy(Forwarder& forwarder, const Name& name = getStrategyName());
41 
42  static const Name&
44 
45  void
46  afterReceiveInterest(const FaceEndpoint& ingress, const Interest& interest,
47  const shared_ptr<pit::Entry>& pitEntry) override;
48 
49  void
50  beforeSatisfyInterest(const shared_ptr<pit::Entry>& pitEntry,
51  const FaceEndpoint& ingress, const Data& data) override;
52 
56  {
57  public:
58  static constexpr int
60  {
61  return 1000;
62  }
63 
65 
66  void
67  inheritFrom(const MeasurementsEntryInfo& other);
68 
69  shared_ptr<Face>
70  getBestFace();
71 
72  void
73  updateBestFace(const Face& face);
74 
75  void
77 
78  private:
79  void
80  adjustPredictDown();
81 
82  void
83  ageBestFace();
84 
85  public:
86  weak_ptr<Face> bestFace;
87  weak_ptr<Face> previousFace;
88  time::microseconds prediction;
89 
90  static const time::microseconds INITIAL_PREDICTION;
91  static const time::microseconds MIN_PREDICTION;
92  static const int ADJUST_PREDICT_DOWN_SHIFT = 7;
93  static const time::microseconds MAX_PREDICTION;
94  static const int ADJUST_PREDICT_UP_SHIFT = 3;
95  };
96 
98  class PitEntryInfo : public StrategyInfo
99  {
100  public:
101  static constexpr int
103  {
104  return 1001;
105  }
106 
107  ~PitEntryInfo() override;
108 
109  public:
111  scheduler::EventId bestFaceTimeout;
113  scheduler::EventId propagateTimer;
115  time::microseconds maxInterval;
116  };
117 
118 protected:
121 
123  getMeasurementsEntryInfo(const shared_ptr<pit::Entry>& entry);
124 
126  void
127  doPropagate(FaceId inFaceId, weak_ptr<pit::Entry> pitEntryWeak);
128 
130  void
131  timeoutOnBestFace(weak_ptr<pit::Entry> pitEntryWeak);
132 
133 protected:
134  static const time::microseconds DEFER_FIRST_WITHOUT_BEST_FACE;
135  static const time::microseconds DEFER_RANGE_WITHOUT_BEST_FACE;
136  static const int UPDATE_MEASUREMENTS_N_LEVELS = 2;
137  static const time::nanoseconds MEASUREMENTS_LIFETIME;
138 };
139 
140 } // namespace fw
141 } // namespace nfd
142 
143 #endif // NFD_DAEMON_FW_NCC_STRATEGY_HPP
static const int ADJUST_PREDICT_UP_SHIFT
Main class of NFD&#39;s forwarding engine.
Definition: forwarder.hpp:51
void timeoutOnBestFace(weak_ptr< pit::Entry > pitEntryWeak)
best face did not reply within prediction
time::microseconds maxInterval
maximum interval between forwarding to two nexthops except best and previous
weak_ptr< Face > bestFace
weak_ptr< Face > previousFace
static constexpr int getTypeId()
Represents a Measurements entry.
static const int UPDATE_MEASUREMENTS_N_LEVELS
time::microseconds prediction
void adjustPredictUp()
#define PUBLIC_WITH_TESTS_ELSE_PROTECTED
Definition: common.hpp:40
scheduler::EventId bestFaceTimeout
timer that expires when best face does not respond within predicted time
static const time::nanoseconds MEASUREMENTS_LIFETIME
StrategyInfo on pit::Entry.
void doPropagate(FaceId inFaceId, weak_ptr< pit::Entry > pitEntryWeak)
propagate to another upstream
shared_ptr< Face > getBestFace()
MeasurementsEntryInfo & getMeasurementsEntryInfo(measurements::Entry *entry)
scheduler::EventId propagateTimer
timer for propagating to another face
void inheritFrom(const MeasurementsEntryInfo &other)
Represents a face-endpoint pair in the forwarder.
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
Definition: algorithm.hpp:32
static const time::microseconds DEFER_RANGE_WITHOUT_BEST_FACE
contains arbitrary information forwarding strategy places on table entries
NccStrategy(Forwarder &forwarder, const Name &name=getStrategyName())
void updateBestFace(const Face &face)
static const time::microseconds MIN_PREDICTION
void afterReceiveInterest(const FaceEndpoint &ingress, const Interest &interest, const shared_ptr< pit::Entry > &pitEntry) override
Trigger after Interest is received.
generalization of a network interface
Definition: face.hpp:54
MeasurementsEntryInfo()
A forwarding strategy similar to CCNx 0.7.2.
static const int ADJUST_PREDICT_DOWN_SHIFT
Represents a forwarding strategy.
Definition: strategy.hpp:37
static const Name & getStrategyName()
void beforeSatisfyInterest(const shared_ptr< pit::Entry > &pitEntry, const FaceEndpoint &ingress, const Data &data) override
Trigger before PIT entry is satisfied.
static const time::microseconds INITIAL_PREDICTION
StrategyInfo on measurements::Entry.
static const time::microseconds DEFER_FIRST_WITHOUT_BEST_FACE
static const time::microseconds MAX_PREDICTION
uint64_t FaceId
Identifies a face.
Definition: face-common.hpp:44
static constexpr int getTypeId()