-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathred_topo.py
More file actions
executable file
·141 lines (108 loc) · 4.62 KB
/
red_topo.py
File metadata and controls
executable file
·141 lines (108 loc) · 4.62 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
from mininet.topo import Topo
from mininet.net import Mininet
from mininet.node import CPULimitedHost
from mininet.link import TCLink, TCIntf, Link
from mininet.util import dumpNetConnections
import sys
import os
from time import sleep, time
from subprocess import Popen, PIPE
#High simulation bandwdith, in Mbps
BW_HIGH = 100
#Low simulation bandwidth, in Mbps
BW_LOW = 45
#Default options to pass to tc-red; as specified originally in link.py
DEFAULT_RED_PARAMS = {'enable_red': True, 'red_limit': 1000000,
'red_min': 20000, 'red_max': 25000, 'red_avpkt': 1000,
'red_burst': 20, 'red_prob': 1.0}
class Fig4Topo(Topo):
"Topology from figure 4 of RED paper"
def __init__(self):
Topo.__init__(self);
l1config = {'bw': 100, 'delay': '1ms', 'max_queue_size': None }
l2config = {'bw': 100, 'delay': '4ms', 'max_queue_size': None }
l3config = {'bw': 100, 'delay': '8ms', 'max_queue_size': None }
l4config = {'bw': 100, 'delay': '5ms', 'max_queue_size': None }
l6config = {'bw': 45, 'delay': '2ms', 'max_queue_size': None }
hconfig = {'cpu': None}
s1 = self.add_switch('s1')
h1 = self.add_host('h1', **hconfig);
h2 = self.add_host('h2', **hconfig);
h3 = self.add_host('h3', **hconfig);
h4 = self.add_host('h4', **hconfig);
sink = self.add_host('sink', **hconfig);
self.add_link(h1, s1,
port1=0, port2=1, **l1config);
self.add_link(h2, s1,
port1=0, port2=2, **l2config);
self.add_link(h3, s1,
port1=0, port2=3, **l3config);
self.add_link(h4, s1,
port1=0, port2=4, **l4config);
self.add_link(s1, sink,
port1=0, port2=0, **l6config);
def numSources(self):
return 4
class BurstTestTopo(Topo):
"Topology to test our bursty traffic generator"
def __init__(self, red_params=DEFAULT_RED_PARAMS):
Topo.__init__(self)
src_lconfig = {'bw': BW_LOW, 'delay': '16ms', 'max_queue_size': None}
dst_lconfig = {'bw': BW_LOW, 'delay': '2ms', 'max_queue_size': None}
switch_lconfig = dst_lconfig.copy()
switch_lconfig.update(red_params)
hconfig = {'cpu': None}
s1 = self.add_switch('s1')
host = self.add_host('h1', **hconfig)
self.add_link(host, s1, port1=0, port2=1, **src_lconfig)
sink = self.add_host('sink', **hconfig)
self.add_link(s1, sink, cls=Link, port1=0, port2=0,
cls1=TCIntf, cls2=TCIntf,
params1=switch_lconfig, params2=dst_lconfig)
def numSources(self):
return 1
class Fig6Topo(Topo):
def __init__(self, red_params=DEFAULT_RED_PARAMS):
Topo.__init__(self)
src_lconfig = {'bw': BW_HIGH, 'delay': '1ms', 'max_queue_size': None}
dst_lconfig = {'bw': BW_LOW, 'delay': '20ms', 'max_queue_size': None}
switch_lconfig = dst_lconfig.copy()
switch_lconfig.update(red_params)
hconfig = {'cpu': None}
s1 = self.add_switch('s1')
# hosts 1..2
for i in range(1, 3):
host = self.add_host('h%d' % i, **hconfig)
self.add_link(host, s1, port1=0, port2=i, **src_lconfig)
sink = self.add_host('sink', **hconfig)
self.add_link(s1, sink, cls=Link, port1=0, port2=0,
cls1=TCIntf, cls2=TCIntf,
params1=switch_lconfig, params2=dst_lconfig)
def numSources(self):
return 2
class Fig11Topo(Topo):
def __init__(self, red_params=DEFAULT_RED_PARAMS):
Topo.__init__(self)
l1config = {'bw': BW_HIGH, 'delay': '1ms', 'max_queue_size': None }
l2config = {'bw': BW_LOW, 'delay': '16ms', 'max_queue_size': None }
dst_lconfig = {'bw': BW_LOW, 'delay': '2ms', 'max_queue_size': None }
switch_lconfig = dst_lconfig.copy()
switch_lconfig.update(red_params)
hconfig = {'cpu': None }
s1 = self.add_switch('s1')
# hosts 1..4
for i in range(1, 5):
host = self.add_host('h%d' % i, **hconfig)
self.add_link(host, s1, port1=0,
port2=i, **l1config)
# host 5
h5 = self.add_host('h5', **hconfig)
self.add_link(h5, s1, port1=0, port2=5, **l2config)
# sink
sink = self.add_host('sink', **hconfig)
self.add_link(s1, sink, cls=Link, port1=0, port2=0,
cls1=TCIntf, cls2=TCIntf,
params1=switch_lconfig, params2=dst_lconfig)
#self.add_link(s1, sink, port1=0, port2=0, **l3config)
def numSources(self):
return 5