-
Notifications
You must be signed in to change notification settings - Fork 1
/
run_demo.py
87 lines (71 loc) · 2.67 KB
/
run_demo.py
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
import atexit
from logging import info
import os
import subprocess
from mininet.net import Mininet
from mininet.link import TCLink
from mininet.node import Docker, RemoteController
from mininet.topo import Topo
from mininet.cli import CLI
from mininet.log import info,setLogLevel
def run_command(command):
returncode = subprocess.run(command.split()).returncode
if returncode != 0:
print(f'failed to run:\n{command}')
exit(0)
setup_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'scripts')
net = None
#router = None
def main():
### Init network
topo=Topo()
info('*** Adding docker containers\n')
gNodeB1 = topo.addHost('h1', cls=Docker, ip='10.0.0.2', dimage="ubuntu:trusty")
gNodeB2 = topo.addHost('h2', cls=Docker, ip='10.0.0.3', dimage="ubuntu:trusty")
bbudc = topo.addHost('h3',cls=Docker, ip='10.0.0.4', dimage="ubuntu:trusty")
regionaldc = topo.addHost('h4', cls=Docker, ip='10.0.0.5', dimage="ubuntu:trusty")
coredc = topo.addHost('h5',cls=Docker, ip='10.0.0.6', dimage="ubuntu:trusty")
info('*** Adding switches\n')
s1 = topo.addSwitch('s1')
s2 = topo.addSwitch('s2')
s3 = topo.addSwitch('s3')
s4 = topo.addSwitch('s4')
s5 = topo.addSwitch('s5')
s6 = topo.addSwitch('s6')
info('*** Creating links\n')
topo.addLink(gNodeB1, s1)
topo.addLink(gNodeB2, s2)
topo.addLink(s1, bbudc, delay='0.5ms', bw=1000)
topo.addLink(s2, bbudc, delay='0.5ms', bw=1000)
topo.addLink(s1, s3, delay='3ms', bw=1000)
topo.addLink(s2, s4, delay='3ms', bw=1000)
topo.addLink(s3, regionaldc, delay='2ms', bw=1000)
topo.addLink(s4, regionaldc, delay='2ms', bw=1000)
topo.addLink(s3, s5, delay='11ms', bw=1000)
topo.addLink(s4, s6, delay='11ms', bw=1000)
topo.addLink(s5, coredc, delay='11ms', bw=1000)
topo.addLink(s6, coredc, delay='11ms', bw=1000)
topo.addLink(s1, s4, delay='3ms', bw=1000)
topo.addLink(s2, s3, delay='3ms', bw=1000)
topo.addLink(s3, s6, delay='11ms', bw=1000)
topo.addLink(s4, s5, delay='11ms', bw=1000)
net = Mininet(topo=topo, controller=None, link=TCLink, autoSetMacs=True, autoStaticArp=True)
net.addController('c0',controller=RemoteController, ip='127.0.0.1', port=6653)
net.start()
info('*** Starting RAN\n')
os.chdir(setup_path)
run_command('./start_ran.sh')
info('*** Connecting Core to the network\n')
run_command('./connect_core.sh')
### Start mininet CLI
CLI(net)
### End network
net.stop()
def stopNetwork():
if net is not None:
net.stop()
#router.reset() # reset routing
if __name__ == '__main__':
atexit.register(stopNetwork)
setLogLevel('info')
main()