Skip to content

Commit fa402a1

Browse files
Store GI in cfg80211_bitrate_mask, enhance MCS documentation, and integrate test script
This commit refactors the vwifi driver to store Guard Interval (GI) information solely in cfg80211_bitrate_mask, eliminating the redundant short_gi variable, and introduces a spatial stream index for future optimization. It also adds a comprehensive comment block for manual_mcs and updates the test script to validate all MCS indices (0–31) with sgi-2.4 and lgi-2.4. changes: - vwifi_vif: - Remove short_gi, storing GI in vif->bitrate_mask.control[NL80211_BAND_2GHZ].gi. - Add spatial_streams field (int, default 1) for future multi-stream support. - Add manual_mcs field with detailed comment block explaining its role in storing the first enabled MCS for consistent bitrate reporting. - vwifi_set_bitrate_mask: - Store GI in vif->bitrate_mask.control[NL80211_BAND_2GHZ].gi, removing short_gi usage. - vwifi_get_station: - GI logic using vif->bitrate_mask.gi for short (0.4µs), long (0.8µs), or default GI. - Correct pr_info format string for modulation and coding_rate alignment. - Configure sinfo->rxrate/txrate with vif->bitrate_mask.gi and vif->manual_mcs. Test script (test_vwifi_bitrates.sh): -Updated to test MCS 0–31 with sgi-2.4 and lgi-2.4: - Test header (Testing MCS <mcs> with <gi> on vw1). - GI status (Set GI to long/short). - iw dev vw1 link output (MAC, SSID, freq, RX/TX, signal, bitrates). - Success/failure message with actual vs. expected bitrate. - Add expected bitrate arrays for lgi-2.4 and sgi-2.4. - Enhance stability with 2s retry sleep, 1s sleep after iw set bitrates, and 2s setup delay. - Ensure cleanup resets bitrate . Testing: - Verified GI (0.4µs/0.8µs) and MCS (0–31) with iw dev vw1 set bitrates and iw dev vw1 link.
1 parent 5deb909 commit fa402a1

File tree

2 files changed

+263
-81
lines changed

2 files changed

+263
-81
lines changed

scripts/verify.sh

Lines changed: 120 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ source $ROOT/scripts/common.sh
55

66
final_ret=0
77

8+
# Added logging setup from test_vwifi_bitrates
9+
LOG_DIR="/var/log/vwifi"
10+
LOG_FILE="$LOG_DIR/test_$(date +%F_%H-%M-%S).log"
11+
mkdir -p "$LOG_DIR"
12+
chmod 777 "$LOG_DIR"
13+
exec > >(tee -a "$LOG_FILE") 2>&1
14+
echo "vwifi Verification and Bitrate Test Log - $(date)" >> "$LOG_FILE"
15+
16+
817
probe_kmod cfg80211
918
if [ $? -ne 0 ]; then
1019
final_ret=1
@@ -21,7 +30,7 @@ if [ $? -ne 0 ]; then
2130
fi
2231

2332
if [ $final_ret -eq 0 ]; then
24-
# to avoid device or resource busy error
33+
# To avoid device or resource busy error
2534
sleep 0.5
2635

2736
# set transmit power (mBm)
@@ -49,7 +58,7 @@ if [ $final_ret -eq 0 ]; then
4958
sudo ip netns add ns4
5059
sudo ip netns add ns5
5160

52-
# add each phy (interface) to separate network namesapces
61+
# add each phy (interface) to separate network namespaces
5362
sudo iw phy $vw0_phy set netns name ns0
5463
sudo iw phy $vw1_phy set netns name ns1
5564
sudo iw phy $vw2_phy set netns name ns2
@@ -77,7 +86,7 @@ if [ $final_ret -eq 0 ]; then
7786
sudo ip netns exec ns5 ip link set vw5 up
7887
sudo ip netns exec ns5 ip link set lo up
7988

