19 #include "ns3/abort.h" 20 #include "ns3/net-device.h" 21 #include "ns3/net-device-container.h" 22 #include "ns3/point-to-point-helper.h" 23 #include "ns3/ipv4-address-helper.h" 24 #include "ns3/random-variable-stream.h" 25 #include "ns3/data-rate.h" 26 #include "ns3/rng-seed-manager.h" 39 std::string newseedFile)
40 : m_confFile (confFile),
41 m_seedFile (seedFile),
42 m_newSeedFile (newseedFile),
50 m_uv = CreateObject<UniformRandomVariable> ();
55 : m_confFile (confFile),
63 m_uv = CreateObject<UniformRandomVariable> ();
102 for (
int i = 0; i < g->GetNumNodes (); ++i)
105 nodeInfo.
nodeId = g->GetNodePtr (i)->GetId ();
106 nodeInfo.
xCoordinate = g->GetNodePtr (i)->GetNodeInfo ()->GetCoordX ();
107 nodeInfo.
yCoordinate = g->GetNodePtr (i)->GetNodeInfo ()->GetCoordY ();
108 nodeInfo.
inDegree = g->GetNodePtr (i)->GetInDegree ();
109 nodeInfo.
outDegree = g->GetNodePtr (i)->GetOutDegree ();
111 switch (g->GetNodePtr (i)->GetNodeInfo ()->GetNodeType ())
113 case brite::NodeConf::RT_NODE:
115 if (((brite::RouterNodeConf*)(g->GetNodePtr (i)->GetNodeInfo ()))->GetASId () == -1)
121 m_numAs = nodeInfo.
asId = ((brite::RouterNodeConf*)(g->GetNodePtr (i)->GetNodeInfo ()))->GetASId ();
124 switch (((brite::RouterNodeConf*)(g->GetNodePtr (i)->GetNodeInfo ()))->GetRouterType ())
126 case brite::RouterNodeConf::RT_NONE:
127 nodeInfo.
type =
"RT_NONE ";
129 case brite::RouterNodeConf::RT_LEAF:
130 nodeInfo.
type =
"RT_LEAF ";
132 case brite::RouterNodeConf::RT_BORDER:
133 nodeInfo.
type =
"RT_BORDER";
135 case brite::RouterNodeConf::RT_STUB:
136 nodeInfo.
type =
"RT_STUB ";
138 case brite::RouterNodeConf::RT_BACKBONE:
139 nodeInfo.
type =
"RT_BACKBONE ";
142 NS_FATAL_ERROR (
"Topology::Output(): Improperly classfied Router node encountered...");
146 case brite::NodeConf::AS_NODE:
148 ((brite::ASNodeConf*)(g->GetNodePtr (i)->GetNodeInfo ()))->GetASId ();
150 switch (((brite::ASNodeConf*)(g->GetNodePtr (i)->GetNodeInfo ()))->GetASType ())
152 case brite::ASNodeConf::AS_NONE:
153 nodeInfo.
type =
"AS_NONE ";
155 case brite::ASNodeConf::AS_LEAF:
156 nodeInfo.
type =
"AS_LEAF ";
158 case brite::ASNodeConf::AS_STUB:
159 nodeInfo.
type =
"AS_STUB ";
161 case brite::ASNodeConf::AS_BORDER:
162 nodeInfo.
type =
"AS_BORDER ";
164 case brite::ASNodeConf::AS_BACKBONE:
165 nodeInfo.
type =
"AS_BACKBONE ";
168 NS_FATAL_ERROR (
"Topology::Output(): Improperly classfied AS node encountered...");
187 std::list<brite::Edge*>::iterator el;
188 std::list<brite::Edge*> edgeList = g->GetEdges ();
190 for (el = edgeList.begin (); el != edgeList.end (); el++)
193 edgeInfo.
edgeId = (*el)->GetId ();
194 edgeInfo.
srcId = (*el)->GetSrc ()->GetId ();
195 edgeInfo.
destId = (*el)->GetDst ()->GetId ();
196 edgeInfo.
length = (*el)->Length ();
198 switch ((*el)->GetConf ()->GetEdgeType ())
200 case brite::EdgeConf::RT_EDGE:
201 edgeInfo.
delay = ((brite::RouterEdgeConf*)((*el)->GetConf ()))->GetDelay ();
202 edgeInfo.
bandwidth = (*el)->GetConf ()->GetBW ();
204 edgeInfo.
asFrom = (((brite::RouterNodeConf*)((*el)->GetSrc ()->GetNodeInfo ()))->GetASId () == -1) ? 0 : ((brite::RouterNodeConf*)((*el)->GetSrc ()->GetNodeInfo ()))->GetASId ();
205 edgeInfo.
asTo = (((brite::RouterNodeConf*)((*el)->GetDst ()->GetNodeInfo ()))->GetASId () == -1) ? 0 : ((brite::RouterNodeConf*)((*el)->GetDst ()->GetNodeInfo ()))->GetASId ();
208 case brite::EdgeConf::AS_EDGE:
210 edgeInfo.
bandwidth = (*el)->GetConf ()->GetBW ();
211 edgeInfo.
asFrom = ((brite::ASNodeConf*)((*el)->GetSrc ()->GetNodeInfo ()))->GetASId ();
212 edgeInfo.
asTo = ((brite::ASNodeConf*)((*el)->GetDst ()->GetNodeInfo ()))->GetASId ();
216 NS_FATAL_ERROR (
"Topology::Output(): Invalid Edge type encountered...");
219 switch ((*el)->GetConf ()->GetEdgeType ())
221 case brite::EdgeConf::RT_EDGE:
222 switch (((brite::RouterEdgeConf*)(*el)->GetConf ())->GetRouterEdgeType ())
224 case brite::RouterEdgeConf::RT_NONE:
225 edgeInfo.
type =
"E_RT_NONE ";
227 case brite::RouterEdgeConf::RT_STUB:
228 edgeInfo.
type =
"E_RT_STUB ";
230 case brite::RouterEdgeConf::RT_BORDER:
231 edgeInfo.
type =
"E_RT_BORDER ";
233 case brite::RouterEdgeConf::RT_BACKBONE:
234 edgeInfo.
type =
"E_RT_BACKBONE ";
241 case brite::EdgeConf::AS_EDGE:
242 switch (((brite::ASEdgeConf*)((*el)->GetConf ()))->GetASEdgeType ())
244 case brite::ASEdgeConf::AS_NONE:
245 edgeInfo.
type =
"E_AS_NONE ";
247 case brite::ASEdgeConf::AS_STUB:
248 edgeInfo.
type =
"E_AS_STUB ";
250 case brite::ASEdgeConf::AS_BORDER:
251 edgeInfo.
type =
"E_AS_BORDER ";
253 case brite::ASEdgeConf::AS_BACKBONE:
254 edgeInfo.
type =
"E_AS_BACKBONE ";
325 if (generateSeedFile)
329 std::ofstream seedFile;
332 seedFile.open (
"briteSeedFile.txt", std::ios_base::out | std::ios_base::trunc);
357 if (generateSeedFile)
359 remove (
"briteSeedFile.txt");
372 for (uint32_t i = 0; i <
m_numAs; ++i)
398 for (uint32_t i = 0; i <
m_numAs; ++i)
400 int val = i % systemCount;
448 for (uint32_t i = 0; i <
m_numAs; ++i)
478 if ((*it).type ==
"RT_LEAF ")
uint32_t GetNNodesForAs(uint32_t asNum)
Returns the total number of nodes for a given AS.
Node information from BRITE.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
uint32_t GetNLeafNodesForAs(uint32_t asNum)
Returns the number of router leaf nodes for a given AS.
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
uint32_t m_numEdges
stores the number of edges created in the BRITE topology
uint32_t GetSystemNumberForAs(uint32_t asNum) const
Returns the system number for the MPI instance that this AS is assigned to.
NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible")
NetDeviceContainer Install(NodeContainer c)
Ptr< Node > GetNodeForAs(uint32_t asNum, uint32_t nodeNum)
Returns a given router node for a given AS.
Edge information from BRITE.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
aggregate IP/TCP/UDP functionality to existing Nodes.
void AssignIpv6Addresses(Ipv6AddressHelper &address)
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
void ConstructTopology(void)
void SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper.
void AssignStreams(int64_t streamNumber)
Assigns stream number to UniformRandomVariable used to generate brite seed file.
brite::Topology * m_topology
the Brite topology
std::vector< NodeContainer * > m_nodesByAs
stores all of the nodes in the brite topology by AS number
Class for representing data rates.
virtual uint32_t GetInteger(void)=0
Get the next random value as an integer drawn from the distribution.
std::string m_newSeedFile
brite seed file to generate for next run
AttributeValue implementation for Time.
BriteTopologyHelper(std::string confFile, std::string seedFile, std::string newseedFile)
Construct a BriteTopologyHelper.
void BuildBriteNodeInfoList(void)
void AssignIpv4Addresses(Ipv4AddressHelper &address)
void BuildBriteEdgeInfoList(void)
holds a vector of ns3::NetDevice pointers
uint32_t GetNAs(void) const
Returns the number of AS created in the topology.
std::vector< int > m_systemForAs
stores the MPI system number each AS assigned to. All assigned to 0 if MPI not used.
uint32_t GetNEdgesTopology() const
Returns the number of edges created within the topology.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint32_t GetNNodesTopology() const
Returns the number of nodes created within the topology.
keep track of a set of node pointers.
void GenerateBriteTopology(void)
BriteNodeInfoList m_briteNodeInfoList
The BRITE code generates multiple nodes and edges.
std::string m_confFile
brite configuration file to use
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
Helper class to auto-assign global IPv6 unicast addresses.
void Add(NodeContainer other)
Append the contents of another NodeContainer to the end of this container.
AttributeValue implementation for DataRate.
Ptr< UniformRandomVariable > m_uv
random variable stream for brite seed file
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Time Seconds(double value)
Construct a Time in the indicated unit.
std::vector< NetDeviceContainer * > m_netDevices
stores the netdevices created for each AS
std::vector< NodeContainer * > m_asLeafNodes
stores the leaf router nodes for each AS
uint32_t m_numAs
stores the number of AS in the BRITE generated topology
static const int mbpsToBps
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
PointToPointHelper m_britePointToPointHelper
used to create the links within the topology
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ptr< Node > GetLeafNodeForAs(uint32_t asNum, uint32_t leafNum)
Returns a given router leaf node from a given AS.
std::string m_seedFile
brite seed file to use
uint32_t m_numNodes
stores the number of nodes created in the BRITE topology
void BuildBriteTopology(InternetStackHelper &stack)
Create NS3 topology using information generated from BRITE.
BriteEdgeInfoList m_briteEdgeInfoList
The BRITE code generates multiple nodes and edges.