13#include "ns3/node-container.h"
37 static TypeId tid =
TypeId(
"ns3::RocketfuelTopologyReader")
39 .SetGroupName(
"TopologyReader")
65#define MAYSPACE "[ \t]*"
68#define ROCKETFUEL_MAPS_LINE \
69 START "(-*[0-9]+)" SPACE "(@[?A-Za-z0-9,+-]+)" SPACE "(\\+)*" MAYSPACE "(bb)*" MAYSPACE \
70 "\\(([0-9]+)\\)" SPACE "(&[0-9]+)*" MAYSPACE "->" MAYSPACE "(<[0-9 \t<>]+>)*" MAYSPACE \
71 "(\\{-[0-9\\{\\} \t-]+\\})*" SPACE "=([A-Za-z0-9.!-]+)" SPACE "r([0-9])" MAYSPACE END
74#define ROCKETFUEL_WEIGHTS_LINE START "([^ \t]+)" SPACE "([^ \t]+)" SPACE "([0-9.]+)" MAYSPACE END
108 NS_LOG_INFO(
"Load Node[" <<
uid <<
"]: location: " << loc <<
" dns: " <<
dns <<
" bb: " <<
bb
111 <<
") externals: \"%s\"(%d) "
112 <<
"name: " << name <<
" radius: " <<
radius);
133 if (!
argv[2].empty())
138 if (!
argv[3].empty())
155 if (!
argv[6].empty())
161 std::regex_replace(std::back_inserter(
temp),
170 std::sregex_token_iterator
last;
180 if (!
argv[7].empty())
186 if (!
argv[8].empty())
205 std::string
nodename =
"RocketFuelTopology/NodeName/" +
uid;
222 std::string
nodename =
"RocketFuelTopology/NodeName/" +
nuid;
248 std::string::size_type
endptr;
267 std::string
nodename =
"RocketFuelTopology/NodeName/" +
sname;
277 std::string
nodename =
"RocketFuelTopology/NodeName/" +
tname;
284 <<
" to: " <<
tname);
350 std::vector<std::string>
argv;
375 NS_LOG_WARN(
"match failed (maps file): %s" << line);
384 NS_LOG_WARN(
"match failed (weights file): %s" << line);
414 NS_LOG_WARN(
"Unsupported file format (only Maps/Weights are supported)");
static void Add(std::string name, Ptr< Object > object)
Add the association between the string "name" and the Ptr<Object> obj.
keep track of a set of node pointers.
Smart pointer class similar to boost::intrusive_ptr.
Topology file reader (Rocketfuel-format type).
RF_FileType
Enum of the possible file types.
RocketfuelTopologyReader()
NodeContainer GenerateFromWeightsFile(const std::vector< std::string > &argv)
Topology read function from a file containing the nodes weights.
std::map< std::string, Ptr< Node > > m_nodeMap
Map of the nodes (name, node).
int m_nodesNumber
Number of nodes.
static TypeId GetTypeId()
Get the type ID.
RF_FileType GetFileType(const std::string &buf)
Classifies the file type according to its content.
NodeContainer GenerateFromMapsFile(const std::vector< std::string > &argv)
Topology read function from a file containing the nodes map.
~RocketfuelTopologyReader() override
NodeContainer Read() override
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.
void AddLink(Link link)
Adds a link to the topology.
ConstLinksIterator LinksEnd() const
Returns an iterator to the the last link in this block.
std::string GetFileName() const
Returns the input file name.
ConstLinksIterator LinksBegin() const
Returns an iterator to the the first link in this block.
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.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static const std::regex rocketfuel_maps_regex(ROCKETFUEL_MAPS_LINE)
Build a Regex object for RocketFuel topology maps file type.
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.
static const std::regex rocketfuel_weights_regex(ROCKETFUEL_WEIGHTS_LINE)
Build a Regex object for RocketFuel topology weights file type.
#define ROCKETFUEL_MAPS_LINE
Regex expression matching a MAP line.
#define ROCKETFUEL_WEIGHTS_LINE
Regex expression matching a WEIGHT line.
ns3::RocketfuelTopologyReader declaration.