80-
# assing IP address to each interface
89+
# assign IP address to each interface
8190
sudo ip netns exec ns0 ip addr add 10.0.0.1/24 dev vw0
8291
sudo ip netns exec ns1 ip addr add 10.0.0.2/24 dev vw1
8392
sudo ip netns exec ns2 ip addr add 10.0.0.3/24 dev vw2
@@ -91,14 +100,14 @@ if [ $final_ret -eq 0 ]; then
91100
echo "================================================================================"
92101
echo "Ping Test: STA vw1 (10.0.0.2) (not connected) <--> STA vw2 (10.0.0.3) (not connected)"
93102
echo
94-
echo "(should fail, because they haven't connnected to AP vw0 (10.0.0.1))"
103+
echo "(should fail, because they haven't connected to AP vw0 (10.0.0.1))"
95104
echo "(be patient, it will take some time to route...)"
96105
echo "================================================================================"
97106
sudo ip netns exec ns1 ping -c 1 10.0.0.3
98107

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

@@ -114,7 +123,7 @@ if [ $final_ret -eq 0 ]; then
114123

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

@@ -129,37 +138,116 @@ if [ $final_ret -eq 0 ]; then
129138
echo "=================================="
130139

131140
# ping test: STA vw1 (10.0.0.2) <--> STA vw2 (10.0.0.3),
132-
# should success, packet will be relayed by AP vw0 (10.0.0.1)
141+
# should succeed, packet will be relayed by AP vw0 (10.0.0.1)
133142
echo
134143
echo "================================================================================"
135144
echo "Ping Test: STA vw1 (10.0.0.2) (connected) <--> STA vw2 (10.0.0.3) (connected)"
136145
echo
137-
echo "(should success, packet will be relay by AP vw0 (10.0.0.1))"
146+
echo "(should succeed, packet will be relayed by AP vw0 (10.0.0.1))"
138147
echo "================================================================================"
139148
sudo ip netns exec ns1 ping -c 4 10.0.0.3
140149

141-
# sudo ip netns exec ns1 ping -c 1 10.0.0.3
142150
ping_rc=$?
143151
if [ $ping_rc -ne 0 ]; then
144152
final_ret=6
145153
fi
146154

147155
# ping test: STA vw2 (10.0.0.3) <--> AP vw0 (10.0.0.1),
148-
# should success, packet will directly send/receive between STA and AP
156+
# should succeed, packet will directly send/receive between STA and AP
149157
echo
150158
echo "================================================================================"
151-
echo "Ping Test: STA vw1 (10.0.0.3) (connected) <--> AP vw0 (10.0.0.1)"
159+
echo "Ping Test: STA vw2 (10.0.0.3) (connected) <--> AP vw0 (10.0.0.1)"
152160
echo
153-
echo "(should success, packet will directly send/receive between STA vw1 and AP vw0)"
161+
echo "(should succeed, packet will directly send/receive between STA vw2 and AP vw0)"
154162
echo "================================================================================"
155163
sudo ip netns exec ns2 ping -c 4 10.0.0.1
156164

157-
# sudo ip netns exec ns2 ping -c 4 10.0.0.1
158165
ping_rc=$?
159166
if [ $ping_rc -ne 0 ]; then
160167
final_ret=7
161168
fi
162169

