Skip to content

Commit c800205

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. - correct history typo. 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 7557465 commit c800205

File tree

2 files changed

+249
-72
lines changed

2 files changed

+249
-72
lines changed

scripts/verify.sh

Lines changed: 106 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ 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+
816
probe_kmod cfg80211
917
if [ $? -ne 0 ]; then
1018
final_ret=1
@@ -21,7 +29,7 @@ if [ $? -ne 0 ]; then
2129
fi
2230

2331
if [ $final_ret -eq 0 ]; then
24-
# to avoid device or resource busy error
32+
# To avoid device or resource busy error
2533
sleep 0.5
2634

2735
# set transmit power (mBm)
@@ -49,7 +57,7 @@ if [ $final_ret -eq 0 ]; then
4957
sudo ip netns add ns4
5058
sudo ip netns add ns5
5159

52-
# add each phy (interface) to separate network namesapces
60+
# add each phy (interface) to separate network namespaces
5361
sudo iw phy $vw0_phy set netns name ns0
5462
sudo iw phy $vw1_phy set netns name ns1
5563
sudo iw phy $vw2_phy set netns name ns2
@@ -77,7 +85,7 @@ if [ $final_ret -eq 0 ]; then
7785
sudo ip netns exec ns5 ip link set vw5 up
7886
sudo ip netns exec ns5 ip link set lo up
7987

80-
# assing IP address to each interface
88+
# assign IP address to each interface
8189
sudo ip netns exec ns0 ip addr add 10.0.0.1/24 dev vw0
8290
sudo ip netns exec ns1 ip addr add 10.0.0.2/24 dev vw1
8391
sudo ip netns exec ns2 ip addr add 10.0.0.3/24 dev vw2
@@ -91,14 +99,14 @@ if [ $final_ret -eq 0 ]; then
9199
echo "================================================================================"
92100
echo "Ping Test: STA vw1 (10.0.0.2) (not connected) <--> STA vw2 (10.0.0.3) (not connected)"
93101
echo
94-
echo "(should fail, because they haven't connnected to AP vw0 (10.0.0.1))"
102+
echo "(should fail, because they haven't connected to AP vw0 (10.0.0.1))"
95103
echo "(be patient, it will take some time to route...)"
96104
echo "================================================================================"
97105
sudo ip netns exec ns1 ping -c 1 10.0.0.3
98106

99107
# STA vw1 performs scan and connect to TestAP
100108
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
109+
cat scan_result.log | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}' | tail -n 1 > scan_bssid.log
102110
sudo ip netns exec ns1 iw dev vw1 connect test
103111
sudo ip netns exec ns1 iw dev vw1 link | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}' > connected.log
104112

@@ -114,7 +122,7 @@ if [ $final_ret -eq 0 ]; then
114122

115123
# STA vw2 performs scan and connect to TestAP
116124
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
125+
cat scan_result.log | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}' | tail -n 1 > scan_bssid.log
118126
sudo ip netns exec ns2 iw dev vw2 connect test
119127
sudo ip netns exec ns2 iw dev vw2 link | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}' > connected.log
120128

@@ -129,37 +137,115 @@ if [ $final_ret -eq 0 ]; then
129137
echo "=================================="
130138

131139
# 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)
140+
# should succeed, packet will be relayed by AP vw0 (10.0.0.1)
133141
echo
134142
echo "================================================================================"
135143
echo "Ping Test: STA vw1 (10.0.0.2) (connected) <--> STA vw2 (10.0.0.3) (connected)"
136144
echo
137-
echo "(should success, packet will be relay by AP vw0 (10.0.0.1))"
145+
echo "(should succeed, packet will be relayed by AP vw0 (10.0.0.1))"
138146
echo "================================================================================"
139147
sudo ip netns exec ns1 ping -c 4 10.0.0.3
140148

141-
# sudo ip netns exec ns1 ping -c 1 10.0.0.3
142149
ping_rc=$?
143150
if [ $ping_rc -ne 0 ]; then
144151
final_ret=6
145152
fi
146153

147154
# 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
155+
# should succeed, packet will directly send/receive between STA and AP
149156
echo
150157
echo "================================================================================"
151-
echo "Ping Test: STA vw1 (10.0.0.3) (connected) <--> AP vw0 (10.0.0.1)"
158+
echo "Ping Test: STA vw2 (10.0.0.3) (connected) <--> AP vw0 (10.0.0.1)"
152159
echo
153-
echo "(should success, packet will directly send/receive between STA vw1 and AP vw0)"
160+
echo "(should succeed, packet will directly send/receive between STA vw2 and AP vw0)"
154161
echo "================================================================================"
155162
sudo ip netns exec ns2 ping -c 4 10.0.0.1
156163

157-
# sudo ip netns exec ns2 ping -c 4 10.0.0.1
158164
ping_rc=$?
159165
if [ $ping_rc -ne 0 ]; then
160166
final_ret=7
161167
fi
162168

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

195-
# ping test: IBSS vw3 <--> IBSS vw5, should fail
281+
# ping test: IBSS test: -vw3 <--> IBSS vw5, should fail
196282
echo
197283
echo "================================================================================"
198284
echo "Ping Test: IBSS vw3 (10.0.0.4) (in ibss1) <--> IBSS vw5 (10.0.0.6) (in ibss2)"
@@ -202,17 +288,16 @@ if [ $final_ret -eq 0 ]; then
202288
echo "================================================================================"
203289
sudo ip netns exec ns3 ping -c 1 10.0.0.6
204290

205-
# ping test: IBSS vw3 <--> IBSS vw4, should success
291+
# ping test: IBSS vw3 <--> IBSS vw4, should succeed
206292
echo
207293
echo "================================================================================"
208294
echo "Ping Test: IBSS vw3 (10.0.0.4) (in ibss1) <--> IBSS vw4 (10.0.0.5) (in ibss1)"
209295
echo
210-
echo "(should success)"
296+
echo "(should succeed)"
211297
echo "(be patient, it will take some time to route...)"
212298
echo "================================================================================"
213299
sudo ip netns exec ns3 ping -c 1 10.0.0.5
214300

215-
# sudo ip netns exec ns3 ping -c 1 10.0.0.5
216301
ping_rc=$?
217302
if [ $ping_rc -ne 0 ]; then
218303
final_ret=8
@@ -223,16 +308,15 @@ if [ $final_ret -eq 0 ]; then
223308
tsf=$(cat scan_result.log | grep "TSF" | tail -n 1 | awk '{print $2}')
224309
uptime=$(cat /proc/uptime | awk '{print $1}')
225310
uptime=$(echo "$uptime*1000000" | bc | awk -F "." '{print $1}')
226-
diff=$((tsf - uptime))
227311

228-
# difference between tsf and uptime should less than 0.5 sec.
312+
# difference between tsf and uptime should be less than or equal to 0.5 sec.
229313
if [ "${diff#-}" -gt 500000 ]; then
230314
final_ret=9
231315
fi
232316

233317
# 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}')
318+
echo -e "\n "\n\n######## collecting RSSI information of vw0, please wait... ##########"
319+
vw0_mac=$(sudo ip netns exec ns0 iw dev | grep -E 'vw0$' -A -3 | grep addr | awk '{print $2}')
236320
counts=1000 # do get_station 1000 times
237321

238322
for i in $(seq 1 1 $counts); do
@@ -276,4 +360,4 @@ fi
276360

277361
echo "FAILED (code: $final_ret)"
278362
echo "==== Test FAILED ===="
279-
exit $final_ret
363+
exit $final_ret

0 commit comments

Comments
 (0)