asf-probing-module.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014-2022, 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_ASF_PROBING_MODULE_HPP
27 #define NFD_DAEMON_FW_ASF_PROBING_MODULE_HPP
28 
29 #include "asf-measurements.hpp"
30 
31 namespace nfd::fw::asf {
32 
36 {
37 public:
38  explicit
39  ProbingModule(AsfMeasurements& measurements);
40 
41  void
42  scheduleProbe(const fib::Entry& fibEntry, time::milliseconds interval);
43 
44  Face*
45  getFaceToProbe(const Face& inFace, const Interest& interest,
46  const fib::Entry& fibEntry, const Face& faceUsed);
47 
48  bool
49  isProbingNeeded(const fib::Entry& fibEntry, const Name& interestName);
50 
51  void
52  afterForwardingProbe(const fib::Entry& fibEntry, const Name& interestName);
53 
54  void
55  setProbingInterval(time::milliseconds probingInterval);
56 
57  time::milliseconds
59  {
60  return m_probingInterval;
61  }
62 
63 private:
64  // Used to associate FaceInfo with the face in a NextHop
65  using FaceInfoFacePair = std::pair<FaceInfo*, Face*>;
66 
67  struct FaceInfoCompare
68  {
69  bool
70  operator()(const FaceInfoFacePair& leftPair, const FaceInfoFacePair& rightPair) const
71  {
72  const FaceInfo& lhs = *leftPair.first;
73  const FaceInfo& rhs = *rightPair.first;
74 
75  // Sort by RTT: if a face has timed-out, rank it behind non-timed-out faces
76  return (!lhs.hasTimeout() && rhs.hasTimeout()) ||
77  (lhs.hasTimeout() == rhs.hasTimeout() && lhs.getSrtt() < rhs.getSrtt());
78  }
79  };
80 
81  using FaceInfoFacePairSet = std::set<FaceInfoFacePair, FaceInfoCompare>;
82 
83  static Face*
84  chooseFace(const FaceInfoFacePairSet& rankedFaces);
85 
86  static double
87  getProbingProbability(uint64_t rank, uint64_t rankSum, uint64_t nFaces);
88 
89 public:
90  static constexpr time::milliseconds DEFAULT_PROBING_INTERVAL = 1_min;
91  static constexpr time::milliseconds MIN_PROBING_INTERVAL = 1_s;
92 
93 private:
94  time::milliseconds m_probingInterval;
95  AsfMeasurements& m_measurements;
96 };
97 
98 } // namespace nfd::fw::asf
99 
100 #endif // NFD_DAEMON_FW_ASF_PROBING_MODULE_HPP
Generalization of a network interface.
Definition: face.hpp:56
Represents an entry in the FIB.
Definition: fib-entry.hpp:54
Helper class to retrieve and create strategy measurements.
Strategy information for each face in a namespace.
time::nanoseconds getSrtt() const
Face * getFaceToProbe(const Face &inFace, const Interest &interest, const fib::Entry &fibEntry, const Face &faceUsed)
bool isProbingNeeded(const fib::Entry &fibEntry, const Name &interestName)
time::milliseconds getProbingInterval() const
static constexpr time::milliseconds MIN_PROBING_INTERVAL
void afterForwardingProbe(const fib::Entry &fibEntry, const Name &interestName)
void setProbingInterval(time::milliseconds probingInterval)
void scheduleProbe(const fib::Entry &fibEntry, time::milliseconds interval)
ProbingModule(AsfMeasurements &measurements)
static constexpr time::milliseconds DEFAULT_PROBING_INTERVAL