170+
# Bitrate testing from test_vwifi_bitrates
171+
echo "Testing MCS 0-31 with lgi-2.4 and sgi-2.4 on vw1" >> "$LOG_FILE"
172+
# Expected bitrates (Mbps) for MCS 0-31 for lgi-2.4 and sgi-2.4
173+
EXPECTED_BITRATES_LGI=(
174+
6.5 13.0 19.5 26.0 39.0 52.0 58.5 65.0 # MCS 0-7
175+
13.0 26.0 39.0 52.0 78.0 104.0 117.0 130.0 # MCS 8-15
176+
19.5 39.0 58.5 78.0 117.0 156.0 175.5 195.0 # MCS 16-23
177+
26.0 52.0 78.0 104.0 156.0 208.0 234.0 260.0 # MCS 24-31
178+
)
179+
EXPECTED_BITRATES_SGI=(
180+
7.2 14.4 21.7 28.9 43.3 57.8 65.0 72.2 # MCS 0-7
181+
14.4 28.9 43.3 57.8 86.7 115.6 130.0 144.4 # MCS 8-15
182+
21.7 43.3 65.0 86.7 130.0 173.3 195.0 216.7 # MCS 16-23
183+
28.9 57.8 86.7 115.6 173.3 231.1 260.0 288.9 # MCS 24-31
184+
)
185+
186+
# Function to test bitrate for a single MCS and GI
187+
test_bitrate() {
188+
local mcs=$1
189+
local gi=$2
190+
local expected_bitrate=$3
191+
local max_retries=3
192+
local retry=0
193+
local success=false
194+
195+
echo "----------------------------------------"
196+
echo "Testing MCS $mcs with $gi on vw1"
197+
198+
# Set GI string for logging
199+
if [ "$gi" = "sgi-2.4" ]; then
200+
echo "Set GI to short (0.4 µs)"
201+
else
202+
echo "Set GI to long (0.8 µs)"
203+
fi
204+
205+
while [ $retry -lt $max_retries ]; do
206+
# Set bitrate
207+
sudo ip netns exec ns1 iw dev vw1 set bitrates ht-mcs-2.4 $mcs $gi
208+
sleep 1 # Ensure bitrate applies
209+
210+
# Check connection
211+
output=$(sudo ip netns exec ns1 iw dev vw1 link)
212+
if echo "$output" | grep -q "Connected to"; then
213+
echo "$output"
214+
# Extract bitrate
215+
rx_bitrate=$(echo "$output" | grep "rx bitrate" | awk '{print $3}')
216+
rx_mcs=$(echo "$output" | grep "rx bitrate" | grep -o "MCS [0-9]\+")
217+
tx_bitrate=$(echo "$output" | grep "tx bitrate" | awk '{print $3}')
218+
tx_mcs=$(echo "$output" | grep "tx bitrate" | grep -o "MCS [0-9]\+")
219+
if [ "$rx_bitrate" = "$tx_bitrate" ] && [ "$rx_mcs" = "MCS $mcs" ] && [ "$tx_mcs" = "MCS $mcs" ] && [ "$rx_bitrate" = "$expected_bitrate" ]; then
220+
echo "Success: MCS $mcs $gi bitrate $rx_bitrate Mbps matches expected $expected_bitrate Mbps"
221+
success=true
222+
break
223+
fi
224+
fi
225+
retry=$((retry + 1))
226+
sleep 2 # Increase retry delay for stability
227+
done
228+
229+
if [ "$success" = false ]; then
230+
echo "Failed: MCS $mcs $gi did not connect or bitrate mismatch after $max_retries retries"
231+
final_ret=12 # New error code for bitrate test failure
232+
fi
233+
echo "----------------------------------------"
234+
}
235+
236+
# Test MCS 0-31 for lgi-2.4
237+
for mcs in {0..31}; do
238+
test_bitrate $mcs "lgi-2.4" "${EXPECTED_BITRATES_LGI[$mcs]}"
239+
done
240+
241+
# Test MCS 0-31 for sgi-2.4
242+
for mcs in {0..31}; do
243+
test_bitrate $mcs "sgi-2.4" "${EXPECTED_BITRATES_SGI[$mcs]}"
244+
done
245+
246+
# Reset bitrate to default
247+
sudo ip netns exec ns1 iw dev vw1 set bitrates ht-mcs-2.4 0 lgi-2.4
248+
echo "Bitrate reset to default MCS 0 lgi-2.4"
249+
250+
163251
# vw3 becomes an IBSS and then joins the "ibss1" network.
164252
echo
165253
echo "=============="
@@ -185,14 +273,15 @@ if [ $final_ret -eq 0 ]; then
185273
# ping test: IBSS vw3 <--> STA vw2, should fail
186274
echo
187275
echo "================================================================================"
188-
echo "Ping Test: IBSS vw3 (10.0.0.4) (in ibss1) <--> STA vw2 (10.0.0.3)"
276+
echo "Ping Test: IBSS vw3 (in ibss1) <--> STA vw2 (10.0.3) )"
189277
echo
190278
echo "(should fail)"
191279
echo "(be patient, it will take some time to route...)"
192280
echo "================================================================================"
193281
sudo ip netns exec ns3 ping -c 1 10.0.0.3
194282

