ndnping: recognize and trace Nack

Change-Id: If47877892c75ae0849375f36430a66e02fb7a608
refs: #3335
diff --git a/tools/ping/client/ping.cpp b/tools/ping/client/ping.cpp
index b60be65..966d29e 100644
--- a/tools/ping/client/ping.cpp
+++ b/tools/ping/client/ping.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014-2015,  Arizona Board of Regents.
+ * Copyright (c) 2014-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.
@@ -18,6 +18,7 @@
  *
  * @author: Jerald Paul Abraham <jeraldabraham@email.arizona.edu>
  * @author: Eric Newberry <enewberry@email.arizona.edu>
+ * @author: Teng Liang <philoliang@email.arizona.edu>
  */
 
 #include "ping.hpp"
@@ -63,8 +64,10 @@
   interest.setMustBeFresh(!m_options.shouldAllowStaleData);
   interest.setInterestLifetime(m_options.timeout);
 
+  auto now = time::steady_clock::now();
   m_face.expressInterest(interest,
-                         bind(&Ping::onData, this, _1, _2, m_nextSeq, time::steady_clock::now()),
+                         bind(&Ping::onData, this, _1, _2, m_nextSeq, now),
+                         bind(&Ping::onNack, this, _1, _2, m_nextSeq, now),
                          bind(&Ping::onTimeout, this, _1, m_nextSeq));
 
   ++m_nSent;
@@ -80,11 +83,27 @@
 }
 
 void
-Ping::onData(const Interest& interest, Data& data, uint64_t seq, const time::steady_clock::TimePoint& sendTime)
+Ping::onData(const Interest& interest,
+             const Data& data,
+             uint64_t seq,
+             const time::steady_clock::TimePoint& sendTime)
 {
   time::nanoseconds rtt = time::steady_clock::now() - sendTime;
 
-  afterResponse(seq, rtt);
+  afterData(seq, rtt);
+
+  finish();
+}
+
+void
+Ping::onNack(const Interest& interest,
+             const lp::Nack& nack,
+             uint64_t seq,
+             const time::steady_clock::TimePoint& sendTime)
+{
+  time::nanoseconds rtt = time::steady_clock::now() - sendTime;
+
+  afterNack(seq, rtt, nack.getHeader());
 
   finish();
 }