Created
December 16, 2022 10:07
-
-
Save dat-adi/53d0cc59ebf44ebe357f9408389126af to your computer and use it in GitHub Desktop.
This script was made to emulate a station migration scenario, in a heterogeneous controller environment, using Mininet-Wifi.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
""" | |
This script is used to emulate a scenario where | |
a station migrates from one AP to another, while | |
attempting to ping a station from the third AP. | |
Controllers used to test: ODL, FL, Ryu. | |
Emulator used: Mininet-Wifi | |
Initial state | |
------------- | |
AP1 AP3 | |
| | | |
sta1.............sta3 | |
AP2 | |
Final state | |
----------- | |
AP1 AP3 | |
| | |
sta3 | |
. | |
.../ | |
../ | |
AP2 .../ | |
| ../ | |
sta1 | |
""" | |
from mininet.node import Controller, RemoteController | |
from mininet.log import setLogLevel, info | |
from mn_wifi.net import Mininet_wifi | |
from mn_wifi.node import Station | |
from mn_wifi.cli import CLI | |
from mn_wifi.link import wmediumd | |
from mn_wifi.wmediumdConnector import interference | |
def network_init(): | |
# Setting initial network config | |
net = Mininet_wifi( | |
topo=None, | |
build=False, | |
link=wmediumd, | |
wmediumd_mode=interference, | |
) | |
info("*** Adding controller\n") | |
c0 = net.addController( | |
name="c0", controller=RemoteController, ip="192.168.0.122", protocols="tcp", port=6653 | |
) | |
c1 = net.addController( | |
name="c1", controller=RemoteController, ip="192.168.0.141", protocols="tcp", port=6653 | |
) | |
c2 = net.addController( | |
name="c2", controller=RemoteController, ip="192.168.0.217", protocols="tcp", port=6633 | |
) | |
info("*** Add switches/APs\n") | |
ap1 = net.addAccessPoint( | |
"ap1", ssid="ap1-ssid", channel="1", mode="g", position="270,339,0" | |
) | |
ap2 = net.addAccessPoint( | |
"ap2", ssid="ap2-ssid", channel="2", mode="g", position="790,340,0" | |
) | |
ap3 = net.addAccessPoint( | |
"ap3", ssid="ap3-ssid", channel="3", mode="g", position="270,1039,0" | |
) | |
info("*** Add hosts/stations\n") | |
sta1 = net.addStation("sta1", ip="192.168.0.29", position="300,400,0") | |
sta2 = net.addStation("sta2", ip="192.168.0.25", position="300,300,0") | |
sta3 = net.addStation("sta3", ip="192.168.0.35", position="700,470,0") | |
sta4 = net.addStation("sta4", ip="192.168.0.28", position="700,500,0") | |
sta5 = net.addStation("sta5", ip="192.168.0.26", position="300,1000,0") | |
net.configureWifiNodes() | |
info("*** Add links\n") | |
net.addLink(ap1, sta1) | |
net.addLink(ap1, sta2) | |
net.addLink(ap2, sta3) | |
net.addLink(ap2, sta4) | |
net.addLink(ap3, sta5) | |
net.addLink(ap1, ap2) | |
net.addLink(ap1, ap3) | |
info("*** Mobility\n") | |
p1, p2 = dict(), dict() | |
p1 = {"position": "300, 1000, 0"} | |
p2 = {"position": "270, 300, 0"} | |
net.startMobility(time=0, AC="ssf") | |
net.mobility(sta5, "start", time=1, **p1) | |
net.mobility(sta5, "stop", time=60, **p2) | |
net.stopMobility(time=60) | |
net.plotGraph(max_x=1000, max_y=1000) | |
info("*** Starting network\n") | |
net.build() | |
info("*** Starting controllers\n") | |
for controller in net.controllers: | |
controller.start() | |
info("*** Starting switches/APs\n") | |
net.get("ap1").start([c0, c1, c2]) | |
net.get("ap2").start([c0, c1, c2]) | |
net.get("ap3").start([c0, c1, c2]) | |
info("*** Post configure nodes\n") | |
CLI(net) | |
net.stop() | |
if __name__ == "__main__": | |
network_init() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment