ndnping: recognize and trace Nack
Change-Id: If47877892c75ae0849375f36430a66e02fb7a608
refs: #3335
diff --git a/tools/ping/client/tracer.cpp b/tools/ping/client/tracer.cpp
index c521b20..9510af8 100644
--- a/tools/ping/client/tracer.cpp
+++ b/tools/ping/client/tracer.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2015, Arizona Board of Regents.
+ * Copyright (c) 2015-2016, 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.
@@ -17,6 +17,7 @@
* ndn-tools, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*
* @author: Eric Newberry <enewberry@email.arizona.edu>
+ * @author: Teng Liang <philoliang@email.arizona.edu>
*/
#include "tracer.hpp"
@@ -28,12 +29,13 @@
Tracer::Tracer(Ping& ping, const Options& options)
: m_options(options)
{
- ping.afterResponse.connect(bind(&Tracer::onResponse, this, _1, _2));
+ ping.afterData.connect(bind(&Tracer::onData, this, _1, _2));
+ ping.afterNack.connect(bind(&Tracer::onNack, this, _1, _2, _3));
ping.afterTimeout.connect(bind(&Tracer::onTimeout, this, _1));
}
void
-Tracer::onResponse(uint64_t seq, Rtt rtt)
+Tracer::onData(uint64_t seq, Rtt rtt)
{
if (m_options.shouldPrintTimestamp) {
std::cout << time::toIsoString(time::system_clock::now()) << " - ";
@@ -44,6 +46,17 @@
}
void
+Tracer::onNack(uint64_t seq, Rtt rtt, const lp::NackHeader& header)
+{
+ if (m_options.shouldPrintTimestamp) {
+ std::cout << time::toIsoString(time::system_clock::now()) << " - ";
+ }
+
+ std::cout << "nack from " << m_options.prefix << ": seq=" << seq << " time="
+ << rtt.count() << " ms" << " reason=" << header.getReason() << std::endl;
+}
+
+void
Tracer::onTimeout(uint64_t seq)
{
if (m_options.shouldPrintTimestamp) {