-
Notifications
You must be signed in to change notification settings - Fork 0
/
topology.cpp
36 lines (34 loc) · 975 Bytes
/
topology.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "topology.h"
void GenerateWiredTopology(int topo[][SWITCH_NUM])
{
memset(topo, 0, SWITCH_NUM * SWITCH_NUM * sizeof(int));// initialize topology
// from tor to core
int num = AGGR_NUM;
for (int i = num; i < num * 2; i++)
{
int sort = i % (K / 2);
sort = -sort;
for (int j = 0; j < (K / 2); j++) {
topo[i][i - num + sort + j] = 1;
topo[i - num + sort + j][i] = 1;
}
}
int core = CORE_NUM;
for (int i = num * 2; i < num * 2 + core; i++) {
int part = (i - 2 * num) / (K / 2);
for (int j = 0; j < K; j++) {
topo[i][num + j*K / 2 + part] = 1;
topo[num + j*K / 2 + part][i] = 1;
}
}
cout << "GenerateWiredTopology() succeeds !!!" << endl;
}
void GetHybridTopology(int topo[][SWITCH_NUM], vector<Link*>& selectedWirelessLinks)
{
for (int i = 0; i < selectedWirelessLinks.size(); i++)
{
Link* link = selectedWirelessLinks[i];
topo[link->src][link->dst] = 1;
}
cout << "GetHybridTopology() succeeds !!!" << endl;
}