blob: 83bff131fd051361369f37365a775430bdda02ca [file] [log] [blame]
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2024, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
* Washington University in St. Louis,
* Beijing Institute of Technology,
* The University of Memphis.
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef NFD_DAEMON_FW_ASF_STRATEGY_HPP
#define NFD_DAEMON_FW_ASF_STRATEGY_HPP
#include "strategy.hpp"
#include "asf-measurements.hpp"
#include "asf-probing-module.hpp"
#include "process-nack-traits.hpp"
#include "retx-suppression-exponential.hpp"
namespace nfd::fw {
namespace asf {
/**
* \brief Adaptive SRTT-based forwarding strategy.
*
* \see Vince Lehman, Ashlesh Gawande, Rodrigo Aldecoa, Dmitri Krioukov, Beichuan Zhang,
* Lixia Zhang, and Lan Wang, "An Experimental Investigation of Hyperbolic Routing
* with a Smart Forwarding Plane in NDN", NDN Technical Report NDN-0042, 2016.
* https://named-data.net/publications/techreports/ndn-0042-1-asf/
*/
class AsfStrategy : public Strategy, public ProcessNackTraits<AsfStrategy>
{
public:
explicit
AsfStrategy(Forwarder& forwarder, const Name& name = getStrategyName());
static const Name&
getStrategyName();
public: // triggers
void
afterReceiveInterest(const Interest& interest, const FaceEndpoint& ingress,
const shared_ptr<pit::Entry>& pitEntry) override;
void
beforeSatisfyInterest(const Data& data, const FaceEndpoint& ingress,
const shared_ptr<pit::Entry>& pitEntry) override;
void
afterReceiveNack(const lp::Nack& nack, const FaceEndpoint& ingress,
const shared_ptr<pit::Entry>& pitEntry) override;
private:
pit::OutRecord*
forwardInterest(const Interest& interest, Face& outFace, const fib::Entry& fibEntry,
const shared_ptr<pit::Entry>& pitEntry);
void
sendProbe(const Interest& interest, const FaceEndpoint& ingress, const Face& faceToUse,
const fib::Entry& fibEntry, const shared_ptr<pit::Entry>& pitEntry);
Face*
getBestFaceForForwarding(const Interest& interest, const Face& inFace,
const fib::Entry& fibEntry, const shared_ptr<pit::Entry>& pitEntry,
bool isNewInterest = true);
void
onTimeoutOrNack(const Name& interestName, FaceId faceId, bool isNack);
void
sendNoRouteNack(Face& face, const shared_ptr<pit::Entry>& pitEntry);
private:
AsfMeasurements m_measurements{getMeasurements()};
NFD_PUBLIC_WITH_TESTS_ELSE_PRIVATE:
struct FaceStatsForwardingCompare
{
bool
operator()(const FaceStats& lhs, const FaceStats& rhs) const noexcept;
};
using FaceStatsForwardingSet = std::set<FaceStats, FaceStatsForwardingCompare>;
std::unique_ptr<RetxSuppressionExponential> m_retxSuppression;
ProbingModule m_probing{m_measurements};
size_t m_nMaxTimeouts = 3;
friend ProcessNackTraits<AsfStrategy>;
};
} // namespace asf
using asf::AsfStrategy;
} // namespace nfd::fw
#endif // NFD_DAEMON_FW_ASF_STRATEGY_HPP