Vince Lehman | 8a4c29e | 2016-07-11 08:49:35 +0000 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (c) 2014-2016, 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 { |
| 32 | namespace fw { |
| 33 | namespace asf { |
| 34 | |
| 35 | /** \brief ASF Probing Module |
| 36 | */ |
| 37 | class ProbingModule |
| 38 | { |
| 39 | public: |
| 40 | explicit |
| 41 | ProbingModule(AsfMeasurements& measurements); |
| 42 | |
| 43 | void |
Junxiao Shi | 8d84314 | 2016-07-11 22:42:42 +0000 | [diff] [blame^] | 44 | scheduleProbe(const fib::Entry& fibEntry, const time::milliseconds& interval); |
Vince Lehman | 8a4c29e | 2016-07-11 08:49:35 +0000 | [diff] [blame] | 45 | |
| 46 | shared_ptr<Face> |
| 47 | getFaceToProbe(const Face& inFace, |
| 48 | const Interest& interest, |
Junxiao Shi | 8d84314 | 2016-07-11 22:42:42 +0000 | [diff] [blame^] | 49 | const fib::Entry& fibEntry, |
Vince Lehman | 8a4c29e | 2016-07-11 08:49:35 +0000 | [diff] [blame] | 50 | const Face& faceUsed); |
| 51 | |
| 52 | bool |
Junxiao Shi | 8d84314 | 2016-07-11 22:42:42 +0000 | [diff] [blame^] | 53 | isProbingNeeded(const fib::Entry& fibEntry, const ndn::Interest& interest); |
Vince Lehman | 8a4c29e | 2016-07-11 08:49:35 +0000 | [diff] [blame] | 54 | |
| 55 | void |
Junxiao Shi | 8d84314 | 2016-07-11 22:42:42 +0000 | [diff] [blame^] | 56 | afterForwardingProbe(const fib::Entry& fibEntry, const ndn::Interest& interest); |
Vince Lehman | 8a4c29e | 2016-07-11 08:49:35 +0000 | [diff] [blame] | 57 | |
| 58 | private: |
| 59 | // Used to associate FaceInfo with the face in a NextHop |
| 60 | typedef std::pair<FaceInfo*, shared_ptr<Face>> FaceInfoFacePair; |
| 61 | typedef std::function<bool(FaceInfoFacePair, FaceInfoFacePair)> FaceInfoPredicate; |
| 62 | typedef std::set<FaceInfoFacePair, FaceInfoPredicate> FaceInfoFacePairSet; |
| 63 | |
| 64 | shared_ptr<Face> |
| 65 | getFaceBasedOnProbability(const FaceInfoFacePairSet& rankedFaces); |
| 66 | |
| 67 | double |
| 68 | getProbingProbability(uint64_t rank, uint64_t rankSum, uint64_t nFaces); |
| 69 | |
| 70 | double |
| 71 | getRandomNumber(double start, double end); |
| 72 | |
| 73 | public: |
| 74 | static constexpr time::seconds DEFAULT_PROBING_INTERVAL = time::seconds(60); |
| 75 | |
| 76 | private: |
| 77 | time::seconds m_probingInterval; |
| 78 | AsfMeasurements& m_measurements; |
| 79 | }; |
| 80 | |
| 81 | } // namespace asf |
| 82 | } // namespace fw |
| 83 | } // namespace nfd |
| 84 | |
| 85 | #endif // NFD_DAEMON_FW_ASF_PROBING_MODULE_HPP |