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) : m_confFile (confFile),
40 m_seedFile (seedFile),
41 m_newSeedFile (newseedFile),
49 m_uv = CreateObject<UniformRandomVariable> ();
61 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)
119 m_numAs = nodeInfo.
asId = ((brite::RouterNodeConf*)(g->GetNodePtr (i)->GetNodeInfo ()))->GetASId ();
122 switch (((brite::RouterNodeConf*)(g->GetNodePtr (i)->GetNodeInfo ()))->GetRouterType ())
124 case brite::RouterNodeConf::RT_NONE:
125 nodeInfo.
type =
"RT_NONE ";
127 case brite::RouterNodeConf::RT_LEAF:
128 nodeInfo.
type =
"RT_LEAF ";
130 case brite::RouterNodeConf::RT_BORDER:
131 nodeInfo.
type =
"RT_BORDER";
133 case brite::RouterNodeConf::RT_STUB:
134 nodeInfo.
type =
"RT_STUB ";
136 case brite::RouterNodeConf::RT_BACKBONE:
137 nodeInfo.
type =
"RT_BACKBONE ";
140 NS_FATAL_ERROR (
"Topology::Output(): Improperly classfied Router node encountered...");
144 case brite::NodeConf::AS_NODE:
146 ((brite::ASNodeConf*)(g->GetNodePtr (i)->GetNodeInfo ()))->GetASId ();
148 switch (((brite::ASNodeConf*)(g->GetNodePtr (i)->GetNodeInfo ()))->GetASType ())
150 case brite::ASNodeConf::AS_NONE:
151 nodeInfo.
type =
"AS_NONE ";
153 case brite::ASNodeConf::AS_LEAF:
154 nodeInfo.
type =
"AS_LEAF ";
156 case brite::ASNodeConf::AS_STUB:
157 nodeInfo.
type =
"AS_STUB ";
159 case brite::ASNodeConf::AS_BORDER:
160 nodeInfo.
type =
"AS_BORDER ";
162 case brite::ASNodeConf::AS_BACKBONE:
163 nodeInfo.
type =
"AS_BACKBONE ";
166 NS_FATAL_ERROR (
"Topology::Output(): Improperly classfied AS node encountered...");
185 std::list<brite::Edge*>::iterator el;
186 std::list<brite::Edge*> edgeList = g->GetEdges ();
188 for (el = edgeList.begin (); el != edgeList.end (); el++)
191 edgeInfo.
edgeId = (*el)->GetId ();
192 edgeInfo.
srcId = (*el)->GetSrc ()->GetId ();
193 edgeInfo.
destId = (*el)->GetDst ()->GetId ();
194 edgeInfo.
length = (*el)->Length ();
196 switch ((*el)->GetConf ()->GetEdgeType ())
198 case brite::EdgeConf::RT_EDGE:
199 edgeInfo.
delay = ((brite::RouterEdgeConf*)((*el)->GetConf ()))->GetDelay ();
200 edgeInfo.
bandwidth = (*el)->GetConf ()->GetBW ();
202 edgeInfo.
asFrom = (((brite::RouterNodeConf*)((*el)->GetSrc ()->GetNodeInfo ()))->GetASId () == -1) ? 0 : ((brite::RouterNodeConf*)((*el)->GetSrc ()->GetNodeInfo ()))->GetASId ();
203 edgeInfo.
asTo = (((brite::RouterNodeConf*)((*el)->GetDst ()->GetNodeInfo ()))->GetASId () == -1) ? 0 : ((brite::RouterNodeConf*)((*el)->GetDst ()->GetNodeInfo ()))->GetASId ();
206 case brite::EdgeConf::AS_EDGE:
208 edgeInfo.
bandwidth = (*el)->GetConf ()->GetBW ();
209 edgeInfo.
asFrom = ((brite::ASNodeConf*)((*el)->GetSrc ()->GetNodeInfo ()))->GetASId ();
210 edgeInfo.
asTo = ((brite::ASNodeConf*)((*el)->GetDst ()->GetNodeInfo ()))->GetASId ();
214 NS_FATAL_ERROR (
"Topology::Output(): Invalid Edge type encountered...");
217 switch ((*el)->GetConf ()->GetEdgeType ())
219 case brite::EdgeConf::RT_EDGE:
220 switch (((brite::RouterEdgeConf*)(*el)->GetConf ())->GetRouterEdgeType ())
222 case brite::RouterEdgeConf::RT_NONE:
223 edgeInfo.
type =
"E_RT_NONE ";
225 case brite::RouterEdgeConf::RT_STUB:
226 edgeInfo.
type =
"E_RT_STUB ";
228 case brite::RouterEdgeConf::RT_BORDER:
229 edgeInfo.
type =
"E_RT_BORDER ";
231 case brite::RouterEdgeConf::RT_BACKBONE:
232 edgeInfo.
type =
"E_RT_BACKBONE ";
239 case brite::EdgeConf::AS_EDGE:
240 switch (((brite::ASEdgeConf*)((*el)->GetConf ()))->GetASEdgeType ())
242 case brite::ASEdgeConf::AS_NONE:
243 edgeInfo.
type =
"E_AS_NONE ";
245 case brite::ASEdgeConf::AS_STUB:
246 edgeInfo.
type =
"E_AS_STUB ";
248 case brite::ASEdgeConf::AS_BORDER:
249 edgeInfo.
type =
"E_AS_BORDER ";
251 case brite::ASEdgeConf::AS_BACKBONE:
252 edgeInfo.
type =
"E_AS_BACKBONE ";
323 if (generateSeedFile)
327 std::ofstream seedFile;
330 seedFile.open (
"briteSeedFile.txt", std::ios_base::out | std::ios_base::trunc);
355 if (generateSeedFile)
357 remove (
"briteSeedFile.txt");
370 for (uint32_t i = 0; i <
m_numAs; ++i)
396 for (uint32_t i = 0; i <
m_numAs; ++i)
398 int val = i % systemCount;
446 for (uint32_t i = 0; i <
m_numAs; ++i)
476 if ((*it).type ==
"RT_LEAF ")
uint32_t GetNNodesForAs(uint32_t asNum)
Node information from BRITE.
#define NS_LOG_FUNCTION(parameters)
uint32_t GetNLeafNodesForAs(uint32_t asNum)
void SetStream(int64_t stream)
Specifies the stream number for this RNG stream.
NetDeviceContainer Install(NodeContainer c)
Ptr< Node > GetNodeForAs(uint32_t asNum, uint32_t nodeNum)
Edge information from BRITE.
#define NS_ASSERT(condition)
#define NS_LOG_COMPONENT_DEFINE(name)
uint32_t GetNAs(void) const
aggregate IP/TCP/UDP functionality to existing Nodes.
void AssignIpv6Addresses(Ipv6AddressHelper &address)
void ConstructTopology(void)
void SetDeviceAttribute(std::string name, const AttributeValue &value)
void AssignStreams(int64_t streamNumber)
brite::Topology * m_topology
std::vector< NodeContainer * > m_nodesByAs
#define NS_FATAL_ERROR(msg)
fatal error handling
Ipv6InterfaceContainer Assign(const NetDeviceContainer &c)
Allocate an Ipv6InterfaceContainer with auto-assigned addresses.
Class for representing data rates.
std::string m_newSeedFile
hold objects of type ns3::Time
uint32_t GetNEdgesTopology() const
BriteTopologyHelper(std::string confFile, std::string seedFile, std::string newseedFile)
void BuildBriteNodeInfoList(void)
void AssignIpv4Addresses(Ipv4AddressHelper &address)
uint32_t GetNNodesTopology() const
void BuildBriteEdgeInfoList(void)
holds a vector of ns3::NetDevice pointers
std::vector< int > m_systemForAs
#define NS_LOG_LOGIC(msg)
keep track of a set of node pointers.
void GenerateBriteTopology(void)
void Install(std::string nodeName) const
BriteNodeInfoList m_briteNodeInfoList
void SetChannelAttribute(std::string name, const AttributeValue &value)
Helper class to auto-assign global IPv6 unicast addresses.
#define NS_ASSERT_MSG(condition, message)
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
void Add(NodeContainer other)
Append the contents of another NodeContainer to the end of this container.
uint32_t GetSystemNumberForAs(uint32_t asNum) const
hold objects of type ns3::DataRate
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
Ptr< UniformRandomVariable > m_uv
#define NS_LOG_DEBUG(msg)
std::vector< NetDeviceContainer * > m_netDevices
std::vector< NodeContainer * > m_asLeafNodes
static const int mbpsToBps
PointToPointHelper m_britePointToPointHelper
Ipv4Address NewNetwork(void)
Increment the network number and reset the IP address counter to the base value provided in the SetBa...
void NewNetwork(Ipv6Address network, Ipv6Prefix prefix) NS_DEPRECATED
Allocate a new network.
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)
void BuildBriteTopology(InternetStackHelper &stack)
BriteEdgeInfoList m_briteEdgeInfoList