-
Notifications
You must be signed in to change notification settings - Fork 0
/
example_1.py
53 lines (39 loc) · 1.44 KB
/
example_1.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
import sys
from utility import ConfigUtility
from emu import SdnEmu
from net import RpiNet
from node import RpiSwitch, RpiHost, RpiController
from app import Application
print "Hello PiSNet!"
machines = ConfigUtility()
machines.read('machines.cfg')
rpinet = RpiNet()
s1 = rpinet.addSwitch( 's1', machines.get('RPI_C06') )
s2 = rpinet.addSwitch( 's2', machines.get('RPI_C07') )
s3 = rpinet.addSwitch( 's3', machines.get('RPI_C08') )
s4 = rpinet.addSwitch( 's4', machines.get('RPI_C10') )
h1 = rpinet.addHost( 'h1', machines.get('RPI_C02') )
h2 = rpinet.addHost( 'h2', machines.get('RPI_C03') )
c1 = rpinet.addController( 'c1', machines.get('RPI_C04') )
rpinet.addLink(h1, s1)
rpinet.addLink(s1, s2)
rpinet.addLink(s2, s3)
rpinet.addLink(s3, s4)
rpinet.addLink(h2, s4)
cmd = ConfigUtility()
cmd.read( sys.argv[1] )
c1.addService( cmd.get('REMOTE','NOHUP'), cmd.get('RYU') )
video_streaming = Application( cmd.get('VIDEO_STREAMING') )
video_streaming.setServer( h1, cmd.get('REMOTE','GENERAL') )
video_streaming.setClient( h2, cmd.get('REMOTE','PSEUDO_TERMINAL') )
monitoring = Application( cmd.get('MONITORING') )
monitoring.setServer( h1, cmd.get('REMOTE','GENERAL') )
monitoring.setClient( h2, cmd.get('REMOTE','GENERAL') )
monitoring.setLogNo( sys.argv[2] )
emu = SdnEmu(rpinet)
emu.addStartQueue( monitoring ) #FIFO
emu.addStartQueue( video_streaming )
emu.start()
emu.callChecker( video_streaming )
emu.addStopQueue( monitoring ) #FIFO
emu.stop()