Repository navigation
Expand file tree
/
Copy pathhandover-controller.py
More file actions
executable file
·74 lines (59 loc) · 2.37 KB
/
Copy pathhandover-controller.py
File metadata and controls
executable file
·74 lines (59 loc) · 2.37 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
#!/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 mininet.node import RemoteController
from mininet.log import setLogLevel, info
from mn_wifi.node import UserAP
from mn_wifi.link import wmediumd
from mn_wifi.cli import CLI_wifi
from mn_wifi.net import Mininet_wifi
from mn_wifi.wmediumdConnector import interference
def topology():
"Create a network."
net = Mininet_wifi(controller=RemoteController, accessPoint=UserAP,
link=wmediumd, wmediumd_mode=interference)
info("*** Creating nodes\n")
sta1 = net.addStation('sta1', position='15,20,0')
sta2 = net.addStation('sta2', position='35,20,0')
ap1 = net.addAccessPoint('ap1', mac='00:00:00:00:00:01', ssid="handover",
mode="g", channel="1", passwd='123456789a',
encrypt='wpa2', position='10,30,0')
ap2 = net.addAccessPoint('ap2', mac='00:00:00:00:00:02', ssid="handover",
mode="g", channel="6", passwd='123456789a',
encrypt='wpa2', position='60,30,0')
ap3 = net.addAccessPoint('ap3', mac='00:00:00:00:00:03', ssid="handover",
mode="g", channel="1", passwd='123456789a',
encrypt='wpa2', position='120,100,0')
h1 = net.addHost('h1')
h2 = net.addHost('h2')
h3 = net.addHost('h3')
c1 = net.addController('c1', controller=RemoteController)
info("*** Configuring Propagation Model\n")
net.setPropagationModel(model="logDistance", exp=3.5)
info("*** Configuring wifi nodes\n")
net.configureWifiNodes()
info("*** Creating links\n")
net.addLink(ap1, ap2)
net.addLink(ap2, ap3)
net.addLink(h1, ap1)
net.addLink(h2, ap2)
net.addLink(h3, ap3)
net.plotGraph(min_x=-100, min_y=-100, max_x=200, max_y=200)
info("*** Starting network\n")
net.build()
c1.start()
ap1.start([c1])
ap2.start([c1])
ap3.start([c1])
sta1.cmd('wpa_cli -i sta1-wlan0 roam 00:00:00:00:00:01')
sta2.cmd('wpa_cli -i sta2-wlan0 roam 00:00:00:00:00:01')
sta1.cmd('./sta1_2.py &')
sta2.cmd('./sta2_2.py &')
info("*** Running CLI\n")
CLI_wifi(net)
info("*** Stopping network\n")
net.stop()
if __name__ == '__main__':
setLogLevel('info')
topology()