Skip to content

Commit

Permalink
Enforce consistent naming scheme
Browse files Browse the repository at this point in the history
Changes are made to the prefix of functions, variables and related
 symbols from "owl" to "vwifi", just like the name of this project.
At the same time, the prefix of the name for virtual interfaces are
changed, too. Virtual interfaces used "owl" as the prefix of their
name but now they use "vw" for the prefix of their name.
For example "owl0" are changed to "vw0".

Close #52
  • Loading branch information
vax-r committed Jan 10, 2024
1 parent f1f4b65 commit 21a60d0
Show file tree
Hide file tree
Showing 5 changed files with 369 additions and 363 deletions.
58 changes: 29 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ To check the network interfaces, run the following command:
$ ip link
```

There should be entries starting with `owl0`, `owl1`, and `owl2`, which correspond to the interfaces created by `vwifi`.
There should be entries starting with `vw0`, `vw1`, and `vw2`, which correspond to the interfaces created by `vwifi`.

To view the available wireless interfaces, execute the following command:
```shell
Expand All @@ -95,19 +95,19 @@ $ sudo iw dev
You should see something similar to the following output:
```
phy#2
Interface owl2
Interface vw2
ifindex 5
wdev 0x200000001
addr 00:6f:77:6c:32:00
type managed
phy#1
Interface owl1
Interface vw1
ifindex 4
wdev 0x100000001
addr 00:6f:77:6c:31:00
type managed
phy#0
Interface owl0
Interface vw0
ifindex 3
wdev 0x1
addr 00:6f:77:6c:30:00
Expand Down Expand Up @@ -217,15 +217,15 @@ $ sudo iw phy phy2 set netns name ns2

Now, assign an IP address to both interfaces using the following commands:
```shell
$ sudo ip netns exec ns0 ip addr add 10.0.0.1/24 dev owl0
$ sudo ip netns exec ns1 ip addr add 10.0.0.2/24 dev owl1
$ sudo ip netns exec ns2 ip addr add 10.0.0.3/24 dev owl2
$ sudo ip netns exec ns0 ip addr add 10.0.0.1/24 dev vw0
$ sudo ip netns exec ns1 ip addr add 10.0.0.2/24 dev vw1
$ sudo ip netns exec ns2 ip addr add 10.0.0.3/24 dev vw2
```

### Running hostapd on the HostAP Mode Interface
Prepare the following script `hostapd.conf` (you can modify the script based on your needs):
```
interface=owl0
interface=vw0
driver=nl80211
debug=1
ctrl_interface=/var/run/hostapd
Expand All @@ -238,9 +238,9 @@ wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP
```
Run `hostapd` on the interface `owl0`:
Run `hostapd` on the interface `vw0`:
```shell
$ sudo ip netns exec ns0 hostapd -i owl0 -B hostapd.conf
$ sudo ip netns exec ns0 hostapd -i vw0 -B hostapd.conf
```

### Running `wpa_supplicant` on the Station Mode Interfaces
Expand All @@ -255,39 +255,39 @@ network={
Then run the `wpa_supplicant` on the interface `ns1` and `ns2`:
```shell
$ sudo ip netns exec ns1 \
wpa_supplicant -i owl1 -B -c wpa_supplicant.conf
wpa_supplicant -i vw1 -B -c wpa_supplicant.conf
$ sudo ip netns exec ns2 \
wpa_supplicant -i owl2 -B -c wpa_supplicant.conf
wpa_supplicant -i vw2 -B -c wpa_supplicant.conf
```

### Validating the Connection
To validate the connection, use the following command:
```shell
$ sudo ip netns exec ns1 iw dev owl1 link
$ sudo ip netns exec ns1 iw dev vw1 link
```

The output might seem like this:
```
Connected to 00:6f:77:6c:30:00 (on owl1)
Connected to 00:6f:77:6c:30:00 (on vw1)
SSID: test
freq: 2437
RX: 282 bytes (2 packets)
TX: 248 bytes (2 packets)
signal: -84 dBm
```

It shows that `owl1` has connected to the BSS with BSSID `00:6f:77:6c:30:00`, which is the MAC address of `owl0`.
It shows that `vw1` has connected to the BSS with BSSID `00:6f:77:6c:30:00`, which is the MAC address of `vw0`.

You may also check the connection of `owl2` by slightly changing the command above.
You may also check the connection of `vw2` by slightly changing the command above.

On the other hand, we can validate all the stations connected to `owl0` by the following commands:
On the other hand, we can validate all the stations connected to `vw0` by the following commands:
```shell
sudo ip netns exec ns0 iw dev owl0 station dump
sudo ip netns exec ns0 iw dev vw0 station dump
```

The output may seem like this:
```
Station 00:6f:77:6c:31:00 (on owl0)
Station 00:6f:77:6c:31:00 (on vw0)
inactive time: 5588 ms
rx bytes: 5366
rx packets: 65
Expand All @@ -296,7 +296,7 @@ Station 00:6f:77:6c:31:00 (on owl0)
tx failed: 74
signal: -57 dBm
current time: 1689679337171 ms
Station 00:6f:77:6c:32:00 (on owl0)
Station 00:6f:77:6c:32:00 (on vw0)
inactive time: 5588 ms
rx bytes: 5366
rx packets: 65
Expand All @@ -309,7 +309,7 @@ Station 00:6f:77:6c:32:00 (on owl0)

