/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
 * Copyright (c) 2015,  Arizona Board of Regents.
 *
 * This file is part of ndn-tools (Named Data Networking Essential Tools).
 * See AUTHORS.md for complete list of ndn-tools authors and contributors.
 *
 * ndn-tools 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.
 *
 * ndn-tools 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
 * ndn-tools, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @author: Jerald Paul Abraham <jeraldabraham@email.arizona.edu>
 * @author: Eric Newberry <enewberry@email.arizona.edu>
 */

#ifndef NDN_TOOLS_PING_CLIENT_PING_HPP
#define NDN_TOOLS_PING_CLIENT_PING_HPP

#include "core/common.hpp"

namespace ndn {
namespace ping {
namespace client {

typedef time::duration<double, time::milliseconds::period> Rtt;

/**
 * @brief options for ndnping client
 */
struct Options
{
  Name prefix;                      //!< prefix pinged
  bool shouldAllowStaleData;        //!< allow stale Data
  bool shouldGenerateRandomSeq;     //!< random ping sequence
  bool shouldPrintTimestamp;        //!< print timestamp
  int nPings;                       //!< number of pings
  time::milliseconds interval;      //!< ping interval
  time::milliseconds timeout;       //!< timeout threshold
  uint64_t startSeq;                //!< start ping sequence number
  name::Component clientIdentifier; //!< client identifier
};

/**
 * @brief NDN modular ping client
 */
class Ping : noncopyable
{
public:
  Ping(Face& face, const Options& options);

  /**
   * Signals on the successful return of a packet
   * @param seq ping sequence number
   * @param rtt round trip time
   */
  signal::Signal<Ping, uint64_t, Rtt> afterResponse;

  /**
   * Signals on timeout of a packet
   * @param seq ping sequence number
   */
  signal::Signal<Ping, uint64_t> afterTimeout;

  /**
   * Signals when finished pinging
   */
  signal::Signal<Ping> afterFinish;

  /**
   * Executes the pings
   */
  void
  run();

private:
  /**
   * Creates a ping Name from the sequence number
   * @param seq ping sequence number
   */
  Name
  makePingName(uint64_t seq) const;

  /**
   * Performs individual ping
   */
  void
  performPing();

  /**
   * Called when ping returned successfully
   * @param interest NDN interest
   * @param data returned data
   * @param seq ping sequence number
   * @param sendTime time ping sent
   */
  void
  onData(const Interest& interest, Data& data, uint64_t seq, const time::steady_clock::TimePoint& sendTime);

  /**
   * Called when ping timed out
   * @param interest NDN interest
   * @param seq ping sequence number
   */
  void
  onTimeout(const Interest& interest, uint64_t seq);

  /**
   * Called after ping received or timed out
   */
  void
  finish();

private:
  const Options& m_options;
  int m_nSent;
  uint64_t m_nextSeq;
  int m_nOutstanding;
  Face& m_face;
  scheduler::Scheduler m_scheduler;
};

} // namespace client
} // namespace ping
} // namespace ndn

#endif // NDN_TOOLS_PING_CLIENT_PING_HPP
