11#include "ns3/data-rate.h" 
   12#include "ns3/ipv4-address-helper.h" 
   14#include "ns3/net-device-container.h" 
   15#include "ns3/net-device.h" 
   16#include "ns3/point-to-point-helper.h" 
   17#include "ns3/random-variable-stream.h" 
   18#include "ns3/rng-seed-manager.h" 
   30                                         std::string newseedFile)
 
 
   83    m_uv->SetStream(streamNumber);
 
 
   91    for (
int i = 0; i < g->GetNumNodes(); ++i)
 
   94        nodeInfo.
nodeId = g->GetNodePtr(i)->GetId();
 
   95        nodeInfo.
xCoordinate = g->GetNodePtr(i)->GetNodeInfo()->GetCoordX();
 
   96        nodeInfo.
yCoordinate = g->GetNodePtr(i)->GetNodeInfo()->GetCoordY();
 
   97        nodeInfo.
inDegree = g->GetNodePtr(i)->GetInDegree();
 
   98        nodeInfo.
outDegree = g->GetNodePtr(i)->GetOutDegree();
 
  100        switch (g->GetNodePtr(i)->GetNodeInfo()->GetNodeType())
 
  102        case brite::NodeConf::RT_NODE:
 
  104            if (((brite::RouterNodeConf*)(g->GetNodePtr(i)->GetNodeInfo()))->GetASId() == -1)
 
  111                    ((brite::RouterNodeConf*)(g->GetNodePtr(i)->GetNodeInfo()))->GetASId();
 
  114            switch (((brite::RouterNodeConf*)(g->GetNodePtr(i)->GetNodeInfo()))->GetRouterType())
 
  116            case brite::RouterNodeConf::RT_NONE:
 
  117                nodeInfo.
type = 
"RT_NONE ";
 
  119            case brite::RouterNodeConf::RT_LEAF:
 
  120                nodeInfo.
type = 
"RT_LEAF ";
 
  122            case brite::RouterNodeConf::RT_BORDER:
 
  123                nodeInfo.
type = 
"RT_BORDER";
 
  125            case brite::RouterNodeConf::RT_STUB:
 
  126                nodeInfo.
type = 
"RT_STUB ";
 
  128            case brite::RouterNodeConf::RT_BACKBONE:
 
  129                nodeInfo.
type = 
"RT_BACKBONE ";
 
  133                    "Topology::Output(): Improperly classified Router node encountered...");
 
  137        case brite::NodeConf::AS_NODE:
 
  139                ((brite::ASNodeConf*)(g->GetNodePtr(i)->GetNodeInfo()))->GetASId();
 
  141            switch (((brite::ASNodeConf*)(g->GetNodePtr(i)->GetNodeInfo()))->GetASType())
 
  143            case brite::ASNodeConf::AS_NONE:
 
  144                nodeInfo.
type = 
"AS_NONE ";
 
  146            case brite::ASNodeConf::AS_LEAF:
 
  147                nodeInfo.
type = 
"AS_LEAF ";
 
  149            case brite::ASNodeConf::AS_STUB:
 
  150                nodeInfo.
type = 
"AS_STUB ";
 
  152            case brite::ASNodeConf::AS_BORDER:
 
  153                nodeInfo.
type = 
"AS_BORDER ";
 
  155            case brite::ASNodeConf::AS_BACKBONE:
 
  156                nodeInfo.
type = 
"AS_BACKBONE ";
 
  159                NS_FATAL_ERROR(
"Topology::Output(): Improperly classified AS node encountered...");
 
 
  178    std::list<brite::Edge*> edgeList = g->GetEdges();
 
  180    for (
auto el = edgeList.begin(); el != edgeList.end(); el++)
 
  183        edgeInfo.
edgeId = (*el)->GetId();
 
  184        edgeInfo.
srcId = (*el)->GetSrc()->GetId();
 
  185        edgeInfo.
destId = (*el)->GetDst()->GetId();
 
  186        edgeInfo.
length = (*el)->Length();
 
  188        switch ((*el)->GetConf()->GetEdgeType())
 
  190        case brite::EdgeConf::RT_EDGE:
 
  191            edgeInfo.
delay = ((brite::RouterEdgeConf*)((*el)->GetConf()))->GetDelay();
 
  192            edgeInfo.
