Repository navigation
Expand file tree
/
Copy pathforwardingBySSID.py
More file actions
executable file
·71 lines (56 loc) · 2.28 KB
/
Copy pathforwardingBySSID.py
File metadata and controls
executable file
·71 lines (56 loc) · 2.28 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
#!/usr/bin/python
# autor: Ramon dos Reis Fontes
# livro: Emulando Redes sem Fio com Mininet-WiFi
# github: https://github.com/ramonfontes/mn-wifi-book-pt
from mn_wifi.net import Mininet_wifi
from mn_wifi.node import OVSAP
from mn_wifi.cli import CLI_wifi
from mininet.node import Controller
from mininet.log import setLogLevel, info
def topology():
"Create a network."
net = Mininet_wifi( controller=Controller, autoAssociation=False )
info("*** Creating nodes\n")
sta1 = net.addStation( 'sta1', position='10,60,0' )
sta2 = net.addStation( 'sta2', position='20,15,0' )
sta3 = net.addStation( 'sta3', position='10,25,0' )
sta4 = net.addStation( 'sta4', position='50,30,0' )
sta5 = net.addStation( 'sta5', position='45,65,0' )
ap1 = net.addAccessPoint( 'ap1', vssids=4, ssid="ssid,ssid1,ssid2,ssid3,ssid4",
mode="g", channel="1", position='30,40,0' )
c0 = net.addController('c0', controller=Controller)
net.setPropagationModel(model='logDistance', exp=4)
info("*** Configuring wifi nodes\n")
net.configureWifiNodes()
"plotting graph"
net.plotGraph(max_x=100, max_y=100)
info("*** Starting network\n")
net.build()
c0.start()
ap1.start( [c0] )
sta1.setRange(15)
sta2.setRange(15)
sta3.setRange(15)
sta4.setRange(15)
sta5.setRange(15)
sta1.cmd('iwconfig sta1-wlan0 essid %s ap %s' %
(ap1.params['ssid'][1], ap1.params['mac'][1]))
sta2.cmd('iwconfig sta2-wlan0 essid %s ap %s' %
(ap1.params['ssid'][2], ap1.params['mac'][2]))
sta3.cmd('iwconfig sta3-wlan0 essid %s ap %s' %
(ap1.params['ssid'][2], ap1.params['mac'][2]))
sta4.cmd('iwconfig sta4-wlan0 essid %s ap %s' %
(ap1.params['ssid'][3], ap1.params['mac'][3]))
sta5.cmd('iwconfig sta5-wlan0 essid %s ap %s' %
(ap1.params['ssid'][4], ap1.params['mac'][4]))
ap1.cmd('ovs-ofctl add-flow ap1 in_port=2,actions=3')
ap1.cmd('ovs-ofctl add-flow ap1 in_port=3,actions=2')
ap1.cmd('ovs-ofctl add-flow ap1 in_port=4,actions=5')
ap1.cmd('ovs-ofctl add-flow ap1 in_port=5,actions=4')
info("*** Running CLI\n")
CLI_wifi( net )
info("*** Stopping network\n")
net.stop()
if __name__ == '__main__':
setLogLevel( 'info' )
topology()