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

#include "core/common.hpp"

namespace nfd {

/**
 * \brief implements the Mean-Deviation RTT estimator
 *
 * reference: ns3::RttMeanDeviation
 *
 * This RttEstimator algorithm is designed for TCP, which is a continuous stream.
 * NDN Interest-Data traffic is not always a continuous stream,
 * so NDN may need a different RttEstimator.
 * The design of a more suitable RttEstimator is a research question.
 */
class RttEstimator
{
public:
  typedef time::microseconds Duration;

  static Duration
  getInitialRtt(void)
  {
    return time::seconds(1);
  }

  RttEstimator(uint16_t maxMultiplier = 16,
               Duration minRto = time::milliseconds(1),
               double gain = 0.1);

  void
  addMeasurement(Duration measure);

  void
  incrementMultiplier();

  void
  doubleMultiplier();

  Duration
  computeRto() const;

private:
  uint16_t m_maxMultiplier;
  double m_minRto;

  double m_rtt;
  double m_gain;
  double m_variance;
  uint16_t m_multiplier;
  uint32_t m_nSamples;
};

} // namespace nfd

#endif // NFD_CORE_RTT_ESTIMATOR_HPP
