20#include "ns3/data-rate.h"
21#include "ns3/ipv4-address-helper.h"
23#include "ns3/net-device-container.h"
24#include "ns3/net-device.h"
25#include "ns3/point-to-point-helper.h"
26#include "ns3/random-variable-stream.h"
27#include "ns3/rng-seed-manager.h"
39 std::string newseedFile)
40 : m_confFile(confFile),
42 m_newSeedFile(newseedFile),
50 m_uv = CreateObject<UniformRandomVariable>();
54 : m_confFile(confFile),
62 m_uv = CreateObject<UniformRandomVariable>();
100 for (
int i = 0; i < g->GetNumNodes(); ++i)
103 nodeInfo.
nodeId = g->GetNodePtr(i)->GetId();
104 nodeInfo.
xCoordinate = g->GetNodePtr(i)->GetNodeInfo()->GetCoordX();
105 nodeInfo.
yCoordinate = g->GetNodePtr(i)->GetNodeInfo()->GetCoordY();
106 nodeInfo.
inDegree = g->GetNodePtr(i)->GetInDegree();
107 nodeInfo.
outDegree = g->GetNodePtr(i)->GetOutDegree();
109 switch (g->GetNodePtr(i)->GetNodeInfo()->GetNodeType())
111 case brite::NodeConf::RT_NODE:
113 if (((brite::RouterNodeConf*)(g->GetNodePtr(i)->GetNodeInfo()))->GetASId() == -1)
120 ((brite::RouterNodeConf*)(g->GetNodePtr(i)->GetNodeInfo()))->GetASId();
123 switch (((brite::RouterNodeConf*)(g->GetNodePtr(i)->GetNodeInfo()))->GetRouterType())
125 case brite::RouterNodeConf::RT_NONE:
126 nodeInfo.
type =
"RT_NONE ";
128 case brite::RouterNodeConf::RT_LEAF:
129 nodeInfo.
type =
"RT_LEAF ";
131 case brite::RouterNodeConf::RT_BORDER:
132 nodeInfo.
type =
"RT_BORDER";
134 case brite::RouterNodeConf::RT_STUB:
135 nodeInfo.
type =
"RT_STUB ";
137 case brite::RouterNodeConf::RT_BACKBONE:
138 nodeInfo.
type =
"RT_BACKBONE ";
142 "Topology::Output(): Improperly classified 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 classified 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();
205 (((brite::RouterNodeConf*)((*el)->GetSrc()->GetNodeInfo()))->GetASId() == -1)
207 : ((brite::RouterNodeConf*)((*el)->GetSrc()->GetNodeInfo()))->GetASId();
209 (((brite::RouterNodeConf*)((*el)->GetDst()->GetNodeInfo()))->GetASId() == -1)
211 : ((brite::RouterNodeConf*)((*el)->GetDst()->GetNodeInfo()))->GetASId();
214 case brite::EdgeConf::AS_EDGE:
216 edgeInfo.
bandwidth = (*el)->GetConf()->GetBW();
217 edgeInfo.
asFrom = ((brite::ASNodeConf*)((*el)->GetSrc()->GetNodeInfo()))->GetASId();
218 edgeInfo.
asTo = ((brite::ASNodeConf*)((*el)->GetDst()->GetNodeInfo()))->GetASId();
222 NS_FATAL_ERROR(
"Topology::Output(): Invalid Edge type encountered...");
225 switch ((*el)->GetConf()->GetEdgeType())
227 case brite::EdgeConf::RT_EDGE:
228 switch (((brite::RouterEdgeConf*)(*el)->GetConf())->GetRouterEdgeType())
230 case brite::RouterEdgeConf::RT_NONE:
231 edgeInfo.
type =
"E_RT_NONE ";
233 case brite::RouterEdgeConf::RT_STUB:
234 edgeInfo.
type =
"E_RT_STUB ";
236 case brite::RouterEdgeConf::RT_BORDER:
237 edgeInfo.
type =
"E_RT_BORDER ";
239 case brite::RouterEdgeConf::RT_BACKBONE:
240 edgeInfo.
type =
"E_RT_BACKBONE ";
247 case brite::EdgeConf::AS_EDGE:
248 switch (((brite::ASEdgeConf*)((*el)->GetConf()))->GetASEdgeType())
250 case brite::ASEdgeConf::AS_NONE:
251 edgeInfo.
type =
"E_AS_NONE ";
253 case brite::ASEdgeConf::AS_STUB:
254 edgeInfo.
type =
"E_AS_STUB ";
256 case brite::ASEdgeConf::AS_BORDER:
257 edgeInfo.
type =
"E_AS_BORDER ";
259 case brite::ASEdgeConf::AS_BACKBONE:
260 edgeInfo.
type =
"E_AS_BACKBONE ";
331 if (generateSeedFile)
335 std::ofstream seedFile;
338 seedFile.open(
"briteSeedFile.txt", std::ios_base::out | std::ios_base::trunc);
370 if (generateSeedFile)
372 remove(
"briteSeedFile.txt");
373 remove(
"last_seed_file");
413 int val = i % systemCount;
499 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
AttributeValue implementation for DataRate.
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.
AttributeValue implementation for Time.
#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.