/* -*- 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_FACE_GENERIC_LINK_SERVICE_HPP
#define NFD_DAEMON_FACE_GENERIC_LINK_SERVICE_HPP

#include "link-service.hpp"
#include "lp-fragmenter.hpp"
#include "lp-reassembler.hpp"
#include "lp-reliability.hpp"

#include <limits>

namespace nfd::face {

/**
 * \brief Counters provided by GenericLinkService.
 * \note The type name GenericLinkServiceCounters is an implementation detail.
 *       Use GenericLinkService::Counters in public API.
 */
class GenericLinkServiceCounters : public virtual LinkService::Counters
{
public:
  /// Count of failed fragmentations.
  PacketCounter nFragmentationErrors;

  /**
   * \brief Count of outgoing LpPackets dropped due to exceeding MTU limit.
   *
   * If this counter is non-zero, the operator should enable fragmentation.
   */
  PacketCounter nOutOverMtu;

  /// Count of invalid LpPackets dropped before reassembly.
  PacketCounter nInLpInvalid;

  /// Count of network-layer packets currently being reassembled.
  SizeCounter<LpReassembler> nReassembling;

  /// Count of dropped partial network-layer packets due to reassembly timeout.
  PacketCounter nReassemblyTimeouts;

  /// Count of invalid reassembled network-layer packets dropped.
  PacketCounter nInNetInvalid;

  /// Count of network-layer packets that did not require retransmission of a fragment.
  PacketCounter nAcknowledged;

  /**
   * \brief Count of network-layer packets that had at least one fragment retransmitted,
   *        but were eventually received in full.
   */
  PacketCounter nRetransmitted;

  /**
   * \brief Count of network-layer packets dropped because a fragment reached the maximum
   *        number of retransmissions.
   */
  PacketCounter nRetxExhausted;

  /// Count of LpPackets dropped due to duplicate Sequence numbers.
  PacketCounter nDuplicateSequence;

  /// Count of outgoing LpPackets that were marked with congestion marks.
  PacketCounter nCongestionMarked;
};

/**
 * \brief Options that control the behavior of GenericLinkService.
 * \note The type name GenericLinkServiceOptions is an implementation detail.
 *       Use GenericLinkService::Options in public API.
 */
struct GenericLinkServiceOptions
{
  /** \brief Enables encoding of IncomingFaceId, and decoding of NextHopFaceId and CachePolicy.
   */
  bool allowLocalFields = false;

  /** \brief Enables fragmentation.
   */
  bool allowFragmentation = false;

  /** \brief Options for fragmentation.
   */
  LpFragmenter::Options fragmenterOptions;

  /** \brief Enables reassembly.
   */
  bool allowReassembly = false;

  /** \brief Options for reassembly.
   */
  LpReassembler::Options reassemblerOptions;

  /** \brief Options for reliability.
   */
  LpReliability::Options reliabilityOptions;

  /** \brief Enables send queue congestion detection and marking.
   */
  bool allowCongestionMarking = false;

  /** \brief Starting value for congestion marking interval.
   *
   *  Packets are marked if the queue size stays above THRESHOLD for at least one INTERVAL.
   *
   *  The default value (100 ms) is taken from RFC 8289 (CoDel).
   */
  time::nanoseconds baseCongestionMarkingInterval = 100_ms;

  /** \brief Default congestion threshold in bytes.
   *
   *  Packets are marked if the queue size stays above THRESHOLD for at least one INTERVAL.
   *
   *  The default value (64 KiB) works well for a queue capacity of 200 KiB.
   */
  size_t defaultCongestionThreshold = 65536;

  /** \brief Enables self-learning forwarding support.
   */
  bool allowSelfLearning = true;

  /** \brief Overrides the MTU provided by Transport.
   *
   *  This MTU value will be used instead of the MTU provided by the transport if it is less than
   *  the transport MTU. However, it will not be utilized when the transport MTU is unlimited.
   *
   *  Acceptable values for this option are values >= #MIN_MTU, which can be validated before
   *  being set with canOverrideMtuTo().
   */
  ssize_t overrideMtu = std::numeric_limits<ssize_t>::max();
};

/**
 * \brief GenericLinkService is a LinkService that implements the NDNLPv2 protocol.
 * \sa https://redmine.named-data.net/projects/nfd/wiki/NDNLPv2
 */
