Adding --enable-ndn-plugins option to waf
Support for topology and mobility plugins, provided that appropriate
patches are applied to the base NS-3 system
diff --git a/plugins/topology/patches/0001-topology-read-Several-extensions-of-TopologyReader.patch b/plugins/topology/patches/0001-topology-read-Several-extensions-of-TopologyReader.patch
new file mode 100644
index 0000000..ffaefe7
--- /dev/null
+++ b/plugins/topology/patches/0001-topology-read-Several-extensions-of-TopologyReader.patch
@@ -0,0 +1,146 @@
+From 19ebf81e3d32dbdda4ef06406c28566c6d771f9d Mon Sep 17 00:00:00 2001
+From: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+Date: Mon, 12 Dec 2011 18:01:12 -0800
+Subject: [PATCH 1/3] topology-read: Several extensions of TopologyReader
+
+---
+ src/topology-read/model/topology-reader.cc | 17 ++++++++++++++
+ src/topology-read/model/topology-reader.h | 35 +++++++++++++++++++++++-----
+ 2 files changed, 46 insertions(+), 6 deletions(-)
+
+diff --git a/src/topology-read/model/topology-reader.cc b/src/topology-read/model/topology-reader.cc
+index b531a6d..82a8343 100644
+--- a/src/topology-read/model/topology-reader.cc
++++ b/src/topology-read/model/topology-reader.cc
+@@ -106,12 +106,23 @@ TopologyReader::Link::Link ()
+ {
+ }
+
++void
++TopologyReader::Link::SetNetDevices (Ptr<NetDevice> from, Ptr<NetDevice> to)
++{
++ m_fromNetDevice = from;
++ m_toNetDevice = to;
++}
+
+ Ptr<Node> TopologyReader::Link::GetFromNode (void) const
+ {
+ return m_fromPtr;
+ }
+
++Ptr<NetDevice> TopologyReader::Link::GetFromNetDevice (void) const
++{
++ return m_fromNetDevice;
++}
++
+ std::string
+ TopologyReader::Link::GetFromNodeName (void) const
+ {
+@@ -124,6 +135,12 @@ TopologyReader::Link::GetToNode (void) const
+ return m_toPtr;
+ }
+
++Ptr<NetDevice>
++TopologyReader::Link::GetToNetDevice (void) const
++{
++ return m_toNetDevice;
++}
++
+ std::string
+ TopologyReader::Link::GetToNodeName (void) const
+ {
+diff --git a/src/topology-read/model/topology-reader.h b/src/topology-read/model/topology-reader.h
+index 865b7d3..48c0c1d 100644
+--- a/src/topology-read/model/topology-reader.h
++++ b/src/topology-read/model/topology-reader.h
+@@ -32,6 +32,8 @@
+
+ namespace ns3 {
+
++class NetDevice;
++
+ /**
+ * \ingroup topology
+ *
+@@ -53,7 +55,7 @@ public:
+ */
+ class Link
+ {
+-public:
++ public:
+ /**
+ * \brief Constant iterator to scan the map of link attributes.
+ */
+@@ -66,14 +68,27 @@ public:
+ * \param toPtr Ptr to the node the link is directed to
+ * \param toName name of the node the link is directed to
+ */
+- Link ( Ptr<Node> fromPtr, const std::string &fromName, Ptr<Node> toPtr, const std::string &toName );
++ Link (Ptr<Node> fromPtr, const std::string &fromName, Ptr<Node> toPtr, const std::string &toName);
+
+ /**
++ * \brief Set netdevices associated with the link
++ * \param from NetDevice associated with From node
++ * \param to NetDevice associated with To node
++ */
++ void
++ SetNetDevices (Ptr<NetDevice> from, Ptr<NetDevice> to);
++
++ /**
+ * \brief Returns a Ptr<Node> to the "from" node of the link
+ * \return a Ptr<Node> to the "from" node of the link
+ */
+ Ptr<Node> GetFromNode (void) const;
+ /**
++ * \brief Returns a Ptr<NetDevice> of the "from" node of the link
++ * \return a Ptr<NetDevice> of the "from" node of the link
++ */
++ Ptr<NetDevice> GetFromNetDevice (void) const;
++ /**
+ * \brief Returns the name of the "from" node of the link
+ * \return the name of the "from" node of the link
+ */
+@@ -84,6 +99,11 @@ public:
+ */
+ Ptr<Node> GetToNode (void) const;
+ /**
++ * \brief Returns a Ptr<NetDevice> of the "to" node of the link
++ * \return a Ptr<NetDevice> of the "to" node of the link
++ */
++ Ptr<NetDevice> GetToNetDevice (void) const;
++ /**
+ * \brief Returns the name of the "to" node of the link
+ * \return the name of the "to" node of the link
+ */
+@@ -127,7 +147,9 @@ private:
+ Ptr< Node > m_fromPtr;
+ std::string m_toName;
+ Ptr< Node > m_toPtr;
+- std::map<std::string, std::string> m_linkAttr;
++ Ptr< NetDevice > m_fromNetDevice;
++ Ptr< NetDevice > m_toNetDevice;
++ std::map<std::string, std::string > m_linkAttr;
+ };
+
+ /**
+@@ -195,13 +217,14 @@ private:
+ */
+ void AddLink (Link link);
+
++protected:
++ std::string m_fileName;
++ std::list<Link> m_linksList;
++
+ private:
+ TopologyReader (const TopologyReader&);
+ TopologyReader& operator= (const TopologyReader&);
+
+- std::string m_fileName;
+- std::list<Link> m_linksList;
+-
+ // end class TopologyReader
+ };
+
+--
+1.7.10.2
+
diff --git a/plugins/topology/patches/0002-topology-read-TopologyReader-and-derivatives-are-no-.patch b/plugins/topology/patches/0002-topology-read-TopologyReader-and-derivatives-are-no-.patch
new file mode 100644
index 0000000..db3f957
--- /dev/null
+++ b/plugins/topology/patches/0002-topology-read-TopologyReader-and-derivatives-are-no-.patch
@@ -0,0 +1,299 @@
+From cd1527f264045510fd79f3a6bd44ce5c48a8278d Mon Sep 17 00:00:00 2001
+From: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+Date: Tue, 13 Dec 2011 13:17:25 -0800
+Subject: [PATCH 2/3] topology-read: TopologyReader and derivatives are no
+ longer Objects
+
+To allow smart pointers, TopologyReader is just inherited from
+SimpleRefCount<TopologyReader> class
+---
+ src/topology-read/helper/topology-reader-helper.cc | 7 +++----
+ src/topology-read/helper/topology-reader-helper.h | 5 ++---
+ src/topology-read/model/inet-topology-reader.cc | 20 ++++++++++----------
+ src/topology-read/model/inet-topology-reader.h | 2 +-
+ src/topology-read/model/orbis-topology-reader.cc | 20 ++++++++++----------
+ src/topology-read/model/orbis-topology-reader.h | 2 +-
+ .../model/rocketfuel-topology-reader.cc | 20 ++++++++++----------
+ .../model/rocketfuel-topology-reader.h | 3 +--
+ src/topology-read/model/topology-reader.cc | 19 +++++++++----------
+ src/topology-read/model/topology-reader.h | 8 +++-----
+ 10 files changed, 50 insertions(+), 56 deletions(-)
+
+diff --git a/src/topology-read/helper/topology-reader-helper.cc b/src/topology-read/helper/topology-reader-helper.cc
+index ea4a9b2..c4678d1 100644
+--- a/src/topology-read/helper/topology-reader-helper.cc
++++ b/src/topology-read/helper/topology-reader-helper.cc
+@@ -47,7 +47,6 @@ TopologyReaderHelper::SetFileType (const std::string fileType)
+ m_fileType = fileType;
+ }
+
+-
+ Ptr<TopologyReader>
+ TopologyReaderHelper::GetTopologyReader ()
+ {
+@@ -59,17 +58,17 @@ TopologyReaderHelper::GetTopologyReader ()
+ if (m_fileType == "Orbis")
+ {
+ NS_LOG_INFO ("Creating Orbis formatted data input.");
+- m_inFile = CreateObject<OrbisTopologyReader> ();
++ m_inFile = Create<OrbisTopologyReader> ();
+ }
+ else if (m_fileType == "Inet")
+ {
+ NS_LOG_INFO ("Creating Inet formatted data input.");
+- m_inFile = CreateObject<InetTopologyReader> ();
++ m_inFile = Create<InetTopologyReader> ();
+ }
+ else if (m_fileType == "Rocketfuel")
+ {
+ NS_LOG_INFO ("Creating Rocketfuel formatted data input.");
+- m_inFile = CreateObject<RocketfuelTopologyReader> ();
++ m_inFile = Create<RocketfuelTopologyReader> ();
+ }
+ else
+ {
+diff --git a/src/topology-read/helper/topology-reader-helper.h b/src/topology-read/helper/topology-reader-helper.h
+index c4bfbbe..c1cc198 100644
+--- a/src/topology-read/helper/topology-reader-helper.h
++++ b/src/topology-read/helper/topology-reader-helper.h
+@@ -22,11 +22,10 @@
+ #ifndef TOPOLOGY_READER_HELPER_H
+ #define TOPOLOGY_READER_HELPER_H
+
+-#include "ns3/topology-reader.h"
+-#include <string>
+-
+ namespace ns3 {
+
++class TopologyReader;
++
+ /**
+ * \ingroup topology
+ *
+diff --git a/src/topology-read/model/inet-topology-reader.cc b/src/topology-read/model/inet-topology-reader.cc
+index ab1cc5d..10d1ac3 100644
+--- a/src/topology-read/model/inet-topology-reader.cc
++++ b/src/topology-read/model/inet-topology-reader.cc
+@@ -28,19 +28,19 @@
+
+ using namespace std;
+
+-namespace ns3 {
+-
+ NS_LOG_COMPONENT_DEFINE ("InetTopologyReader");
+
+-NS_OBJECT_ENSURE_REGISTERED (InetTopologyReader);
++namespace ns3 {
++
++// NS_OBJECT_ENSURE_REGISTERED (InetTopologyReader);
+
+-TypeId InetTopologyReader::GetTypeId (void)
+-{
+- static TypeId tid = TypeId ("ns3::InetTopologyReader")
+- .SetParent<Object> ()
+- ;
+- return tid;
+-}
++// TypeId InetTopologyReader::GetTypeId (void)
++// {
++// static TypeId tid = TypeId ("ns3::InetTopologyReader")
++// .SetParent<Object> ()
++// ;
++// return tid;
++// }
+
+ InetTopologyReader::InetTopologyReader ()
+ {
+diff --git a/src/topology-read/model/inet-topology-reader.h b/src/topology-read/model/inet-topology-reader.h
+index 31aa4a0..d235370 100644
+--- a/src/topology-read/model/inet-topology-reader.h
++++ b/src/topology-read/model/inet-topology-reader.h
+@@ -47,7 +47,7 @@ namespace ns3 {
+ class InetTopologyReader : public TopologyReader
+ {
+ public:
+- static TypeId GetTypeId (void);
++ // static TypeId GetTypeId (void);
+
+ InetTopologyReader ();
+ virtual ~InetTopologyReader ();
+diff --git a/src/topology-read/model/orbis-topology-reader.cc b/src/topology-read/model/orbis-topology-reader.cc
+index 04dbaf9..bdcd139 100644
+--- a/src/topology-read/model/orbis-topology-reader.cc
++++ b/src/topology-read/model/orbis-topology-reader.cc
+@@ -29,19 +29,19 @@
+
+ using namespace std;
+
+-namespace ns3 {
+-
+ NS_LOG_COMPONENT_DEFINE ("OrbisTopologyReader");
+
+-NS_OBJECT_ENSURE_REGISTERED (OrbisTopologyReader);
++namespace ns3 {
++
++// NS_OBJECT_ENSURE_REGISTERED (OrbisTopologyReader);
+
+-TypeId OrbisTopologyReader::GetTypeId (void)
+-{
+- static TypeId tid = TypeId ("ns3::OrbisTopologyReader")
+- .SetParent<Object> ()
+- ;
+- return tid;
+-}
++// TypeId OrbisTopologyReader::GetTypeId (void)
++// {
++// static TypeId tid = TypeId ("ns3::OrbisTopologyReader")
++// .SetParent<Object> ()
++// ;
++// return tid;
++// }
+
+ OrbisTopologyReader::OrbisTopologyReader ()
+ {
+diff --git a/src/topology-read/model/orbis-topology-reader.h b/src/topology-read/model/orbis-topology-reader.h
+index 21b32cf..b25db15 100644
+--- a/src/topology-read/model/orbis-topology-reader.h
++++ b/src/topology-read/model/orbis-topology-reader.h
+@@ -44,7 +44,7 @@ namespace ns3 {
+ class OrbisTopologyReader : public TopologyReader
+ {
+ public:
+- static TypeId GetTypeId (void);
++ // static TypeId GetTypeId (void);
+
+ OrbisTopologyReader ();
+ virtual ~OrbisTopologyReader ();
+diff --git a/src/topology-read/model/rocketfuel-topology-reader.cc b/src/topology-read/model/rocketfuel-topology-reader.cc
+index d048148..c103271 100644
+--- a/src/topology-read/model/rocketfuel-topology-reader.cc
++++ b/src/topology-read/model/rocketfuel-topology-reader.cc
+@@ -28,19 +28,19 @@
+ #include "ns3/unused.h"
+ #include "rocketfuel-topology-reader.h"
+
+-namespace ns3 {
+-
+ NS_LOG_COMPONENT_DEFINE ("RocketfuelTopologyReader");
+
+-NS_OBJECT_ENSURE_REGISTERED (RocketfuelTopologyReader);
++namespace ns3 {
++
++// NS_OBJECT_ENSURE_REGISTERED (RocketfuelTopologyReader);
+
+-TypeId RocketfuelTopologyReader::GetTypeId (void)
+-{
+- static TypeId tid = TypeId ("ns3::RocketfuelTopologyReader")
+- .SetParent<Object> ()
+- ;
+- return tid;
+-}
++// TypeId RocketfuelTopologyReader::GetTypeId (void)
++// {
++// static TypeId tid = TypeId ("ns3::RocketfuelTopologyReader")
++// .SetParent<Object> ()
++// ;
++// return tid;
++// }
+
+ RocketfuelTopologyReader::RocketfuelTopologyReader ()
+ {
+diff --git a/src/topology-read/model/rocketfuel-topology-reader.h b/src/topology-read/model/rocketfuel-topology-reader.h
+index afb667d..c512ea0 100644
+--- a/src/topology-read/model/rocketfuel-topology-reader.h
++++ b/src/topology-read/model/rocketfuel-topology-reader.h
+@@ -21,7 +21,6 @@
+ #ifndef ROCKETFUEL_TOPOLOGY_READER_H
+ #define ROCKETFUEL_TOPOLOGY_READER_H
+
+-#include "ns3/nstime.h"
+ #include "topology-reader.h"
+
+ namespace ns3 {
+@@ -43,7 +42,7 @@ namespace ns3 {
+ class RocketfuelTopologyReader : public TopologyReader
+ {
+ public:
+- static TypeId GetTypeId (void);
++ // static TypeId GetTypeId (void);
+
+ RocketfuelTopologyReader ();
+ virtual ~RocketfuelTopologyReader ();
+diff --git a/src/topology-read/model/topology-reader.cc b/src/topology-read/model/topology-reader.cc
+index 82a8343..a2e66cb 100644
+--- a/src/topology-read/model/topology-reader.cc
++++ b/src/topology-read/model/topology-reader.cc
+@@ -19,24 +19,23 @@
+ * Author: Valerio Sartini (valesar@gmail.com)
+ */
+
+-#include "ns3/log.h"
+-
+ #include "topology-reader.h"
+
++#include "ns3/log.h"
+
+ namespace ns3 {
+
+ NS_LOG_COMPONENT_DEFINE ("TopologyReader");
+
+-NS_OBJECT_ENSURE_REGISTERED (TopologyReader);
++// NS_OBJECT_ENSURE_REGISTERED (TopologyReader);
+
+-TypeId TopologyReader::GetTypeId (void)
+-{
+- static TypeId tid = TypeId ("ns3::TopologyReader")
+- .SetParent<Object> ()
+- ;
+- return tid;
+-}
++// TypeId TopologyReader::GetTypeId (void)
++// {
++// static TypeId tid = TypeId ("ns3::TopologyReader")
++// .SetParent<Object> ()
++// ;
++// return tid;
++// }
+
+ TopologyReader::TopologyReader ()
+ {
+diff --git a/src/topology-read/model/topology-reader.h b/src/topology-read/model/topology-reader.h
+index 48c0c1d..94eb37a 100644
+--- a/src/topology-read/model/topology-reader.h
++++ b/src/topology-read/model/topology-reader.h
+@@ -22,13 +22,11 @@
+ #ifndef TOPOLOGY_READER_H
+ #define TOPOLOGY_READER_H
+
+-#include <string>
+ #include <map>
+ #include <list>
+
+-#include "ns3/object.h"
+ #include "ns3/node-container.h"
+-
++#include "ns3/simple-ref-count.h"
+
+ namespace ns3 {
+
+@@ -42,7 +40,7 @@ class NetDevice;
+ * This interface perform the shared tasks among all possible input file readers.
+ * Each different file format is handled by its own topology reader.
+ */
+-class TopologyReader : public Object
++class TopologyReader : public SimpleRefCount<TopologyReader>
+ {
+
+ public:
+@@ -157,7 +155,7 @@ private:
+ */
+ typedef std::list< Link >::const_iterator ConstLinksIterator;
+
+- static TypeId GetTypeId (void);
++ // static TypeId GetTypeId (void);
+
+ TopologyReader ();
+ virtual ~TopologyReader ();
+--
+1.7.10.2
+
diff --git a/plugins/topology/patches/0003-topology-read-Making-default-constructor-for-Topolog.patch b/plugins/topology/patches/0003-topology-read-Making-default-constructor-for-Topolog.patch
new file mode 100644
index 0000000..1dcafa3
--- /dev/null
+++ b/plugins/topology/patches/0003-topology-read-Making-default-constructor-for-Topolog.patch
@@ -0,0 +1,35 @@
+From 4fd8af52681dc3ab641e93a28b8f2c044272bb16 Mon Sep 17 00:00:00 2001
+From: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+Date: Thu, 19 Jan 2012 16:57:13 -0800
+Subject: [PATCH 3/3] topology-read: Making default constructor for
+ TopologyReader::Link public.
+
+This is necessary for some STL containers operations.
+---
+ src/topology-read/model/topology-reader.h | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/src/topology-read/model/topology-reader.h b/src/topology-read/model/topology-reader.h
+index 94eb37a..d748989 100644
+--- a/src/topology-read/model/topology-reader.h
++++ b/src/topology-read/model/topology-reader.h
+@@ -59,6 +59,8 @@ public:
+ */
+ typedef std::map<std::string, std::string>::const_iterator ConstAttributesIterator;
+
++ Link (); // default constructor
++
+ /**
+ * \brief Constructor
+ * \param fromPtr Ptr to the node the link is orginating from
+@@ -140,7 +142,6 @@ public:
+ ConstAttributesIterator AttributesEnd (void);
+
+ private:
+- Link ();
+ std::string m_fromName;
+ Ptr< Node > m_fromPtr;
+ std::string m_toName;
+--
+1.7.10.2
+
diff --git a/plugins/topology/rocketfuel-weights-reader.cc b/plugins/topology/rocketfuel-weights-reader.cc
index acd3235..f1c4cc8 100644
--- a/plugins/topology/rocketfuel-weights-reader.cc
+++ b/plugins/topology/rocketfuel-weights-reader.cc
@@ -45,7 +45,6 @@
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
-#include "../utils/spring-mobility-helper.h"
#include <iomanip>
#include <set>
@@ -60,7 +59,13 @@
: AnnotatedTopologyReader (path)
{
NS_LOG_FUNCTION (this);
- SetMobilityModel ("ns3::SpringMobilityModel");
+
+ // TypeId tid;
+ // bool ok = TypeId::LookupByNameFailSafe ("ns3::SpringMobilityModel", &tid);
+ // if (ok)
+ // SetMobilityModel ("ns3::SpringMobilityModel");
+ // else
+ // Use default mobility model (supplied by AnnotatedTopologyReader)
}
RocketfuelWeightsReader::~RocketfuelWeightsReader ()
@@ -174,7 +179,7 @@
{
ApplySettings ();
- SpringMobilityHelper::InstallSprings (LinksBegin (), LinksEnd ());
+ // SpringMobilityHelper::InstallSprings (LinksBegin (), LinksEnd ());
}
} /* namespace ns3 */
diff --git a/wscript b/wscript
index 00eec0e..bded3d0 100644
--- a/wscript
+++ b/wscript
@@ -9,6 +9,9 @@
def options(opt):
opt.tool_options('boost', tooldir=["waf-tools"])
+ opt.add_option('--enable-ndn-plugins',
+ help=("Enable NDN plugins (may require patching)"),
+ dest='enable_ndn_plugins')
def configure(conf):
try:
@@ -23,6 +26,10 @@
conf.env['ENABLE_NDN_ABSTRACT']=False;
conf.env['MODULES_NOT_BUILT'].append('NDNabstraction')
return
+
+ conf.env['NDN_plugins'] = []
+ if Options.options.enable_ndn_plugins:
+ conf.env['NDN_plugins'] = Options.options.enable_ndn_plugins.split(',')
conf.env['ENABLE_NDN_ABSTRACT']=True;
@@ -89,6 +96,20 @@
# "utils/annotated-topology-reader.h",
]
+ if 'topology' in bld.env['NDN_plugins']:
+ headers.source.extend ([
+ "plugins/topology/rocketfuel-weights-reader.h",
+ "plugins/topology/annotated-topology-reader.h",
+ ])
+ module.source.extend (bld.path.ant_glob(['plugins/topology/*.cc']))
+
+ if 'mobility' in bld.env['NDN_plugins']:
+ headers.source.extend ([
+ "plugins/mobility/spring-mobility-model.h",
+ "plugins/mobility/spring-mobility-helper.h",
+ ])
+ module.source.extend (bld.path.ant_glob(['plugins/mobility/*.cc']))
+
tests.source = bld.path.ant_glob('test/*.cc');
if bld.env.ENABLE_EXAMPLES: