blob: 02ef1554221e53512d57febae9e192bb7a91eaca [file] [log] [blame]
Vince Lehman8a4c29e2016-07-11 08:49:35 +00001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Ashlesh Gawande92e4ea52017-07-19 11:38:12 -05002/*
3 * Copyright (c) 2014-2018, Regents of the University of California,
Vince Lehman8a4c29e2016-07-11 08:49:35 +00004 * 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
31namespace nfd {
32namespace fw {
33namespace asf {
34
35/** \brief ASF Probing Module
36 */
37class ProbingModule
38{
39public:
40 explicit
41 ProbingModule(AsfMeasurements& measurements);
42
43 void
Junxiao Shi8d843142016-07-11 22:42:42 +000044 scheduleProbe(const fib::Entry& fibEntry, const time::milliseconds& interval);
Vince Lehman8a4c29e2016-07-11 08:49:35 +000045
Junxiao Shia6de4292016-07-12 02:08:10 +000046 Face*
Vince Lehman8a4c29e2016-07-11 08:49:35 +000047 getFaceToProbe(const Face& inFace,
48 const Interest& interest,
Junxiao Shi8d843142016-07-11 22:42:42 +000049 const fib::Entry& fibEntry,
Vince Lehman8a4c29e2016-07-11 08:49:35 +000050 const Face& faceUsed);
51
52 bool
Junxiao Shifc021862016-08-25 21:51:18 +000053 isProbingNeeded(const fib::Entry& fibEntry, const Interest& interest);
Vince Lehman8a4c29e2016-07-11 08:49:35 +000054
55 void
Junxiao Shifc021862016-08-25 21:51:18 +000056 afterForwardingProbe(const fib::Entry& fibEntry, const Interest& interest);
Vince Lehman8a4c29e2016-07-11 08:49:35 +000057
Ashlesh Gawande92e4ea52017-07-19 11:38:12 -050058 void
59 setProbingInterval(size_t probingInterval);
60
61 time::milliseconds
62 getProbingInterval() const
63 {
64 return m_probingInterval;
65 }
66
Vince Lehman8a4c29e2016-07-11 08:49:35 +000067private:
68 // Used to associate FaceInfo with the face in a NextHop
Junxiao Shia6de4292016-07-12 02:08:10 +000069 typedef std::pair<FaceInfo*, Face*> FaceInfoFacePair;
Vince Lehman8a4c29e2016-07-11 08:49:35 +000070 typedef std::function<bool(FaceInfoFacePair, FaceInfoFacePair)> FaceInfoPredicate;
71 typedef std::set<FaceInfoFacePair, FaceInfoPredicate> FaceInfoFacePairSet;
72
Junxiao Shia6de4292016-07-12 02:08:10 +000073 Face*
Vince Lehman8a4c29e2016-07-11 08:49:35 +000074 getFaceBasedOnProbability(const FaceInfoFacePairSet& rankedFaces);
75
76 double
77 getProbingProbability(uint64_t rank, uint64_t rankSum, uint64_t nFaces);
78
79 double
80 getRandomNumber(double start, double end);
81
82public:
Davide Pesaventoe4b22382018-06-10 14:37:24 -040083 static constexpr time::milliseconds DEFAULT_PROBING_INTERVAL = 1_min;
84 static constexpr time::milliseconds MIN_PROBING_INTERVAL = 1_s;
Vince Lehman8a4c29e2016-07-11 08:49:35 +000085
86private:
Ashlesh Gawande92e4ea52017-07-19 11:38:12 -050087 time::milliseconds m_probingInterval;
Vince Lehman8a4c29e2016-07-11 08:49:35 +000088 AsfMeasurements& m_measurements;
89};
90
91} // namespace asf
92} // namespace fw
93} // namespace nfd
94
95#endif // NFD_DAEMON_FW_ASF_PROBING_MODULE_HPP