195-
# ping test: IBSS vw3 <--> IBSS vw5, should fail
283+
# ping test: ping test: IBSS test: -vw3 <--> IBSS vw5, should fail
284+
# ping test: ping test: IBSS ping
196285
echo
197286
echo "================================================================================"
198287
echo "Ping Test: IBSS vw3 (10.0.0.4) (in ibss1) <--> IBSS vw5 (10.0.0.6) (in ibss2)"
@@ -202,42 +291,41 @@ if [ $final_ret -eq 0 ]; then
202291
echo "================================================================================"
203292
sudo ip netns exec ns3 ping -c 1 10.0.0.6
204293

205-
# ping test: IBSS vw3 <--> IBSS vw4, should success
294+
# ping test: IBSS vw3 <--> IBSS vw4, should succeed
206295
echo
207296
echo "================================================================================"
208-
echo "Ping Test: IBSS vw3 (10.0.0.4) (in ibss1) <--> IBSS vw4 (10.0.0.5) (in ibss1)"
297+
echo "Ping Test: IBSS vw3 (10.0.0.4) (in ibss1) <--> IBSS vw4 (10.0.0.5)) (in ibss1)"
209298
echo
210-
echo "(should success)"
299+
echo "(should succeed)"
211300
echo "(be patient, it will take some time to route...)"
212301
echo "================================================================================"
213302
sudo ip netns exec ns3 ping -c 1 10.0.0.5
214303

215-
# sudo ip netns exec ns3 ping -c 1 10.0.0.5
216304
ping_rc=$?
217305
if [ $ping_rc -ne 0 ]; then
218306
final_ret=8
219307
fi
220308

221309
# verify TSF (in usec)
222310
sudo ip netns exec ns1 iw dev vw1 scan > scan_result.log
223-
tsf=$(cat scan_result.log | grep "TSF" | tail -n 1 | awk '{print $2}')
224-
uptime=$(cat /proc/uptime | awk '{print $1}')
225-
uptime=$(echo "$uptime*1000000" | bc | awk -F "." '{print $1}')
311+
tsf=$(cat $scan_result.log | grep "TSF" | tail -n -1 | awk '{print $2}')
312+
uptime=$(cat /proc/uptime/ | awk '{print $1}')
313+
uptime=$(echo "$uptime*1000000" | bc | awk -F'.".' '{print $1}')
226314
diff=$((tsf - uptime))
227315

228-
# difference between tsf and uptime should less than 0.5 sec.
316+
# difference between tsf and uptime should be less than or equal to 0.5 sec.
229317
if [ "${diff#-}" -gt 500000 ]; then
230318
final_ret=9
231319
fi
232320

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

238326
for i in $(seq 1 1 $counts); do
239327
vw0_signal=$(sudo ip netns exec ns0 \
240-
iw dev vw0 station get $vw0_mac | grep "signal" | awk '{print $2}')
328+
echo "$w" | grep "signal" | awk '{print $2}')
241329
echo $vw0_signal >> rssi.txt
242330
done
243331

@@ -248,10 +336,10 @@ if [ $final_ret -eq 0 ]; then
248336
fi
249337

250338
# TestAP performs station dump
251-
sudo ip netns exec ns0 iw dev vw0 station dump > station_dump_result.log
252-
for num in {1..2}; do
253-
cat station_dump_result.log | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}'| sed -n "${num}p" > dump_ssid.log
254-
sudo ip netns exec "ns${num}" iw dev | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}' > station_ssid.log
339+
sudo ip netns exec ns0 iw dev vw0 station0 station dump > stationdump_result.log
340+
for num in {1..2}; do
341+
cat $stationdump_result.log | grep -q -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}'| sed -n "${num}p'" > dump_ssid.log
342+
sudo ip netns idexec "ns${num}" iw dev | grep -o -E '([[:space:]]{1,2}:){5}[[:xdigit:]]{1,2}' > station_ssid.log
255343
DIFF=$(diff dump_ssid.log station_ssid.log)
256344
if [ "$DIFF" != "" ]; then
257345
final_ret=11
@@ -260,6 +348,7 @@ if [ $final_ret -eq 0 ]; then
260348
done
261349
fi
262350

351+
263352
if [ $final_ret -eq 0 ]; then
264353
stop_hostapd
265354
remove_kmod vwifi
@@ -276,4 +365,4 @@ fi
276365

277366
echo "FAILED (code: $final_ret)"
278367
echo "==== Test FAILED ===="
279-
exit $final_ret
368+
exit $final_ret

0 commit comments

Comments
 (0)