apps + examples: Enabling NACK support
Change-Id: I3d16bcf29f4858049d1040a3e421e1c7151b2bb2
Refs: #3871
diff --git a/apps/ndn-app.cpp b/apps/ndn-app.cpp
index 0472550..4121eef 100644
--- a/apps/ndn-app.cpp
+++ b/apps/ndn-app.cpp
@@ -49,13 +49,21 @@
MakeTraceSourceAccessor(&App::m_receivedDatas),
"ns3::ndn::App::DataTraceCallback")
+ .AddTraceSource("ReceivedNacks", "ReceivedNacks",
+ MakeTraceSourceAccessor(&App::m_receivedNacks),
+ "ns3::ndn::App::NackTraceCallback")
+
.AddTraceSource("TransmittedInterests", "TransmittedInterests",
MakeTraceSourceAccessor(&App::m_transmittedInterests),
"ns3::ndn::App::InterestTraceCallback")
.AddTraceSource("TransmittedDatas", "TransmittedDatas",
MakeTraceSourceAccessor(&App::m_transmittedDatas),
- "ns3::ndn::App::DataTraceCallback");
+ "ns3::ndn::App::DataTraceCallback")
+
+ .AddTraceSource("TransmittedNacks", "TransmittedNacks",
+ MakeTraceSourceAccessor(&App::m_transmittedNacks),
+ "ns3::ndn::App::NackTraceCallback");
return tid;
}
@@ -122,7 +130,7 @@
NS_LOG_FUNCTION(this << nack);
// @TODO Implement
- // m_receivedDatas(data, this, m_face);
+ m_receivedNacks(nack, this, m_face);
}
// Application Methods
diff --git a/apps/ndn-app.hpp b/apps/ndn-app.hpp
index c5b3ae7..5af75b5 100644
--- a/apps/ndn-app.hpp
+++ b/apps/ndn-app.hpp
@@ -83,7 +83,7 @@
public:
typedef void (*InterestTraceCallback)(shared_ptr<const Interest>, Ptr<App>, shared_ptr<Face>);
typedef void (*DataTraceCallback)(shared_ptr<const Data>, Ptr<App>, shared_ptr<Face>);
- // @TODO add NACK
+ typedef void (*NackTraceCallback)(shared_ptr<const lp::Nack>, Ptr<App>, shared_ptr<Face>);
protected:
virtual void
@@ -112,7 +112,8 @@
TracedCallback<shared_ptr<const Data>, Ptr<App>, shared_ptr<Face>>
m_receivedDatas; ///< @brief App-level trace of received Data
- // @TODO add NACK
+ TracedCallback<shared_ptr<const lp::Nack>, Ptr<App>, shared_ptr<Face>>
+ m_receivedNacks; ///< @brief App-level trace of received Nacks
TracedCallback<shared_ptr<const Interest>, Ptr<App>, shared_ptr<Face>>
m_transmittedInterests; ///< @brief App-level trace of transmitted Interests
@@ -120,7 +121,8 @@
TracedCallback<shared_ptr<const Data>, Ptr<App>, shared_ptr<Face>>
m_transmittedDatas; ///< @brief App-level trace of transmitted Data
- // @TODO add NACK
+ TracedCallback<shared_ptr<const lp::Nack>, Ptr<App>, shared_ptr<Face>>
+ m_transmittedNacks; ///< @brief App-level trace of transmitted Nacks
};
} // namespace ndn
diff --git a/apps/ndn-consumer-zipf-mandelbrot.hpp b/apps/ndn-consumer-zipf-mandelbrot.hpp
index f973240..cdf58a2 100644
--- a/apps/ndn-consumer-zipf-mandelbrot.hpp
+++ b/apps/ndn-consumer-zipf-mandelbrot.hpp
@@ -63,6 +63,7 @@
virtual void
SendPacket();
+
uint32_t
GetNextSeq();
diff --git a/apps/ndn-consumer.cpp b/apps/ndn-consumer.cpp
index 3a1ec45..3ed9355 100644
--- a/apps/ndn-consumer.cpp
+++ b/apps/ndn-consumer.cpp
@@ -253,6 +253,16 @@
}
void
+Consumer::OnNack(shared_ptr<const lp::Nack> nack)
+{
+ /// tracing inside
+ App::OnNack(nack);
+
+ NS_LOG_INFO("NACK received for: " << nack->getInterest().getName()
+ << ", reason: " << nack->getReason());
+}
+
+void
Consumer::OnTimeout(uint32_t sequenceNumber)
{
NS_LOG_FUNCTION(sequenceNumber);
diff --git a/apps/ndn-consumer.hpp b/apps/ndn-consumer.hpp
index 0906f07..872c46a 100644
--- a/apps/ndn-consumer.hpp
+++ b/apps/ndn-consumer.hpp
@@ -63,6 +63,10 @@
virtual void
OnData(shared_ptr<const Data> contentObject);
+ // From App
+ virtual void
+ OnNack(shared_ptr<const lp::Nack> nack);
+
/**
* @brief Timeout event
* @param sequenceNumber time outed sequence number