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 | /* |
Davide Pesavento | b3570c6 | 2022-02-19 19:19:00 -0500 | [diff] [blame] | 3 | * Copyright (c) 2015-2022, 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 | |
Davide Pesavento | b3570c6 | 2022-02-19 19:19:00 -0500 | [diff] [blame] | 30 | namespace ndn::ping::client { |
Eric Newberry | 4164b8e | 2015-04-23 17:29:18 -0700 | [diff] [blame] | 31 | |
| 32 | /** |
| 33 | * @brief prints ping responses and timeouts |
| 34 | */ |
| 35 | class Tracer : noncopyable |
| 36 | { |
| 37 | public: |
| 38 | /** |
| 39 | * @param ping NDN ping client |
| 40 | * @param options ping client options |
| 41 | */ |
| 42 | Tracer(Ping& ping, const Options& options); |
| 43 | |
| 44 | /** |
Teng Liang | 6288486 | 2016-03-31 18:15:36 -0700 | [diff] [blame] | 45 | * @brief Prints ping results when a Data packet is received |
Alexander Afanasyev | 1e7a7b2 | 2015-08-26 15:35:26 -0700 | [diff] [blame] | 46 | * |
Eric Newberry | 4164b8e | 2015-04-23 17:29:18 -0700 | [diff] [blame] | 47 | * @param seq ping sequence number |
| 48 | * @param rtt round trip time |
| 49 | */ |
| 50 | void |
Teng Liang | 6288486 | 2016-03-31 18:15:36 -0700 | [diff] [blame] | 51 | 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 Newberry | 4164b8e | 2015-04-23 17:29:18 -0700 | [diff] [blame] | 62 | |
| 63 | /** |
Alexander Afanasyev | 1e7a7b2 | 2015-08-26 15:35:26 -0700 | [diff] [blame] | 64 | * @brief Prints ping results when timed out |
| 65 | * |
Eric Newberry | 4164b8e | 2015-04-23 17:29:18 -0700 | [diff] [blame] | 66 | * @param seq ping sequence number |
| 67 | */ |
| 68 | void |
| 69 | onTimeout(uint64_t seq); |
| 70 | |
| 71 | /** |
Alexander Afanasyev | 1e7a7b2 | 2015-08-26 15:35:26 -0700 | [diff] [blame] | 72 | * @brief Outputs ping errors to cerr |
Eric Newberry | 4164b8e | 2015-04-23 17:29:18 -0700 | [diff] [blame] | 73 | */ |
| 74 | void |
Davide Pesavento | f8d9a53 | 2021-07-03 16:04:12 -0400 | [diff] [blame] | 75 | onError(const std::string& msg); |
Eric Newberry | 4164b8e | 2015-04-23 17:29:18 -0700 | [diff] [blame] | 76 | |
| 77 | private: |
| 78 | const Options& m_options; |
| 79 | }; |
| 80 | |
Davide Pesavento | b3570c6 | 2022-02-19 19:19:00 -0500 | [diff] [blame] | 81 | } // namespace ndn::ping::client |
Eric Newberry | 4164b8e | 2015-04-23 17:29:18 -0700 | [diff] [blame] | 82 | |
| 83 | #endif // NDN_TOOLS_PING_CLIENT_TRACER_HPP |