-
Notifications
You must be signed in to change notification settings - Fork 1
/
fill_rt.py
54 lines (48 loc) · 3.28 KB
/
fill_rt.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
from subprocess import call
from mininet.util import irange
def configure_downlink(net, tsa_host):
ue_ip = tsa_host.host.IP()
call(["ovs-ofctl", 'add-flow', tsa_host.tsa_switch.name,
"idle_timeout=0,priority=33001,"
"dl_type=0x800,nw_dst={ip},actions=output:{port}".format(ip=ue_ip, port=tsa_host.in_port)])
ap_name = tsa_host.selected_ap.name
ap = net[ap_name]
# add ap OF-rule for downlink in ap
for ap_intf, tsa_switch_intf in ap.connectionsTo(tsa_host.tsa_switch):
call(['ovs-ofctl', 'add-flow', ap_name, 'idle_timeout=0,priority=33000,dl_type=0x800,nw_dst={ip},'
'actions=output:{out}'.format(ip=ue_ip, out=ap.ports[ap_intf])])
for switch_name in ['s101', 's102', 's103', 's104']:
switch = net[switch_name]
for ap_intf, switch_intf in ap.connectionsTo(switch):
# downlink rule
call(['ovs-ofctl', 'add-flow', switch_name, 'idle_timeout=0,priority=33000,dl_type=0x800,nw_dst={ip},'
'actions=output:{out}'.format(ip=ue_ip,
out=switch.ports[switch_intf])])
for switch_intf2, s105_intf in switch.connectionsTo(net['s105']):
call(['ovs-ofctl', 'add-flow', 's105', 'idle_timeout=0,priority=33000,dl_type=0x800,nw_dst={ip},'
'actions=output:{out}'.format(ip=ue_ip,
out=net['s105'].ports[s105_intf])])
def configure_uplinks(net):
for host_name in ['h1', 'h2']:
host = net[host_name]
switch = net['s105']
for s105_intf, host_intf in switch.connectionsTo(host):
call(['ovs-ofctl', 'add-flow', 's105', 'idle_timeout=0,priority=33000,dl_type=0x800,nw_dst={ip},'
'actions=output:{out}'.format(ip=host.IP(),
out=switch.ports[s105_intf])])
for switch_name in ['s101', 's102', 's103', 's104']:
switch = net[switch_name]
for switch_intf, s105_intf in switch.connectionsTo(net['s105']):
call(['ovs-ofctl', 'add-flow', switch_name, 'idle_timeout=0,priority=33000,dl_type=0x800,nw_dst={ip},'
'actions=output:{out}'.format(ip=host.IP(),
out=switch.ports[
switch_intf])])
for i in irange(1, 16):
ap_name = "sap%d" % i
switch_name = "s10%d" % ((i - 1) / 4 + 1)
ap = net[ap_name]
switch = net[switch_name]
for ap_intf, switch_intf in ap.connectionsTo(switch):
call(['ovs-ofctl', 'add-flow', ap_name, 'idle_timeout=0,priority=33000,dl_type=0x800,nw_dst={ip},'
'actions=output:{out}'.format(ip=host.IP(),
out=ap.ports[ap_intf])])