blob: d78baf6459d6acfd8ac80fa4141b00a07561be55 [file] [log] [blame]
Junxiao Shi986b8492014-08-20 12:07:14 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Davide Pesaventob84bd3a2016-04-22 02:21:45 +02003 * Copyright (c) 2014-2016, Regents of the University of California,
Junxiao Shi192af1f2015-01-13 23:19:39 -07004 * 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 Shi986b8492014-08-20 12:07:14 -070010 *
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 Shi684fa0f2015-02-23 21:39:57 -070030#include "retx-suppression-exponential.hpp"
Junxiao Shi986b8492014-08-20 12:07:14 -070031
32namespace nfd {
33namespace fw {
34
Junxiao Shi5e5e4452015-09-24 16:56:52 -070035/** \brief Best Route strategy version 4
Junxiao Shi986b8492014-08-20 12:07:14 -070036 *
37 * This strategy forwards a new Interest to the lowest-cost nexthop (except downstream).
Junxiao Shi684fa0f2015-02-23 21:39:57 -070038 * After that, if consumer retransmits the Interest (and is not suppressed according to
39 * exponential backoff algorithm), the strategy forwards the Interest again to
40 * the lowest-cost nexthop (except downstream) that is not previously used.
Junxiao Shi5e5e4452015-09-24 16:56:52 -070041 * If all nexthops have been used, the strategy starts over with the first nexthop.
42 *
43 * This strategy returns Nack to all downstreams with reason NoRoute
44 * if there is no usable nexthop, which may be caused by:
45 * (a) the FIB entry contains no nexthop;
46 * (b) the FIB nexthop happens to be the sole downstream;
47 * (c) the FIB nexthops violate scope.
48 *
49 * This strategy returns Nack to all downstreams if all upstreams have returned Nacks.
50 * The reason of the sent Nack equals the least severe reason among received Nacks.
Junxiao Shi986b8492014-08-20 12:07:14 -070051 */
52class BestRouteStrategy2 : public Strategy
53{
54public:
55 BestRouteStrategy2(Forwarder& forwarder, const Name& name = STRATEGY_NAME);
56
57 virtual void
Junxiao Shi5e5e4452015-09-24 16:56:52 -070058 afterReceiveInterest(const Face& inFace, const Interest& interest,
Junxiao Shia6de4292016-07-12 02:08:10 +000059
Davide Pesaventob84bd3a2016-04-22 02:21:45 +020060 shared_ptr<pit::Entry> pitEntry) override;
Junxiao Shi986b8492014-08-20 12:07:14 -070061
Junxiao Shi5e5e4452015-09-24 16:56:52 -070062 virtual void
63 afterReceiveNack(const Face& inFace, const lp::Nack& nack,
Junxiao Shia6de4292016-07-12 02:08:10 +000064
Davide Pesaventob84bd3a2016-04-22 02:21:45 +020065 shared_ptr<pit::Entry> pitEntry) override;
Junxiao Shi5e5e4452015-09-24 16:56:52 -070066
Junxiao Shi986b8492014-08-20 12:07:14 -070067public:
68 static const Name STRATEGY_NAME;
Junxiao Shi192af1f2015-01-13 23:19:39 -070069
Junxiao Shi52e85402015-11-11 06:06:58 -070070PUBLIC_WITH_TESTS_ELSE_PRIVATE:
71 static const time::milliseconds RETX_SUPPRESSION_INITIAL;
72 static const time::milliseconds RETX_SUPPRESSION_MAX;
Junxiao Shi684fa0f2015-02-23 21:39:57 -070073 RetxSuppressionExponential m_retxSuppression;
Junxiao Shi986b8492014-08-20 12:07:14 -070074};
75
76} // namespace fw
77} // namespace nfd
78
79#endif // NFD_DAEMON_FW_BEST_ROUTE_STRATEGY2_HPP