blob: c2d375ec9b84da6a38a39b809eeb31ca9d6454fe [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/*
Davide Pesaventob3570c62022-02-19 19:19:00 -05003 * Copyright (c) 2015-2022, 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
Davide Pesaventob3570c62022-02-19 19:19:00 -050030namespace ndn::ping::client {
Eric Newberry4164b8e2015-04-23 17:29:18 -070031
32/**
33 * @brief prints ping responses and timeouts
34 */
35class Tracer : noncopyable
36{
37public:
38 /**
39 * @param ping NDN ping client
40 * @param options ping client options
41 */
42 Tracer(Ping& ping, const Options& options);
43
44 /**
Teng Liang62884862016-03-31 18:15:36 -070045 * @brief Prints ping results when a Data packet is received
Alexander Afanasyev1e7a7b22015-08-26 15:35:26 -070046 *
Eric Newberry4164b8e2015-04-23 17:29:18 -070047 * @param seq ping sequence number
48 * @param rtt round trip time
49 */
50 void
Teng Liang62884862016-03-31 18:15:36 -070051 onData(uint64_t seq, Rtt rtt);
52
53 /**
54 * @brief Prints NackReason when a Nack is received
55 *
56 * @param seq ping sequence number
57 * @param rtt round trip time
58 * @param header the header of Nack
59 */
60 void
61 onNack(uint64_t seq, Rtt rtt, const lp::NackHeader& header);
Eric Newberry4164b8e2015-04-23 17:29:18 -070062
63 /**
Alexander Afanasyev1e7a7b22015-08-26 15:35:26 -070064 * @brief Prints ping results when timed out
65 *
Eric Newberry4164b8e2015-04-23 17:29:18 -070066 * @param seq ping sequence number
67 */
68 void
69 onTimeout(uint64_t seq);
70
71 /**
Alexander Afanasyev1e7a7b22015-08-26 15:35:26 -070072 * @brief Outputs ping errors to cerr
Eric Newberry4164b8e2015-04-23 17:29:18 -070073 */
74 void
Davide Pesaventof8d9a532021-07-03 16:04:12 -040075 onError(const std::string& msg);
Eric Newberry4164b8e2015-04-23 17:29:18 -070076
77private:
78 const Options& m_options;
79};
80
Davide Pesaventob3570c62022-02-19 19:19:00 -050081} // namespace ndn::ping::client
Eric Newberry4164b8e2015-04-23 17:29:18 -070082
83#endif // NDN_TOOLS_PING_CLIENT_TRACER_HPP