blob: b6b48121c565410aea0b25f69fdbd2d2cf42cfba [file] [log] [blame]
Eric Newberry4164b8e2015-04-23 17:29:18 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Davide Pesaventof8d9a532021-07-03 16:04:12 -04002/*
3 * Copyright (c) 2015-2021, Arizona Board of Regents.
Eric Newberry4164b8e2015-04-23 17:29:18 -07004 *
5 * This file is part of ndn-tools (Named Data Networking Essential Tools).
6 * See AUTHORS.md for complete list of ndn-tools authors and contributors.
7 *
8 * ndn-tools is free software: you can redistribute it and/or modify it under the terms
9 * of the GNU General Public License as published by the Free Software Foundation,
10 * either version 3 of the License, or (at your option) any later version.
11 *
12 * ndn-tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * ndn-tools, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
18 *
Davide Pesaventof8d9a532021-07-03 16:04:12 -040019 * @author Eric Newberry <enewberry@email.arizona.edu>
20 * @author Teng Liang <philoliang@email.arizona.edu>
Eric Newberry4164b8e2015-04-23 17:29:18 -070021 */
22
23#ifndef NDN_TOOLS_PING_CLIENT_TRACER_HPP
24#define NDN_TOOLS_PING_CLIENT_TRACER_HPP
25
26#include "core/common.hpp"
27
28#include "ping.hpp"
29
30namespace ndn {
31namespace ping {
32namespace client {
33
34/**
35 * @brief prints ping responses and timeouts
36 */
37class Tracer : noncopyable
38{
39public:
40 /**
41 * @param ping NDN ping client
42 * @param options ping client options
43 */
44 Tracer(Ping& ping, const Options& options);
45
46 /**
Teng Liang62884862016-03-31 18:15:36 -070047 * @brief Prints ping results when a Data packet is received
Alexander Afanasyev1e7a7b22015-08-26 15:35:26 -070048 *
Eric Newberry4164b8e2015-04-23 17:29:18 -070049 * @param seq ping sequence number
50 * @param rtt round trip time
51 */
52 void
Teng Liang62884862016-03-31 18:15:36 -070053 onData(uint64_t seq, Rtt rtt);
54
55 /**
56 * @brief Prints NackReason when a Nack is received
57 *
58 * @param seq ping sequence number
59 * @param rtt round trip time
60 * @param header the header of Nack
61 */
62 void
63 onNack(uint64_t seq, Rtt rtt, const lp::NackHeader& header);
Eric Newberry4164b8e2015-04-23 17:29:18 -070064
65 /**
Alexander Afanasyev1e7a7b22015-08-26 15:35:26 -070066 * @brief Prints ping results when timed out
67 *
Eric Newberry4164b8e2015-04-23 17:29:18 -070068 * @param seq ping sequence number
69 */
70 void
71 onTimeout(uint64_t seq);
72
73 /**
Alexander Afanasyev1e7a7b22015-08-26 15:35:26 -070074 * @brief Outputs ping errors to cerr
Eric Newberry4164b8e2015-04-23 17:29:18 -070075 */
76 void
Davide Pesaventof8d9a532021-07-03 16:04:12 -040077 onError(const std::string& msg);
Eric Newberry4164b8e2015-04-23 17:29:18 -070078
79private:
80 const Options& m_options;
81};
82
83} // namespace client
84} // namespace ping
85} // namespace ndn
86
87#endif // NDN_TOOLS_PING_CLIENT_TRACER_HPP