class GenericLinkService NFD_FINAL_UNLESS_WITH_TESTS : public LinkService
                                                     , protected virtual GenericLinkServiceCounters
{
public:
  /**
   * \brief %Counters provided by GenericLinkService.
   */
  using Counters = GenericLinkServiceCounters;

  /**
   * \brief %Options for GenericLinkService.
   */
  using Options = GenericLinkServiceOptions;

  explicit
  GenericLinkService(const Options& options = {});

  /**
   * \brief Get the options used by GenericLinkService.
   */
  const Options&
  getOptions() const
  {
    return m_options;
  }

  /**
   * \brief Sets the options used by GenericLinkService.
   */
  void
  setOptions(const Options& options);

  const Counters&
  getCounters() const NFD_OVERRIDE_WITH_TESTS_ELSE_FINAL
  {
    return *this;
  }

  ssize_t
  getEffectiveMtu() const NFD_OVERRIDE_WITH_TESTS_ELSE_FINAL;

  /** \brief Whether MTU can be overridden to the specified value.
   *
   *  If the transport MTU is unlimited, then this will always return false.
   */
  bool
  canOverrideMtuTo(ssize_t mtu) const;

NFD_PROTECTED_WITH_TESTS_ELSE_PRIVATE: // send path
  /** \brief Request an IDLE packet to transmit pending service fields.
   */
  void
  requestIdlePacket();

  /** \brief Send an LpPacket.
   */
  void
  sendLpPacket(lp::Packet&& pkt);

  void
  doSendInterest(const Interest& interest) NFD_OVERRIDE_WITH_TESTS_ELSE_FINAL;

  void
  doSendData(const Data& data) NFD_OVERRIDE_WITH_TESTS_ELSE_FINAL;

  void
  doSendNack(const ndn::lp::Nack& nack) NFD_OVERRIDE_WITH_TESTS_ELSE_FINAL;

  /** \brief Assign consecutive sequence numbers to LpPackets.
   */
  void
  assignSequences(std::vector<lp::Packet>& pkts);

private: // send path
  /** \brief Encode link protocol fields from tags onto an outgoing LpPacket.
   *  \param netPkt network-layer packet to extract tags from
   *  \param lpPacket LpPacket to add link protocol fields to
   */
  void
  encodeLpFields(const ndn::PacketBase& netPkt, lp::Packet& lpPacket);

  /** \brief Send a complete network layer packet.
   *  \param pkt LpPacket containing a complete network layer packet
   *  \param isInterest whether the network layer packet is an Interest
   */
  void
  sendNetPacket(lp::Packet&& pkt, bool isInterest);

  /** \brief If the send queue is found to be congested, add a congestion mark to the packet
   *         according to CoDel.
   *  \sa https://tools.ietf.org/html/rfc8289
   */
  void
  checkCongestionLevel(lp::Packet& pkt);

private: // receive path
  void
  doReceivePacket(const Block& packet, const EndpointId& endpoint) NFD_OVERRIDE_WITH_TESTS_ELSE_FINAL;

  /** \brief Decode incoming network-layer packet.
   *  \param netPkt reassembled network-layer packet
   *  \param firstPkt LpPacket of first fragment
   *  \param endpointId endpoint of peer who sent the packet
   *
   *  If decoding is successful, a receive signal is emitted;
   *  otherwise, a warning is logged.
   */
  void
  decodeNetPacket(const Block& netPkt, const lp::Packet& firstPkt, const EndpointId& endpointId);

  /** \brief Decode incoming Interest.
   *  \param netPkt reassembled network-layer packet; TLV-TYPE must be Interest
   *  \param firstPkt LpPacket of first fragment; must not have Nack field
   *  \param endpointId endpoint of peer who sent the Interest
   *
   *  If decoding is successful, receiveInterest signal is emitted;
   *  otherwise, a warning is logged.
   *
   *  \throw tlv::Error parse error in an LpHeader field
   */
  void
  decodeInterest(const Block& netPkt, const lp::Packet& firstPkt, const EndpointId& endpointId);

  /** \brief Decode incoming Interest.
   *  \param netPkt reassembled network-layer packet; TLV-TYPE must be Data
   *  \param firstPkt LpPacket of first fragment
   *  \param endpointId endpoint of peer who sent the Data
   *
   *  If decoding is successful, receiveData signal is emitted;
   *  otherwise, a warning is logged.
   *
   *  \throw tlv::Error parse error in an LpHeader field
   */
  void
  decodeData(const Block& netPkt, const lp::Packet& firstPkt, const EndpointId& endpointId);

  /** \brief Decode incoming Interest.
   *  \param netPkt reassembled network-layer packet; TLV-TYPE must be Interest
   *  \param firstPkt LpPacket of first fragment; must have Nack field
   *  \param endpointId endpoint of peer who sent the Nack
   *
   *  If decoding is successful, receiveNack signal is emitted;
   *  otherwise, a warning is logged.
   *
   *  \throw tlv::Error parse error in an LpHeader field
   */
  void
  decodeNack(const Block& netPkt, const lp::Packet& firstPkt, const EndpointId& endpointId);

NFD_PROTECTED_WITH_TESTS_ELSE_PRIVATE:
  Options m_options;
  LpFragmenter m_fragmenter;
  LpReassembler m_reassembler;
  LpReliability m_reliability;
  lp::Sequence m_lastSeqNo = static_cast<lp::Sequence>(-2);

NFD_PUBLIC_WITH_TESTS_ELSE_PRIVATE:
  /// Time to mark next packet due to send queue congestion
  time::steady_clock::time_point m_nextMarkTime = time::steady_clock::time_point::max();
  /// Number of marked packets in the current incident of congestion
  size_t m_nMarkedSinceInMarkingState = 0;

  friend LpReliability;
};

} // namespace nfd::face

#endif // NFD_DAEMON_FACE_GENERIC_LINK_SERVICE_HPP
