blob: 7c41f3e911af09cbd8a031261c45a96347c42621 [file] [log] [blame]
Eric Newberry69b63dc2017-11-04 15:42:46 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
Davide Pesaventoe422f9e2022-06-03 01:30:23 -04003 * Copyright (c) 2014-2022, Regents of the University of California,
Eric Newberry69b63dc2017-11-04 15:42:46 -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.
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_TESTS_OTHER_FW_CONGESTION_MARK_STRATEGY_HPP
27#define NFD_TESTS_OTHER_FW_CONGESTION_MARK_STRATEGY_HPP
28
Davide Pesavento7922d122021-03-05 22:41:23 -050029#include "daemon/fw/best-route-strategy.hpp"
Eric Newberry69b63dc2017-11-04 15:42:46 -070030
Davide Pesaventoe422f9e2022-06-03 01:30:23 -040031namespace nfd::fw {
Eric Newberry69b63dc2017-11-04 15:42:46 -070032
Davide Pesavento7922d122021-03-05 22:41:23 -050033/** \brief Congestion Mark integration testing strategy
Eric Newberry69b63dc2017-11-04 15:42:46 -070034 *
35 * This strategy adds a CongestionMark to each Interest it forwards. Otherwise, behaves like
Davide Pesavento7922d122021-03-05 22:41:23 -050036 * BestRouteStrategy.
Eric Newberry69b63dc2017-11-04 15:42:46 -070037 *
38 * The value of the added CongestionMark can be specified through a strategy parameter (defaults
39 * to 1). In addition, an optional boolean parameter specifies whether the strategy will preserve
40 * existing CongestionMarks (default) or replace them.
41 */
Davide Pesavento7922d122021-03-05 22:41:23 -050042class CongestionMarkStrategy : public BestRouteStrategy
Eric Newberry69b63dc2017-11-04 15:42:46 -070043{
44public:
45 explicit
46 CongestionMarkStrategy(Forwarder& forwarder, const Name& name = getStrategyName());
47
48 static const Name&
49 getStrategyName();
50
51 void
Davide Pesavento0498ce82021-06-14 02:02:21 -040052 afterReceiveInterest(const Interest& interest, const FaceEndpoint& ingress,
Eric Newberry69b63dc2017-11-04 15:42:46 -070053 const shared_ptr<pit::Entry>& pitEntry) override;
54
55private:
Davide Pesavento7922d122021-03-05 22:41:23 -050056 uint64_t m_congestionMark = 1;
57 bool m_shouldPreserveMark = true;
Eric Newberry69b63dc2017-11-04 15:42:46 -070058};
59
Davide Pesaventoe422f9e2022-06-03 01:30:23 -040060} // namespace nfd::fw
Eric Newberry69b63dc2017-11-04 15:42:46 -070061
62#endif // NFD_TESTS_OTHER_FW_CONGESTION_MARK_STRATEGY_HPP