Objectives
COMP4336/9336 Mobile Data Networking Lab 4: WiFi API
• To access the WiFi API of your OS from your program/code
Prerequisites
Copyright By PowCoder代写 加微信 powcoder
You need to have access to a Mac/Windows/Linux laptop/desktop
Introduction
While Wireshark allows you to collect detailed data about the WiFi networking interface of your computer, it does so in an off-line manner. To develop a piece of software that would read and act on WiFi interface data in real-time, you will need to access the WiFi API. In this lab, you will learn how to access the WiFi API of your OS.
Your Tasks
Task 1: WiFi API information extraction [1 mark]
Try to run the following commands to output the WiFi information:
You can simply use this command to fetch AP information: lists all the visible APs individually:
Show current AP:
Try to run this short shell script in your terminal to show the signal strength:
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resourc es/airport -s
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/R esources/airport -I
while i=1; do echo -ne ‘Wifi signal strength:’ $(/System/Library/PrivateFramewor ks/Apple80211.framework/Versions/Current/Resources/airport -I | grep CtlRSSI | awk {‘print $2’}) ‘\r’; sleep 0.3; done
sample output:
Wifi signal strength: -18
Run the following commands in your terminal to print out the interface information:
netsh wlan show networks mode=Bssid
sample output:
You can get the rssi value of your current link when using WiFi station as follows (wlan0 is the usual default wi-fi device, but depends on the driver and configuration):
$ iw dev wlan0 link
Connected to 9c:4e:20:c8:ee:9e (on wlan0)
SSID: CORP1
freq: 5240
RX: 7306266 bytes (6124 packets)
TX: 776491 bytes (4117 packets) signal: -75 dBm
tx bitrate: 39.0 MBit/s MCS 4
To list available WiFi signals:
$ ip link set wlan0 up
$ iw dev wlan0 scan
BSS 9c:4e:20:c8:ee:9d(on wlan0) TSF: 0 usec (0d, 00:00:00)
freq: 5240
beacon interval: 102 TUs
capability: ESS Privacy RadioMeasure (0x1011) signal: -75.00 dBm
last seen: 765 ms ago
SSID: CORP1
Task 2: Counting surrounding devices and distance estimation [3 marks] Python programming with system API
You are required to plot the table showing the surrounding WiFi AP at real-time in your program. The table should display the SSID, signal strength, also show other information(e.g. frequency, channel, rate …) if applicable. And use the Free space path loss equation to calculate the estimate distance.
distance = 10 ^ ((27.55 – (20 * log10(frequency)) + signalLevel)/20)
Please note that your program should have the environment check before running or you can provide a readme documentation about the working environment (i.e. which OS and the version).
A sample of application:
$ python3 wifi_distance.py
There are 3 devices visible:
SSID | Frequency | Channel |Signal strength| Est. distance —–+———–+———+—————+—————— UNSW | 2.4 GHz | 1 | -57 dbm | 7m —–+———–+———+—————+—————— Home|5GHz | 9 | -60dbm | 4.73m —–+———–+———+—————+—————— Mall|5GHz | 60 | -75dbm | 25.3m
What to submit?
1. Submit a ZIP file containing the program file.
2. Submit a PDF report containing the following:
a. Your observations of Task 1: What do you get from the command? [1 mark]
b. A brief document about how to run your program and a screenshot of sample output
Penalty at the rate of 5% for each day late will be strictly enforced for all lab submissions. All submissions will be subject to strict UNSW plagiarism rules.
End of Lab 4 – Hope you enjoyed this lab
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com