41 .SetGroupName (
"TopologyReader")
61 std::map<std::string, Ptr<Node> > nodeMap;
64 if ( !topgen.is_open () )
66 NS_LOG_WARN (
"Inet topology file object is not open, check file name and permissions");
80 std::istringstream lineBuffer;
83 getline (topgen,line);
84 lineBuffer.str (line);
86 lineBuffer >> totnode;
87 lineBuffer >> totlink;
88 NS_LOG_INFO (
"Inet topology should have " << totnode <<
" nodes and " << totlink <<
" links");
90 for (
int i = 0; i < totnode && !topgen.eof (); i++)
92 getline (topgen,line);
95 for (
int i = 0; i < totlink && !topgen.eof (); i++)
97 getline (topgen,line);
99 lineBuffer.str (line);
103 lineBuffer >> linkAttr;
105 if ( (!from.empty ()) && (!to.empty ()) )
107 NS_LOG_INFO (
"Link " << linksNumber <<
" from: " << from <<
" to: " << to);
109 if ( nodeMap[from] == 0 )
111 NS_LOG_INFO (
"Node " << nodesNumber <<
" name: " << from);
112 Ptr<Node> tmpNode = CreateObject<Node> ();
113 nodeMap[from] = tmpNode;
118 if (nodeMap[to] == 0)
120 NS_LOG_INFO (
"Node " << nodesNumber <<
" name: " << to);
121 Ptr<Node> tmpNode = CreateObject<Node> ();
122 nodeMap[to] = tmpNode;
127 Link link ( nodeMap[from], from, nodeMap[to], to );
128 if ( !linkAttr.empty () )
130 NS_LOG_INFO (
"Link " << linksNumber <<
" weight: " << linkAttr);
139 NS_LOG_INFO (
"Inet topology created with " << nodesNumber <<
" nodes and " << linksNumber <<
" links");
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
std::string GetFileName(void) const
Returns the input file name.
static TypeId GetTypeId(void)
Get the type ID.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
void AddLink(Link link)
Adds a link to the topology.
Inner class holding the details about a link between two nodes.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
virtual NodeContainer Read(void)
Main topology reading function.
keep track of a set of node pointers.
void SetAttribute(const std::string &name, const std::string &value)
Sets an arbitrary link attribute.
virtual ~InetTopologyReader()
void Add(NodeContainer other)
Append the contents of another NodeContainer to the end of this container.
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
A base class which provides memory management and object aggregation.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)