/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
 * Copyright (c) 2014-2016,  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/>.
 */

#include "retx-suppression-fixed.hpp"
#include "pit-algorithm.hpp"

namespace nfd {
namespace fw {

const time::milliseconds RetxSuppressionFixed::DEFAULT_MIN_RETX_INTERVAL(100);

RetxSuppressionFixed::RetxSuppressionFixed(const time::milliseconds& minRetxInterval)
  : m_minRetxInterval(minRetxInterval)
{
  BOOST_ASSERT(minRetxInterval > time::milliseconds::zero());
}

RetxSuppression::Result
RetxSuppressionFixed::decide(const Face& inFace, const Interest& interest,
                             pit::Entry& pitEntry) const
{
  bool isNewPitEntry = !hasPendingOutRecords(pitEntry);
  if (isNewPitEntry) {
    return NEW;
  }

  time::steady_clock::TimePoint lastOutgoing = this->getLastOutgoing(pitEntry);
  time::steady_clock::TimePoint now = time::steady_clock::now();
  time::steady_clock::Duration sinceLastOutgoing = now - lastOutgoing;
  bool shouldSuppress = sinceLastOutgoing < m_minRetxInterval;
  return shouldSuppress ? SUPPRESS : FORWARD;
}

} // namespace fw
} // namespace nfd