bandwidth = (*el)->GetConf()->GetBW();
 
  195                (((brite::RouterNodeConf*)((*el)->GetSrc()->GetNodeInfo()))->GetASId() == -1)
 
  197                    : ((brite::RouterNodeConf*)((*el)->GetSrc()->GetNodeInfo()))->GetASId();
 
  199                (((brite::RouterNodeConf*)((*el)->GetDst()->GetNodeInfo()))->GetASId() == -1)
 
  201                    : ((brite::RouterNodeConf*)((*el)->GetDst()->GetNodeInfo()))->GetASId();
 
  204        case brite::EdgeConf::AS_EDGE:
 
  206            edgeInfo.
bandwidth = (*el)->GetConf()->GetBW();
 
  207            edgeInfo.
asFrom = ((brite::ASNodeConf*)((*el)->GetSrc()->GetNodeInfo()))->GetASId();
 
  208            edgeInfo.
asTo = ((brite::ASNodeConf*)((*el)->GetDst()->GetNodeInfo()))->GetASId();
 
  212            NS_FATAL_ERROR(
"Topology::Output(): Invalid Edge type encountered...");
 
  215        switch ((*el)->GetConf()->GetEdgeType())
 
  217        case brite::EdgeConf::RT_EDGE:
 
  218            switch (((brite::RouterEdgeConf*)(*el)->GetConf())->GetRouterEdgeType())
 
  220            case brite::RouterEdgeConf::RT_NONE:
 
  221                edgeInfo.
type = 
"E_RT_NONE ";
 
  223            case brite::RouterEdgeConf::RT_STUB:
 
  224                edgeInfo.
type = 
"E_RT_STUB ";
 
  226            case brite::RouterEdgeConf::RT_BORDER:
 
  227                edgeInfo.
type = 
"E_RT_BORDER ";
 
  229            case brite::RouterEdgeConf::RT_BACKBONE:
 
  230                edgeInfo.
type = 
"E_RT_BACKBONE ";
 
  237        case brite::EdgeConf::AS_EDGE:
 
  238            switch (((brite::ASEdgeConf*)((*el)->GetConf()))->GetASEdgeType())
 
  240            case brite::ASEdgeConf::AS_NONE:
 
  241                edgeInfo.
type = 
"E_AS_NONE ";
 
  243            case brite::ASEdgeConf::AS_STUB:
 
  244                edgeInfo.
type = 
"E_AS_STUB ";
 
  246            case brite::ASEdgeConf::AS_BORDER:
 
  247                edgeInfo.
type = 
"E_AS_BORDER ";
 
  249            case brite::ASEdgeConf::AS_BACKBONE:
 
  250                edgeInfo.
type = 
"E_AS_BACKBONE ";
 
 
  321    if (generateSeedFile)
 
  325        std::ofstream seedFile;
 
  328        seedFile.open(
"briteSeedFile.txt", std::ios_base::out | std::ios_base::trunc);
 
  335        seedFile << 
"PLACES " << 
m_uv->GetInteger(0, 65535) << 
" " << 
m_uv->GetInteger(0, 65535)
 
  336                 << 
" " << 
m_uv->GetInteger(0, 65535) << std::endl;
 
  337        seedFile << 
"CONNECT " << 
m_uv->GetInteger(0, 65535) << 
" " << 
m_uv->GetInteger(0, 65535)
 
  338                 << 
" " << 
m_uv->GetInteger(0, 65535) << std::endl;
 
  339        seedFile << 
"EDGE_CONN " << 
m_uv->GetInteger(0, 65535) << 
" " << 
m_uv->GetInteger(0, 65535)
 
  340                 << 
" " << 
m_uv->GetInteger(0, 65535) << std::endl;
 
  341        seedFile << 
"GROUPING " << 
m_uv->GetInteger(0, 65535) << 
" " << 
m_uv->GetInteger(0, 65535)
 
  342                 << 
" " << 
m_uv->GetInteger(0, 65535) << std::endl;
 
  343        seedFile << 
"ASSIGNMENT " << 
m_uv->GetInteger(0, 65535) << 
" " << 
m_uv->GetInteger(0, 65535)
 
  344                 << 
" " << 
m_uv->GetInteger(0, 65535) << std::endl;
 
  345        seedFile << 
"BANDWIDTH " << 
m_uv->GetInteger(0, 65535) << 
" " << 
m_uv->GetInteger(0, 65535)
 
  346                 << 
" " << 
m_uv->GetInteger(0, 65535) << std::endl;
 
  360    if (generateSeedFile)
 
  362        remove(
"briteSeedFile.txt");
 
  363        remove(
"last_seed_file");
 
 
  430        address.NewNetwork();
 
 
  442        address.NewNetwork();
 
 
  483        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
Class for representing data rates.
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.
Smart pointer class similar to boost::intrusive_ptr.
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.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
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.