/* -*- 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;

  /**
   * Runs the ping client (blocking)
   */
  void
  run();

  /**
   * Runs the ping client (non-blocking)
   */
  void
  start();

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
