ndnSIM-v2: Initial implementation
- Name, name::Components, Interest, Data now use ndn-cxx
- Ptr is replaced with shared_ptr for ndn-cxx structures
Credits for the change also to Mickey Sweat, Wentao Shang, and Alex Afanasyev
diff --git a/apps/ndn-app.cpp b/apps/ndn-app.cpp
index f353e62..b5d3e35 100644
--- a/apps/ndn-app.cpp
+++ b/apps/ndn-app.cpp
@@ -23,8 +23,6 @@
#include "ns3/assert.h"
#include "ns3/packet.h"
-#include "ns3/ndn-interest.hpp"
-#include "ns3/ndn-data.hpp"
#include "ns3/ndn-l3-protocol.hpp"
#include "ns3/ndn-fib.hpp"
#include "ns3/ndn-app-face.hpp"
@@ -48,9 +46,6 @@
.AddTraceSource("ReceivedInterests", "ReceivedInterests",
MakeTraceSourceAccessor(&App::m_receivedInterests))
- .AddTraceSource("ReceivedNacks", "ReceivedNacks",
- MakeTraceSourceAccessor(&App::m_receivedNacks))
-
.AddTraceSource("ReceivedDatas", "ReceivedDatas",
MakeTraceSourceAccessor(&App::m_receivedDatas))
@@ -93,24 +88,17 @@
}
void
-App::OnInterest(Ptr<const Interest> interest)
+App::OnInterest(shared_ptr<const Interest> interest)
{
NS_LOG_FUNCTION(this << interest);
m_receivedInterests(interest, this, m_face);
}
void
-App::OnNack(Ptr<const Interest> interest)
+App::OnData(shared_ptr<const Data> data)
{
- NS_LOG_FUNCTION(this << interest);
- m_receivedNacks(interest, this, m_face);
-}
-
-void
-App::OnData(Ptr<const Data> contentObject)
-{
- NS_LOG_FUNCTION(this << contentObject);
- m_receivedDatas(contentObject, this, m_face);
+ NS_LOG_FUNCTION(this << data);
+ m_receivedDatas(data, this, m_face);
}
// Application Methods
diff --git a/apps/ndn-app.hpp b/apps/ndn-app.hpp
index edede34..f0ac19b 100644
--- a/apps/ndn-app.hpp
+++ b/apps/ndn-app.hpp
@@ -21,6 +21,9 @@
#ifndef NDN_APP_H
#define NDN_APP_H
+#include "ns3/ndnSIM/model/ndn-common.hpp"
+#include "ns3/ndnSIM/model/ndn-app-face.hpp"
+
#include "ns3/application.h"
#include "ns3/ptr.h"
#include "ns3/callback.h"
@@ -32,11 +35,6 @@
namespace ndn {
-class Interest;
-class Data;
-
-class Face;
-
/**
* \ingroup ndn
* \defgroup ndn-apps NDN applications
@@ -72,14 +70,7 @@
* may be useful to get packet tags
*/
virtual void
- OnInterest(Ptr<const Interest> interest);
-
- /**
- * @brief Method that will be called every time new NACK arrives
- * @param interest Interest header
- */
- virtual void
- OnNack(Ptr<const Interest> interest);
+ OnInterest(shared_ptr<const Interest> interest);
/**
* @brief Method that will be called every time new Data arrives
@@ -88,7 +79,7 @@
* original packet)
*/
virtual void
- OnData(Ptr<const Data> contentObject);
+ OnData(shared_ptr<const Data> data);
protected:
/**
@@ -110,19 +101,16 @@
Ptr<Face> m_face; ///< @brief automatically created application face through which application
/// communicates
- TracedCallback<Ptr<const Interest>, Ptr<App>, Ptr<Face>>
+ TracedCallback<shared_ptr<const Interest>, Ptr<App>, Ptr<Face>>
m_receivedInterests; ///< @brief App-level trace of received Interests
- TracedCallback<Ptr<const Interest>, Ptr<App>, Ptr<Face>>
- m_receivedNacks; ///< @brief App-level trace of received NACKs
+ TracedCallbackshared_ptr<const Data>, Ptr<App>,
+ Ptr<Face>> m_receivedDatas; ///< @brief App-level trace of received Data
- TracedCallback<Ptr<const Data>, Ptr<App>, Ptr<Face>>
- m_receivedDatas; ///< @brief App-level trace of received Data
-
- TracedCallback<Ptr<const Interest>, Ptr<App>, Ptr<Face>>
+ TracedCallback<shared_ptr<const Interest>, Ptr<App>, Ptr<Face>>
m_transmittedInterests; ///< @brief App-level trace of transmitted Interests
- TracedCallback<Ptr<const Data>, Ptr<App>, Ptr<Face>>
+ TracedCallback<shared_ptr<const Data>, Ptr<App>, Ptr<Face>>
m_transmittedDatas; ///< @brief App-level trace of transmitted Data
};
diff --git a/apps/ndn-consumer-batches.hpp b/apps/ndn-consumer-batches.hpp
index 0c7c25d..79b5d2b 100644
--- a/apps/ndn-consumer-batches.hpp
+++ b/apps/ndn-consumer-batches.hpp
@@ -21,6 +21,8 @@
#ifndef NDN_CONSUMER_BATCHES_H
#define NDN_CONSUMER_BATCHES_H
+#include "ns3/ndnSIM/model/ndn-common.hpp"
+
#include "ndn-consumer.hpp"
#include "ns3/traced-value.h"
#include "../utils/batches.hpp"
@@ -44,13 +46,13 @@
// From App
// virtual void
- // OnInterest (const Ptr<const Interest> &interest);
+ // OnInterest (const shared_ptr<const Interest> &interest);
// virtual void
- // OnNack (const Ptr<const Interest> &interest);
+ // OnNack (const shared_ptr<const Interest> &interest);
// virtual void
- // OnData (const Ptr<const Data> &contentObject,
+ // OnData (const shared_ptr<const Data> &contentObject,
// const Ptr<const Packet> &payload);
// virtual void
diff --git a/apps/ndn-consumer-cbr.cpp b/apps/ndn-consumer-cbr.cpp
index c9c81b9..f64ae22 100644
--- a/apps/ndn-consumer-cbr.cpp
+++ b/apps/ndn-consumer-cbr.cpp
@@ -31,8 +31,6 @@
#include "ns3/double.h"
#include "ns3/ndn-app-face.hpp"
-#include "ns3/ndn-interest.hpp"
-#include "ns3/ndn-data.hpp"
NS_LOG_COMPONENT_DEFINE("ndn.ConsumerCbr");
@@ -128,14 +126,14 @@
///////////////////////////////////////////////////
// void
-// Consumer::OnData (const Ptr<const Data> &contentObject,
+// Consumer::OnData (const shared_ptr<const Data> &contentObject,
// const Ptr<const Packet> &payload)
// {
// Consumer::OnData (contentObject, payload); // tracing inside
// }
// void
-// Consumer::OnNack (const Ptr<const Interest> &interest)
+// Consumer::OnNack (const shared_ptr<const Interest> &interest)
// {
// Consumer::OnNack (interest); // tracing inside
// }
diff --git a/apps/ndn-consumer-cbr.hpp b/apps/ndn-consumer-cbr.hpp
index 47134b6..126560b 100644
--- a/apps/ndn-consumer-cbr.hpp
+++ b/apps/ndn-consumer-cbr.hpp
@@ -22,6 +22,8 @@
#ifndef NDN_CONSUMER_CBR_H
#define NDN_CONSUMER_CBR_H
+#include "ns3/ndnSIM/model/ndn-common.hpp"
+
#include "ndn-consumer.hpp"
namespace ns3 {
@@ -45,13 +47,13 @@
// From NdnApp
// virtual void
- // OnInterest (const Ptr<const Interest> &interest);
+ // OnInterest (const shared_ptr<const Interest> &interest);
// virtual void
- // OnNack (const Ptr<const Interest> &interest);
+ // OnNack (const shared_ptr<const Interest> &interest);
// virtual void
- // OnData (const Ptr<const Data> &contentObject,
+ // OnData (const shared_ptr<const Data> &contentObject,
// const Ptr<const Packet> &payload);
protected:
diff --git a/apps/ndn-consumer-window.cpp b/apps/ndn-consumer-window.cpp
index 595842c..d1531bd 100644
--- a/apps/ndn-consumer-window.cpp
+++ b/apps/ndn-consumer-window.cpp
@@ -27,8 +27,6 @@
#include "ns3/string.h"
#include "ns3/uinteger.h"
#include "ns3/double.h"
-#include "ns3/ndn-data.hpp"
-#include "ns3/ndn-interest.hpp"
NS_LOG_COMPONENT_DEFINE("ndn.ConsumerWindow");
@@ -183,7 +181,7 @@
///////////////////////////////////////////////////
void
-ConsumerWindow::OnData(Ptr<const Data> contentObject)
+ConsumerWindow::OnData(shared_ptr<const Data> contentObject)
{
Consumer::OnData(contentObject);
@@ -197,7 +195,7 @@
}
void
-ConsumerWindow::OnNack(Ptr<const Interest> interest)
+ConsumerWindow::OnNack(shared_ptr<const Interest> interest)
{
Consumer::OnNack(interest);
diff --git a/apps/ndn-consumer-window.hpp b/apps/ndn-consumer-window.hpp
index 923cae0..0d0536f 100644
--- a/apps/ndn-consumer-window.hpp
+++ b/apps/ndn-consumer-window.hpp
@@ -22,6 +22,8 @@
#ifndef NDN_CONSUMER_WINDOW_H
#define NDN_CONSUMER_WINDOW_H
+#include "ns3/ndnSIM/model/ndn-common.hpp"
+
#include "ndn-consumer.hpp"
#include "ns3/traced-value.h"
@@ -48,13 +50,13 @@
// From App
// virtual void
- // OnInterest (const Ptr<const Interest> &interest);
+ // OnInterest (const shared_ptr<const Interest> &interest);
virtual void
- OnNack(Ptr<const Interest> interest);
+ OnNack(shared_ptr<const Interest> interest);
virtual void
- OnData(Ptr<const Data> contentObject);
+ OnData(shared_ptr<const Data> contentObject);
virtual void
OnTimeout(uint32_t sequenceNumber);
diff --git a/apps/ndn-consumer-zipf-mandelbrot.cpp b/apps/ndn-consumer-zipf-mandelbrot.cpp
index 806b8e3..f6037e3 100644
--- a/apps/ndn-consumer-zipf-mandelbrot.cpp
+++ b/apps/ndn-consumer-zipf-mandelbrot.cpp
@@ -21,8 +21,6 @@
#include "ndn-consumer-zipf-mandelbrot.hpp"
#include "ns3/ndn-app-face.hpp"
-#include "ns3/ndn-interest.hpp"
-#include "ns3/ndn-data.hpp"
#include "ns3/ndnSIM/utils/ndn-fw-hop-count-tag.hpp"
@@ -171,11 +169,11 @@
// std::cout << Simulator::Now ().ToDouble (Time::S) << "s -> " << seq << "\n";
//
- Ptr<Name> nameWithSequence = Create<Name>(m_interestName);
+ shared_ptr<Name> nameWithSequence = make_shared<Name>(m_interestName);
nameWithSequence->appendSeqNum(seq);
//
- Ptr<Interest> interest = Create<Interest>();
+ shared_ptr<Interest> interest = make_shared<Interest>();
interest->SetNonce(m_rand.GetValue());
interest->SetName(nameWithSequence);
diff --git a/apps/ndn-consumer-zipf-mandelbrot.hpp b/apps/ndn-consumer-zipf-mandelbrot.hpp
index ee192db..dd03563 100644
--- a/apps/ndn-consumer-zipf-mandelbrot.hpp
+++ b/apps/ndn-consumer-zipf-mandelbrot.hpp
@@ -21,6 +21,8 @@
#ifndef NDN_CONSUMER_ZIPF_MANDELBROT_H_
#define NDN_CONSUMER_ZIPF_MANDELBROT_H_
+#include "ns3/ndnSIM/model/ndn-common.hpp"
+
#include "ndn-consumer.hpp"
#include "ns3/ptr.h"
#include "ns3/log.h"
diff --git a/apps/ndn-consumer.cpp b/apps/ndn-consumer.cpp
index fabbe95..c64bb7e 100644
--- a/apps/ndn-consumer.cpp
+++ b/apps/ndn-consumer.cpp
@@ -31,15 +31,11 @@
#include "ns3/double.h"
#include "ns3/ndn-app-face.hpp"
-#include "ns3/ndn-interest.hpp"
-#include "ns3/ndn-data.hpp"
#include "ns3/ndnSIM/utils/ndn-fw-hop-count-tag.hpp"
#include "ns3/ndnSIM/utils/ndn-rtt-mean-deviation.hpp"
#include <boost/ref.hpp>
-#include "ns3/names.h"
-
NS_LOG_COMPONENT_DEFINE("ndn.Consumer");
namespace ns3 {
@@ -183,11 +179,11 @@
}
//
- Ptr<Name> nameWithSequence = Create<Name>(m_interestName);
+ shared_ptr<Name> nameWithSequence = make_shared<Name>(m_interestName);
nameWithSequence->appendSeqNum(seq);
//
- Ptr<Interest> interest = Create<Interest>();
+ shared_ptr<Interest> interest = make_shared<Interest>();
interest->SetNonce(m_rand.GetValue());
interest->SetName(nameWithSequence);
interest->SetInterestLifetime(m_interestLifeTime);
@@ -211,7 +207,7 @@
///////////////////////////////////////////////////
void
-Consumer::OnData(Ptr<const Data> data)
+Consumer::OnData(shared_ptr<const Data> data)
{
if (!m_active)
return;
@@ -253,7 +249,7 @@
}
void
-Consumer::OnNack(Ptr<const Interest> interest)
+Consumer::OnNack(shared_ptr<const Interest> interest)
{
if (!m_active)
return;
diff --git a/apps/ndn-consumer.hpp b/apps/ndn-consumer.hpp
index 83ece12..25de4cd 100644
--- a/apps/ndn-consumer.hpp
+++ b/apps/ndn-consumer.hpp
@@ -22,9 +22,10 @@
#ifndef NDN_CONSUMER_H
#define NDN_CONSUMER_H
+#include "ns3/ndnSIM/model/ndn-common.hpp"
+
#include "ndn-app.hpp"
#include "ns3/random-variable.h"
-#include "ns3/ndn-name.hpp"
#include "ns3/nstime.h"
#include "ns3/data-rate.h"
#include "ns3/ndn-rtt-estimator.hpp"
@@ -58,13 +59,13 @@
// From App
// virtual void
- // OnInterest (const Ptr<const Interest> &interest);
+ // OnInterest (const shared_ptr<const Interest> &interest);
virtual void
- OnNack(Ptr<const Interest> interest);
+ OnNack(shared_ptr<const Interest> interest);
virtual void
- OnData(Ptr<const Data> contentObject);
+ OnData(shared_ptr<const Data> contentObject);
/**
* @brief Timeout event
diff --git a/apps/ndn-producer.cpp b/apps/ndn-producer.cpp
index 67a5043..60bc1dc 100644
--- a/apps/ndn-producer.cpp
+++ b/apps/ndn-producer.cpp
@@ -21,8 +21,6 @@
#include "ndn-producer.hpp"
#include "ns3/log.h"
-#include "ns3/ndn-interest.hpp"
-#include "ns3/ndn-data.hpp"
#include "ns3/string.h"
#include "ns3/uinteger.h"
#include "ns3/packet.h"
@@ -115,7 +113,7 @@
}
void
-Producer::OnInterest(Ptr<const Interest> interest)
+Producer::OnInterest(shared_ptr<const Interest> interest)
{
App::OnInterest(interest); // tracing inside
@@ -124,8 +122,8 @@
if (!m_active)
return;
- Ptr<Data> data = Create<Data>(Create<Packet>(m_virtualPayloadSize));
- Ptr<Name> dataName = Create<Name>(interest->GetName());
+ shared_ptr<Data> data = make_shared<Data>(Create<Packet>(m_virtualPayloadSize));
+ shared_ptr<Name> dataName = make_shared<Name>(interest->GetName());
dataName->append(m_postfix);
data->SetName(dataName);
data->SetFreshness(m_freshness);
@@ -133,7 +131,7 @@
data->SetSignature(m_signature);
if (m_keyLocator.size() > 0) {
- data->SetKeyLocator(Create<Name>(m_keyLocator));
+ data->SetKeyLocator(make_shared<Name>(m_keyLocator));
}
NS_LOG_INFO("node(" << GetNode()->GetId() << ") respodning with Data: " << data->GetName());
diff --git a/apps/ndn-producer.hpp b/apps/ndn-producer.hpp
index 11ebc56..e414f4e 100644
--- a/apps/ndn-producer.hpp
+++ b/apps/ndn-producer.hpp
@@ -22,6 +22,8 @@
#ifndef NDN_PRODUCER_H
#define NDN_PRODUCER_H
+#include "ns3/ndnSIM/model/ndn-common.hpp"
+
#include "ndn-app.hpp"
#include "ns3/ptr.h"
@@ -49,7 +51,7 @@
// inherited from NdnApp
void
- OnInterest(Ptr<const Interest> interest);
+ OnInterest(shared_ptr<const Interest> interest);
protected:
// inherited from Application base class.