model+apps+utils+examples+ci+docs: Update code for changes in ns-2.23
- Replace removed RandomVariable with RandomVariableStream
- Replace deprecated usages of AddTraceSource
- Update changed LogComponent interface
ci: This commit also integrates a script for Jenkins and Travis CI to
clone NS-3 and pybindgen repositories, so the code can be built.
docs: Update to reflect new home of ndnSIM and related sources
Change-Id: Ic14e1269bf15366b0041fd670c577053b6704dc7
Refs: #3122, #3123
diff --git a/apps/ndn-app.cpp b/apps/ndn-app.cpp
index fdeb4e7..802f697 100644
--- a/apps/ndn-app.cpp
+++ b/apps/ndn-app.cpp
@@ -41,16 +41,20 @@
.AddConstructor<App>()
.AddTraceSource("ReceivedInterests", "ReceivedInterests",
- MakeTraceSourceAccessor(&App::m_receivedInterests))
+ MakeTraceSourceAccessor(&App::m_receivedInterests),
+ "ns3::ndn::App::InterestTraceCallback")
.AddTraceSource("ReceivedDatas", "ReceivedDatas",
- MakeTraceSourceAccessor(&App::m_receivedDatas))
+ MakeTraceSourceAccessor(&App::m_receivedDatas),
+ "ns3::ndn::App::DataTraceCallback")
.AddTraceSource("TransmittedInterests", "TransmittedInterests",
- MakeTraceSourceAccessor(&App::m_transmittedInterests))
+ MakeTraceSourceAccessor(&App::m_transmittedInterests),
+ "ns3::ndn::App::InterestTraceCallback")
.AddTraceSource("TransmittedDatas", "TransmittedDatas",
- MakeTraceSourceAccessor(&App::m_transmittedDatas));
+ MakeTraceSourceAccessor(&App::m_transmittedDatas),
+ "ns3::ndn::App::DataTraceCallback");
return tid;
}
diff --git a/apps/ndn-app.hpp b/apps/ndn-app.hpp
index 7d335b3..8ba90d3 100644
--- a/apps/ndn-app.hpp
+++ b/apps/ndn-app.hpp
@@ -80,6 +80,10 @@
virtual void
OnData(shared_ptr<const Data> data);
+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>);
+
protected:
/**
* @brief Do cleanup when application is destroyed
diff --git a/apps/ndn-consumer-cbr.cpp b/apps/ndn-consumer-cbr.cpp
index 491051a..fc5be6d 100644
--- a/apps/ndn-consumer-cbr.cpp
+++ b/apps/ndn-consumer-cbr.cpp
@@ -68,7 +68,6 @@
ConsumerCbr::ConsumerCbr()
: m_frequency(1.0)
, m_firstTime(true)
- , m_random(0)
{
NS_LOG_FUNCTION_NOARGS();
m_seqMax = std::numeric_limits<uint32_t>::max();
@@ -76,8 +75,6 @@
ConsumerCbr::~ConsumerCbr()
{
- if (m_random)
- delete m_random;
}
void
@@ -99,14 +96,15 @@
void
ConsumerCbr::SetRandomize(const std::string& value)
{
- if (m_random)
- delete m_random;
-
if (value == "uniform") {
- m_random = new UniformVariable(0.0, 2 * 1.0 / m_frequency);
+ m_random = CreateObject<UniformRandomVariable>();
+ m_random->SetAttribute("Min", DoubleValue(0.0));
+ m_random->SetAttribute("Max", DoubleValue(2 * 1.0 / m_frequency));
}
else if (value == "exponential") {
- m_random = new ExponentialVariable(1.0 / m_frequency, 50 * 1.0 / m_frequency);
+ m_random = CreateObject<ExponentialRandomVariable>();
+ m_random->SetAttribute("Mean", DoubleValue(1.0 / m_frequency));
+ m_random->SetAttribute("Bound", DoubleValue(50 * 1.0 / m_frequency));
}
else
m_random = 0;
diff --git a/apps/ndn-consumer-cbr.hpp b/apps/ndn-consumer-cbr.hpp
index 6e8f6c1..fbf606c 100644
--- a/apps/ndn-consumer-cbr.hpp
+++ b/apps/ndn-consumer-cbr.hpp
@@ -68,7 +68,7 @@
protected:
double m_frequency; // Frequency of interest packets (in hertz)
bool m_firstTime;
- RandomVariable* m_random;
+ Ptr<RandomVariableStream> m_random;
std::string m_randomType;
};
diff --git a/apps/ndn-consumer-window.cpp b/apps/ndn-consumer-window.cpp
index d02ea1d..b806190 100644
--- a/apps/ndn-consumer-window.cpp
+++ b/apps/ndn-consumer-window.cpp
@@ -73,9 +73,11 @@
.AddTraceSource("WindowTrace",
"Window that controls how many outstanding interests are allowed",
- MakeTraceSourceAccessor(&ConsumerWindow::m_window))
+ MakeTraceSourceAccessor(&ConsumerWindow::m_window),
+ "ns3::ndn::ConsumerWindow::WindowTraceCallback")
.AddTraceSource("InFlight", "Current number of outstanding interests",
- MakeTraceSourceAccessor(&ConsumerWindow::m_inFlight));
+ MakeTraceSourceAccessor(&ConsumerWindow::m_inFlight),
+ "ns3::ndn::ConsumerWindow::WindowTraceCallback");
return tid;
}
diff --git a/apps/ndn-consumer-window.hpp b/apps/ndn-consumer-window.hpp
index 1f229d8..4e76c50 100644
--- a/apps/ndn-consumer-window.hpp
+++ b/apps/ndn-consumer-window.hpp
@@ -56,6 +56,9 @@
virtual void
WillSendOutInterest(uint32_t sequenceNumber);
+public:
+ typedef void (*WindowTraceCallback)(uint32_t);
+
protected:
/**
* \brief Constructs the Interest packet and sends it using a callback to the underlying NDN
diff --git a/apps/ndn-consumer-zipf-mandelbrot.cpp b/apps/ndn-consumer-zipf-mandelbrot.cpp
index 2c7f71f..ac83022 100644
--- a/apps/ndn-consumer-zipf-mandelbrot.cpp
+++ b/apps/ndn-consumer-zipf-mandelbrot.cpp
@@ -64,7 +64,7 @@
: m_N(100) // needed here to make sure when SetQ/SetS are called, there is a valid value of N
, m_q(0.7)
, m_s(0.7)
- , m_SeqRng(0.0, 1.0)
+ , m_seqRng(CreateObject<UniformRandomVariable>())
{
// SetNumberOfContents is called by NS-3 object system during the initialization
}
@@ -174,7 +174,7 @@
//
shared_ptr<Interest> interest = make_shared<Interest>();
- interest->setNonce(m_rand.GetValue());
+ interest->setNonce(m_rand->GetValue(0, std::numeric_limits<uint32_t>::max()));
interest->setName(*nameWithSequence);
// NS_LOG_INFO ("Requesting Interest: \n" << *interest);
@@ -204,9 +204,9 @@
uint32_t content_index = 1; //[1, m_N]
double p_sum = 0;
- double p_random = m_SeqRng.GetValue();
+ double p_random = m_seqRng->GetValue();
while (p_random == 0) {
- p_random = m_SeqRng.GetValue();
+ p_random = m_seqRng->GetValue();
}
// if (p_random == 0)
NS_LOG_LOGIC("p_random=" << p_random);
diff --git a/apps/ndn-consumer-zipf-mandelbrot.hpp b/apps/ndn-consumer-zipf-mandelbrot.hpp
index d0cd4f1..f973240 100644
--- a/apps/ndn-consumer-zipf-mandelbrot.hpp
+++ b/apps/ndn-consumer-zipf-mandelbrot.hpp
@@ -35,7 +35,7 @@
#include "ns3/string.h"
#include "ns3/uinteger.h"
#include "ns3/double.h"
-#include "ns3/random-variable.h"
+#include "ns3/random-variable-stream.h"
namespace ns3 {
namespace ndn {
@@ -95,7 +95,7 @@
double m_s; // s in (k+q)^s
std::vector<double> m_Pcum; // cumulative probability
- UniformVariable m_SeqRng; // RNG
+ Ptr<UniformRandomVariable> m_seqRng; // RNG
};
} /* namespace ndn */
diff --git a/apps/ndn-consumer.cpp b/apps/ndn-consumer.cpp
index 7350b0f..4d39bea 100644
--- a/apps/ndn-consumer.cpp
+++ b/apps/ndn-consumer.cpp
@@ -66,17 +66,19 @@
.AddTraceSource("LastRetransmittedInterestDataDelay",
"Delay between last retransmitted Interest and received Data",
- MakeTraceSourceAccessor(&Consumer::m_lastRetransmittedInterestDataDelay))
+ MakeTraceSourceAccessor(&Consumer::m_lastRetransmittedInterestDataDelay),
+ "ns3::ndn::Consumer::LastRetransmittedInterestDataDelayCallback")
.AddTraceSource("FirstInterestDataDelay",
"Delay between first transmitted Interest and received Data",
- MakeTraceSourceAccessor(&Consumer::m_firstInterestDataDelay));
+ MakeTraceSourceAccessor(&Consumer::m_firstInterestDataDelay),
+ "ns3::ndn::Consumer::FirstInterestDataDelayCallback");
return tid;
}
Consumer::Consumer()
- : m_rand(0, std::numeric_limits<uint32_t>::max())
+ : m_rand(CreateObject<UniformRandomVariable>())
, m_seq(0)
, m_seqMax(0) // don't request anything
{
@@ -185,7 +187,7 @@
// shared_ptr<Interest> interest = make_shared<Interest> ();
shared_ptr<Interest> interest = make_shared<Interest>();
- interest->setNonce(m_rand.GetValue());
+ interest->setNonce(m_rand->GetValue(0, std::numeric_limits<uint32_t>::max()));
interest->setName(*nameWithSequence);
time::milliseconds interestLifeTime(m_interestLifeTime.GetMilliSeconds());
interest->setInterestLifetime(interestLifeTime);
diff --git a/apps/ndn-consumer.hpp b/apps/ndn-consumer.hpp
index 665e20f..0906f07 100644
--- a/apps/ndn-consumer.hpp
+++ b/apps/ndn-consumer.hpp
@@ -24,7 +24,7 @@
#include "ndn-app.hpp"
-#include "ns3/random-variable.h"
+#include "ns3/random-variable-stream.h"
#include "ns3/nstime.h"
#include "ns3/data-rate.h"
@@ -89,6 +89,10 @@
virtual void
WillSendOutInterest(uint32_t sequenceNumber);
+public:
+ typedef void (*LastRetransmittedInterestDataDelayCallback)(Ptr<App> app, uint32_t seqno, Time delay, int32_t hopCount);
+ typedef void (*FirstInterestDataDelayCallback)(Ptr<App> app, uint32_t seqno, Time delay, uint32_t retxCount, int32_t hopCount);
+
protected:
// from App
virtual void
@@ -125,7 +129,7 @@
GetRetxTimer() const;
protected:
- UniformVariable m_rand; ///< @brief nonce generator
+ Ptr<UniformRandomVariable> m_rand; ///< @brief nonce generator
uint32_t m_seq; ///< @brief currently requested sequence number
uint32_t m_seqMax; ///< @brief maximum number of sequence number