Modularize topology-read module and move it to src
authorMitch Watrous <watrous@u.washington.edu>
Fri, 04 Mar 2011 09:59:42 -0800
changeset 6854 dc1057c9879d
parent 6853 b0c4fd623715
child 6855 104f16f72979
Modularize topology-read module and move it to src
src/contrib/topology-read/inet-topology-reader.cc
src/contrib/topology-read/inet-topology-reader.h
src/contrib/topology-read/orbis-topology-reader.cc
src/contrib/topology-read/orbis-topology-reader.h
src/contrib/topology-read/rocketfuel-topology-reader.cc
src/contrib/topology-read/rocketfuel-topology-reader.h
src/contrib/topology-read/topology-reader.cc
src/contrib/topology-read/topology-reader.h
src/contrib/topology-read/topology.h
src/contrib/topology-read/wscript
src/topology-read/model/inet-topology-reader.cc
src/topology-read/model/inet-topology-reader.h
src/topology-read/model/orbis-topology-reader.cc
src/topology-read/model/orbis-topology-reader.h
src/topology-read/model/rocketfuel-topology-reader.cc
src/topology-read/model/rocketfuel-topology-reader.h
src/topology-read/model/topology-reader.cc
src/topology-read/model/topology-reader.h
src/topology-read/model/topology.h
src/topology-read/wscript
src/wscript
--- a/src/contrib/topology-read/inet-topology-reader.cc	Thu Mar 03 22:32:06 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,140 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2010 Universita' di Firenze, Italy
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Tommaso Pecorella (tommaso.pecorella@unifi.it)
- * Author: Valerio Sartini (Valesar@gmail.com)
- */
-
-#include <fstream>
-#include <cstdlib>
-#include <sstream>
-
-#include "ns3/log.h"
-#include "inet-topology-reader.h"
-
-using namespace std;
-
-namespace ns3 {
-
-NS_LOG_COMPONENT_DEFINE ("InetTopologyReader");
-
-NS_OBJECT_ENSURE_REGISTERED (InetTopologyReader);
-
-TypeId InetTopologyReader::GetTypeId (void)
-{
-  static TypeId tid = TypeId ("ns3::InetTopologyReader")
-    .SetParent<Object> ()
-  ;
-  return tid;
-}
-
-InetTopologyReader::InetTopologyReader ()
-{
-  NS_LOG_FUNCTION (this);
-}
-
-InetTopologyReader::~InetTopologyReader ()
-{
-  NS_LOG_FUNCTION (this);
-}
-
-NodeContainer
-InetTopologyReader::Read (void)
-{
-  ifstream topgen;
-  topgen.open (GetFileName ().c_str ());
-  map<string, Ptr<Node> > nodeMap;
-  NodeContainer nodes;
-
-  if ( !topgen.is_open () )
-    {
-      return nodes;
-    }
-
-  string from;
-  string to;
-  string linkAttr;
-
-  int linksNumber = 0;
-  int nodesNumber = 0;
-
-  int totnode = 0;
-  int totlink = 0;
-
-  istringstream lineBuffer;
-  string line;
-
-  getline (topgen,line);
-  lineBuffer.str (line);
-
-  lineBuffer >> totnode;
-  lineBuffer >> totlink;
-  NS_LOG_INFO ("Inet topology should have " << totnode << " nodes and " << totlink << " links");
-
-  for (int i = 0; i <= totnode; i++)
-    {
-      getline (topgen,line);
-    }
-
-  for (int i = 0; i < totlink && !topgen.eof (); i++)
-    {
-      getline (topgen,line);
-      lineBuffer.clear ();
-      lineBuffer.str (line);
-
-      lineBuffer >> from;
-      lineBuffer >> to;
-      lineBuffer >> linkAttr;
-
-      if ( (!from.empty ()) && (!to.empty ()) )
-        {
-          NS_LOG_INFO ( linksNumber << " From: " << from << " to: " << to );
-
-          if ( nodeMap[from] == 0 )
-            {
-              Ptr<Node> tmpNode = CreateObject<Node> ();
-              nodeMap[from] = tmpNode;
-              nodes.Add (tmpNode);
-              nodesNumber++;
-            }
-
-          if (nodeMap[to] == 0)
-            {
-              Ptr<Node> tmpNode = CreateObject<Node> ();
-              nodeMap[to] = tmpNode;
-              nodes.Add (tmpNode);
-              nodesNumber++;
-            }
-
-          Link link ( nodeMap[from], from, nodeMap[to], to );
-          if ( !linkAttr.empty () )
-            {
-              link.SetAttribute ("Weight", linkAttr);
-            }
-          AddLink (link);
-
-          linksNumber++;
-        }
-    }
-
-  NS_LOG_INFO ("Inet topology created with " << nodesNumber << " nodes and " << linksNumber << " links");
-  topgen.close ();
-
-  return nodes;
-}
-
-} /* namespace ns3 */
--- a/src/contrib/topology-read/inet-topology-reader.h	Thu Mar 03 22:32:06 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2010 Universita' di Firenze, Italy
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Tommaso Pecorella (tommaso.pecorella@unifi.it)
- * Author: Valerio Sartini (valesar@gmail.com)
- */
-
-#ifndef __INET_TOPOLOGY_READER_H__
-#define __INET_TOPOLOGY_READER_H__
-
-#include "ns3/nstime.h"
-
-#include "topology-reader.h"
-
-namespace ns3 {
-
-
-// ------------------------------------------------------------
-// --------------------------------------------
-/**
- * \ingroup topology
- * \brief Topology file reader (Inet-format type).
- *
- * This class takes an input file in Inet format and extracts all
- * the informations needed to build the topology
- * (i.e.number of nodes, links and links structure).
- * It have been tested with Inet 3.0
- * http://topology.eecs.umich.edu/inet/
- *
- * It might set a link attribute named "Weight", corresponding to
- * the euclidean distance between two nodes, the nodes being randomly positioned.
- */
-class InetTopologyReader : public TopologyReader
-{
-public:
-  static TypeId GetTypeId (void);
-
-  InetTopologyReader ();
-  virtual ~InetTopologyReader ();
-
-  /**
-   * \brief Main topology reading function.
-   *
-   * This method opens an input stream and reads the Inet-format file.
-   * From the first line it takes the total number of nodes and links.
-   * Then discards a number of rows equals to total nodes (containing
-   * useless geographical informations).
-   * Then reads until the end of the file (total links number rows) and saves
-   * the structure of every single link in the topology.
-   *
-   * \return the container of the nodes created (or empty container if there was an error)
-   */
-  virtual NodeContainer Read (void);
-
-private:
-  InetTopologyReader (const InetTopologyReader&);
-  InetTopologyReader& operator= (const InetTopologyReader&);
-
-  // end class InetTopologyReader
-};
-
-// end namespace ns3
-};
-
-
-#endif // __INET_TOPOLOGY_READER_H__
--- a/src/contrib/topology-read/orbis-topology-reader.cc	Thu Mar 03 22:32:06 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,121 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2010 Universita' di Firenze, Italy
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Tommaso Pecorella (tommaso.pecorella@unifi.it)
- * Author: Valerio Sartini (valesar@gmail.com)
- */
-
-#include <fstream>
-#include <cstdlib>
-#include <iostream>
-#include <sstream>
-
-#include "ns3/log.h"
-#include "orbis-topology-reader.h"
-
-using namespace std;
-
-namespace ns3 {
-
-NS_LOG_COMPONENT_DEFINE ("OrbisTopologyReader");
-
-NS_OBJECT_ENSURE_REGISTERED (OrbisTopologyReader);
-
-TypeId OrbisTopologyReader::GetTypeId (void)
-{
-  static TypeId tid = TypeId ("ns3::OrbisTopologyReader")
-    .SetParent<Object> ()
-  ;
-  return tid;
-}
-
-OrbisTopologyReader::OrbisTopologyReader ()
-{
-  NS_LOG_FUNCTION (this);
-}
-
-OrbisTopologyReader::~OrbisTopologyReader ()
-{
-  NS_LOG_FUNCTION (this);
-}
-
-NodeContainer
-OrbisTopologyReader::Read (void)
-{
-  ifstream topgen;
-  topgen.open (GetFileName ().c_str ());
-  map<string, Ptr<Node> > nodeMap;
-  NodeContainer nodes;
-
-  if ( !topgen.is_open () )
-    {
-      return nodes;
-    }
-
-  string from;
-  string to;
-  istringstream lineBuffer;
-  string line;
-
-  int linksNumber = 0;
-  int nodesNumber = 0;
-
-  while (!topgen.eof ())
-    {
-      line.clear ();
-      lineBuffer.clear ();
-      from.clear ();
-      to.clear ();
-
-      getline (topgen,line);
-      lineBuffer.str (line);
-      lineBuffer >> from;
-      lineBuffer >> to;
-
-      if ( (!from.empty ()) && (!to.empty ()) )
-        {
-          NS_LOG_INFO ( linksNumber << " From: " << from << " to: " << to );
-          if ( nodeMap[from] == 0 )
-            {
-              Ptr<Node> tmpNode = CreateObject<Node> ();
-              nodeMap[from] = tmpNode;
-              nodes.Add (tmpNode);
-              nodesNumber++;
-            }
-
-          if (nodeMap[to] == 0)
-            {
-              Ptr<Node> tmpNode = CreateObject<Node> ();
-              nodeMap[to] = tmpNode;
-              nodes.Add (tmpNode);
-              nodesNumber++;
-            }
-
-          Link link ( nodeMap[from], from, nodeMap[to], to );
-          AddLink (link);
-
-          linksNumber++;
-        }
-    }
-  NS_LOG_INFO ("Orbis topology created with " << nodesNumber << " nodes and " << linksNumber << " links");
-  topgen.close ();
-
-  return nodes;
-}
-
-} /* namespace ns3 */
-
--- a/src/contrib/topology-read/orbis-topology-reader.h	Thu Mar 03 22:32:06 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,77 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2010 Universita' di Firenze, Italy
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Tommaso Pecorella (tommaso.pecorella@unifi.it)
- * Author: Valerio Sartini (valesar@gmail.com)
- */
-
-#ifndef __ORBIS_TOPOLOGY_READER_H__
-#define __ORBIS_TOPOLOGY_READER_H__
-
-#include "ns3/nstime.h"
-
-#include "topology-reader.h"
-
-namespace ns3 {
-
-
-// ------------------------------------------------------------
-// --------------------------------------------
-/**
- * \ingroup topology
- * \brief Topology file reader (Orbis-format type).
- *
- * This class takes an input file in Orbis format and extracts all
- * the informations needed to build the topology
- * (i.e.number of nodes, links and links structure).
- * It have been tested with Orbis 0.70
- * http://www.sysnet.ucsd.edu/~pmahadevan/topo_research/topo.html
- */
-class OrbisTopologyReader : public TopologyReader
-{
-public:
-  static TypeId GetTypeId (void);
-
-  OrbisTopologyReader ();
-  virtual ~OrbisTopologyReader ();
-
-  /**
-   * \brief Main topology reading function.
-   *
-   * This method opens an input stream and reads the Orbis-format file.
-   * Every row represents a topology link (the ids of a couple of nodes),
-   * so the input file is read line by line to figure out how many links
-   * and nodes are in the topology.
-   *
-   * \return the container of the nodes created (or empty container if there was an error)
-   */
-  virtual NodeContainer Read (void);
-
-private:
-  OrbisTopologyReader (const OrbisTopologyReader&);
-  OrbisTopologyReader& operator= (const OrbisTopologyReader&);
-
-  // end class OrbisTopologyReader
-};
-
-// end namespace ns3
-};
-
-
-#endif // __ORBIS_TOPOLOGY_READER_H__
-
-
--- a/src/contrib/topology-read/rocketfuel-topology-reader.cc	Thu Mar 03 22:32:06 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,482 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2010 Hajime Tazaki
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Hajime Tazaki (tazaki@sfc.wide.ad.jp)
- */
-
-#include <fstream>
-#include <cstdlib>
-#include <iostream>
-#include <sstream>
-#include <regex.h>
-
-#include "ns3/log.h"
-#include "rocketfuel-topology-reader.h"
-
-namespace ns3 {
-
-NS_LOG_COMPONENT_DEFINE ("RocketfuelTopologyReader");
-
-NS_OBJECT_ENSURE_REGISTERED (RocketfuelTopologyReader);
-
-TypeId RocketfuelTopologyReader::GetTypeId (void)
-{
-  static TypeId tid = TypeId ("ns3::RocketfuelTopologyReader")
-    .SetParent<Object> ()
-  ;
-  return tid;
-}
-
-RocketfuelTopologyReader::RocketfuelTopologyReader ()
-{
-  NS_LOG_FUNCTION (this);
-}
-
-RocketfuelTopologyReader::~RocketfuelTopologyReader ()
-{
-  NS_LOG_FUNCTION (this);
-}
-
-/* uid @loc [+] [bb] (num_neigh) [&ext] -> <nuid-1> <nuid-2> ... {-euid} ... =name[!] rn */
-
-#define REGMATCH_MAX 16
-
-#define START "^"
-#define END "$"
-#define SPACE "[ \t]+"
-#define MAYSPACE "[ \t]*"
-
-#define ROCKETFUEL_MAPS_LINE \
-  START "(-*[0-9]+)" SPACE "(@[?A-Za-z0-9,+]+)" SPACE \
-  "(\\+)*" MAYSPACE "(bb)*" MAYSPACE \
-  "\\(([0-9]+)\\)" SPACE "(&[0-9]+)*" MAYSPACE \
-  "->" MAYSPACE "(<[0-9 \t<>]+>)*" MAYSPACE \
-  "(\\{-[0-9\\{\\} \t-]+\\})*" SPACE \
-  "=([A-Za-z0-9.!-]+)" SPACE "r([0-9])" \
-  MAYSPACE END
-
-#define ROCKETFUEL_WEIGHTS_LINE \
-  START "([^ \t]+)" SPACE "([^ \t]+)" SPACE "([0-9.]+)" MAYSPACE END
-
-int linksNumber = 0;
-int nodesNumber = 0;
-std::map<std::string, Ptr<Node> > nodeMap;
-
-NodeContainer
-RocketfuelTopologyReader::GenerateFromMapsFile (int argc, char *argv[])
-{
-  std::string uid;
-  std::string loc;
-  std::string ptr;
-  std::string name;
-  std::string nuid;
-  bool dns = false;
-  bool bb = false;
-  int num_neigh = 0;
-  int ext_conn = 0;
-  int radius = 0;
-  std::vector <std::string> neigh_list;
-  NodeContainer nodes;
-
-  uid = argv[0];
-  loc = argv[1];
-
-  if (argv[2])
-    dns = true;
-
-  if (argv[3])
-    bb = true;
-
-  num_neigh = ::atoi (argv[4]);
-
-  /* the first char should be '&' */
-  if (argv[5])
-    {
-      ext_conn = ::atoi (&argv[5][1]);
-    }
-
-  /* neighbors */
-  if (argv[6])
-    {
-      char *nbr;
-      char *stringp = argv[6];
-      while ((nbr = strsep (&stringp, " \t")) != NULL)
-        {
-          nbr[strlen (nbr) - 1] = '\0';
-          neigh_list.push_back (nbr + 1);
-        }
-    }
-
-  /* externs */
-  if (argv[7])
-    {
-      //      euid = argv[7];
-    }
-
-  /* name */
-  if (argv[8])
-    {
-      name = argv[8];
-    }
-
-  radius = ::atoi (&argv[9][1]);
-  if (radius > 0)
-    {
-      return nodes;
-    }
-
-  /* uid @loc [+] [bb] (num_neigh) [&ext] -> <nuid-1> <nuid-2> ... {-euid} ... =name[!] rn */
-  NS_LOG_INFO ("Load Node[" << uid << "]: location: " << loc << " dns: " << dns
-               << " bb: " << bb << " neighbors: " << neigh_list.size ()
-               << "(" << "%d" << ") externals: \"%s\"(%d) " 
-               << "name: " << name << " radius: " << radius); 
-
-  // Create node and link
-  if (!uid.empty ())
-    {
-      if (nodeMap[uid] == 0)
-        {
-          Ptr<Node> tmpNode = CreateObject<Node> ();
-          nodeMap[uid] = tmpNode;
-          nodes.Add (tmpNode);
-          nodesNumber++;
-        }
-
-      for (uint32_t i = 0; i < neigh_list.size (); ++i)
-        {
-          nuid = neigh_list[i];
-
-          if (nuid.empty ())
-            {
-              return nodes;
-            }
-
-          if (nodeMap[nuid] == 0)
-            {
-              Ptr<Node> tmpNode = CreateObject<Node> ();
-              nodeMap[nuid] = tmpNode;
-              nodes.Add (tmpNode);
-              nodesNumber++;
-            }
-          NS_LOG_INFO (linksNumber << ":" << nodesNumber << " From: " << uid << " to: " << nuid);
-          Link link (nodeMap[uid], uid, nodeMap[nuid], nuid);
-          AddLink (link);
-          linksNumber++;
-        }
-    }
-  return nodes;
-}
-
-NodeContainer
-RocketfuelTopologyReader::GenerateFromWeightsFile (int argc, char *argv[])
-{
-  /* uid @loc [+] [bb] (num_neigh) [&ext] -> <nuid-1> <nuid-2> ... {-euid} ... =name[!] rn */
-  std::string sname;
-  std::string tname;
-  double weight;
-  char *endptr;
-  NodeContainer nodes;
-
-  sname = argv[0];
-  tname = argv[1];
-  weight = strtod (argv[2], &endptr);
-  if (*endptr != '\0')
-    {
-      NS_LOG_WARN ("invalid weight: " << argv[2]);
-      return nodes;
-    }
-
-  // Create node and link
-  if (!sname.empty () && !tname.empty ())
-    {
-      if (nodeMap[sname] == 0)
-        {
-          Ptr<Node> tmpNode = CreateObject<Node> ();
-          nodeMap[sname] = tmpNode;
-          nodes.Add (tmpNode);
-          nodesNumber++;
-        }
-
-      if (nodeMap[tname] == 0)
-        {
-          Ptr<Node> tmpNode = CreateObject<Node> ();
-          nodeMap[tname] = tmpNode;
-          nodes.Add (tmpNode);
-          nodesNumber++;
-        }
-      NS_LOG_INFO (linksNumber << ":" << nodesNumber << " From: " << sname << " to: " << tname);
-      TopologyReader::ConstLinksIterator iter;
-      bool found = false;
-      for (iter = LinksBegin (); iter != LinksEnd (); iter++)
-        {
-          if ((iter->GetFromNode () == nodeMap[tname]) &&
-              (iter->GetToNode () == nodeMap[sname]))
-            {
-              found = true;
-              break;
-            }
-        }
-
-      if (!found)
-        {
-          Link link (nodeMap[sname], sname, nodeMap[tname], tname);
-          AddLink (link);
-          linksNumber++;
-        }
-    }
-  return nodes;
-}
-
-enum RocketfuelTopologyReader::RF_FileType
-RocketfuelTopologyReader::GetFileType (const char *line)
-{
-  int ret;
-  regmatch_t regmatch[REGMATCH_MAX];
-  regex_t regex;
-  char errbuf[512];
-
-  // Check whether MAPS file or not
-  ret = regcomp (&regex, ROCKETFUEL_MAPS_LINE, REG_EXTENDED|REG_NEWLINE);
-  if (ret != 0)
-    {
-      regerror (ret, &regex, errbuf, sizeof (errbuf));
-      return RF_UNKNOWN;
-    }
-  ret = regexec (&regex, line, REGMATCH_MAX, regmatch, 0);
-  if (ret != REG_NOMATCH)
-    {
-      regfree (&regex);
-      return RF_MAPS;
-    }
-  regfree (&regex);
-
-  // Check whether Weights file or not
-  ret = regcomp (&regex, ROCKETFUEL_WEIGHTS_LINE, REG_EXTENDED|REG_NEWLINE);
-  if (ret != 0)
-    {
-      regerror (ret, &regex, errbuf, sizeof (errbuf));
-      return RF_UNKNOWN;
-    }
-  ret = regexec (&regex, line, REGMATCH_MAX, regmatch, 0);
-  if (ret != REG_NOMATCH)
-    {
-      regfree (&regex);
-      return RF_WEIGHTS;
-    }
-  regfree (&regex);
-
-  return RF_UNKNOWN;
-}
-
-
-NodeContainer
-RocketfuelTopologyReader::Read (void)
-{
-  std::ifstream topgen;
-  topgen.open (GetFileName ().c_str ());
-  NodeContainer nodes;
-
-  std::istringstream lineBuffer;
-  std::string line;
-  int lineNumber = 0;
-  enum RF_FileType ftype = RF_UNKNOWN;
-  char errbuf[512];
-
-  if (!topgen.is_open ())
-    {
-      NS_LOG_WARN ("Couldn't open the file " << GetFileName ());
-      return nodes;
-    }
-
-  while (!topgen.eof ())
-    {
-      int ret;
-      int argc;
-      char *argv[REGMATCH_MAX];
-      char *buf;
-
-      lineNumber++;
-      line.clear ();
-      lineBuffer.clear ();
-
-      getline (topgen, line);
-      buf = (char *)line.c_str ();
-
-      if (lineNumber == 1)
-        {
-          ftype = GetFileType (buf);
-          if (ftype == RF_UNKNOWN)
-            {
-              NS_LOG_INFO ("Unknown File Format (" << GetFileName () << ")");
-              break;
-            }
-        }
-
-      regmatch_t regmatch[REGMATCH_MAX];
-      regex_t regex;
-
-      if (ftype == RF_MAPS)
-        {
-          ret = regcomp (&regex, ROCKETFUEL_MAPS_LINE, REG_EXTENDED|REG_NEWLINE);
-          if (ret != 0)
-            {
-              regerror (ret, &regex, errbuf, sizeof (errbuf));
-              regfree (&regex);
-              break;
-            }
-
-          ret = regexec (&regex, buf, REGMATCH_MAX, regmatch, 0);
-          if (ret == REG_NOMATCH)
-            {
-              NS_LOG_WARN ("match failed (maps file): %s" << buf);
-              regfree (&regex);
-              break;
-            }
-        }
-      else if (ftype == RF_WEIGHTS)
-        {
-          ret = regcomp (&regex, ROCKETFUEL_WEIGHTS_LINE, REG_EXTENDED|REG_NEWLINE);
-          if (ret != 0)
-            {
-              regerror (ret, &regex, errbuf, sizeof (errbuf));
-              regfree (&regex);
-              break;
-            }
-
-          ret = regexec (&regex, buf, REGMATCH_MAX, regmatch, 0);
-          if (ret == REG_NOMATCH)
-            {
-              NS_LOG_WARN ("match failed (weights file): %s" << buf);
-              regfree (&regex);
-              break;
-            }
-        }
-
-      line = buf;
-      argc = 0;
-
-      /* regmatch[0] is the entire strings that matched */
-      for (int i = 1; i < REGMATCH_MAX; i++)
-        {
-          if (regmatch[i].rm_so == -1)
-            {
-              argv[i-1] = NULL;
-            }
-          else
-            {
-              line[regmatch[i].rm_eo] = '\0';
-              argv[i-1] = &line[regmatch[i].rm_so];
-              argc = i;
-            }
-        }
-
-      if (ftype == RF_MAPS)
-        {
-          nodes.Add (GenerateFromMapsFile (argc, argv));
-        }
-      else if (ftype == RF_WEIGHTS)
-        {
-          nodes.Add (GenerateFromWeightsFile (argc, argv));
-        }
-      else
-        {
-          NS_LOG_WARN ("Unsupported file format (only Maps/Weights are supported)");
-        }
-
-      regfree (&regex);
-    }
-
-
-  topgen.close ();
-
-  NS_LOG_INFO ("Rocketfuel topology created with " << nodesNumber << " nodes and " << linksNumber << " links");
-  return nodes;
-}
-
-} /* namespace ns3 */
-
-
-//-----------------------------------------------------------------------------
-// Unit tests
-//-----------------------------------------------------------------------------
-
-#include "ns3/log.h"
-#include "ns3/abort.h"
-#include "ns3/attribute.h"
-#include "ns3/object-factory.h"
-#include "ns3/object-factory.h"
-#include "ns3/simulator.h"
-#include "ns3/test.h"
-
-namespace ns3 {
-
-class RocketfuelTopologyReaderTest: public TestCase 
-{
-public:
-  RocketfuelTopologyReaderTest ();
-private:
-  virtual void DoRun (void);
-};
-
-RocketfuelTopologyReaderTest::RocketfuelTopologyReaderTest ()
-  : TestCase ("RocketfuelTopologyReaderTest") 
-{}
-
-
-void
-RocketfuelTopologyReaderTest::DoRun (void)
-{
-  Ptr<RocketfuelTopologyReader> inFile;
-  NodeContainer nodes;
-  
-  std::string input ("./examples/topology-read/RocketFuel_toposample_1239_weights.txt");
-
-  inFile = CreateObject<RocketfuelTopologyReader> ();
-  inFile->SetFileName(input);
-
-  if (inFile != 0)
-    {
-      nodes = inFile->Read ();
-    }
-
-  NS_TEST_ASSERT_MSG_NE (nodes.GetN (), 0, "Problems reading node information the topology file..");
-
-  NS_TEST_ASSERT_MSG_NE (inFile->LinksSize (), 0, "Problems reading the topology file.");
-
-  NS_LOG_INFO ("Rocketfuel topology created with " << nodes.GetN () << " nodes and " << 
-               inFile->LinksSize () << " links (from " << input << ")");
-
-  NS_TEST_EXPECT_MSG_EQ (nodes.GetN (),315, "noes");
-  NS_TEST_EXPECT_MSG_EQ (inFile->LinksSize (),972, "links");
-  Simulator::Destroy ();
-}
-
-static class RocketfuelTopologyReaderTestSuite : public TestSuite
-{
-public:
-  RocketfuelTopologyReaderTestSuite ();
-private:
-} g_rocketfueltopologyreaderTests;
-
-RocketfuelTopologyReaderTestSuite::RocketfuelTopologyReaderTestSuite ()
-  : TestSuite ("rocketfuel-topology-reader", UNIT)
-{
-  AddTestCase (new RocketfuelTopologyReaderTest ());
-}
-
-
-}
--- a/src/contrib/topology-read/rocketfuel-topology-reader.h	Thu Mar 03 22:32:06 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,90 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2010 Hajime Tazaki
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Hajime Tazaki (tazaki@sfc.wide.ad.jp)
- */
-
-#ifndef __ROCKETFUEL_TOPOLOGY_READER_H__
-#define __ROCKETFUEL_TOPOLOGY_READER_H__
-
-#include "ns3/nstime.h"
-
-#include "topology-reader.h"
-
-namespace ns3 {
-
-
-// ------------------------------------------------------------
-// --------------------------------------------
-/**
- * \ingroup topology
- * \brief Topology file reader (Rocketfuel-format type).
- *
- * http://www.cs.washington.edu/research/networking/rocketfuel/
- *
- * May 2nd, 2010: Currently only support "weights" file and "cch" file.
- * http://www.cs.washington.edu/research/networking/rocketfuel/maps/weights-dist.tar.gz
- * http://www.cs.washington.edu/research/networking/rocketfuel/maps/rocketfuel_maps_cch.tar.gz
- */
-class RocketfuelTopologyReader : public TopologyReader
-{
-public:
-  static TypeId GetTypeId (void);
-
-  RocketfuelTopologyReader ();
-  virtual ~RocketfuelTopologyReader ();
-
-  /**
-   * \brief Main topology reading function.
-   *
-   * This method opens an input stream and reads the Rocketfuel-format file.
-   * Every row represents a topology link (the ids of a couple of nodes),
-   * so the input file is read line by line to figure out how many links
-   * and nodes are in the topology.
-   *
-   * \return the container of the nodes created (or empty container if there was an error)
-   */
-  virtual NodeContainer Read (void);
-
-private:
-  RocketfuelTopologyReader (const RocketfuelTopologyReader&);
-  RocketfuelTopologyReader& operator= (const RocketfuelTopologyReader&);
-  // Parser for the *.cch file available at:
-  // http://www.cs.washington.edu/research/networking/rocketfuel/maps/rocketfuel_maps_cch.tar.gz
-  NodeContainer GenerateFromMapsFile (int argc, char *argv[]);
-  // Parser for the weights.* file available at:
-  // http://www.cs.washington.edu/research/networking/rocketfuel/maps/weights-dist.tar.gz
-  NodeContainer GenerateFromWeightsFile (int argc, char *argv[]);
-
-  enum RF_FileType
-    {   
-      RF_MAPS,
-      RF_WEIGHTS,
-      RF_UNKNOWN
-    };
-  enum RF_FileType GetFileType (const char *);
-
-  // end class RocketfuelTopologyReader
-};
-
-// end namespace ns3
-};
-
-
-#endif // __ROCKETFUEL_TOPOLOGY_READER_H__
-
-
--- a/src/contrib/topology-read/topology-reader.cc	Thu Mar 03 22:32:06 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,169 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2010 Universita' di Firenze, Italy
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Tommaso Pecorella (tommaso.pecorella@unifi.it)
- * Author: Valerio Sartini (valesar@gmail.com)
- */
-
-#include "ns3/log.h"
-
-#include "topology-reader.h"
-
-
-namespace ns3 {
-
-NS_LOG_COMPONENT_DEFINE ("TopologyReader");
-
-NS_OBJECT_ENSURE_REGISTERED (TopologyReader);
-
-TypeId TopologyReader::GetTypeId (void)
-{
-  static TypeId tid = TypeId ("ns3::TopologyReader")
-    .SetParent<Object> ()
-  ;
-  return tid;
-}
-
-TopologyReader::TopologyReader ()
-{
-  NS_LOG_FUNCTION (this);
-}
-
-TopologyReader::~TopologyReader ()
-{
-  NS_LOG_FUNCTION (this);
-}
-
-void
-TopologyReader::SetFileName (const std::string fileName)
-{
-  m_fileName = fileName;
-}
-
-std::string
-TopologyReader::GetFileName () const
-{
-  return m_fileName;
-}
-
-/* Manipulating the address block */
-
-TopologyReader::ConstLinksIterator
-TopologyReader::LinksBegin (void) const
-{
-  return m_linksList.begin ();
-}
-
-TopologyReader::ConstLinksIterator
-TopologyReader::LinksEnd (void) const
-{
-  return m_linksList.end ();
-}
-
-int
-TopologyReader::LinksSize (void) const
-{
-  return m_linksList.size ();
-}
-
-bool
-TopologyReader::LinksEmpty (void) const
-{
-  return m_linksList.empty ();
-}
-
-void
-TopologyReader::AddLink (Link link)
-{
-  m_linksList.push_back (link);
-  return;
-}
-
-
-TopologyReader::Link::Link ( Ptr<Node> fromPtr, std::string fromName, Ptr<Node> toPtr, std::string toName )
-{
-  m_fromPtr = fromPtr;
-  m_fromName = fromName;
-  m_toPtr = toPtr;
-  m_toName = toName;
-}
-
-TopologyReader::Link::Link ()
-{
-}
-
-
-Ptr<Node> TopologyReader::Link::GetFromNode (void) const
-{
-  return m_fromPtr;
-}
-
-std::string
-TopologyReader::Link::GetFromNodeName (void) const
-{
-  return m_fromName;
-}
-
-Ptr<Node>
-TopologyReader::Link::GetToNode (void) const
-{
-  return m_toPtr;
-}
-
-std::string
-TopologyReader::Link::GetToNodeName (void) const
-{
-  return m_toName;
-}
-
-std::string
-TopologyReader::Link::GetAttribute (std::string name)
-{
-  NS_ASSERT_MSG (m_linkAttr.find ("name") == m_linkAttr.end (), "Requested topology link attribute not found");
-  return m_linkAttr[name];
-}
-
-bool
-TopologyReader::Link::GetAttributeFailSafe (std::string name, std::string &value)
-{
-  if ( m_linkAttr.find ("name") == m_linkAttr.end () )
-    {
-      return false;
-    }
-  value = m_linkAttr[name];
-  return true;
-}
-
-void
-TopologyReader::Link::SetAttribute (std::string name, std::string &value)
-{
-  m_linkAttr[name] = value;
-}
-
-TopologyReader::Link::ConstAttributesIterator
-TopologyReader::Link::AttributesBegin (void)
-{
-  return m_linkAttr.begin ();
-}
-TopologyReader::Link::ConstAttributesIterator
-TopologyReader::Link::AttributesEnd (void)
-{
-  return m_linkAttr.end ();
-}
-
-
-} /* namespace ns3 */
--- a/src/contrib/topology-read/topology-reader.h	Thu Mar 03 22:32:06 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,207 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2010 Universita' di Firenze, Italy
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Tommaso Pecorella (tommaso.pecorella@unifi.it)
- * Author: Valerio Sartini (valesar@gmail.com)
- */
-
-#ifndef __TOPOLOGY_READER_H__
-#define __TOPOLOGY_READER_H__
-
-#include <string>
-#include <map>
-#include <list>
-
-#include "ns3/object.h"
-#include "ns3/node-container.h"
-
-
-namespace ns3 {
-
-/**
- * \defgroup topology Topology Input Readers
- */
-
-/**
- * \ingroup topology
- * \brief Interface for input file readers management.
- *
- * 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
-{
-
-public:
-  /**
-   * \ingroup topology
-   * \brief Inner class holding the details about a link between two nodes.
-   *
-   * The link is not described in terms of technology. Rather it is only stating
-   * an association between two nodes. The nodes are characterized also with names
-   * reflecting how the nodes are called in the original topology file.
-   */
-  class Link
-  {
-public:
-    typedef std::map<std::string, std::string >::const_iterator ConstAttributesIterator;
-
-    Link ( Ptr<Node> fromPtr, std::string fromName, Ptr<Node> toPtr, std::string toName );
-
-    /**
-     * \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 the name of the "from" node of the link
-     * \return the name of the "from" node of the link
-     */
-    std::string GetFromNodeName (void) const;
-    /**
-     * \brief Returns a Ptr<Node> to the "to" node of the link
-     * \return a Ptr<Node> to the "to" node of the link
-     */
-    Ptr<Node> GetToNode (void) const;
-    /**
-     * \brief Returns the name of the "to" node of the link
-     * \return the name of the "to" node of the link
-     */
-    std::string GetToNodeName (void) const;
-    /**
-     * \brief Returns the value of a link attribute. The attribute must exist.
-     *
-     * \param name the name of the attribute
-     *
-     * \return the value of the attribute
-     */
-    std::string GetAttribute (std::string name);
-    /**
-     * \brief Returns the value of a link attribute.
-     * \param name the name of the attribute
-     * \param value the value of the attribute
-     *
-     * \return true if the attribute was defined, false otherwise.
-     */
-    bool GetAttributeFailSafe (std::string name, std::string &value);
-    /**
-     * \brief Sets an arbitrary link attribute.
-     * \param name the name of the attribute
-     * \param value the value of the attribute
-     */
-    void SetAttribute (std::string name, std::string &value);
-    /**
-     * \brief Returns an iterator to the begin of the attributes.
-     * \return a const iterator to the first attribute of a link.
-     */
-    ConstAttributesIterator AttributesBegin (void);
-    /**
-     * \brief Returns an iterator to the end of the attributes.
-     * \return a const iterator to the last attribute of a link.
-     */
-    ConstAttributesIterator AttributesEnd (void);
-
-private:
-    Link ();
-    std::string m_fromName;
-    Ptr< Node > m_fromPtr;
-    std::string m_toName;
-    Ptr< Node > m_toPtr;
-    std::map<std::string, std::string > m_linkAttr;
-  };
-
-  /**
-   * \brief Constant iterator to the list of the links.
-   */
-  typedef std::list< Link >::const_iterator ConstLinksIterator;
-
-  static TypeId GetTypeId (void);
-
-  TopologyReader ();
-  virtual ~TopologyReader ();
-
-  /**
-   * \brief Main topology reading function.
-   *
-   * The data is parsed and the results are returned in the passed lists.
-   * The rationale behind this choice is to allow non-progressive node IDs
-   * in the topology files, as well as to separate the topology
-   * reader from the choices about actual IP number assignment and
-   * kind of links between nodes.
-   *
-   * \return the container of the nodes created (or null if there was an error)
-   */
-  virtual NodeContainer Read (void) = 0;
-
-  /**
-   * \brief Sets the input file name.
-   * \param fileName the input file name.
-   */
-  void SetFileName (const std::string fileName);
-
-  /**
-   * \brief Returns the input file name.
-   * \return the input file name.
-   */
-  std::string GetFileName (void) const;
-
-  /**
-   * \brief Returns an iterator to the the first link in this block.
-   * \return a const iterator to the first link in this block.
-   */
-  ConstLinksIterator LinksBegin (void) const;
-
-  /**
-   * \brief Returns an iterator to the the last link in this block.
-   * \return a const iterator to the last link in this block.
-   */
-  ConstLinksIterator LinksEnd (void) const;
-
-  /**
-   * \brief Returns the number of links in this block.
-   * \return the number of links in this block.
-   */
-  int LinksSize (void) const;
-
-  /**
-   * \brief Checks if the block contains any links.
-   * \return true if there are no links in this block, false otherwise.
-   */
-  bool LinksEmpty (void) const;
-
-  /**
-   * \brief Adds a link to the topology.
-   * \param link the link to be added.
-   */
-  void AddLink (Link link);
-
-private:
-
-  TopologyReader (const TopologyReader&);
-  TopologyReader& operator= (const TopologyReader&);
-
-  std::string m_fileName;
-  std::list<Link> m_linksList;
-
-  // end class TopologyReader
-};
-
-// end namespace ns3
-};
-
-
-#endif // __TOPOLOGY_READER_H__
--- a/src/contrib/topology-read/topology.h	Thu Mar 03 22:32:06 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-/**
- * \addtogroup topology Topology Input Readers
- *
- * The topology modules aim at reading a topology file generated by an automatic topology generator.
- *
- * The process is divided in two steps:
- * - running a topology generator to build a topology file
- * - reading the topology file and build a ns-3 simulation
- *
- * Hence, model is focused on being able to read correctly the various topology formats.
- *
- * Currently there are two models:
- * - Orbis 0.7
- * - Inet 3.0
- *
- * A good source for topology data is also Archipelago (http://www.caida.org/projects/ark/)
- *
- * The current Archipelago Measurements, monthly updated, are stored here:
- * http://data.caida.org/datasets/topology/ipv4.allpref24-aslinks/
- * (complete notation and triple data source, one for each working group)
- *
- * A different and more compact notation that signs only the AS-relationships is here:
- * http://www.caida.org/data/active/as-relationships/index.xml
- * (a sort of more Orbis-like format)
- *
- * The compact notation can be easily stripped down to a pure Orbis format, just removing
- * the double relationships (the compact format use one-way links, while Orbis use two-way
- * links) and pruning the 3rd parameter. Note that with the compact data Orbis can then be
- * used create a rescaled version of the topology, thus being the most effective way
- * (to my best knowledge) to make an internet-like topology.
- *
- */
--- a/src/contrib/topology-read/wscript	Thu Mar 03 22:32:06 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,19 +0,0 @@
-## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
-
-def build(bld):
-    obj = bld.create_ns3_module('topology-read', ['network'])
-    obj.source = [
-       'topology-reader.cc',
-       'inet-topology-reader.cc',
-       'orbis-topology-reader.cc',
-       'rocketfuel-topology-reader.cc',
-        ]
-    headers = bld.new_task_gen('ns3header')
-    headers.module = 'topology-read'
-    headers.source = [
-       'topology-reader.h',
-       'inet-topology-reader.h',
-       'orbis-topology-reader.h',
-       'rocketfuel-topology-reader.h',
-        ]
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/topology-read/model/inet-topology-reader.cc	Fri Mar 04 09:59:42 2011 -0800
@@ -0,0 +1,140 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2010 Universita' di Firenze, Italy
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Tommaso Pecorella (tommaso.pecorella@unifi.it)
+ * Author: Valerio Sartini (Valesar@gmail.com)
+ */
+
+#include <fstream>
+#include <cstdlib>
+#include <sstream>
+
+#include "ns3/log.h"
+#include "inet-topology-reader.h"
+
+using namespace std;
+
+namespace ns3 {
+
+NS_LOG_COMPONENT_DEFINE ("InetTopologyReader");
+
+NS_OBJECT_ENSURE_REGISTERED (InetTopologyReader);
+
+TypeId InetTopologyReader::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::InetTopologyReader")
+    .SetParent<Object> ()
+  ;
+  return tid;
+}
+
+InetTopologyReader::InetTopologyReader ()
+{
+  NS_LOG_FUNCTION (this);
+}
+
+InetTopologyReader::~InetTopologyReader ()
+{
+  NS_LOG_FUNCTION (this);
+}
+
+NodeContainer
+InetTopologyReader::Read (void)
+{
+  ifstream topgen;
+  topgen.open (GetFileName ().c_str ());
+  map<string, Ptr<Node> > nodeMap;
+  NodeContainer nodes;
+
+  if ( !topgen.is_open () )
+    {
+      return nodes;
+    }
+
+  string from;
+  string to;
+  string linkAttr;
+
+  int linksNumber = 0;
+  int nodesNumber = 0;
+
+  int totnode = 0;
+  int totlink = 0;
+
+  istringstream lineBuffer;
+  string line;
+
+  getline (topgen,line);
+  lineBuffer.str (line);
+
+  lineBuffer >> totnode;
+  lineBuffer >> totlink;
+  NS_LOG_INFO ("Inet topology should have " << totnode << " nodes and " << totlink << " links");
+
+  for (int i = 0; i <= totnode; i++)
+    {
+      getline (topgen,line);
+    }
+
+  for (int i = 0; i < totlink && !topgen.eof (); i++)
+    {
+      getline (topgen,line);
+      lineBuffer.clear ();
+      lineBuffer.str (line);
+
+      lineBuffer >> from;
+      lineBuffer >> to;
+      lineBuffer >> linkAttr;
+
+      if ( (!from.empty ()) && (!to.empty ()) )
+        {
+          NS_LOG_INFO ( linksNumber << " From: " << from << " to: " << to );
+
+          if ( nodeMap[from] == 0 )
+            {
+              Ptr<Node> tmpNode = CreateObject<Node> ();
+              nodeMap[from] = tmpNode;
+              nodes.Add (tmpNode);
+              nodesNumber++;
+            }
+
+          if (nodeMap[to] == 0)
+            {
+              Ptr<Node> tmpNode = CreateObject<Node> ();
+              nodeMap[to] = tmpNode;
+              nodes.Add (tmpNode);
+              nodesNumber++;
+            }
+
+          Link link ( nodeMap[from], from, nodeMap[to], to );
+          if ( !linkAttr.empty () )
+            {
+              link.SetAttribute ("Weight", linkAttr);
+            }
+          AddLink (link);
+
+          linksNumber++;
+        }
+    }
+
+  NS_LOG_INFO ("Inet topology created with " << nodesNumber << " nodes and " << linksNumber << " links");
+  topgen.close ();
+
+  return nodes;
+}
+
+} /* namespace ns3 */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/topology-read/model/inet-topology-reader.h	Fri Mar 04 09:59:42 2011 -0800
@@ -0,0 +1,80 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2010 Universita' di Firenze, Italy
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Tommaso Pecorella (tommaso.pecorella@unifi.it)
+ * Author: Valerio Sartini (valesar@gmail.com)
+ */
+
+#ifndef __INET_TOPOLOGY_READER_H__
+#define __INET_TOPOLOGY_READER_H__
+
+#include "ns3/nstime.h"
+
+#include "topology-reader.h"
+
+namespace ns3 {
+
+
+// ------------------------------------------------------------
+// --------------------------------------------
+/**
+ * \ingroup topology
+ * \brief Topology file reader (Inet-format type).
+ *
+ * This class takes an input file in Inet format and extracts all
+ * the informations needed to build the topology
+ * (i.e.number of nodes, links and links structure).
+ * It have been tested with Inet 3.0
+ * http://topology.eecs.umich.edu/inet/
+ *
+ * It might set a link attribute named "Weight", corresponding to
+ * the euclidean distance between two nodes, the nodes being randomly positioned.
+ */
+class InetTopologyReader : public TopologyReader
+{
+public:
+  static TypeId GetTypeId (void);
+
+  InetTopologyReader ();
+  virtual ~InetTopologyReader ();
+
+  /**
+   * \brief Main topology reading function.
+   *
+   * This method opens an input stream and reads the Inet-format file.
+   * From the first line it takes the total number of nodes and links.
+   * Then discards a number of rows equals to total nodes (containing
+   * useless geographical informations).
+   * Then reads until the end of the file (total links number rows) and saves
+   * the structure of every single link in the topology.
+   *
+   * \return the container of the nodes created (or empty container if there was an error)
+   */
+  virtual NodeContainer Read (void);
+
+private:
+  InetTopologyReader (const InetTopologyReader&);
+  InetTopologyReader& operator= (const InetTopologyReader&);
+
+  // end class InetTopologyReader
+};
+
+// end namespace ns3
+};
+
+
+#endif // __INET_TOPOLOGY_READER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/topology-read/model/orbis-topology-reader.cc	Fri Mar 04 09:59:42 2011 -0800
@@ -0,0 +1,121 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2010 Universita' di Firenze, Italy
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Tommaso Pecorella (tommaso.pecorella@unifi.it)
+ * Author: Valerio Sartini (valesar@gmail.com)
+ */
+
+#include <fstream>
+#include <cstdlib>
+#include <iostream>
+#include <sstream>
+
+#include "ns3/log.h"
+#include "orbis-topology-reader.h"
+
+using namespace std;
+
+namespace ns3 {
+
+NS_LOG_COMPONENT_DEFINE ("OrbisTopologyReader");
+
+NS_OBJECT_ENSURE_REGISTERED (OrbisTopologyReader);
+
+TypeId OrbisTopologyReader::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::OrbisTopologyReader")
+    .SetParent<Object> ()
+  ;
+  return tid;
+}
+
+OrbisTopologyReader::OrbisTopologyReader ()
+{
+  NS_LOG_FUNCTION (this);
+}
+
+OrbisTopologyReader::~OrbisTopologyReader ()
+{
+  NS_LOG_FUNCTION (this);
+}
+
+NodeContainer
+OrbisTopologyReader::Read (void)
+{
+  ifstream topgen;
+  topgen.open (GetFileName ().c_str ());
+  map<string, Ptr<Node> > nodeMap;
+  NodeContainer nodes;
+
+  if ( !topgen.is_open () )
+    {
+      return nodes;
+    }
+
+  string from;
+  string to;
+  istringstream lineBuffer;
+  string line;
+
+  int linksNumber = 0;
+  int nodesNumber = 0;
+
+  while (!topgen.eof ())
+    {
+      line.clear ();
+      lineBuffer.clear ();
+      from.clear ();
+      to.clear ();
+
+      getline (topgen,line);
+      lineBuffer.str (line);
+      lineBuffer >> from;
+      lineBuffer >> to;
+
+      if ( (!from.empty ()) && (!to.empty ()) )
+        {
+          NS_LOG_INFO ( linksNumber << " From: " << from << " to: " << to );
+          if ( nodeMap[from] == 0 )
+            {
+              Ptr<Node> tmpNode = CreateObject<Node> ();
+              nodeMap[from] = tmpNode;
+              nodes.Add (tmpNode);
+              nodesNumber++;
+            }
+
+          if (nodeMap[to] == 0)
+            {
+              Ptr<Node> tmpNode = CreateObject<Node> ();
+              nodeMap[to] = tmpNode;
+              nodes.Add (tmpNode);
+              nodesNumber++;
+            }
+
+          Link link ( nodeMap[from], from, nodeMap[to], to );
+          AddLink (link);
+
+          linksNumber++;
+        }
+    }
+  NS_LOG_INFO ("Orbis topology created with " << nodesNumber << " nodes and " << linksNumber << " links");
+  topgen.close ();
+
+  return nodes;
+}
+
+} /* namespace ns3 */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/topology-read/model/orbis-topology-reader.h	Fri Mar 04 09:59:42 2011 -0800
@@ -0,0 +1,77 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2010 Universita' di Firenze, Italy
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Tommaso Pecorella (tommaso.pecorella@unifi.it)
+ * Author: Valerio Sartini (valesar@gmail.com)
+ */
+
+#ifndef __ORBIS_TOPOLOGY_READER_H__
+#define __ORBIS_TOPOLOGY_READER_H__
+
+#include "ns3/nstime.h"
+
+#include "topology-reader.h"
+
+namespace ns3 {
+
+
+// ------------------------------------------------------------
+// --------------------------------------------
+/**
+ * \ingroup topology
+ * \brief Topology file reader (Orbis-format type).
+ *
+ * This class takes an input file in Orbis format and extracts all
+ * the informations needed to build the topology
+ * (i.e.number of nodes, links and links structure).
+ * It have been tested with Orbis 0.70
+ * http://www.sysnet.ucsd.edu/~pmahadevan/topo_research/topo.html
+ */
+class OrbisTopologyReader : public TopologyReader
+{
+public:
+  static TypeId GetTypeId (void);
+
+  OrbisTopologyReader ();
+  virtual ~OrbisTopologyReader ();
+
+  /**
+   * \brief Main topology reading function.
+   *
+   * This method opens an input stream and reads the Orbis-format file.
+   * Every row represents a topology link (the ids of a couple of nodes),
+   * so the input file is read line by line to figure out how many links
+   * and nodes are in the topology.
+   *
+   * \return the container of the nodes created (or empty container if there was an error)
+   */
+  virtual NodeContainer Read (void);
+
+private:
+  OrbisTopologyReader (const OrbisTopologyReader&);
+  OrbisTopologyReader& operator= (const OrbisTopologyReader&);
+
+  // end class OrbisTopologyReader
+};
+
+// end namespace ns3
+};
+
+
+#endif // __ORBIS_TOPOLOGY_READER_H__
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/topology-read/model/rocketfuel-topology-reader.cc	Fri Mar 04 09:59:42 2011 -0800
@@ -0,0 +1,482 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2010 Hajime Tazaki
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Hajime Tazaki (tazaki@sfc.wide.ad.jp)
+ */
+
+#include <fstream>
+#include <cstdlib>
+#include <iostream>
+#include <sstream>
+#include <regex.h>
+
+#include "ns3/log.h"
+#include "rocketfuel-topology-reader.h"
+
+namespace ns3 {
+
+NS_LOG_COMPONENT_DEFINE ("RocketfuelTopologyReader");
+
+NS_OBJECT_ENSURE_REGISTERED (RocketfuelTopologyReader);
+
+TypeId RocketfuelTopologyReader::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::RocketfuelTopologyReader")
+    .SetParent<Object> ()
+  ;
+  return tid;
+}
+
+RocketfuelTopologyReader::RocketfuelTopologyReader ()
+{
+  NS_LOG_FUNCTION (this);
+}
+
+RocketfuelTopologyReader::~RocketfuelTopologyReader ()
+{
+  NS_LOG_FUNCTION (this);
+}
+
+/* uid @loc [+] [bb] (num_neigh) [&ext] -> <nuid-1> <nuid-2> ... {-euid} ... =name[!] rn */
+
+#define REGMATCH_MAX 16
+
+#define START "^"
+#define END "$"
+#define SPACE "[ \t]+"
+#define MAYSPACE "[ \t]*"
+
+#define ROCKETFUEL_MAPS_LINE \
+  START "(-*[0-9]+)" SPACE "(@[?A-Za-z0-9,+]+)" SPACE \
+  "(\\+)*" MAYSPACE "(bb)*" MAYSPACE \
+  "\\(([0-9]+)\\)" SPACE "(&[0-9]+)*" MAYSPACE \
+  "->" MAYSPACE "(<[0-9 \t<>]+>)*" MAYSPACE \
+  "(\\{-[0-9\\{\\} \t-]+\\})*" SPACE \
+  "=([A-Za-z0-9.!-]+)" SPACE "r([0-9])" \
+  MAYSPACE END
+
+#define ROCKETFUEL_WEIGHTS_LINE \
+  START "([^ \t]+)" SPACE "([^ \t]+)" SPACE "([0-9.]+)" MAYSPACE END
+
+int linksNumber = 0;
+int nodesNumber = 0;
+std::map<std::string, Ptr<Node> > nodeMap;
+
+NodeContainer
+RocketfuelTopologyReader::GenerateFromMapsFile (int argc, char *argv[])
+{
+  std::string uid;
+  std::string loc;
+  std::string ptr;
+  std::string name;
+  std::string nuid;
+  bool dns = false;
+  bool bb = false;
+  int num_neigh = 0;
+  int ext_conn = 0;
+  int radius = 0;
+  std::vector <std::string> neigh_list;
+  NodeContainer nodes;
+
+  uid = argv[0];
+  loc = argv[1];
+
+  if (argv[2])
+    dns = true;
+
+  if (argv[3])
+    bb = true;
+
+  num_neigh = ::atoi (argv[4]);
+
+  /* the first char should be '&' */
+  if (argv[5])
+    {
+      ext_conn = ::atoi (&argv[5][1]);
+    }
+
+  /* neighbors */
+  if (argv[6])
+    {
+      char *nbr;
+      char *stringp = argv[6];
+      while ((nbr = strsep (&stringp, " \t")) != NULL)
+        {
+          nbr[strlen (nbr) - 1] = '\0';
+          neigh_list.push_back (nbr + 1);
+        }
+    }
+
+  /* externs */
+  if (argv[7])
+    {
+      //      euid = argv[7];
+    }
+
+  /* name */
+  if (argv[8])
+    {
+      name = argv[8];
+    }
+
+  radius = ::atoi (&argv[9][1]);
+  if (radius > 0)
+    {
+      return nodes;
+    }
+
+  /* uid @loc [+] [bb] (num_neigh) [&ext] -> <nuid-1> <nuid-2> ... {-euid} ... =name[!] rn */
+  NS_LOG_INFO ("Load Node[" << uid << "]: location: " << loc << " dns: " << dns
+               << " bb: " << bb << " neighbors: " << neigh_list.size ()
+               << "(" << "%d" << ") externals: \"%s\"(%d) " 
+               << "name: " << name << " radius: " << radius); 
+
+  // Create node and link
+  if (!uid.empty ())
+    {
+      if (nodeMap[uid] == 0)
+        {
+          Ptr<Node> tmpNode = CreateObject<Node> ();
+          nodeMap[uid] = tmpNode;
+          nodes.Add (tmpNode);
+          nodesNumber++;
+        }
+
+      for (uint32_t i = 0; i < neigh_list.size (); ++i)
+        {
+          nuid = neigh_list[i];
+
+          if (nuid.empty ())
+            {
+              return nodes;
+            }
+
+          if (nodeMap[nuid] == 0)
+            {
+              Ptr<Node> tmpNode = CreateObject<Node> ();
+              nodeMap[nuid] = tmpNode;
+              nodes.Add (tmpNode);
+              nodesNumber++;
+            }
+          NS_LOG_INFO (linksNumber << ":" << nodesNumber << " From: " << uid << " to: " << nuid);
+          Link link (nodeMap[uid], uid, nodeMap[nuid], nuid);
+          AddLink (link);
+          linksNumber++;
+        }
+    }
+  return nodes;
+}
+
+NodeContainer
+RocketfuelTopologyReader::GenerateFromWeightsFile (int argc, char *argv[])
+{
+  /* uid @loc [+] [bb] (num_neigh) [&ext] -> <nuid-1> <nuid-2> ... {-euid} ... =name[!] rn */
+  std::string sname;
+  std::string tname;
+  double weight;
+  char *endptr;
+  NodeContainer nodes;
+
+  sname = argv[0];
+  tname = argv[1];
+  weight = strtod (argv[2], &endptr);
+  if (*endptr != '\0')
+    {
+      NS_LOG_WARN ("invalid weight: " << argv[2]);
+      return nodes;
+    }
+
+  // Create node and link
+  if (!sname.empty () && !tname.empty ())
+    {
+      if (nodeMap[sname] == 0)
+        {
+          Ptr<Node> tmpNode = CreateObject<Node> ();
+          nodeMap[sname] = tmpNode;
+          nodes.Add (tmpNode);
+          nodesNumber++;
+        }
+
+      if (nodeMap[tname] == 0)
+        {
+          Ptr<Node> tmpNode = CreateObject<Node> ();
+          nodeMap[tname] = tmpNode;
+          nodes.Add (tmpNode);
+          nodesNumber++;
+        }
+      NS_LOG_INFO (linksNumber << ":" << nodesNumber << " From: " << sname << " to: " << tname);
+      TopologyReader::ConstLinksIterator iter;
+      bool found = false;
+      for (iter = LinksBegin (); iter != LinksEnd (); iter++)
+        {
+          if ((iter->GetFromNode () == nodeMap[tname]) &&
+              (iter->GetToNode () == nodeMap[sname]))
+            {
+              found = true;
+              break;
+            }
+        }
+
+      if (!found)
+        {
+          Link link (nodeMap[sname], sname, nodeMap[tname], tname);
+          AddLink (link);
+          linksNumber++;
+        }
+    }
+  return nodes;
+}
+
+enum RocketfuelTopologyReader::RF_FileType
+RocketfuelTopologyReader::GetFileType (const char *line)
+{
+  int ret;
+  regmatch_t regmatch[REGMATCH_MAX];
+  regex_t regex;
+  char errbuf[512];
+
+  // Check whether MAPS file or not
+  ret = regcomp (&regex, ROCKETFUEL_MAPS_LINE, REG_EXTENDED|REG_NEWLINE);
+  if (ret != 0)
+    {
+      regerror (ret, &regex, errbuf, sizeof (errbuf));
+      return RF_UNKNOWN;
+    }
+  ret = regexec (&regex, line, REGMATCH_MAX, regmatch, 0);
+  if (ret != REG_NOMATCH)
+    {
+      regfree (&regex);
+      return RF_MAPS;
+    }
+  regfree (&regex);
+
+  // Check whether Weights file or not
+  ret = regcomp (&regex, ROCKETFUEL_WEIGHTS_LINE, REG_EXTENDED|REG_NEWLINE);
+  if (ret != 0)
+    {
+      regerror (ret, &regex, errbuf, sizeof (errbuf));
+      return RF_UNKNOWN;
+    }
+  ret = regexec (&regex, line, REGMATCH_MAX, regmatch, 0);
+  if (ret != REG_NOMATCH)
+    {
+      regfree (&regex);
+      return RF_WEIGHTS;
+    }
+  regfree (&regex);
+
+  return RF_UNKNOWN;
+}
+
+
+NodeContainer
+RocketfuelTopologyReader::Read (void)
+{
+  std::ifstream topgen;
+  topgen.open (GetFileName ().c_str ());
+  NodeContainer nodes;
+
+  std::istringstream lineBuffer;
+  std::string line;
+  int lineNumber = 0;
+  enum RF_FileType ftype = RF_UNKNOWN;
+  char errbuf[512];
+
+  if (!topgen.is_open ())
+    {
+      NS_LOG_WARN ("Couldn't open the file " << GetFileName ());
+      return nodes;
+    }
+
+  while (!topgen.eof ())
+    {
+      int ret;
+      int argc;
+      char *argv[REGMATCH_MAX];
+      char *buf;
+
+      lineNumber++;
+      line.clear ();
+      lineBuffer.clear ();
+
+      getline (topgen, line);
+      buf = (char *)line.c_str ();
+
+      if (lineNumber == 1)
+        {
+          ftype = GetFileType (buf);
+          if (ftype == RF_UNKNOWN)
+            {
+              NS_LOG_INFO ("Unknown File Format (" << GetFileName () << ")");
+              break;
+            }
+        }
+
+      regmatch_t regmatch[REGMATCH_MAX];
+      regex_t regex;
+
+      if (ftype == RF_MAPS)
+        {
+          ret = regcomp (&regex, ROCKETFUEL_MAPS_LINE, REG_EXTENDED|REG_NEWLINE);
+          if (ret != 0)
+            {
+              regerror (ret, &regex, errbuf, sizeof (errbuf));
+              regfree (&regex);
+              break;
+            }
+
+          ret = regexec (&regex, buf, REGMATCH_MAX, regmatch, 0);
+          if (ret == REG_NOMATCH)
+            {
+              NS_LOG_WARN ("match failed (maps file): %s" << buf);
+              regfree (&regex);
+              break;
+            }
+        }
+      else if (ftype == RF_WEIGHTS)
+        {
+          ret = regcomp (&regex, ROCKETFUEL_WEIGHTS_LINE, REG_EXTENDED|REG_NEWLINE);
+          if (ret != 0)
+            {
+              regerror (ret, &regex, errbuf, sizeof (errbuf));
+              regfree (&regex);
+              break;
+            }
+
+          ret = regexec (&regex, buf, REGMATCH_MAX, regmatch, 0);
+          if (ret == REG_NOMATCH)
+            {
+              NS_LOG_WARN ("match failed (weights file): %s" << buf);
+              regfree (&regex);
+              break;
+            }
+        }
+
+      line = buf;
+      argc = 0;
+
+      /* regmatch[0] is the entire strings that matched */
+      for (int i = 1; i < REGMATCH_MAX; i++)
+        {
+          if (regmatch[i].rm_so == -1)
+            {
+              argv[i-1] = NULL;
+            }
+          else
+            {
+              line[regmatch[i].rm_eo] = '\0';
+              argv[i-1] = &line[regmatch[i].rm_so];
+              argc = i;
+            }
+        }
+
+      if (ftype == RF_MAPS)
+        {
+          nodes.Add (GenerateFromMapsFile (argc, argv));
+        }
+      else if (ftype == RF_WEIGHTS)
+        {
+          nodes.Add (GenerateFromWeightsFile (argc, argv));
+        }
+      else
+        {
+          NS_LOG_WARN ("Unsupported file format (only Maps/Weights are supported)");
+        }
+
+      regfree (&regex);
+    }
+
+
+  topgen.close ();
+
+  NS_LOG_INFO ("Rocketfuel topology created with " << nodesNumber << " nodes and " << linksNumber << " links");
+  return nodes;
+}
+
+} /* namespace ns3 */
+
+
+//-----------------------------------------------------------------------------
+// Unit tests
+//-----------------------------------------------------------------------------
+
+#include "ns3/log.h"
+#include "ns3/abort.h"
+#include "ns3/attribute.h"
+#include "ns3/object-factory.h"
+#include "ns3/object-factory.h"
+#include "ns3/simulator.h"
+#include "ns3/test.h"
+
+namespace ns3 {
+
+class RocketfuelTopologyReaderTest: public TestCase 
+{
+public:
+  RocketfuelTopologyReaderTest ();
+private:
+  virtual void DoRun (void);
+};
+
+RocketfuelTopologyReaderTest::RocketfuelTopologyReaderTest ()
+  : TestCase ("RocketfuelTopologyReaderTest") 
+{}
+
+
+void
+RocketfuelTopologyReaderTest::DoRun (void)
+{
+  Ptr<RocketfuelTopologyReader> inFile;
+  NodeContainer nodes;
+  
+  std::string input ("./examples/topology-read/RocketFuel_toposample_1239_weights.txt");
+
+  inFile = CreateObject<RocketfuelTopologyReader> ();
+  inFile->SetFileName(input);
+
+  if (inFile != 0)
+    {
+      nodes = inFile->Read ();
+    }
+
+  NS_TEST_ASSERT_MSG_NE (nodes.GetN (), 0, "Problems reading node information the topology file..");
+
+  NS_TEST_ASSERT_MSG_NE (inFile->LinksSize (), 0, "Problems reading the topology file.");
+
+  NS_LOG_INFO ("Rocketfuel topology created with " << nodes.GetN () << " nodes and " << 
+               inFile->LinksSize () << " links (from " << input << ")");
+
+  NS_TEST_EXPECT_MSG_EQ (nodes.GetN (),315, "noes");
+  NS_TEST_EXPECT_MSG_EQ (inFile->LinksSize (),972, "links");
+  Simulator::Destroy ();
+}
+
+static class RocketfuelTopologyReaderTestSuite : public TestSuite
+{
+public:
+  RocketfuelTopologyReaderTestSuite ();
+private:
+} g_rocketfueltopologyreaderTests;
+
+RocketfuelTopologyReaderTestSuite::RocketfuelTopologyReaderTestSuite ()
+  : TestSuite ("rocketfuel-topology-reader", UNIT)
+{
+  AddTestCase (new RocketfuelTopologyReaderTest ());
+}
+
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/topology-read/model/rocketfuel-topology-reader.h	Fri Mar 04 09:59:42 2011 -0800
@@ -0,0 +1,90 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2010 Hajime Tazaki
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Hajime Tazaki (tazaki@sfc.wide.ad.jp)
+ */
+
+#ifndef __ROCKETFUEL_TOPOLOGY_READER_H__
+#define __ROCKETFUEL_TOPOLOGY_READER_H__
+
+#include "ns3/nstime.h"
+
+#include "topology-reader.h"
+
+namespace ns3 {
+
+
+// ------------------------------------------------------------
+// --------------------------------------------
+/**
+ * \ingroup topology
+ * \brief Topology file reader (Rocketfuel-format type).
+ *
+ * http://www.cs.washington.edu/research/networking/rocketfuel/
+ *
+ * May 2nd, 2010: Currently only support "weights" file and "cch" file.
+ * http://www.cs.washington.edu/research/networking/rocketfuel/maps/weights-dist.tar.gz
+ * http://www.cs.washington.edu/research/networking/rocketfuel/maps/rocketfuel_maps_cch.tar.gz
+ */
+class RocketfuelTopologyReader : public TopologyReader
+{
+public:
+  static TypeId GetTypeId (void);
+
+  RocketfuelTopologyReader ();
+  virtual ~RocketfuelTopologyReader ();
+
+  /**
+   * \brief Main topology reading function.
+   *
+   * This method opens an input stream and reads the Rocketfuel-format file.
+   * Every row represents a topology link (the ids of a couple of nodes),
+   * so the input file is read line by line to figure out how many links
+   * and nodes are in the topology.
+   *
+   * \return the container of the nodes created (or empty container if there was an error)
+   */
+  virtual NodeContainer Read (void);
+
+private:
+  RocketfuelTopologyReader (const RocketfuelTopologyReader&);
+  RocketfuelTopologyReader& operator= (const RocketfuelTopologyReader&);
+  // Parser for the *.cch file available at:
+  // http://www.cs.washington.edu/research/networking/rocketfuel/maps/rocketfuel_maps_cch.tar.gz
+  NodeContainer GenerateFromMapsFile (int argc, char *argv[]);
+  // Parser for the weights.* file available at:
+  // http://www.cs.washington.edu/research/networking/rocketfuel/maps/weights-dist.tar.gz
+  NodeContainer GenerateFromWeightsFile (int argc, char *argv[]);
+
+  enum RF_FileType
+    {   
+      RF_MAPS,
+      RF_WEIGHTS,
+      RF_UNKNOWN
+    };
+  enum RF_FileType GetFileType (const char *);
+
+  // end class RocketfuelTopologyReader
+};
+
+// end namespace ns3
+};
+
+
+#endif // __ROCKETFUEL_TOPOLOGY_READER_H__
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/topology-read/model/topology-reader.cc	Fri Mar 04 09:59:42 2011 -0800
@@ -0,0 +1,169 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2010 Universita' di Firenze, Italy
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Tommaso Pecorella (tommaso.pecorella@unifi.it)
+ * Author: Valerio Sartini (valesar@gmail.com)
+ */
+
+#include "ns3/log.h"
+
+#include "topology-reader.h"
+
+
+namespace ns3 {
+
+NS_LOG_COMPONENT_DEFINE ("TopologyReader");
+
+NS_OBJECT_ENSURE_REGISTERED (TopologyReader);
+
+TypeId TopologyReader::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::TopologyReader")
+    .SetParent<Object> ()
+  ;
+  return tid;
+}
+
+TopologyReader::TopologyReader ()
+{
+  NS_LOG_FUNCTION (this);
+}
+
+TopologyReader::~TopologyReader ()
+{
+  NS_LOG_FUNCTION (this);
+}
+
+void
+TopologyReader::SetFileName (const std::string fileName)
+{
+  m_fileName = fileName;
+}
+
+std::string
+TopologyReader::GetFileName () const
+{
+  return m_fileName;
+}
+
+/* Manipulating the address block */
+
+TopologyReader::ConstLinksIterator
+TopologyReader::LinksBegin (void) const
+{
+  return m_linksList.begin ();
+}
+
+TopologyReader::ConstLinksIterator
+TopologyReader::LinksEnd (void) const
+{
+  return m_linksList.end ();
+}
+
+int
+TopologyReader::LinksSize (void) const
+{
+  return m_linksList.size ();
+}
+
+bool
+TopologyReader::LinksEmpty (void) const
+{
+  return m_linksList.empty ();
+}
+
+void
+TopologyReader::AddLink (Link link)
+{
+  m_linksList.push_back (link);
+  return;
+}
+
+
+TopologyReader::Link::Link ( Ptr<Node> fromPtr, std::string fromName, Ptr<Node> toPtr, std::string toName )
+{
+  m_fromPtr = fromPtr;
+  m_fromName = fromName;
+  m_toPtr = toPtr;
+  m_toName = toName;
+}
+
+TopologyReader::Link::Link ()
+{
+}
+
+
+Ptr<Node> TopologyReader::Link::GetFromNode (void) const
+{
+  return m_fromPtr;
+}
+
+std::string
+TopologyReader::Link::GetFromNodeName (void) const
+{
+  return m_fromName;
+}
+
+Ptr<Node>
+TopologyReader::Link::GetToNode (void) const
+{
+  return m_toPtr;
+}
+
+std::string
+TopologyReader::Link::GetToNodeName (void) const
+{
+  return m_toName;
+}
+
+std::string
+TopologyReader::Link::GetAttribute (std::string name)
+{
+  NS_ASSERT_MSG (m_linkAttr.find ("name") == m_linkAttr.end (), "Requested topology link attribute not found");
+  return m_linkAttr[name];
+}
+
+bool
+TopologyReader::Link::GetAttributeFailSafe (std::string name, std::string &value)
+{
+  if ( m_linkAttr.find ("name") == m_linkAttr.end () )
+    {
+      return false;
+    }
+  value = m_linkAttr[name];
+  return true;
+}
+
+void
+TopologyReader::Link::SetAttribute (std::string name, std::string &value)
+{
+  m_linkAttr[name] = value;
+}
+
+TopologyReader::Link::ConstAttributesIterator
+TopologyReader::Link::AttributesBegin (void)
+{
+  return m_linkAttr.begin ();
+}
+TopologyReader::Link::ConstAttributesIterator
+TopologyReader::Link::AttributesEnd (void)
+{
+  return m_linkAttr.end ();
+}
+
+
+} /* namespace ns3 */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/topology-read/model/topology-reader.h	Fri Mar 04 09:59:42 2011 -0800
@@ -0,0 +1,207 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2010 Universita' di Firenze, Italy
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Tommaso Pecorella (tommaso.pecorella@unifi.it)
+ * Author: Valerio Sartini (valesar@gmail.com)
+ */
+
+#ifndef __TOPOLOGY_READER_H__
+#define __TOPOLOGY_READER_H__
+
+#include <string>
+#include <map>
+#include <list>
+
+#include "ns3/object.h"
+#include "ns3/node-container.h"
+
+
+namespace ns3 {
+
+/**
+ * \defgroup topology Topology Input Readers
+ */
+
+/**
+ * \ingroup topology
+ * \brief Interface for input file readers management.
+ *
+ * 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
+{
+
+public:
+  /**
+   * \ingroup topology
+   * \brief Inner class holding the details about a link between two nodes.
+   *
+   * The link is not described in terms of technology. Rather it is only stating
+   * an association between two nodes. The nodes are characterized also with names
+   * reflecting how the nodes are called in the original topology file.
+   */
+  class Link
+  {
+public:
+    typedef std::map<std::string, std::string >::const_iterator ConstAttributesIterator;
+
+    Link ( Ptr<Node> fromPtr, std::string fromName, Ptr<Node> toPtr, std::string toName );
+
+    /**
+     * \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 the name of the "from" node of the link
+     * \return the name of the "from" node of the link
+     */
+    std::string GetFromNodeName (void) const;
+    /**
+     * \brief Returns a Ptr<Node> to the "to" node of the link
+     * \return a Ptr<Node> to the "to" node of the link
+     */
+    Ptr<Node> GetToNode (void) const;
+    /**
+     * \brief Returns the name of the "to" node of the link
+     * \return the name of the "to" node of the link
+     */
+    std::string GetToNodeName (void) const;
+    /**
+     * \brief Returns the value of a link attribute. The attribute must exist.
+     *
+     * \param name the name of the attribute
+     *
+     * \return the value of the attribute
+     */
+    std::string GetAttribute (std::string name);
+    /**
+     * \brief Returns the value of a link attribute.
+     * \param name the name of the attribute
+     * \param value the value of the attribute
+     *
+     * \return true if the attribute was defined, false otherwise.
+     */
+    bool GetAttributeFailSafe (std::string name, std::string &value);
+    /**
+     * \brief Sets an arbitrary link attribute.
+     * \param name the name of the attribute
+     * \param value the value of the attribute
+     */
+    void SetAttribute (std::string name, std::string &value);
+    /**
+     * \brief Returns an iterator to the begin of the attributes.
+     * \return a const iterator to the first attribute of a link.
+     */
+    ConstAttributesIterator AttributesBegin (void);
+    /**
+     * \brief Returns an iterator to the end of the attributes.
+     * \return a const iterator to the last attribute of a link.
+     */
+    ConstAttributesIterator AttributesEnd (void);
+
+private:
+    Link ();
+    std::string m_fromName;
+    Ptr< Node > m_fromPtr;
+    std::string m_toName;
+    Ptr< Node > m_toPtr;
+    std::map<std::string, std::string > m_linkAttr;
+  };
+
+  /**
+   * \brief Constant iterator to the list of the links.
+   */
+  typedef std::list< Link >::const_iterator ConstLinksIterator;
+
+  static TypeId GetTypeId (void);
+
+  TopologyReader ();
+  virtual ~TopologyReader ();
+
+  /**
+   * \brief Main topology reading function.
+   *
+   * The data is parsed and the results are returned in the passed lists.
+   * The rationale behind this choice is to allow non-progressive node IDs
+   * in the topology files, as well as to separate the topology
+   * reader from the choices about actual IP number assignment and
+   * kind of links between nodes.
+   *
+   * \return the container of the nodes created (or null if there was an error)
+   */
+  virtual NodeContainer Read (void) = 0;
+
+  /**
+   * \brief Sets the input file name.
+   * \param fileName the input file name.
+   */
+  void SetFileName (const std::string fileName);
+
+  /**
+   * \brief Returns the input file name.
+   * \return the input file name.
+   */
+  std::string GetFileName (void) const;
+
+  /**
+   * \brief Returns an iterator to the the first link in this block.
+   * \return a const iterator to the first link in this block.
+   */
+  ConstLinksIterator LinksBegin (void) const;
+
+  /**
+   * \brief Returns an iterator to the the last link in this block.
+   * \return a const iterator to the last link in this block.
+   */
+  ConstLinksIterator LinksEnd (void) const;
+
+  /**
+   * \brief Returns the number of links in this block.
+   * \return the number of links in this block.
+   */
+  int LinksSize (void) const;
+
+  /**
+   * \brief Checks if the block contains any links.
+   * \return true if there are no links in this block, false otherwise.
+   */
+  bool LinksEmpty (void) const;
+
+  /**
+   * \brief Adds a link to the topology.
+   * \param link the link to be added.
+   */
+  void AddLink (Link link);
+
+private:
+
+  TopologyReader (const TopologyReader&);
+  TopologyReader& operator= (const TopologyReader&);
+
+  std::string m_fileName;
+  std::list<Link> m_linksList;
+
+  // end class TopologyReader
+};
+
+// end namespace ns3
+};
+
+
+#endif // __TOPOLOGY_READER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/topology-read/model/topology.h	Fri Mar 04 09:59:42 2011 -0800
@@ -0,0 +1,32 @@
+/**
+ * \addtogroup topology Topology Input Readers
+ *
+ * The topology modules aim at reading a topology file generated by an automatic topology generator.
+ *
+ * The process is divided in two steps:
+ * - running a topology generator to build a topology file
+ * - reading the topology file and build a ns-3 simulation
+ *
+ * Hence, model is focused on being able to read correctly the various topology formats.
+ *
+ * Currently there are two models:
+ * - Orbis 0.7
+ * - Inet 3.0
+ *
+ * A good source for topology data is also Archipelago (http://www.caida.org/projects/ark/)
+ *
+ * The current Archipelago Measurements, monthly updated, are stored here:
+ * http://data.caida.org/datasets/topology/ipv4.allpref24-aslinks/
+ * (complete notation and triple data source, one for each working group)
+ *
+ * A different and more compact notation that signs only the AS-relationships is here:
+ * http://www.caida.org/data/active/as-relationships/index.xml
+ * (a sort of more Orbis-like format)
+ *
+ * The compact notation can be easily stripped down to a pure Orbis format, just removing
+ * the double relationships (the compact format use one-way links, while Orbis use two-way
+ * links) and pruning the 3rd parameter. Note that with the compact data Orbis can then be
+ * used create a rescaled version of the topology, thus being the most effective way
+ * (to my best knowledge) to make an internet-like topology.
+ *
+ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/topology-read/wscript	Fri Mar 04 09:59:42 2011 -0800
@@ -0,0 +1,20 @@
+## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
+
+def build(bld):
+    obj = bld.create_ns3_module('topology-read', ['network'])
+    obj.source = [
+       'model/topology-reader.cc',
+       'model/inet-topology-reader.cc',
+       'model/orbis-topology-reader.cc',
+       'model/rocketfuel-topology-reader.cc',
+        ]
+    headers = bld.new_task_gen('ns3header')
+    headers.module = 'topology-read'
+    headers.source = [
+       'model/topology.h',
+       'model/topology-reader.h',
+       'model/inet-topology-reader.h',
+       'model/orbis-topology-reader.h',
+       'model/rocketfuel-topology-reader.h',
+        ]
+
--- a/src/wscript	Thu Mar 03 22:32:06 2011 -0800
+++ b/src/wscript	Fri Mar 04 09:59:42 2011 -0800
@@ -53,7 +53,7 @@
     'wimax',
     'lte',
     'mpi',
-    'contrib/topology-read',
+    'topology-read',
     'contrib/energy',
     'tools/visualizer',
     )