Junxiao Shi | 986b849 | 2014-08-20 12:07:14 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
ashiqopu | c707948 | 2019-02-20 05:34:37 +0000 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2014-2019, Regents of the University of California, |
Junxiao Shi | 192af1f | 2015-01-13 23:19:39 -0700 | [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. |
Junxiao Shi | 986b849 | 2014-08-20 12:07:14 -0700 | [diff] [blame] | 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_BEST_ROUTE_STRATEGY2_HPP |
| 27 | #define NFD_DAEMON_FW_BEST_ROUTE_STRATEGY2_HPP |
| 28 | |
| 29 | #include "strategy.hpp" |
Junxiao Shi | 9954007 | 2017-01-27 19:57:33 +0000 | [diff] [blame] | 30 | #include "process-nack-traits.hpp" |
Junxiao Shi | 684fa0f | 2015-02-23 21:39:57 -0700 | [diff] [blame] | 31 | #include "retx-suppression-exponential.hpp" |
Junxiao Shi | 986b849 | 2014-08-20 12:07:14 -0700 | [diff] [blame] | 32 | |
| 33 | namespace nfd { |
| 34 | namespace fw { |
| 35 | |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 36 | /** \brief Best Route strategy version 4 |
Junxiao Shi | 986b849 | 2014-08-20 12:07:14 -0700 | [diff] [blame] | 37 | * |
| 38 | * This strategy forwards a new Interest to the lowest-cost nexthop (except downstream). |
Junxiao Shi | 684fa0f | 2015-02-23 21:39:57 -0700 | [diff] [blame] | 39 | * After that, if consumer retransmits the Interest (and is not suppressed according to |
| 40 | * exponential backoff algorithm), the strategy forwards the Interest again to |
| 41 | * the lowest-cost nexthop (except downstream) that is not previously used. |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 42 | * If all nexthops have been used, the strategy starts over with the first nexthop. |
| 43 | * |
| 44 | * This strategy returns Nack to all downstreams with reason NoRoute |
| 45 | * if there is no usable nexthop, which may be caused by: |
| 46 | * (a) the FIB entry contains no nexthop; |
| 47 | * (b) the FIB nexthop happens to be the sole downstream; |
| 48 | * (c) the FIB nexthops violate scope. |
| 49 | * |
| 50 | * This strategy returns Nack to all downstreams if all upstreams have returned Nacks. |
| 51 | * The reason of the sent Nack equals the least severe reason among received Nacks. |
ashiqopu | c707948 | 2019-02-20 05:34:37 +0000 | [diff] [blame] | 52 | * |
| 53 | * \note This strategy is not EndpointId-aware. |
Junxiao Shi | 986b849 | 2014-08-20 12:07:14 -0700 | [diff] [blame] | 54 | */ |
| 55 | class BestRouteStrategy2 : public Strategy |
Junxiao Shi | 9954007 | 2017-01-27 19:57:33 +0000 | [diff] [blame] | 56 | , public ProcessNackTraits<BestRouteStrategy2> |
Junxiao Shi | 986b849 | 2014-08-20 12:07:14 -0700 | [diff] [blame] | 57 | { |
| 58 | public: |
Junxiao Shi | 15e98b0 | 2016-08-12 11:21:44 +0000 | [diff] [blame] | 59 | explicit |
Junxiao Shi | 037f4ab | 2016-12-13 04:27:06 +0000 | [diff] [blame] | 60 | BestRouteStrategy2(Forwarder& forwarder, const Name& name = getStrategyName()); |
| 61 | |
| 62 | static const Name& |
| 63 | getStrategyName(); |
Junxiao Shi | 986b849 | 2014-08-20 12:07:14 -0700 | [diff] [blame] | 64 | |
Junxiao Shi | 9954007 | 2017-01-27 19:57:33 +0000 | [diff] [blame] | 65 | void |
ashiqopu | c707948 | 2019-02-20 05:34:37 +0000 | [diff] [blame] | 66 | afterReceiveInterest(const FaceEndpoint& ingress, const Interest& interest, |
Junxiao Shi | 15e98b0 | 2016-08-12 11:21:44 +0000 | [diff] [blame] | 67 | const shared_ptr<pit::Entry>& pitEntry) override; |
Junxiao Shi | 986b849 | 2014-08-20 12:07:14 -0700 | [diff] [blame] | 68 | |
Junxiao Shi | 9954007 | 2017-01-27 19:57:33 +0000 | [diff] [blame] | 69 | void |
ashiqopu | c707948 | 2019-02-20 05:34:37 +0000 | [diff] [blame] | 70 | afterReceiveNack(const FaceEndpoint& ingress, const lp::Nack& nack, |
Junxiao Shi | 15e98b0 | 2016-08-12 11:21:44 +0000 | [diff] [blame] | 71 | const shared_ptr<pit::Entry>& pitEntry) override; |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 72 | |
Junxiao Shi | 52e8540 | 2015-11-11 06:06:58 -0700 | [diff] [blame] | 73 | PUBLIC_WITH_TESTS_ELSE_PRIVATE: |
| 74 | static const time::milliseconds RETX_SUPPRESSION_INITIAL; |
| 75 | static const time::milliseconds RETX_SUPPRESSION_MAX; |
Junxiao Shi | 684fa0f | 2015-02-23 21:39:57 -0700 | [diff] [blame] | 76 | RetxSuppressionExponential m_retxSuppression; |
Junxiao Shi | 9954007 | 2017-01-27 19:57:33 +0000 | [diff] [blame] | 77 | |
| 78 | friend ProcessNackTraits<BestRouteStrategy2>; |
Junxiao Shi | 986b849 | 2014-08-20 12:07:14 -0700 | [diff] [blame] | 79 | }; |
| 80 | |
| 81 | } // namespace fw |
| 82 | } // namespace nfd |
| 83 | |
| 84 | #endif // NFD_DAEMON_FW_BEST_ROUTE_STRATEGY2_HPP |