We will learn how to use a script to create a station and scan for available APs. We will then look at the /scanresults/ URI and the info we can get from a scan through JSON. Please refer to sta_scan_test.py as an example script. | |
--sta_name nameOfStationSpecifies the name of the station to be created, if this option is used, the name will default to sta0000.
--ssid nameOfNetworkSpecifies the name of the network to connect to.
--security {WEP, WPA, WPA2, WPA3, Open}Specifies the security type of the network to connect to.
./sta_scan_test.py --sta_name sta0000 --ssid fake_ssid --security open --radio wiphy0
BSS Signal SSIDThis script produces limited output, for more detail we can look at the webpage hosted by LANforge.
08:36:c9:e3:d4:da -32.0 Logan-Test-Net
10:56:11:0c:04:02 -80.0 :)
22:56:11:0c:04:02 -79.0 xfinitywifi
32:56:11:0c:04:02 -80.0 NA
{"handler":"candela.lanforge.HttpStationScan$FixedJsonResponder","uri":"
scanresults/:shelf_id/:resource_id/:port_id","candela.lanforge.HttpStationScan":
{"duration":"1"},"scan-results":[{"1.1.4.08:36:c9:e3:d4:da":{"age":"2238","auth":"WPA2",
"beacon":"200","bss":"08:36:c9:e3:d4:da","channel":"44","entity id":"1.1.4",
"frequency":"5220","info":"3x3 MCS 0-9 AC","signal":"-32.0","ssid":"Logan-Test-Net"}}]}
data = {
"shelf": 1,
"resource": 1,
"port": self.sta_list
}
self.json_post("/cli-json/scan_wifi", data)
time.sleep(15)
scan_results = self.json_get("scanresults/1/1/%s" % ','.join(self.sta_list))
print("{0:<23}".format("BSS"), "{0:<7}".format("Signal"), "{0:<5}".format("SSID"))
for result in scan_results['scan-results']:
for name, info in result.items():
print("%s\t%s\t%s" % (info['bss'], info['signal'], info['ssid']))
def start(self):
self.station_profile.admin_up()
print(self.sta_list)
print("Sleeping 15s while waiting for scan")
data = {
"shelf": 1,
"resource": 1,
"port": self.sta_list
}
self.json_post("/cli-json/scan_wifi", data)
time.sleep(15)
scan_results = self.json_get("scanresults/1/1/%s" % ','.join(self.sta_list))
print("{0:<23}".format("BSS"), "{0:<7}".format("Signal"), "{0:<5}".format("SSID"))
for result in scan_results['scan-results']:
for name, info in result.items():
print("%s\t%s\t%s" % (info['bss'], info['signal'], info['ssid']))
BSS Signal SSID
00:0e:8e:52:4e:82 -33.0 test-net
08:36:c9:e3:d4:db -31.0 Logan-Test-Net
08:36:c9:e3:d4:dc -27.0 Logan-Test-Net