### Transmission/Receivement test
Finally, we can do the ping test:
1. To perform a ping test between two STAs (`owl1` and `owl2`), use the following command:
1. To perform a ping test between two STAs (`vw1` and `vw2`), use the following command:
```shell
$ sudo ip netns exec ns1 ping -c 4 10.0.0.3
```
Expand All @@ -327,7 +327,7 @@ PING 10.0.0.3 (10.0.0.3) 56(84) bytes of data.
rtt min/avg/max/mdev = 0.082/0.138/0.188/0.037 ms
```

2. To perform a ping test between the AP (`owl0`) and a STA (`owl2`), execute the following command:
2. To perform a ping test between the AP (`vw0`) and a STA (`vw2`), execute the following command:
```shell
$ sudo ip netns exec ns2 ping -c 4 10.0.0.1
```
Expand Down Expand Up @@ -374,13 +374,13 @@ We can use `vwifi-tool` to set or unset blocklist for vwifi, multiple options ar

Set the blocklist pair using vwifi-tool like the following
```
$ ./vwifi-tool -d owl2 -s owl1
$ ./vwifi-tool -d vw2 -s vw1
```
You should see the following output, including your blocklist which will be sent to vwifi
```
vwifi status : live
blocklist:
owl2 blocks owl1
vw2 blocks vw1
Configuring blocklist for vwifi...
Message from vwifi: vwifi has received your blocklist
```
Expand Down Expand Up @@ -569,27 +569,27 @@ insmod vwifi.ko station=1
#### Setting Network Interface
Start the network interface:
```shell
ip link set owl0 up
ip link set vw0 up
```
And assign an IP address. Note that, we should assign different IP addresses (but the same subnet) for every network interface in the three VMs:
```shell
ip addr add <IP address/netmask> dev owl0
ip addr add <IP address/netmask> dev vw0
```
### Start `hostapd` and `wpa_supplicant`
In our testing environment, the HostAP mode interface is in VM1, so running `hostapd` on VM1:
```shell
hostapd -i owl0 -B hostapd.conf
hostapd -i vw0 -B hostapd.conf
```
And running `wpa_supplicant` on the other two VMs:
```shell
wpa_supplicant -i owl0 -B -c wpa_supplicant.conf
wpa_supplicant -i vw0 -B -c wpa_supplicant.conf
```

For now, the two STA mode interfaces in VM1 and VM2 should have been connected to the AP mode interface in VM0.

For validating the connection for the STA mode network interface, use the following command:
```shell
iw dev owl0 link
iw dev vw0 link
```
### Ping Test
In VM1, we can ping the network interfaces in VM2 and VM3:
Expand Down
2 changes: 1 addition & 1 deletion scripts/hostapd.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
interface=owl0
interface=vw0
driver=nl80211
debug=1
ctrl_interface=/var/run/hostapd
Expand Down
2 changes: 1 addition & 1 deletion scripts/plot_rssi.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
ax.set_title('RSSI of sta owl0')
ax.set_title('RSSI of sta vw0')
ax.set_xlabel('times get_station called')
ax.set_ylabel('dBm')

Expand Down
88 changes: 44 additions & 44 deletions scripts/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,55 +26,55 @@ if [ $final_ret -eq 0 ]; then

# get phy number of each interface
sudo iw dev > device.log
owl0_phy=$(cat device.log | grep -B 1 owl0 | grep phy)
owl0_phy=${owl0_phy/\#/}
owl1_phy=$(cat device.log | grep -B 1 owl1 | grep phy)
owl1_phy=${owl1_phy/\#/}
owl2_phy=$(cat device.log | grep -B 1 owl2 | grep phy)
owl2_phy=${owl2_phy/\#/}
vw0_phy=$(cat device.log | grep -B 1 vw0 | grep phy)
vw0_phy=${vw0_phy/\#/}
vw1_phy=$(cat device.log | grep -B 1 vw1 | grep phy)
vw1_phy=${vw1_phy/\#/}
vw2_phy=$(cat device.log | grep -B 1 vw2 | grep phy)
vw2_phy=${vw2_phy/\#/}

# create network namespaces for each phy (interface)
sudo ip netns add ns0
sudo ip netns add ns1
sudo ip netns add ns2

# add each phy (interface) to separate network namesapces
sudo iw phy $owl0_phy set netns name ns0
sudo iw phy $owl1_phy set netns name ns1
sudo iw phy $owl2_phy set netns name ns2
sudo iw phy $vw0_phy set netns name ns0
sudo iw phy $vw1_phy set netns name ns1
sudo iw phy $vw2_phy set netns name ns2

# running hostapd on owl0, so owl0 becomes AP
sudo ip netns exec ns0 ip link set owl0 up
# running hostapd on vw0, so vw0 becomes AP
sudo ip netns exec ns0 ip link set vw0 up
sudo ip netns exec ns0 ip link set lo up
sudo ip netns exec ns0 hostapd -B scripts/hostapd.conf

sudo ip netns exec ns1 ip link set owl1 up
sudo ip netns exec ns1 ip link set vw1 up
sudo ip netns exec ns1 ip link set lo up

sudo ip netns exec ns2 ip link set owl2 up
sudo ip netns exec ns2 ip link set vw2 up
sudo ip netns exec ns2 ip link set lo up

# assing IP address to each interface
sudo ip netns exec ns0 ip addr add 10.0.0.1/24 dev owl0
sudo ip netns exec ns1 ip addr add 10.0.0.2/24 dev owl1
sudo ip netns exec ns2 ip addr add 10.0.0.3/24 dev owl2
sudo ip netns exec ns0 ip addr add 10.0.0.1/24 dev vw0
sudo ip netns exec ns1 ip addr add 10.0.0.2/24 dev vw1
sudo ip netns exec ns2 ip addr add 10.0.0.3/24 dev vw2

# ping test: STA owl1 <--> STA owl2, should fail, because they
# ping test: STA vw1 <--> STA vw2, should fail, because they
# haven't connected to AP
echo
echo "================================================================================"
echo "Ping Test: STA owl1 (10.0.0.2) (not connected) <--> STA owl2 (10.0.0.3) (not connected)"
echo "Ping Test: STA vw1 (10.0.0.2) (not connected) <--> STA vw2 (10.0.0.3) (not connected)"
echo
echo "(should fail, because they haven't connnected to AP owl0 (10.0.0.1))"
echo "(should fail, because they haven't connnected to AP vw0 (10.0.0.1))"
echo "(be patient, it will take some time to route...)"
echo "================================================================================"
sudo ip netns exec ns1 ping -c 1 10.0.0.3

# STA owl1 performs scan and connect to TestAP
sudo ip netns exec ns1 iw dev owl1 scan > scan_result.log
# STA vw1 performs scan and connect to TestAP
sudo ip netns exec ns1 iw dev vw1 scan > scan_result.log
cat scan_result.log | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}'| tail -n 1 > scan_bssid.log
sudo ip netns exec ns1 iw dev owl1 connect test
sudo ip netns exec ns1 iw dev owl1 link | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}' > connected.log
sudo ip netns exec ns1 iw dev vw1 connect test
sudo ip netns exec ns1 iw dev vw1 link | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}' > connected.log

DIFF=$(diff connected.log scan_bssid.log)
if [ "$DIFF" != "" ]; then
Expand All @@ -83,14 +83,14 @@ if [ $final_ret -eq 0 ]; then

echo
echo "=================================="
echo "owl1 connected to AP TestAP (owl0)"
echo "vw1 connected to AP TestAP (vw0)"
echo "=================================="

# STA owl2 performs scan and connect to TestAP
sudo ip netns exec ns2 iw dev owl2 scan > scan_result.log
# STA vw2 performs scan and connect to TestAP
sudo ip netns exec ns2 iw dev vw2 scan > scan_result.log
cat scan_result.log | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}'| tail -n 1 > scan_bssid.log
sudo ip netns exec ns2 iw dev owl2 connect test
sudo ip netns exec ns2 iw dev owl2 link | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}' > connected.log
sudo ip netns exec ns2 iw dev vw2 connect test
sudo ip netns exec ns2 iw dev vw2 link | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}' > connected.log

DIFF=$(diff connected.log scan_bssid.log)
if [ "$DIFF" != "" ]; then
Expand All @@ -99,16 +99,16 @@ if [ $final_ret -eq 0 ]; then

echo
echo "=================================="
echo "owl2 connected to AP TestAP (owl0)"
echo "vw2 connected to AP TestAP (vw0)"
echo "=================================="

# ping test: STA owl1 (10.0.0.2) <--> STA owl2 (10.0.0.3),
# should success, packet will be relayed by AP owl0 (10.0.0.1)
# ping test: STA vw1 (10.0.0.2) <--> STA vw2 (10.0.0.3),
# should success, packet will be relayed by AP vw0 (10.0.0.1)
echo
echo "================================================================================"
echo "Ping Test: STA owl1 (10.0.0.2) (connected) <--> STA owl2 (10.0.0.3) (connected)"
echo "Ping Test: STA vw1 (10.0.0.2) (connected) <--> STA vw2 (10.0.0.3) (connected)"
echo
echo "(should success, packet will be relay by AP owl0 (10.0.0.1))"
echo "(should success, packet will be relay by AP vw0 (10.0.0.1))"
echo "================================================================================"
sudo ip netns exec ns1 ping -c 4 10.0.0.3

Expand All @@ -118,13 +118,13 @@ if [ $final_ret -eq 0 ]; then
final_ret=6
fi

# ping test: STA owl2 (10.0.0.3) <--> AP owl0 (10.0.0.1),
# ping test: STA vw2 (10.0.0.3) <--> AP vw0 (10.0.0.1),
# should success, packet will directly send/receive between STA and AP
echo
echo "================================================================================"
echo "Ping Test: STA owl1 (10.0.0.3) (connected) <--> AP owl0 (10.0.0.1)"
echo "Ping Test: STA vw1 (10.0.0.3) (connected) <--> AP vw0 (10.0.0.1)"
echo
echo "(should success, packet will directly send/receive between STA owl1 and AP owl0)"
echo "(should success, packet will directly send/receive between STA vw1 and AP vw0)"
echo "================================================================================"
sudo ip netns exec ns2 ping -c 4 10.0.0.1

Expand All @@ -135,7 +135,7 @@ if [ $final_ret -eq 0 ]; then
fi

# verify TSF (in usec)
sudo ip netns exec ns1 iw dev owl1 scan > scan_result.log
sudo ip netns exec ns1 iw dev vw1 scan > scan_result.log
tsf=$(cat scan_result.log | grep "TSF" | tail -n 1 | awk '{print $2}')
uptime=$(cat /proc/uptime | awk '{print $1}')
uptime=$(echo "$uptime*1000000" | bc | awk -F "." '{print $1}')
Expand All @@ -146,15 +146,15 @@ if [ $final_ret -eq 0 ]; then
final_ret=8
fi

# plot the distribution of RSSI of owl0
echo -e "\n\n######## collecting RSSI information of owl0, please wait... ##########"
owl0_mac=$(sudo ip netns exec ns0 iw dev | grep -E 'owl0$' -A 3 | grep addr | awk '{print $2}')
# plot the distribution of RSSI of vw0
echo -e "\n\n######## collecting RSSI information of vw0, please wait... ##########"
vw0_mac=$(sudo ip netns exec ns0 iw dev | grep -E 'vw0$' -A 3 | grep addr | awk '{print $2}')
counts=1000 # do get_station 1000 times

for i in $(seq 1 1 $counts); do
owl0_signal=$(sudo ip netns exec ns0 \
iw dev owl0 station get $owl0_mac | grep "signal" | awk '{print $2}')
echo $owl0_signal >> rssi.txt
vw0_signal=$(sudo ip netns exec ns0 \
iw dev vw0 station get $vw0_mac | grep "signal" | awk '{print $2}')
echo $vw0_signal >> rssi.txt
done

python3 $ROOT/scripts/plot_rssi.py
Expand All @@ -164,7 +164,7 @@ if [ $final_ret -eq 0 ]; then
fi

# TestAP performs station dump
sudo ip netns exec ns0 iw dev owl0 station dump > station_dump_result.log
sudo ip netns exec ns0 iw dev vw0 station dump > station_dump_result.log
for num in {1..2}; do
cat station_dump_result.log | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}'| sed -n "${num}p" > dump_ssid.log
sudo ip netns exec "ns${num}" iw dev | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}' > station_ssid.log
Expand Down
Loading

0 comments on commit 21a60d0

Please sign in to comment.