access-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_ACCESS_STRATEGY_HPP
27 #define NFD_DAEMON_FW_ACCESS_STRATEGY_HPP
28 
29 #include "strategy.hpp"
31 
32 #include <ndn-cxx/util/rtt-estimator.hpp>
33 
34 namespace nfd {
35 namespace fw {
36 
48 class AccessStrategy : public Strategy
49 {
50 public:
51  explicit
52  AccessStrategy(Forwarder& forwarder, const Name& name = getStrategyName());
53 
54  static const Name&
56 
57 public: // triggers
58  void
59  afterReceiveInterest(const FaceEndpoint& ingress, const Interest& interest,
60  const shared_ptr<pit::Entry>& pitEntry) override;
61 
62  void
63  beforeSatisfyInterest(const shared_ptr<pit::Entry>& pitEntry,
64  const FaceEndpoint& ingress, const Data& data) override;
65 
66 private: // StrategyInfo
67  using RttEstimator = ndn::util::RttEstimator;
68 
71  class PitInfo : public StrategyInfo
72  {
73  public:
74  static constexpr int
75  getTypeId()
76  {
77  return 1010;
78  }
79 
80  public:
81  scheduler::ScopedEventId rtoTimer;
82  };
83 
86  class MtInfo : public StrategyInfo
87  {
88  public:
89  static constexpr int
90  getTypeId()
91  {
92  return 1011;
93  }
94 
95  explicit
96  MtInfo(shared_ptr<const RttEstimator::Options> opts)
97  : rtt(std::move(opts))
98  {
99  }
100 
101  public:
102  FaceId lastNexthop = face::INVALID_FACEID;
103  RttEstimator rtt;
104  };
105 
108  std::tuple<Name, MtInfo*>
109  findPrefixMeasurements(const pit::Entry& pitEntry);
110 
114  MtInfo*
115  addPrefixMeasurements(const Data& data);
116 
121  class FaceInfo
122  {
123  public:
124  explicit
125  FaceInfo(shared_ptr<const RttEstimator::Options> opts)
126  : rtt(std::move(opts))
127  {
128  }
129 
130  public:
131  RttEstimator rtt;
132  };
133 
134 private: // forwarding procedures
135  void
136  afterReceiveNewInterest(const FaceEndpoint& ingress, const Interest& interest,
137  const shared_ptr<pit::Entry>& pitEntry);
138 
139  void
140  afterReceiveRetxInterest(const FaceEndpoint& ingress, const Interest& interest,
141  const shared_ptr<pit::Entry>& pitEntry);
142 
146  bool
147  sendToLastNexthop(const FaceEndpoint& ingress, const Interest& interest,
148  const shared_ptr<pit::Entry>& pitEntry, MtInfo& mi,
149  const fib::Entry& fibEntry);
150 
151  void
152  afterRtoTimeout(const weak_ptr<pit::Entry>& pitWeak,
153  FaceId inFaceId, FaceId firstOutFaceId);
154 
159  size_t
160  multicast(const Face& inFace, const Interest& interest,
161  const shared_ptr<pit::Entry>& pitEntry, const fib::Entry& fibEntry,
162  FaceId exceptFace = face::INVALID_FACEID);
163 
164  void
165  updateMeasurements(const Face& inFace, const Data& data, time::nanoseconds rtt);
166 
167 private:
168  const shared_ptr<const RttEstimator::Options> m_rttEstimatorOpts;
169  std::unordered_map<FaceId, FaceInfo> m_fit;
170  RetxSuppressionFixed m_retxSuppression;
171  signal::ScopedConnection m_removeFaceConn;
172 };
173 
174 } // namespace fw
175 } // namespace nfd
176 
177 #endif // NFD_DAEMON_FW_ACCESS_STRATEGY_HPP
Main class of NFD&#39;s forwarding engine.
Definition: forwarder.hpp:51
represents a FIB entry
Definition: fib-entry.hpp:53
AccessStrategy(Forwarder &forwarder, const Name &name=getStrategyName())
a retransmission suppression decision algorithm that suppresses retransmissions within a fixed durati...
An Interest table entry.
Definition: pit-entry.hpp:58
Access Router Strategy version 1.
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
contains arbitrary information forwarding strategy places on table entries
generalization of a network interface
Definition: face.hpp:54
void afterReceiveInterest(const FaceEndpoint &ingress, const Interest &interest, const shared_ptr< pit::Entry > &pitEntry) override
Trigger after Interest is received.
Represents a forwarding strategy.
Definition: strategy.hpp:37
static const Name & getStrategyName()
uint64_t FaceId
Identifies a face.
Definition: face-common.hpp:44
const FaceId INVALID_FACEID
indicates an invalid FaceId
Definition: face-common.hpp:47
void beforeSatisfyInterest(const shared_ptr< pit::Entry > &pitEntry, const FaceEndpoint &ingress, const Data &data) override
Trigger before PIT entry is satisfied.