Eric Newberry | 4164b8e | 2015-04-23 17:29:18 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Davide Pesavento | f8d9a53 | 2021-07-03 16:04:12 -0400 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2015-2021, Arizona Board of Regents. |
Eric Newberry | 4164b8e | 2015-04-23 17:29:18 -0700 | [diff] [blame] | 4 | * |
| 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 Pesavento | f8d9a53 | 2021-07-03 16:04:12 -0400 | [diff] [blame] | 19 | * @author Eric Newberry <enewberry@email.arizona.edu> |
| 20 | * @author Teng Liang <philoliang@email.arizona.edu> |
Eric Newberry | 4164b8e | 2015-04-23 17:29:18 -0700 | [diff] [blame] | 21 | */ |
| 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 | |
| 30 | namespace ndn { |
| 31 | namespace ping { |
| 32 | namespace client { |
| 33 | |
| 34 | /** |
| 35 | * @brief prints ping responses and timeouts |
| 36 | */ |
| 37 | class Tracer : noncopyable |
| 38 | { |
| 39 | public: |
| 40 | /** |
| 41 | * @param ping NDN ping client |
| 42 | * @param options ping client options |
| 43 | */ |
| 44 | Tracer(Ping& ping, const Options& options); |
| 45 | |
| 46 | /** |
Teng Liang | 6288486 | 2016-03-31 18:15:36 -0700 | [diff] [blame] | 47 | * @brief Prints ping results when a Data packet is received |
Alexander Afanasyev | 1e7a7b2 | 2015-08-26 15:35:26 -0700 | [diff] [blame] | 48 | * |
Eric Newberry | 4164b8e | 2015-04-23 17:29:18 -0700 | [diff] [blame] | 49 | * @param seq ping sequence number |
| 50 | * @param rtt round trip time |
| 51 | */ |
| 52 | void |
Teng Liang | 6288486 | 2016-03-31 18:15:36 -0700 | [diff] [blame] | 53 | 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 Newberry | 4164b8e | 2015-04-23 17:29:18 -0700 | [diff] [blame] | 64 | |
| 65 | /** |
Alexander Afanasyev | 1e7a7b2 | 2015-08-26 15:35:26 -0700 | [diff] [blame] | 66 | * @brief Prints ping results when timed out |
| 67 | * |
Eric Newberry | 4164b8e | 2015-04-23 17:29:18 -0700 | [diff] [blame] | 68 | * @param seq ping sequence number |
| 69 | */ |
| 70 | void |
| 71 | onTimeout(uint64_t seq); |
| 72 | |
| 73 | /** |
Alexander Afanasyev | 1e7a7b2 | 2015-08-26 15:35:26 -0700 | [diff] [blame] | 74 | * @brief Outputs ping errors to cerr |
Eric Newberry | 4164b8e | 2015-04-23 17:29:18 -0700 | [diff] [blame] | 75 | */ |
| 76 | void |
Davide Pesavento | f8d9a53 | 2021-07-03 16:04:12 -0400 | [diff] [blame] | 77 | onError(const std::string& msg); |
Eric Newberry | 4164b8e | 2015-04-23 17:29:18 -0700 | [diff] [blame] | 78 | |
| 79 | private: |
| 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 |