Another set of refactoring
diff --git a/apps/ndn-app.cc b/apps/ndn-app.cc
index 54ea5c6..ab119d1 100644
--- a/apps/ndn-app.cc
+++ b/apps/ndn-app.cc
@@ -25,57 +25,57 @@
#include "ns3/ndn-interest-header.h"
#include "ns3/ndn-content-object-header.h"
-#include "ns3/ndn.h"
+#include "ns3/ndn-l3-protocol.h"
#include "ns3/ndn-fib.h"
#include "ns3/ndn-app-face.h"
#include "ns3/ndn-forwarding-strategy.h"
-NS_LOG_COMPONENT_DEFINE ("NdnApp");
+NS_LOG_COMPONENT_DEFINE ("ndn.App");
-namespace ns3
-{
+namespace ns3 {
+namespace ndn {
-NS_OBJECT_ENSURE_REGISTERED (NdnApp);
+NS_OBJECT_ENSURE_REGISTERED (App);
TypeId
-NdnApp::GetTypeId (void)
+App::GetTypeId (void)
{
- static TypeId tid = TypeId ("ns3::NdnApp")
+ static TypeId tid = TypeId ("ns3::ndn::App")
.SetGroupName ("Ndn")
.SetParent<Application> ()
- .AddConstructor<NdnApp> ()
+ .AddConstructor<App> ()
.AddTraceSource ("ReceivedInterests", "ReceivedInterests",
- MakeTraceSourceAccessor (&NdnApp::m_receivedInterests))
+ MakeTraceSourceAccessor (&App::m_receivedInterests))
.AddTraceSource ("ReceivedNacks", "ReceivedNacks",
- MakeTraceSourceAccessor (&NdnApp::m_receivedNacks))
+ MakeTraceSourceAccessor (&App::m_receivedNacks))
.AddTraceSource ("ReceivedContentObjects", "ReceivedContentObjects",
- MakeTraceSourceAccessor (&NdnApp::m_receivedContentObjects))
+ MakeTraceSourceAccessor (&App::m_receivedContentObjects))
.AddTraceSource ("TransmittedInterests", "TransmittedInterests",
- MakeTraceSourceAccessor (&NdnApp::m_transmittedInterests))
+ MakeTraceSourceAccessor (&App::m_transmittedInterests))
.AddTraceSource ("TransmittedContentObjects", "TransmittedContentObjects",
- MakeTraceSourceAccessor (&NdnApp::m_transmittedContentObjects))
+ MakeTraceSourceAccessor (&App::m_transmittedContentObjects))
;
return tid;
}
-NdnApp::NdnApp ()
+App::App ()
: m_protocolHandler (0)
, m_active (false)
, m_face (0)
{
}
-NdnApp::~NdnApp ()
+App::~App ()
{
}
void
-NdnApp::DoDispose (void)
+App::DoDispose (void)
{
NS_LOG_FUNCTION_NOARGS ();
@@ -86,27 +86,27 @@
}
void
-NdnApp::RegisterProtocolHandler (ProtocolHandler handler)
+App::RegisterProtocolHandler (ProtocolHandler handler)
{
m_protocolHandler = handler;
}
void
-NdnApp::OnInterest (const Ptr<const NdnInterestHeader> &interest, Ptr<Packet> packet)
+App::OnInterest (const Ptr<const InterestHeader> &interest, Ptr<Packet> packet)
{
NS_LOG_FUNCTION (this << interest);
m_receivedInterests (interest, this, m_face);
}
void
-NdnApp::OnNack (const Ptr<const NdnInterestHeader> &interest, Ptr<Packet> packet)
+App::OnNack (const Ptr<const InterestHeader> &interest, Ptr<Packet> packet)
{
NS_LOG_FUNCTION (this << interest);
m_receivedNacks (interest, this, m_face);
}
void
-NdnApp::OnContentObject (const Ptr<const NdnContentObjectHeader> &contentObject,
+App::OnContentObject (const Ptr<const ContentObjectHeader> &contentObject,
Ptr<Packet> payload)
{
NS_LOG_FUNCTION (this << contentObject << payload);
@@ -115,34 +115,34 @@
// Application Methods
void
-NdnApp::StartApplication () // Called at time specified by Start
+App::StartApplication () // Called at time specified by Start
{
NS_LOG_FUNCTION_NOARGS ();
NS_ASSERT (m_active != true);
m_active = true;
- NS_ASSERT_MSG (GetNode ()->GetObject<Ndn> () != 0,
+ NS_ASSERT_MSG (GetNode ()->GetObject<L3Protocol> () != 0,
"Ndn stack should be installed on the node " << GetNode ());
// step 1. Create a face
- m_face = CreateObject<NdnAppFace> (/*Ptr<NdnApp> (this)*/this);
+ m_face = CreateObject<AppFace> (/*Ptr<App> (this)*/this);
// step 2. Add face to the Ndn stack
- GetNode ()->GetObject<Ndn> ()->AddFace (m_face);
+ GetNode ()->GetObject<L3Protocol> ()->AddFace (m_face);
// step 3. Enable face
m_face->SetUp (true);
}
void
-NdnApp::StopApplication () // Called at time specified by Stop
+App::StopApplication () // Called at time specified by Stop
{
NS_LOG_FUNCTION_NOARGS ();
if (!m_active) return; //don't assert here, just return
- NS_ASSERT (GetNode ()->GetObject<Ndn> () != 0);
+ NS_ASSERT (GetNode ()->GetObject<L3Protocol> () != 0);
m_active = false;
@@ -150,9 +150,9 @@
m_face->SetUp (false);
// step 2. Remove face from Ndn stack
- GetNode ()->GetObject<Ndn> ()->RemoveFace (m_face);
- GetNode ()->GetObject<NdnFib> ()->RemoveFromAll (m_face);
- GetNode ()->GetObject<NdnForwardingStrategy> ()->RemoveFace (m_face); // notify that face is removed
+ GetNode ()->GetObject<L3Protocol> ()->RemoveFace (m_face);
+ GetNode ()->GetObject<Fib> ()->RemoveFromAll (m_face);
+ GetNode ()->GetObject<ForwardingStrategy> ()->RemoveFace (m_face); // notify that face is removed
// step 3. Destroy face
NS_ASSERT_MSG (m_face->GetReferenceCount ()==1,
@@ -161,4 +161,5 @@
m_face = 0;
}
-}
+} // namespace ndn
+} // namespace ns3
diff --git a/apps/ndn-app.h b/apps/ndn-app.h
index c152ff2..f61d54b 100644
--- a/apps/ndn-app.h
+++ b/apps/ndn-app.h
@@ -26,25 +26,27 @@
#include "ns3/callback.h"
#include "ns3/traced-callback.h"
-namespace ns3
-{
+namespace ns3 {
class Packet;
-class NdnInterestHeader;
-class NdnContentObjectHeader;
-class NdnFace;
+
+namespace ndn {
+
+class InterestHeader;
+class ContentObjectHeader;
+class Face;
/**
* @ingroup ndn
- * @brief Base class that all Ndn applications should be derived from.
+ * @brief Base class that all NDN applications should be derived from.
*
* The class implements virtual calls onInterest, onNack, and onContentObject
*/
-class NdnApp: public Application
+class App: public Application
{
public:
/**
- * @brief A callback to pass packets to underlying Ndn protocol
+ * @brief A callback to pass packets to underlying NDN protocol
*/
typedef Callback<bool, const Ptr<const Packet>&> ProtocolHandler;
@@ -53,8 +55,8 @@
/**
* @brief Default constructor
*/
- NdnApp ();
- virtual ~NdnApp ();
+ App ();
+ virtual ~App ();
/**
* @brief Register lower layer callback (to send interests from the application)
@@ -69,14 +71,14 @@
* may be useful to get packet tags
*/
virtual void
- OnInterest (const Ptr<const NdnInterestHeader> &interest, Ptr<Packet> packet);
+ OnInterest (const Ptr<const InterestHeader> &interest, Ptr<Packet> packet);
/**
* @brief Method that will be called every time new NACK arrives
* @param interest Interest header
*/
virtual void
- OnNack (const Ptr<const NdnInterestHeader> &interest, Ptr<Packet> packet);
+ OnNack (const Ptr<const InterestHeader> &interest, Ptr<Packet> packet);
/**
* @brief Method that will be called every time new ContentObject arrives
@@ -84,7 +86,7 @@
* @param payload payload (potentially virtual) of the ContentObject packet (may include packet tags of original packet)
*/
virtual void
- OnContentObject (const Ptr<const NdnContentObjectHeader> &contentObject,
+ OnContentObject (const Ptr<const ContentObjectHeader> &contentObject,
Ptr<Packet> payload);
protected:
@@ -102,27 +104,28 @@
StopApplication (); ///< @brief Called at time specified by Stop
protected:
- ProtocolHandler m_protocolHandler; ///< @brief A callback to pass packets to underlying Ndn protocol
+ ProtocolHandler m_protocolHandler; ///< @brief A callback to pass packets to underlying NDN protocol
bool m_active; ///< @brief Flag to indicate that application is active (set by StartApplication and StopApplication)
- Ptr<NdnFace> m_face; ///< @brief automatically created application face through which application communicates
+ Ptr<Face> m_face; ///< @brief automatically created application face through which application communicates
- TracedCallback<Ptr<const NdnInterestHeader>,
- Ptr<NdnApp>, Ptr<NdnFace> > m_receivedInterests; ///< @brief App-level trace of received Interests
+ TracedCallback<Ptr<const InterestHeader>,
+ Ptr<App>, Ptr<Face> > m_receivedInterests; ///< @brief App-level trace of received Interests
- TracedCallback<Ptr<const NdnInterestHeader>,
- Ptr<NdnApp>, Ptr<NdnFace> > m_receivedNacks; ///< @brief App-level trace of received NACKs
+ TracedCallback<Ptr<const InterestHeader>,
+ Ptr<App>, Ptr<Face> > m_receivedNacks; ///< @brief App-level trace of received NACKs
- TracedCallback<Ptr<const NdnContentObjectHeader>, Ptr<const Packet>,
- Ptr<NdnApp>, Ptr<NdnFace> > m_receivedContentObjects; ///< @brief App-level trace of received Data
+ TracedCallback<Ptr<const ContentObjectHeader>, Ptr<const Packet>,
+ Ptr<App>, Ptr<Face> > m_receivedContentObjects; ///< @brief App-level trace of received Data
- TracedCallback<Ptr<const NdnInterestHeader>,
- Ptr<NdnApp>, Ptr<NdnFace> > m_transmittedInterests; ///< @brief App-level trace of transmitted Interests
+ TracedCallback<Ptr<const InterestHeader>,
+ Ptr<App>, Ptr<Face> > m_transmittedInterests; ///< @brief App-level trace of transmitted Interests
- TracedCallback<Ptr<const NdnContentObjectHeader>, Ptr<const Packet>,
- Ptr<NdnApp>, Ptr<NdnFace> > m_transmittedContentObjects; ///< @brief App-level trace of transmitted Data
+ TracedCallback<Ptr<const ContentObjectHeader>, Ptr<const Packet>,
+ Ptr<App>, Ptr<Face> > m_transmittedContentObjects; ///< @brief App-level trace of transmitted Data
};
+} // namespace ndn
} // namespace ns3
#endif // NDN_APP_H
diff --git a/apps/ndn-consumer-batches.cc b/apps/ndn-consumer-batches.cc
index c7de149..e66b741 100644
--- a/apps/ndn-consumer-batches.cc
+++ b/apps/ndn-consumer-batches.cc
@@ -29,47 +29,47 @@
#include "ns3/double.h"
#include "ns3/batches.h"
-NS_LOG_COMPONENT_DEFINE ("NdnConsumerBatches");
+NS_LOG_COMPONENT_DEFINE ("ndn.ConsumerBatches");
-namespace ns3
-{
+namespace ns3 {
+namespace ndn {
-NS_OBJECT_ENSURE_REGISTERED (NdnConsumerBatches);
+NS_OBJECT_ENSURE_REGISTERED (ConsumerBatches);
TypeId
-NdnConsumerBatches::GetTypeId (void)
+ConsumerBatches::GetTypeId (void)
{
- static TypeId tid = TypeId ("ns3::NdnConsumerBatches")
+ static TypeId tid = TypeId ("ns3::ndn::ConsumerBatches")
.SetGroupName ("Ndn")
- .SetParent<NdnConsumer> ()
- .AddConstructor<NdnConsumerBatches> ()
+ .SetParent<Consumer> ()
+ .AddConstructor<ConsumerBatches> ()
.AddAttribute ("Batches", "Batches to schedule. Should be vector, containing pairs of time and amount",
// TypeId::ATTR_SET,
StringValue (""),
- MakeBatchesAccessor (&NdnConsumerBatches::GetBatch, &NdnConsumerBatches::SetBatch),
+ MakeBatchesAccessor (&ConsumerBatches::GetBatch, &ConsumerBatches::SetBatch),
MakeBatchesChecker ())
;
return tid;
}
-NdnConsumerBatches::NdnConsumerBatches ()
+ConsumerBatches::ConsumerBatches ()
{
}
void
-NdnConsumerBatches::SetBatch (const Batches &batches)
+ConsumerBatches::SetBatch (const Batches &batches)
{
// std::cout << "Batches: " << batches << "\n";
for (Batches::const_iterator i = batches.begin (); i != batches.end (); i++)
{
- Simulator::Schedule (i->get<0> (), &NdnConsumerBatches::AddBatch, this, i->get<1> ());
+ Simulator::Schedule (i->get<0> (), &ConsumerBatches::AddBatch, this, i->get<1> ());
}
}
void
-NdnConsumerBatches::AddBatch (uint32_t amount)
+ConsumerBatches::AddBatch (uint32_t amount)
{
// std::cout << Simulator::Now () << " adding batch of " << amount << "\n";
m_seqMax += amount;
@@ -78,14 +78,15 @@
}
void
-NdnConsumerBatches::ScheduleNextPacket ()
+ConsumerBatches::ScheduleNextPacket ()
{
if (!m_sendEvent.IsRunning ())
- m_sendEvent = Simulator::Schedule (Seconds (m_rtt->RetransmitTimeout ().ToDouble (Time::S) * 0.1), &NdnConsumer::SendPacket, this);
+ m_sendEvent = Simulator::Schedule (Seconds (m_rtt->RetransmitTimeout ().ToDouble (Time::S) * 0.1), &Consumer::SendPacket, this);
}
///////////////////////////////////////////////////
// Process incoming packets //
///////////////////////////////////////////////////
+} // namespace ndn
} // namespace ns3
diff --git a/apps/ndn-consumer-batches.h b/apps/ndn-consumer-batches.h
index f177551..c7479da 100644
--- a/apps/ndn-consumer-batches.h
+++ b/apps/ndn-consumer-batches.h
@@ -25,14 +25,14 @@
#include "ns3/traced-value.h"
#include "ns3/batches.h"
-namespace ns3
-{
+namespace ns3 {
+namespace ndn {
/**
* @ingroup ndn
* \brief Ndn application for sending out Interest packets in batches
*/
-class NdnConsumerBatches: public NdnConsumer
+class ConsumerBatches: public Consumer
{
public:
static TypeId GetTypeId ();
@@ -40,17 +40,17 @@
/**
* \brief Default constructor
*/
- NdnConsumerBatches ();
+ ConsumerBatches ();
- // From NdnApp
+ // From App
// virtual void
- // OnInterest (const Ptr<const NdnInterestHeader> &interest);
+ // OnInterest (const Ptr<const InterestHeader> &interest);
// virtual void
- // OnNack (const Ptr<const NdnInterestHeader> &interest);
+ // OnNack (const Ptr<const InterestHeader> &interest);
// virtual void
- // OnContentObject (const Ptr<const NdnContentObjectHeader> &contentObject,
+ // OnContentObject (const Ptr<const ContentObjectHeader> &contentObject,
// const Ptr<const Packet> &payload);
// virtual void
@@ -67,12 +67,13 @@
AddBatch (uint32_t amount);
protected:
/**
- * \brief Constructs the Interest packet and sends it using a callback to the underlying Ndn protocol
+ * \brief Constructs the Interest packet and sends it using a callback to the underlying NDN protocol
*/
virtual void
ScheduleNextPacket ();
};
+} // namespace ndn
} // namespace ns3
#endif
diff --git a/apps/ndn-consumer-cbr.cc b/apps/ndn-consumer-cbr.cc
index ef52ef5..831e06c 100644
--- a/apps/ndn-consumer-cbr.cc
+++ b/apps/ndn-consumer-cbr.cc
@@ -34,35 +34,35 @@
#include "ns3/ndn-interest-header.h"
#include "ns3/ndn-content-object-header.h"
-NS_LOG_COMPONENT_DEFINE ("NdnConsumerCbr");
+NS_LOG_COMPONENT_DEFINE ("ndn.ConsumerCbr");
-namespace ns3
-{
+namespace ns3 {
+namespace ndn {
-NS_OBJECT_ENSURE_REGISTERED (NdnConsumerCbr);
+NS_OBJECT_ENSURE_REGISTERED (ConsumerCbr);
TypeId
-NdnConsumerCbr::GetTypeId (void)
+ConsumerCbr::GetTypeId (void)
{
- static TypeId tid = TypeId ("ns3::NdnConsumerCbr")
+ static TypeId tid = TypeId ("ns3::ndn::ConsumerCbr")
.SetGroupName ("Ndn")
- .SetParent<NdnConsumer> ()
- .AddConstructor<NdnConsumerCbr> ()
+ .SetParent<Consumer> ()
+ .AddConstructor<ConsumerCbr> ()
.AddAttribute ("Frequency", "Frequency of interest packets",
StringValue ("1.0"),
- MakeDoubleAccessor (&NdnConsumerCbr::m_frequency),
+ MakeDoubleAccessor (&ConsumerCbr::m_frequency),
MakeDoubleChecker<double> ())
.AddAttribute ("Randomize", "Type of send time randomization: none (default), uniform, exponential",
StringValue ("none"),
- MakeStringAccessor (&NdnConsumerCbr::SetRandomize, &NdnConsumerCbr::GetRandomize),
+ MakeStringAccessor (&ConsumerCbr::SetRandomize, &ConsumerCbr::GetRandomize),
MakeStringChecker ())
;
return tid;
}
-NdnConsumerCbr::NdnConsumerCbr ()
+ConsumerCbr::ConsumerCbr ()
: m_frequency (1.0)
, m_firstTime (true)
, m_random (0)
@@ -71,14 +71,14 @@
m_seqMax = std::numeric_limits<uint32_t>::max ();
}
-NdnConsumerCbr::~NdnConsumerCbr ()
+ConsumerCbr::~ConsumerCbr ()
{
if (m_random)
delete m_random;
}
void
-NdnConsumerCbr::ScheduleNextPacket ()
+ConsumerCbr::ScheduleNextPacket ()
{
// double mean = 8.0 * m_payloadSize / m_desiredRate.GetBitRate ();
// std::cout << "next: " << Simulator::Now().ToDouble(Time::S) + mean << "s\n";
@@ -86,7 +86,7 @@
if (m_firstTime)
{
m_sendEvent = Simulator::Schedule (Seconds (0.0),
- &NdnConsumer::SendPacket, this);
+ &Consumer::SendPacket, this);
m_firstTime = false;
}
else if (!m_sendEvent.IsRunning ())
@@ -95,11 +95,11 @@
Seconds(1.0 / m_frequency)
:
Seconds(m_random->GetValue ()),
- &NdnConsumer::SendPacket, this);
+ &Consumer::SendPacket, this);
}
void
-NdnConsumerCbr::SetRandomize (const std::string &value)
+ConsumerCbr::SetRandomize (const std::string &value)
{
if (m_random)
delete m_random;
@@ -119,7 +119,7 @@
}
std::string
-NdnConsumerCbr::GetRandomize () const
+ConsumerCbr::GetRandomize () const
{
return m_randomType;
}
@@ -130,16 +130,17 @@
///////////////////////////////////////////////////
// void
-// NdnConsumer::OnContentObject (const Ptr<const NdnContentObjectHeader> &contentObject,
+// Consumer::OnContentObject (const Ptr<const ContentObjectHeader> &contentObject,
// const Ptr<const Packet> &payload)
// {
-// NdnConsumer::OnContentObject (contentObject, payload); // tracing inside
+// Consumer::OnContentObject (contentObject, payload); // tracing inside
// }
// void
-// NdnConsumer::OnNack (const Ptr<const NdnInterestHeader> &interest)
+// Consumer::OnNack (const Ptr<const InterestHeader> &interest)
// {
-// NdnConsumer::OnNack (interest); // tracing inside
+// Consumer::OnNack (interest); // tracing inside
// }
+} // namespace ndn
} // namespace ns3
diff --git a/apps/ndn-consumer-cbr.h b/apps/ndn-consumer-cbr.h
index 6916d7a..26fef1d 100644
--- a/apps/ndn-consumer-cbr.h
+++ b/apps/ndn-consumer-cbr.h
@@ -24,14 +24,14 @@
#include "ndn-consumer.h"
-namespace ns3
-{
+namespace ns3 {
+namespace ndn {
/**
* @ingroup ndn
* \brief Ndn application for sending out Interest packets at a "constant" rate (Poisson process)
*/
-class NdnConsumerCbr: public NdnConsumer
+class ConsumerCbr: public Consumer
{
public:
static TypeId GetTypeId ();
@@ -40,23 +40,23 @@
* \brief Default constructor
* Sets up randomizer function and packet sequence number
*/
- NdnConsumerCbr ();
- virtual ~NdnConsumerCbr ();
+ ConsumerCbr ();
+ virtual ~ConsumerCbr ();
// From NdnApp
// virtual void
- // OnInterest (const Ptr<const NdnInterestHeader> &interest);
+ // OnInterest (const Ptr<const InterestHeader> &interest);
// virtual void
- // OnNack (const Ptr<const NdnInterestHeader> &interest);
+ // OnNack (const Ptr<const InterestHeader> &interest);
// virtual void
- // OnContentObject (const Ptr<const NdnContentObjectHeader> &contentObject,
+ // OnContentObject (const Ptr<const ContentObjectHeader> &contentObject,
// const Ptr<const Packet> &payload);
protected:
/**
- * \brief Constructs the Interest packet and sends it using a callback to the underlying Ndn protocol
+ * \brief Constructs the Interest packet and sends it using a callback to the underlying NDN protocol
*/
virtual void
ScheduleNextPacket ();
@@ -95,6 +95,7 @@
std::string m_randomType;
};
+} // namespace ndn
} // namespace ns3
#endif
diff --git a/apps/ndn-consumer-window.cc b/apps/ndn-consumer-window.cc
index 242456a..86457c8 100644
--- a/apps/ndn-consumer-window.cc
+++ b/apps/ndn-consumer-window.cc
@@ -28,78 +28,78 @@
#include "ns3/uinteger.h"
#include "ns3/double.h"
-NS_LOG_COMPONENT_DEFINE ("NdnConsumerWindow");
+NS_LOG_COMPONENT_DEFINE ("ndn.ConsumerWindow");
-namespace ns3
-{
+namespace ns3 {
+namespace ndn {
-NS_OBJECT_ENSURE_REGISTERED (NdnConsumerWindow);
+NS_OBJECT_ENSURE_REGISTERED (ConsumerWindow);
TypeId
-NdnConsumerWindow::GetTypeId (void)
+ConsumerWindow::GetTypeId (void)
{
- static TypeId tid = TypeId ("ns3::NdnConsumerWindow")
+ static TypeId tid = TypeId ("ns3::ndn::ConsumerWindow")
.SetGroupName ("Ndn")
- .SetParent<NdnConsumer> ()
- .AddConstructor<NdnConsumerWindow> ()
+ .SetParent<Consumer> ()
+ .AddConstructor<ConsumerWindow> ()
.AddAttribute ("Window", "Initial size of the window",
StringValue ("1"),
- MakeUintegerAccessor (&NdnConsumerWindow::GetWindow, &NdnConsumerWindow::SetWindow),
+ MakeUintegerAccessor (&ConsumerWindow::GetWindow, &ConsumerWindow::SetWindow),
MakeUintegerChecker<uint32_t> ())
.AddAttribute ("PayloadSize", "Average size of content object size (to calculate interest generation rate)",
UintegerValue (1040),
- MakeUintegerAccessor (&NdnConsumerWindow::GetPayloadSize, &NdnConsumerWindow::SetPayloadSize),
+ MakeUintegerAccessor (&ConsumerWindow::GetPayloadSize, &ConsumerWindow::SetPayloadSize),
MakeUintegerChecker<uint32_t>())
.AddAttribute ("Size", "Amount of data in megabytes to request (relies on PayloadSize parameter)",
DoubleValue (-1), // don't impose limit by default
- MakeDoubleAccessor (&NdnConsumerWindow::GetMaxSize, &NdnConsumerWindow::SetMaxSize),
+ MakeDoubleAccessor (&ConsumerWindow::GetMaxSize, &ConsumerWindow::SetMaxSize),
MakeDoubleChecker<double> ())
.AddTraceSource ("WindowTrace",
"Window that controls how many outstanding interests are allowed",
- MakeTraceSourceAccessor (&NdnConsumerWindow::m_window))
+ MakeTraceSourceAccessor (&ConsumerWindow::m_window))
.AddTraceSource ("InFlight",
"Current number of outstanding interests",
- MakeTraceSourceAccessor (&NdnConsumerWindow::m_window))
+ MakeTraceSourceAccessor (&ConsumerWindow::m_window))
;
return tid;
}
-NdnConsumerWindow::NdnConsumerWindow ()
+ConsumerWindow::ConsumerWindow ()
: m_payloadSize (1040)
, m_inFlight (0)
{
}
void
-NdnConsumerWindow::SetWindow (uint32_t window)
+ConsumerWindow::SetWindow (uint32_t window)
{
m_window = window;
}
uint32_t
-NdnConsumerWindow::GetWindow () const
+ConsumerWindow::GetWindow () const
{
return m_window;
}
uint32_t
-NdnConsumerWindow::GetPayloadSize () const
+ConsumerWindow::GetPayloadSize () const
{
return m_payloadSize;
}
void
-NdnConsumerWindow::SetPayloadSize (uint32_t payload)
+ConsumerWindow::SetPayloadSize (uint32_t payload)
{
m_payloadSize = payload;
}
double
-NdnConsumerWindow::GetMaxSize () const
+ConsumerWindow::GetMaxSize () const
{
if (m_seqMax == 0)
return -1.0;
@@ -108,7 +108,7 @@
}
void
-NdnConsumerWindow::SetMaxSize (double size)
+ConsumerWindow::SetMaxSize (double size)
{
m_maxSize = size;
if (m_maxSize < 0)
@@ -124,12 +124,12 @@
void
-NdnConsumerWindow::ScheduleNextPacket ()
+ConsumerWindow::ScheduleNextPacket ()
{
if (m_window == static_cast<uint32_t> (0) || m_inFlight >= m_window)
{
if (!m_sendEvent.IsRunning ())
- m_sendEvent = Simulator::Schedule (Seconds (m_rtt->RetransmitTimeout ().ToDouble (Time::S) * 0.1), &NdnConsumer::SendPacket, this);
+ m_sendEvent = Simulator::Schedule (Seconds (m_rtt->RetransmitTimeout ().ToDouble (Time::S) * 0.1), &Consumer::SendPacket, this);
return;
}
@@ -137,7 +137,7 @@
if (!m_sendEvent.IsRunning ())
{
m_inFlight++;
- m_sendEvent = Simulator::ScheduleNow (&NdnConsumer::SendPacket, this);
+ m_sendEvent = Simulator::ScheduleNow (&Consumer::SendPacket, this);
}
}
@@ -146,10 +146,10 @@
///////////////////////////////////////////////////
void
-NdnConsumerWindow::OnContentObject (const Ptr<const NdnContentObjectHeader> &contentObject,
+ConsumerWindow::OnContentObject (const Ptr<const ContentObjectHeader> &contentObject,
Ptr<Packet> payload)
{
- NdnConsumer::OnContentObject (contentObject, payload);
+ Consumer::OnContentObject (contentObject, payload);
m_window = m_window + 1;
@@ -158,9 +158,9 @@
}
void
-NdnConsumerWindow::OnNack (const Ptr<const NdnInterestHeader> &interest, Ptr<Packet> payload)
+ConsumerWindow::OnNack (const Ptr<const InterestHeader> &interest, Ptr<Packet> payload)
{
- NdnConsumer::OnNack (interest, payload);
+ Consumer::OnNack (interest, payload);
if (m_inFlight > static_cast<uint32_t> (0)) m_inFlight--;
if (m_window > static_cast<uint32_t> (0))
@@ -171,10 +171,11 @@
}
void
-NdnConsumerWindow::OnTimeout (uint32_t sequenceNumber)
+ConsumerWindow::OnTimeout (uint32_t sequenceNumber)
{
if (m_inFlight > static_cast<uint32_t> (0)) m_inFlight--;
- NdnConsumer::OnTimeout (sequenceNumber);
+ Consumer::OnTimeout (sequenceNumber);
}
+} // namespace ndn
} // namespace ns3
diff --git a/apps/ndn-consumer-window.h b/apps/ndn-consumer-window.h
index 5d9adff..5713c70 100644
--- a/apps/ndn-consumer-window.h
+++ b/apps/ndn-consumer-window.h
@@ -25,8 +25,8 @@
#include "ndn-consumer.h"
#include "ns3/traced-value.h"
-namespace ns3
-{
+namespace ns3 {
+namespace ndn {
/**
* @ingroup ndn
@@ -35,7 +35,7 @@
* !!! ATTENTION !!! This is highly experimental and relies on experimental features of the simulator.
* Behavior may be unpredictable if used incorrectly.
*/
-class NdnConsumerWindow: public NdnConsumer
+class ConsumerWindow: public Consumer
{
public:
static TypeId GetTypeId ();
@@ -43,17 +43,17 @@
/**
* \brief Default constructor
*/
- NdnConsumerWindow ();
+ ConsumerWindow ();
- // From NdnApp
+ // From App
// virtual void
- // OnInterest (const Ptr<const NdnInterestHeader> &interest);
+ // OnInterest (const Ptr<const InterestHeader> &interest);
virtual void
- OnNack (const Ptr<const NdnInterestHeader> &interest, Ptr<Packet> payload);
+ OnNack (const Ptr<const InterestHeader> &interest, Ptr<Packet> payload);
virtual void
- OnContentObject (const Ptr<const NdnContentObjectHeader> &contentObject,
+ OnContentObject (const Ptr<const ContentObjectHeader> &contentObject,
Ptr<Packet> payload);
virtual void
@@ -61,7 +61,7 @@
protected:
/**
- * \brief Constructs the Interest packet and sends it using a callback to the underlying Ndn protocol
+ * \brief Constructs the Interest packet and sends it using a callback to the underlying NDN protocol
*/
virtual void
ScheduleNextPacket ();
@@ -93,6 +93,7 @@
TracedValue<uint32_t> m_inFlight;
};
+} // namespace ndn
} // namespace ns3
#endif
diff --git a/apps/ndn-consumer.cc b/apps/ndn-consumer.cc
index 6d976fc..dd61f74 100644
--- a/apps/ndn-consumer.cc
+++ b/apps/ndn-consumer.cc
@@ -44,63 +44,63 @@
namespace ll = boost::lambda;
-NS_LOG_COMPONENT_DEFINE ("NdnConsumer");
+NS_LOG_COMPONENT_DEFINE ("ndn.Consumer");
-namespace ns3
-{
+namespace ns3 {
+namespace ndn {
-NS_OBJECT_ENSURE_REGISTERED (NdnConsumer);
+NS_OBJECT_ENSURE_REGISTERED (Consumer);
TypeId
-NdnConsumer::GetTypeId (void)
+Consumer::GetTypeId (void)
{
- static TypeId tid = TypeId ("ns3::NdnConsumer")
+ static TypeId tid = TypeId ("ns3::ndn::Consumer")
.SetGroupName ("Ndn")
- .SetParent<NdnApp> ()
+ .SetParent<App> ()
.AddAttribute ("StartSeq", "Initial sequence number",
IntegerValue (0),
- MakeIntegerAccessor(&NdnConsumer::m_seq),
+ MakeIntegerAccessor(&Consumer::m_seq),
MakeIntegerChecker<int32_t>())
- .AddAttribute ("Prefix","NdnName of the Interest",
+ .AddAttribute ("Prefix","Name of the Interest",
StringValue ("/"),
- MakeNdnNameComponentsAccessor (&NdnConsumer::m_interestName),
- MakeNdnNameComponentsChecker ())
+ MakeNameComponentsAccessor (&Consumer::m_interestName),
+ MakeNameComponentsChecker ())
.AddAttribute ("LifeTime", "LifeTime for interest packet",
StringValue ("2s"),
- MakeTimeAccessor (&NdnConsumer::m_interestLifeTime),
+ MakeTimeAccessor (&Consumer::m_interestLifeTime),
MakeTimeChecker ())
.AddAttribute ("MinSuffixComponents", "MinSuffixComponents",
IntegerValue(-1),
- MakeIntegerAccessor(&NdnConsumer::m_minSuffixComponents),
+ MakeIntegerAccessor(&Consumer::m_minSuffixComponents),
MakeIntegerChecker<int32_t>())
.AddAttribute ("MaxSuffixComponents", "MaxSuffixComponents",
IntegerValue(-1),
- MakeIntegerAccessor(&NdnConsumer::m_maxSuffixComponents),
+ MakeIntegerAccessor(&Consumer::m_maxSuffixComponents),
MakeIntegerChecker<int32_t>())
.AddAttribute ("ChildSelector", "ChildSelector",
BooleanValue(false),
- MakeBooleanAccessor(&NdnConsumer::m_childSelector),
+ MakeBooleanAccessor(&Consumer::m_childSelector),
MakeBooleanChecker())
- .AddAttribute ("Exclude", "only simple name matching is supported (use NdnNameComponents)",
- NdnNameComponentsValue (),
- MakeNdnNameComponentsAccessor (&NdnConsumer::m_exclude),
- MakeNdnNameComponentsChecker ())
+ .AddAttribute ("Exclude", "only simple name matching is supported (use NameComponents)",
+ NameComponentsValue (),
+ MakeNameComponentsAccessor (&Consumer::m_exclude),
+ MakeNameComponentsChecker ())
.AddAttribute ("RetxTimer",
"Timeout defining how frequent retransmission timeouts should be checked",
StringValue ("50ms"),
- MakeTimeAccessor (&NdnConsumer::GetRetxTimer, &NdnConsumer::SetRetxTimer),
+ MakeTimeAccessor (&Consumer::GetRetxTimer, &Consumer::SetRetxTimer),
MakeTimeChecker ())
.AddTraceSource ("PathWeightsTrace", "PathWeightsTrace",
- MakeTraceSourceAccessor (&NdnConsumer::m_pathWeightsTrace))
+ MakeTraceSourceAccessor (&Consumer::m_pathWeightsTrace))
;
return tid;
}
-NdnConsumer::NdnConsumer ()
+Consumer::Consumer ()
: m_rand (0, std::numeric_limits<uint32_t>::max ())
, m_seq (0)
, m_seqMax (0) // don't request anything
@@ -111,7 +111,7 @@
}
void
-NdnConsumer::SetRetxTimer (Time retxTimer)
+Consumer::SetRetxTimer (Time retxTimer)
{
m_retxTimer = retxTimer;
if (m_retxEvent.IsRunning ())
@@ -119,17 +119,17 @@
// schedule even with new timeout
m_retxEvent = Simulator::Schedule (m_retxTimer,
- &NdnConsumer::CheckRetxTimeout, this);
+ &Consumer::CheckRetxTimeout, this);
}
Time
-NdnConsumer::GetRetxTimer () const
+Consumer::GetRetxTimer () const
{
return m_retxTimer;
}
void
-NdnConsumer::CheckRetxTimeout ()
+Consumer::CheckRetxTimeout ()
{
Time now = Simulator::Now ();
@@ -150,23 +150,23 @@
}
m_retxEvent = Simulator::Schedule (m_retxTimer,
- &NdnConsumer::CheckRetxTimeout, this);
+ &Consumer::CheckRetxTimeout, this);
}
// Application Methods
void
-NdnConsumer::StartApplication () // Called at time specified by Start
+Consumer::StartApplication () // Called at time specified by Start
{
NS_LOG_FUNCTION_NOARGS ();
// do base stuff
- NdnApp::StartApplication ();
+ App::StartApplication ();
ScheduleNextPacket ();
}
void
-NdnConsumer::StopApplication () // Called at time specified by Stop
+Consumer::StopApplication () // Called at time specified by Stop
{
NS_LOG_FUNCTION_NOARGS ();
@@ -174,11 +174,11 @@
Simulator::Cancel (m_sendEvent);
// cleanup base stuff
- NdnApp::StopApplication ();
+ App::StopApplication ();
}
void
-NdnConsumer::SendPacket ()
+Consumer::SendPacket ()
{
if (!m_active) return;
@@ -220,18 +220,18 @@
// std::cout << Simulator::Now ().ToDouble (Time::S) << "s -> " << seq << "\n";
//
- Ptr<NdnNameComponents> nameWithSequence = Create<NdnNameComponents> (m_interestName);
+ Ptr<NameComponents> nameWithSequence = Create<NameComponents> (m_interestName);
(*nameWithSequence) (seq);
//
- NdnInterestHeader interestHeader;
+ InterestHeader interestHeader;
interestHeader.SetNonce (m_rand.GetValue ());
interestHeader.SetName (nameWithSequence);
interestHeader.SetInterestLifetime (m_interestLifeTime);
interestHeader.SetChildSelector (m_childSelector);
if (m_exclude.size ()>0)
{
- interestHeader.SetExclude (Create<NdnNameComponents> (m_exclude));
+ interestHeader.SetExclude (Create<NameComponents> (m_exclude));
}
interestHeader.SetMaxSuffixComponents (m_maxSuffixComponents);
interestHeader.SetMinSuffixComponents (m_minSuffixComponents);
@@ -261,12 +261,12 @@
void
-NdnConsumer::OnContentObject (const Ptr<const NdnContentObjectHeader> &contentObject,
+Consumer::OnContentObject (const Ptr<const ContentObjectHeader> &contentObject,
Ptr<Packet> payload)
{
if (!m_active) return;
- NdnApp::OnContentObject (contentObject, payload); // tracing inside
+ App::OnContentObject (contentObject, payload); // tracing inside
NS_LOG_FUNCTION (this << contentObject << payload);
@@ -300,11 +300,11 @@
}
void
-NdnConsumer::OnNack (const Ptr<const NdnInterestHeader> &interest, Ptr<Packet> origPacket)
+Consumer::OnNack (const Ptr<const InterestHeader> &interest, Ptr<Packet> origPacket)
{
if (!m_active) return;
- NdnApp::OnNack (interest, origPacket); // tracing inside
+ App::OnNack (interest, origPacket); // tracing inside
NS_LOG_DEBUG ("Nack type: " << interest->GetNack ());
@@ -325,7 +325,7 @@
}
void
-NdnConsumer::OnTimeout (uint32_t sequenceNumber)
+Consumer::OnTimeout (uint32_t sequenceNumber)
{
// std::cout << Simulator::Now () << ", TO: " << sequenceNumber << ", current RTO: " << m_rtt->RetransmitTimeout ().ToDouble (Time::S) << "s\n";
@@ -335,4 +335,5 @@
ScheduleNextPacket ();
}
+} // namespace ndn
} // namespace ns3
diff --git a/apps/ndn-consumer.h b/apps/ndn-consumer.h
index 0bc7f70..3be11c1 100644
--- a/apps/ndn-consumer.h
+++ b/apps/ndn-consumer.h
@@ -37,14 +37,14 @@
#include <boost/multi_index/ordered_index.hpp>
#include <boost/multi_index/member.hpp>
-namespace ns3
-{
+namespace ns3 {
+namespace ndn {
/**
* @ingroup ndn
- * \brief Ndn application for sending out Interest packets
+ * \brief NDN application for sending out Interest packets
*/
-class NdnConsumer: public NdnApp
+class Consumer: public App
{
public:
static TypeId GetTypeId ();
@@ -53,18 +53,18 @@
* \brief Default constructor
* Sets up randomizer function and packet sequence number
*/
- NdnConsumer ();
- virtual ~NdnConsumer () {};
+ Consumer ();
+ virtual ~Consumer () {};
- // From NdnApp
+ // From App
// virtual void
- // OnInterest (const Ptr<const NdnInterestHeader> &interest);
+ // OnInterest (const Ptr<const InterestHeader> &interest);
virtual void
- OnNack (const Ptr<const NdnInterestHeader> &interest, Ptr<Packet> packet);
+ OnNack (const Ptr<const InterestHeader> &interest, Ptr<Packet> packet);
virtual void
- OnContentObject (const Ptr<const NdnContentObjectHeader> &contentObject,
+ OnContentObject (const Ptr<const ContentObjectHeader> &contentObject,
Ptr<Packet> payload);
/**
@@ -81,7 +81,7 @@
SendPacket ();
protected:
- // from NdnApp
+ // from App
virtual void
StartApplication ();
@@ -89,7 +89,7 @@
StopApplication ();
/**
- * \brief Constructs the Interest packet and sends it using a callback to the underlying Ndn protocol
+ * \brief Constructs the Interest packet and sends it using a callback to the underlying NDN protocol
*/
virtual void
ScheduleNextPacket () = 0;
@@ -126,12 +126,12 @@
Ptr<RttEstimator> m_rtt; ///< @brief RTT estimator
Time m_offTime; ///< \brief Time interval between packets
- NdnNameComponents m_interestName; ///< \brief NdnName of the Interest (use NdnNameComponents)
+ NameComponents m_interestName; ///< \brief NDN Name of the Interest (use NameComponents)
Time m_interestLifeTime; ///< \brief LifeTime for interest packet
- int32_t m_minSuffixComponents; ///< \brief MinSuffixComponents. See NdnInterestHeader for more information
- int32_t m_maxSuffixComponents; ///< \brief MaxSuffixComponents. See NdnInterestHeader for more information
- bool m_childSelector; ///< \brief ChildSelector. See NdnInterestHeader for more information
- NdnNameComponents m_exclude; ///< \brief Exclude. See NdnInterestHeader for more information
+ int32_t m_minSuffixComponents; ///< \brief MinSuffixComponents. See InterestHeader for more information
+ int32_t m_maxSuffixComponents; ///< \brief MaxSuffixComponents. See InterestHeader for more information
+ bool m_childSelector; ///< \brief ChildSelector. See InterestHeader for more information
+ NameComponents m_exclude; ///< \brief Exclude. See InterestHeader for more information
/// @cond include_hidden
/**
@@ -185,6 +185,7 @@
/// @endcond
};
+} // namespace ndn
} // namespace ns3
#endif
diff --git a/apps/ndn-producer.cc b/apps/ndn-producer.cc
index 541d6d8..0d71101 100644
--- a/apps/ndn-producer.cc
+++ b/apps/ndn-producer.cc
@@ -37,89 +37,89 @@
#include <boost/lambda/bind.hpp>
namespace ll = boost::lambda;
-NS_LOG_COMPONENT_DEFINE ("NdnProducer");
+NS_LOG_COMPONENT_DEFINE ("ndn.Producer");
-namespace ns3
-{
+namespace ns3 {
+namespace ndn {
-NS_OBJECT_ENSURE_REGISTERED (NdnProducer);
+NS_OBJECT_ENSURE_REGISTERED (Producer);
TypeId
-NdnProducer::GetTypeId (void)
+Producer::GetTypeId (void)
{
- static TypeId tid = TypeId ("ns3::NdnProducer")
+ static TypeId tid = TypeId ("ns3::ndn::Producer")
.SetGroupName ("Ndn")
- .SetParent<NdnApp> ()
- .AddConstructor<NdnProducer> ()
+ .SetParent<App> ()
+ .AddConstructor<Producer> ()
.AddAttribute ("Prefix","Prefix, for which producer has the data",
StringValue ("/"),
- MakeNdnNameComponentsAccessor (&NdnProducer::m_prefix),
- MakeNdnNameComponentsChecker ())
+ MakeNameComponentsAccessor (&Producer::m_prefix),
+ MakeNameComponentsChecker ())
.AddAttribute ("PayloadSize", "Virtual payload size for Content packets",
UintegerValue (1024),
- MakeUintegerAccessor(&NdnProducer::m_virtualPayloadSize),
+ MakeUintegerAccessor(&Producer::m_virtualPayloadSize),
MakeUintegerChecker<uint32_t>())
// optional attributes
.AddAttribute ("SignatureBits", "SignatureBits field",
UintegerValue (0),
- MakeUintegerAccessor(&NdnProducer::m_signatureBits),
+ MakeUintegerAccessor(&Producer::m_signatureBits),
MakeUintegerChecker<uint32_t> ())
;
return tid;
}
-NdnProducer::NdnProducer ()
+Producer::Producer ()
{
// NS_LOG_FUNCTION_NOARGS ();
}
// inherited from Application base class.
void
-NdnProducer::StartApplication ()
+Producer::StartApplication ()
{
NS_LOG_FUNCTION_NOARGS ();
- NS_ASSERT (GetNode ()->GetObject<NdnFib> () != 0);
+ NS_ASSERT (GetNode ()->GetObject<Fib> () != 0);
- NdnApp::StartApplication ();
+ App::StartApplication ();
NS_LOG_DEBUG ("NodeID: " << GetNode ()->GetId ());
- Ptr<NdnFib> fib = GetNode ()->GetObject<NdnFib> ();
+ Ptr<Fib> fib = GetNode ()->GetObject<Fib> ();
- Ptr<NdnFibEntry> fibEntry = fib->Add (m_prefix, m_face, 0);
+ Ptr<fib::Entry> fibEntry = fib->Add (m_prefix, m_face, 0);
- fibEntry->UpdateStatus (m_face, NdnFibFaceMetric::NDN_FIB_GREEN);
+ fibEntry->UpdateStatus (m_face, fib::FaceMetric::NDN_FIB_GREEN);
// // make face green, so it will be used primarily
- // StaticCast<NdnFibImpl> (fib)->modify (fibEntry,
- // ll::bind (&NdnFibEntry::UpdateStatus,
- // ll::_1, m_face, NdnFibFaceMetric::NDN_FIB_GREEN));
+ // StaticCast<fib::FibImpl> (fib)->modify (fibEntry,
+ // ll::bind (&fib::Entry::UpdateStatus,
+ // ll::_1, m_face, fib::FaceMetric::NDN_FIB_GREEN));
}
void
-NdnProducer::StopApplication ()
+Producer::StopApplication ()
{
NS_LOG_FUNCTION_NOARGS ();
- NS_ASSERT (GetNode ()->GetObject<NdnFib> () != 0);
+ NS_ASSERT (GetNode ()->GetObject<Fib> () != 0);
- NdnApp::StopApplication ();
+ App::StopApplication ();
}
void
-NdnProducer::OnInterest (const Ptr<const NdnInterestHeader> &interest, Ptr<Packet> origPacket)
+Producer::OnInterest (const Ptr<const InterestHeader> &interest, Ptr<Packet> origPacket)
{
- NdnApp::OnInterest (interest, origPacket); // tracing inside
+ App::OnInterest (interest, origPacket); // tracing inside
NS_LOG_FUNCTION (this << interest);
if (!m_active) return;
- static NdnContentObjectTail tail;
- Ptr<NdnContentObjectHeader> header = Create<NdnContentObjectHeader> ();
- header->SetName (Create<NdnNameComponents> (interest->GetName ()));
+ static ContentObjectTail tail;
+ Ptr<ContentObjectHeader> header = Create<ContentObjectHeader> ();
+ header->SetName (Create<NameComponents> (interest->GetName ()));
header->GetSignedInfo ().SetTimestamp (Simulator::Now ());
header->GetSignature ().SetSignatureBits (m_signatureBits);
@@ -147,4 +147,5 @@
m_transmittedContentObjects (header, packet, this, m_face);
}
+} // namespace ndn
} // namespace ns3
diff --git a/apps/ndn-producer.h b/apps/ndn-producer.h
index 4b0e079..e29a31c 100644
--- a/apps/ndn-producer.h
+++ b/apps/ndn-producer.h
@@ -28,8 +28,8 @@
#include "ns3/ndn-name-components.h"
#include "ns3/ndn-content-object-header.h"
-namespace ns3
-{
+namespace ns3 {
+namespace ndn {
/**
* @brief A simple Interest-sink applia simple Interest-sink application
@@ -39,16 +39,16 @@
* size and name same as in Interest.cation, which replying every incoming Interest
* with Data packet with a specified size and name same as in Interest.
*/
-class NdnProducer : public NdnApp
+class Producer : public App
{
public:
static TypeId
GetTypeId (void);
- NdnProducer ();
+ Producer ();
// inherited from NdnApp
- void OnInterest (const Ptr<const NdnInterestHeader> &interest, Ptr<Packet> packet);
+ void OnInterest (const Ptr<const InterestHeader> &interest, Ptr<Packet> packet);
protected:
// inherited from Application base class.
@@ -59,13 +59,14 @@
StopApplication (); // Called at time specified by Stop
private:
- NdnNameComponents m_prefix;
+ NameComponents m_prefix;
uint32_t m_virtualPayloadSize;
uint32_t m_signatureBits;
- // NdnContentObjectHeader::SignedInfo m_signedInfo;
+ // ContentObjectHeader::SignedInfo m_signedInfo;
};
-}
+} // namespace ndn
+} // namespace ns3
#endif // NDN_PRODUCER_H