21 #include "ns3/abort.h"
22 #include "ns3/data-rate.h"
23 #include "ns3/ipv4-address-helper.h"
25 #include "ns3/net-device-container.h"
26 #include "ns3/net-device.h"
27 #include "ns3/point-to-point-helper.h"
28 #include "ns3/random-variable-stream.h"
29 #include "ns3/rng-seed-manager.h"
41 std::string newseedFile)
44 m_newSeedFile(newseedFile),
52 m_uv = CreateObject<UniformRandomVariable>();
64 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)
122 ((brite::RouterNodeConf*)(g->GetNodePtr(i)->GetNodeInfo()))->GetASId();
125 switch (((brite::RouterNodeConf*)(g->GetNodePtr(i)->GetNodeInfo()))->GetRouterType())
127 case brite::RouterNodeConf::RT_NONE:
128 nodeInfo.
type =
"RT_NONE ";
130 case brite::RouterNodeConf::RT_LEAF:
131 nodeInfo.
type =
"RT_LEAF ";
133 case brite::RouterNodeConf::RT_BORDER:
134 nodeInfo.
type =
"RT_BORDER";
136 case brite::RouterNodeConf::RT_STUB:
137 nodeInfo.
type =
"RT_STUB ";
139 case brite::RouterNodeConf::RT_BACKBONE:
140 nodeInfo.
type =
"RT_BACKBONE ";
144 "Topology::Output(): Improperly classified Router node encountered...");
148 case brite::NodeConf::AS_NODE:
150 ((brite::ASNodeConf*)(g->GetNodePtr(i)->GetNodeInfo()))->GetASId();
152 switch (((brite::ASNodeConf*)(g->GetNodePtr(i)->GetNodeInfo()))->GetASType())
154 case brite::ASNodeConf::AS_NONE:
155 nodeInfo.
type =
"AS_NONE ";
157 case brite::ASNodeConf::AS_LEAF:
158 nodeInfo.
type =
"AS_LEAF ";
160 case brite::ASNodeConf::AS_STUB:
161 nodeInfo.
type =
"AS_STUB ";
163 case brite::ASNodeConf::AS_BORDER:
164 nodeInfo.
type =
"AS_BORDER ";
166 case brite::ASNodeConf::AS_BACKBONE:
167 nodeInfo.
type =
"AS_BACKBONE ";
170 NS_FATAL_ERROR(
"Topology::Output(): Improperly classified AS node encountered...");
189 std::list<brite::Edge*> edgeList = g->GetEdges();
191 for (
auto el = edgeList.begin(); el != edgeList.end(); el++)
194 edgeInfo.
edgeId = (*el)->GetId();
195 edgeInfo.
srcId = (*el)->GetSrc()->GetId();
196 edgeInfo.
destId = (*el)->GetDst()->GetId();
197 edgeInfo.
length = (*el)->Length();
199 switch ((*el)->GetConf()->GetEdgeType())
201 case brite::EdgeConf::RT_EDGE:
202 edgeInfo.
delay = ((brite::RouterEdgeConf*)((*el)->GetConf()))->GetDelay();
203 edgeInfo.
bandwidth = (*el)->GetConf()->GetBW();
206 (((brite::RouterNodeConf*)((*el)->GetSrc()->GetNodeInfo()))->GetASId() == -1)
208 : ((brite::RouterNodeConf*)((*el)->GetSrc()->GetNodeInfo()))->GetASId();
210 (((brite::RouterNodeConf*)((*el)->GetDst()->GetNodeInfo()))->GetASId() == -1)
212 : ((brite::RouterNodeConf*)((*el)->GetDst()->GetNodeInfo()))->GetASId();
215 case brite::EdgeConf::AS_EDGE:
217 edgeInfo.
bandwidth = (*el)->GetConf()->GetBW();
218 edgeInfo.
asFrom = ((brite::ASNodeConf*)((*el)->GetSrc()->GetNodeInfo()))->GetASId();
219 edgeInfo.
asTo = ((brite::ASNodeConf*)((*el)->GetDst()->GetNodeInfo()))->GetASId();
223 NS_FATAL_ERROR(
"Topology::Output(): Invalid Edge type encountered...");
226 switch ((*el)->GetConf()->GetEdgeType())
228 case brite::EdgeConf::RT_EDGE:
229 switch (((brite::RouterEdgeConf*)(*el)->GetConf())->GetRouterEdgeType())
231 case brite::RouterEdgeConf::RT_NONE:
232 edgeInfo.
type =
"E_RT_NONE ";
234 case brite::RouterEdgeConf::RT_STUB:
235 edgeInfo.
type =
"E_RT_STUB ";
237 case brite::RouterEdgeConf::RT_BORDER:
238 edgeInfo.
type =
"E_RT_BORDER ";
240 case brite::RouterEdgeConf::RT_BACKBONE:
241 edgeInfo.
type =
"E_RT_BACKBONE ";
248 case brite::EdgeConf::AS_EDGE:
249 switch (((brite::ASEdgeConf*)((*el)->GetConf()))->GetASEdgeType())
251 case brite::ASEdgeConf::AS_NONE:
252 edgeInfo.
type =
"E_AS_NONE ";
254 case brite::ASEdgeConf::AS_STUB:
255 edgeInfo.
type =
"E_AS_STUB ";
257 case brite::ASEdgeConf::AS_BORDER:
258 edgeInfo.
type =
"E_AS_BORDER ";
260 case brite::ASEdgeConf::AS_BACKBONE:
261 edgeInfo.
type =
"E_AS_BACKBONE ";
332 if (generateSeedFile)
336 std::ofstream seedFile;
339 seedFile.open(
"briteSeedFile.txt", std::ios_base::out | std::ios_base::trunc);
371 if (generateSeedFile)
373 remove(
"briteSeedFile.txt");
374 remove(
"last_seed_file");
386 for (uint32_t i = 0; i <
m_numAs; ++i)
412 for (uint32_t i = 0; i <
m_numAs; ++i)
414 uint32_t val = i % systemCount;
462 for (uint32_t i = 0; i <
m_numAs; ++i)
494 if ((*it).type ==
"RT_LEAF ")
BriteNodeInfoList m_briteNodeInfoList
The BRITE code generates multiple nodes and edges.
void AssignIpv6Addresses(Ipv6AddressHelper &address)
Assign IPv6 addresses.
void AssignStreams(int64_t streamNumber)
Assigns stream number to UniformRandomVariable used to generate brite seed file.
BriteEdgeInfoList m_briteEdgeInfoList
The BRITE code generates multiple nodes and edges.
PointToPointHelper m_britePointToPointHelper
used to create the links within the topology
Ptr< UniformRandomVariable > m_uv
random variable stream for brite seed file
brite::Topology * m_topology
the Brite topology
uint32_t m_numNodes
stores the number of nodes created in the BRITE topology
uint32_t GetNAs() const
Returns the number of AS created in the topology.
std::vector< NetDeviceContainer * > m_netDevices
stores the netdevices created for each AS
uint32_t m_numEdges
stores the number of edges created in the BRITE topology
uint32_t GetNNodesTopology() const
Returns the number of nodes created within the topology.
void BuildBriteTopology(InternetStackHelper &stack)
Create NS3 topology using information generated from BRITE.
std::vector< NodeContainer * > m_asLeafNodes
stores the leaf router nodes for each AS
std::vector< NodeContainer * > m_nodesByAs
stores all of the nodes in the brite topology by AS number
uint32_t m_numAs
stores the number of AS in the BRITE generated topology
void BuildBriteNodeInfoList()
Build the Node Info list.
void GenerateBriteTopology()
Generate the BRITE topology.
static const int mbpsToBps
brite values are unitless however all examples provided use mbps to specify rate this constant value ...
Ptr< Node > GetNodeForAs(uint32_t asNum, uint32_t nodeNum)
Returns a given router node for a given AS.
void ConstructTopology()
Construct the topology.
void BuildBriteEdgeInfoList()
Build the Edge Info list.
void AssignIpv4Addresses(Ipv4AddressHelper &address)
Assign IPv4 addresses.
uint32_t GetNNodesForAs(uint32_t asNum)
Returns the total number of nodes for a given AS.
uint32_t GetNLeafNodesForAs(uint32_t asNum)
Returns the number of router leaf nodes for a given AS.
std::string m_newSeedFile
brite seed file to generate for next run
std::string m_seedFile
brite seed file to use
std::vector< int > m_systemForAs
stores the MPI system number each AS assigned to. All assigned to 0 if MPI not used.
NodeContainer m_nodes
stores all of the nodes used in the BRITE generated topology
uint32_t GetNEdgesTopology() const
Returns the number of edges created within the topology.
BriteTopologyHelper(std::string confFile, std::string seedFile, std::string newseedFile)
Construct a BriteTopologyHelper.
Ptr< Node > GetLeafNodeForAs(uint32_t asNum, uint32_t leafNum)
Returns a given router leaf node from a given AS.
uint32_t GetSystemNumberForAs(uint32_t asNum) const
Returns the system number for the MPI instance that this AS is assigned to.
std::string m_confFile
brite configuration file to use
aggregate IP/TCP/UDP functionality to existing Nodes.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
Helper class to auto-assign global IPv6 unicast addresses.
holds a vector of ns3::NetDevice pointers
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
void Add(const NodeContainer &nc)
Append the contents of another NodeContainer to the end of this container.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
void SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper.
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
NetDeviceContainer Install(NodeContainer c)
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
void(* DataRate)(DataRate oldValue, DataRate newValue)
TracedValue callback signature for DataRate.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Edge information from BRITE.
int asFrom
Originating AS.
std::string type
Edge type.
double bandwidth
Bandwidth.
Node information from BRITE.
int outDegree
Egress (OUT) degree.
int inDegree
Ingress (IN) degree.
double xCoordinate
X coordinate.
std::string type
Node type.
double yCoordinate
Y coordinate.