--- tags: mininet-wifi-tutorials --- # Machine Learning :::info **In this short demo you will:** - Learn on how to use whereami to make some predictions **Requirements** - Mininet-WiFi - https://github.com/intrig-unicamp/mininet-wifi - Whereami - https://github.com/ramonfontes/whereami ::: Firstly you have to take the code below: ```python= #!/usr/bin/python '''@author: Ramon Fontes @email: ramon.fontes@imd.ufrn.br''' import sys from mininet.log import setLogLevel, info from mn_wifi.link import wmediumd from mn_wifi.cli import CLI from mn_wifi.net import Mininet_wifi from mn_wifi.wmediumdConnector import interference def topology(args): "Create a network." net = Mininet_wifi(link=wmediumd, wmediumd_mode=interference, noise_th=-91, fading_cof=1) info("*** Creating nodes\n") ap1 = net.addAccessPoint('ap1', ssid='new-ssid', mode='a', channel='36', position='125,30,0') ap2 = net.addAccessPoint('ap2', ssid='new-ssid', mode='a', channel='36', position='50,30,0') ap3 = net.addAccessPoint('ap3', ssid='new-ssid', mode='a', channel='36', position='50,90,0') ap4 = net.addAccessPoint('ap4', ssid='new-ssid', mode='a', channel='36', position='125,90,0') net.addStation('sta1', ip='10.0.0.1/8', position='10,20,0') info("*** Configuring Propagation Model\n") net.setPropagationModel(model="logDistance", exp=4) info("*** Configuring wifi nodes\n") net.configureWifiNodes() net.plotGraph(max_x=200, max_y=200) info("*** Starting network\n") net.build() ap1.start([]) ap2.start([]) ap3.start([]) ap4.start([]) info("*** Running CLI\n") CLI(net) info("*** Stopping network\n") net.stop() if __name__ == '__main__': setLogLevel('info') topology() ``` Considering that the filename is `predict.py` you run it as below: ``` sudo python predict.py ``` Then you open xterm and run whereami from sta1's terminal. ``` mininet-wifi> xterm sta1 whereami learn -l ap2 --device sta1-wlan0 ``` Change the position to ap1 and run whereami again. ``` mininet-wifi> py sta1.setPosition('150,25,0') whereami learn -l ap1 --device sta1-wlan0 ``` Change the position to ap4 and run whereami. ``` mininet-wifi> py sta1.setPosition('125,125,0') whereami learn -l ap4 --device sta1-wlan0 ``` Change the position to ap3 and run whereami one more time. ``` mininet-wifi> py sta1.setPosition('50,125,0') whereami learn -l ap3 --device sta1-wlan0 ``` At this time you are able to see some txt files at ~/.whereami as well the pkl model. ``` ~/.whereami/*.txt ~/.whereami/model.pkl ``` Lastly, you can change the position of sta1 and make the prediction with whereami as below: ``` whereami predict --device sta1-wlan0 ``` :::info Demo :mega:: https://www.youtube.com/watch?v=8hijoFLS_PU :::