routing = true;
}
-void MooseHelper::Create(MooseHelper::Network& n){
+MooseHelper::Network MooseHelper::Create(Topology& t){
// Create the bridges and hosts
- n.bridges.Create(n.t.bridges);
- n.hosts.Create(n.t.hosts);
+ Network n;
+
+ n.bridges.Create(t.bridges);
+ n.hosts.Create(t.hosts);
std::map<long, std::map<long, Ptr<NetDevice> > > portMap;
// Host-Bridge
for(
- Topology::HostLinks::iterator it = n.t.hostLinks.begin();
- it != n.t.hostLinks.end();
+ Topology::HostLinks::iterator it = t.hostLinks.begin();
+ it != t.hostLinks.end();
it ++){
NodeContainer nc;
- if(it->first >= n.t.hosts){
+ if(it->first >= t.hosts){
assert(false);
}
- if(it->second >= n.t.bridges){
+ if(it->second >= t.bridges){
assert(false);
}
// Bridge-Bridge
for(
- Topology::BridgeLinks::iterator it = n.t.bridgeLinks.begin();
- it != n.t.bridgeLinks.end();
+ Topology::BridgeLinks::iterator it = t.bridgeLinks.begin();
+ it != t.bridgeLinks.end();
it ++){
NodeContainer nc;
- if(it->first >= n.t.bridges){
+ if(it->first >= t.bridges){
assert(false);
}
- if(it->second >= n.t.bridges){
+ if(it->second >= t.bridges){
assert(false);
}
// Djkstra - Give all links the same weight for now.
- std::vector<long> weights(n.t.bridgeLinks.size(), 1);
+ std::vector<long> weights(t.bridgeLinks.size(), 1);
- const long num_nodes = n.t.bridges;
+ const long num_nodes = t.bridges;
- graph_t g(n.t.bridgeLinks.begin(), n.t.bridgeLinks.end(), weights.begin(), num_nodes);
+ graph_t g(t.bridgeLinks.begin(), t.bridgeLinks.end(), weights.begin(), num_nodes);
boost::property_map<graph_t, boost::edge_weight_t>::type weightmap = get(boost::edge_weight, g);
- for(long root = 0; root < n.t.bridges; root ++){
+ for(long root = 0; root < t.bridges; root ++){
std::vector<vertex_descriptor> p(num_vertices(g));
vertex_descriptor s = boost::vertex(root,g);
// Realtime routing
- for(long i = 0; i < n.t.bridges; i ++){
+ for(long i = 0; i < t.bridges; i ++){
Ptr<Node> bridgeNode = n.bridges.Get(i);
mooseHelper.Install(bridgeNode, n.bridgeDevices[i]);
}
// Kruskall's - Give all links the same weight for now.
- const long num_nodes = n.t.bridges;
+ const long num_nodes = t.bridges;
std::vector<edge_descriptor> tree;
- std::vector<long> weights(n.t.bridgeLinks.size(), 1);
+ std::vector<long> weights(t.bridgeLinks.size(), 1);
- graph_t g(n.t.bridgeLinks.begin(), n.t.bridgeLinks.end(), weights.begin(), num_nodes);
- boost::property_map<graph_t, boost::edge_weight_t>::type weightmap = get(boost::edge_weight, g);
+ graph_t g(t.bridgeLinks.begin(), t.bridgeLinks.end(), weights.begin(), num_nodes);
kruskal_minimum_spanning_tree(g,std::back_inserter(tree));
std::map<long,std::map<long,bool> > spanning;
- for(long i = 0; i < n.t.bridges; ++i){
- for(long j = 0; i < n.t.bridges; ++i){
+ for(long i = 0; i < t.bridges; ++i){
+ for(long j = 0; i < t.bridges; ++i){
spanning[i][j] = false;
}
}
// Question: is bridge[0][1] in spanning tree? -> i.e. is there some x, for which tree[x] = <0,1>
- for(long i = 0; i < n.t.bridges; i ++){
+
+ for(long i = 0; i < t.bridges; i ++){
std::map<Ptr<NetDevice>, bool> portsEnabled;
} else {
// Requires STP implementation
- for(long i = 0; i < n.t.bridges; i ++){
+ for(long i = 0; i < t.bridges; i ++){
Ptr<Node> bridgeNode = n.bridges.Get(i);
ethernetHelper.Install(bridgeNode, n.bridgeDevices[i]);
internet.Install(n.hosts);
- for(long i = 0; i < n.t.hosts; i ++){
+ for(long i = 0; i < t.hosts; i ++){
n.interfaces[i] = ipv4.Assign(n.hostDevices[i]);
}
+ return n;
+
}
public:
- typedef boost::adjacency_list< boost::listS, boost::vecS, boost::undirectedS, boost::no_property, boost::property<boost::edge_weight_t, int> > graph_t;
+ typedef boost::adjacency_list< boost::listS, boost::vecS, boost::undirectedS, boost::no_property, boost::property<boost::edge_weight_t, long> > graph_t;
typedef boost::graph_traits< graph_t >::vertex_descriptor vertex_descriptor;
typedef boost::graph_traits< graph_t >::edge_descriptor edge_descriptor;
struct Network {
- Topology t;
-
// Contains all the nodes :-)
NodeContainer bridges;
// IP Interfaces
- std::map<long, Ipv4InterfaceContainer> interfaces;
+ std::map<long, Ipv4InterfaceContainer > interfaces;
};
void DisableDynamicRouting();
- void Create(Network& t);
+ Network Create(Topology& t);
private: