27#include "ns3/node-container.h" 
   44  static TypeId tid = 
TypeId (
"ns3::RocketfuelTopologyReader")
 
   46    .SetGroupName (
"TopologyReader")
 
   68#define REGMATCH_MAX 16 
   77#define MAYSPACE "[ \t]*" 
   80#define ROCKETFUEL_MAPS_LINE \ 
   81  START "(-*[0-9]+)" SPACE "(@[?A-Za-z0-9,+]+)" SPACE \
 
   82  "(\\+)*" MAYSPACE "(bb)*" MAYSPACE \
 
   83  "\\(([0-9]+)\\)" SPACE "(&[0-9]+)*" MAYSPACE \
 
   84  "->" MAYSPACE "(<[0-9 \t<>]+>)*" MAYSPACE \
 
   85  "(\\{-[0-9\\{\\} \t-]+\\})*" SPACE \
 
   86  "=([A-Za-z0-9.!-]+)" SPACE "r([0-9])" \
 
   90#define ROCKETFUEL_WEIGHTS_LINE \ 
   91  START "([^ \t]+)" SPACE "([^ \t]+)" SPACE "([0-9.]+)" MAYSPACE END
 
  105               std::vector <std::string>::size_type neighListSize,
 
  106               std::string & name, 
int radius)
 
  109  NS_LOG_INFO (
"Load Node[" << uid << 
"]: location: " << loc << 
" dns: " << dns
 
  110                            << 
" bb: " << bb << 
" neighbors: " << neighListSize
 
  111                            << 
"(" << 
"%d" << 
") externals: \"%s\"(%d) " 
  112                            << 
"name: " << name << 
" radius: " << radius);
 
  126  unsigned int num_neigh = 0;
 
  128  std::vector <std::string> neigh_list;
 
  144  num_neigh_s = ::atoi (argv[4]);
 
  148      NS_LOG_WARN (
"Negative number of neighbors given");
 
  152      num_neigh = num_neigh_s;
 
  159      char *stringp = argv[6];
 
  160      while ((nbr = strsep (&stringp, 
" \t")) != NULL)
 
  162          nbr[strlen (nbr) - 1] = 
'\0';
 
  163          neigh_list.push_back (nbr + 1);
 
  166  if (num_neigh != neigh_list.size ())
 
  168      NS_LOG_WARN (
"Given number of neighbors = " << num_neigh << 
" != size of neighbors list = " << neigh_list.size ());
 
  183  radius = ::atoi (&argv[9][1]);
 
  189  PrintNodeInfo (uid, loc, dns, bb, neigh_list.size (), name, radius);
 
  196          Ptr<Node> tmpNode = CreateObject<Node> ();
 
  202      for (
uint32_t i = 0; i < neigh_list.size (); ++i)
 
  204          nuid = neigh_list[i];
 
  213              Ptr<Node> tmpNode = CreateObject<Node> ();
 
  241  [[maybe_unused]] 
double v = strtod (argv[2], &endptr); 
 
  250  if (!sname.empty () && !tname.empty ())
 
  254          Ptr<Node> tmpNode = CreateObject<Node> ();
 
  262          Ptr<Node> tmpNode = CreateObject<Node> ();
 
  272          if ((iter->GetFromNode () == 
m_nodeMap[tname])
 
  273              && (iter->GetToNode () == 
m_nodeMap[sname]))
 
  305      regerror (ret, ®ex, errbuf, 
sizeof (errbuf));
 
  308  ret = regexec (®ex, line, 
REGMATCH_MAX, regmatch, 0);
 
  309  if (ret != REG_NOMATCH)
 
  320      regerror (ret, ®ex, errbuf, 
sizeof (errbuf));
 
  323  ret = regexec (®ex, line, 
REGMATCH_MAX, regmatch, 0);
 
  324  if (ret != REG_NOMATCH)
 
  338  std::ifstream topgen;
 
  342  std::istringstream lineBuffer;
 
  348  if (!topgen.is_open ())
 
  354  while (!topgen.eof ())
 
  365      getline (topgen, line);
 
  366      buf = (
char *)line.c_str ();
 
  386              regerror (ret, ®ex, errbuf, 
sizeof (errbuf));
 
  392          if (ret == REG_NOMATCH)
 
  394              NS_LOG_WARN (
"match failed (maps file): %s" << buf);
 
  404              regerror (ret, ®ex, errbuf, 
sizeof (errbuf));
 
  410          if (ret == REG_NOMATCH)
 
  412              NS_LOG_WARN (
"match failed (weights file): %s" << buf);
 
  424          if (regmatch[i].rm_so == -1)
 
  430              line[regmatch[i].rm_eo] = 
'\0';
 
  431              argv[i - 1] = &line[regmatch[i].rm_so];
 
  446          NS_LOG_WARN (
"Unsupported file format (only Maps/Weights are supported)");
 
keep track of a set of node pointers.
Topology file reader (Rocketfuel-format type).
RF_FileType
Enum of the possible file types.
static TypeId GetTypeId(void)
Get the type ID.
enum RF_FileType GetFileType(const char *buf)
Classifies the file type according to its content.
NodeContainer GenerateFromWeightsFile(int argc, char *argv[])
Topology read function from a file containing the nodes weights.
RocketfuelTopologyReader()
std::map< std::string, Ptr< Node > > m_nodeMap
Map of the nodes (name, node).
int m_nodesNumber
Number of nodes.
NodeContainer GenerateFromMapsFile(int argc, char *argv[])
Topology read function from a file containing the nodes map.
virtual ~RocketfuelTopologyReader()
virtual NodeContainer Read(void)
Main topology reading function.
int m_linksNumber
Number of links.
Inner class holding the details about a link between two nodes.
Interface for input file readers management.
ConstLinksIterator LinksBegin(void) const
Returns an iterator to the the first link in this block.
void AddLink(Link link)
Adds a link to the topology.
ConstLinksIterator LinksEnd(void) const
Returns an iterator to the the last link in this block.
std::string GetFileName(void) const
Returns the input file name.
std::list< Link >::const_iterator ConstLinksIterator
Constant iterator to the list of the links.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static void PrintNodeInfo(std::string &uid, std::string &loc, bool dns, bool bb, std::vector< std::string >::size_type neighListSize, std::string &name, int radius)
Print node info.
#define ROCKETFUEL_MAPS_LINE
Regex expression matching a MAP line.
#define ROCKETFUEL_WEIGHTS_LINE
Regex expression matching a WEIGHT line.
#define REGMATCH_MAX
Maximum nuber of matches in a regex query.
ns3::RocketfuelTopologyReader declaration.