Vince Lehman | 8a4c29e | 2016-07-11 08:49:35 +0000 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Ashlesh Gawande | 92e4ea5 | 2017-07-19 11:38:12 -0500 | [diff] [blame] | 2 | /* |
awlane | 5fdcbec | 2023-12-15 14:56:05 -0600 | [diff] [blame] | 3 | * Copyright (c) 2014-2024, Regents of the University of California, |
Vince Lehman | 8a4c29e | 2016-07-11 08:49:35 +0000 | [diff] [blame] | 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 | |
Davide Pesavento | e422f9e | 2022-06-03 01:30:23 -0400 | [diff] [blame] | 31 | namespace nfd::fw::asf { |
Vince Lehman | 8a4c29e | 2016-07-11 08:49:35 +0000 | [diff] [blame] | 32 | |
awlane | 5fdcbec | 2023-12-15 14:56:05 -0600 | [diff] [blame] | 33 | /** |
| 34 | * \brief Container for ranking-related values. |
| 35 | */ |
| 36 | struct FaceStats |
| 37 | { |
| 38 | Face* face = nullptr; |
| 39 | time::nanoseconds rtt = 0_ns; |
| 40 | time::nanoseconds srtt = 0_ns; |
| 41 | uint64_t cost = 0; |
| 42 | }; |
| 43 | |
| 44 | /** |
| 45 | * \brief ASF Probing Module. |
Vince Lehman | 8a4c29e | 2016-07-11 08:49:35 +0000 | [diff] [blame] | 46 | */ |
| 47 | class ProbingModule |
| 48 | { |
| 49 | public: |
| 50 | explicit |
| 51 | ProbingModule(AsfMeasurements& measurements); |
| 52 | |
| 53 | void |
Davide Pesavento | a6f637a | 2019-08-28 23:23:20 -0400 | [diff] [blame] | 54 | scheduleProbe(const fib::Entry& fibEntry, time::milliseconds interval); |
Vince Lehman | 8a4c29e | 2016-07-11 08:49:35 +0000 | [diff] [blame] | 55 | |
Junxiao Shi | a6de429 | 2016-07-12 02:08:10 +0000 | [diff] [blame] | 56 | Face* |
Davide Pesavento | a6f637a | 2019-08-28 23:23:20 -0400 | [diff] [blame] | 57 | getFaceToProbe(const Face& inFace, const Interest& interest, |
| 58 | const fib::Entry& fibEntry, const Face& faceUsed); |
Vince Lehman | 8a4c29e | 2016-07-11 08:49:35 +0000 | [diff] [blame] | 59 | |
| 60 | bool |
Saurab Dulal | 432be57 | 2021-01-26 12:09:29 -0600 | [diff] [blame] | 61 | isProbingNeeded(const fib::Entry& fibEntry, const Name& interestName); |
Vince Lehman | 8a4c29e | 2016-07-11 08:49:35 +0000 | [diff] [blame] | 62 | |
| 63 | void |
Saurab Dulal | 432be57 | 2021-01-26 12:09:29 -0600 | [diff] [blame] | 64 | afterForwardingProbe(const fib::Entry& fibEntry, const Name& interestName); |
Vince Lehman | 8a4c29e | 2016-07-11 08:49:35 +0000 | [diff] [blame] | 65 | |
Ashlesh Gawande | 92e4ea5 | 2017-07-19 11:38:12 -0500 | [diff] [blame] | 66 | void |
Ashlesh Gawande | 1ef93d0 | 2022-04-08 00:25:06 -0400 | [diff] [blame] | 67 | setProbingInterval(time::milliseconds probingInterval); |
Ashlesh Gawande | 92e4ea5 | 2017-07-19 11:38:12 -0500 | [diff] [blame] | 68 | |
| 69 | time::milliseconds |
| 70 | getProbingInterval() const |
| 71 | { |
| 72 | return m_probingInterval; |
| 73 | } |
| 74 | |
Vince Lehman | 8a4c29e | 2016-07-11 08:49:35 +0000 | [diff] [blame] | 75 | public: |
Davide Pesavento | e4b2238 | 2018-06-10 14:37:24 -0400 | [diff] [blame] | 76 | static constexpr time::milliseconds DEFAULT_PROBING_INTERVAL = 1_min; |
| 77 | static constexpr time::milliseconds MIN_PROBING_INTERVAL = 1_s; |
Vince Lehman | 8a4c29e | 2016-07-11 08:49:35 +0000 | [diff] [blame] | 78 | |
awlane | 5fdcbec | 2023-12-15 14:56:05 -0600 | [diff] [blame] | 79 | struct FaceStatsProbingCompare |
| 80 | { |
| 81 | bool |
| 82 | operator()(const FaceStats& lhs, const FaceStats& rhs) const noexcept; |
| 83 | }; |
| 84 | using FaceStatsProbingSet = std::set<FaceStats, FaceStatsProbingCompare>; |
| 85 | |
Vince Lehman | 8a4c29e | 2016-07-11 08:49:35 +0000 | [diff] [blame] | 86 | private: |
Ashlesh Gawande | 92e4ea5 | 2017-07-19 11:38:12 -0500 | [diff] [blame] | 87 | time::milliseconds m_probingInterval; |
Vince Lehman | 8a4c29e | 2016-07-11 08:49:35 +0000 | [diff] [blame] | 88 | AsfMeasurements& m_measurements; |
| 89 | }; |
| 90 | |
Davide Pesavento | e422f9e | 2022-06-03 01:30:23 -0400 | [diff] [blame] | 91 | } // namespace nfd::fw::asf |
Vince Lehman | 8a4c29e | 2016-07-11 08:49:35 +0000 | [diff] [blame] | 92 | |
| 93 | #endif // NFD_DAEMON_FW_ASF_PROBING_MODULE_HPP |