@@ -5,6 +5,15 @@ source $ROOT/scripts/common.sh
5
5
6
6
final_ret=0
7
7
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
+
8
17
probe_kmod cfg80211
9
18
if [ $? -ne 0 ]; then
10
19
final_ret=1
@@ -21,7 +30,7 @@ if [ $? -ne 0 ]; then
21
30
fi
22
31
23
32
if [ $final_ret -eq 0 ]; then
24
- # to avoid device or resource busy error
33
+ # To avoid device or resource busy error
25
34
sleep 0.5
26
35
27
36
# set transmit power (mBm)
@@ -49,7 +58,7 @@ if [ $final_ret -eq 0 ]; then
49
58
sudo ip netns add ns4
50
59
sudo ip netns add ns5
51
60
52
- # add each phy (interface) to separate network namesapces
61
+ # add each phy (interface) to separate network namespaces
53
62
sudo iw phy $vw0_phy set netns name ns0
54
63
sudo iw phy $vw1_phy set netns name ns1
55
64
sudo iw phy $vw2_phy set netns name ns2
@@ -77,7 +86,7 @@ if [ $final_ret -eq 0 ]; then
77
86
sudo ip netns exec ns5 ip link set vw5 up
78
87
sudo ip netns exec ns5 ip link set lo up
79
88
80
- # assing IP address to each interface
89
+ # assign IP address to each interface
81
90
sudo ip netns exec ns0 ip addr add 10.0.0.1/24 dev vw0
82
91
sudo ip netns exec ns1 ip addr add 10.0.0.2/24 dev vw1
83
92
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
91
100
echo " ================================================================================"
92
101
echo " Ping Test: STA vw1 (10.0.0.2) (not connected) <--> STA vw2 (10.0.0.3) (not connected)"
93
102
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))"
95
104
echo " (be patient, it will take some time to route...)"
96
105
echo " ================================================================================"
97
106
sudo ip netns exec ns1 ping -c 1 10.0.0.3
98
107
99
108
# STA vw1 performs scan and connect to TestAP
100
109
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
102
111
sudo ip netns exec ns1 iw dev vw1 connect test
103
112
sudo ip netns exec ns1 iw dev vw1 link | grep -o -E ' ([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}' > connected.log
104
113
@@ -114,7 +123,7 @@ if [ $final_ret -eq 0 ]; then
114
123
115
124
# STA vw2 performs scan and connect to TestAP
116
125
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
118
127
sudo ip netns exec ns2 iw dev vw2 connect test
119
128
sudo ip netns exec ns2 iw dev vw2 link | grep -o -E ' ([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}' > connected.log
120
129
@@ -129,37 +138,116 @@ if [ $final_ret -eq 0 ]; then
129
138
echo " =================================="
130
139
131
140
# 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)
133
142
echo
134
143
echo " ================================================================================"
135
144
echo " Ping Test: STA vw1 (10.0.0.2) (connected) <--> STA vw2 (10.0.0.3) (connected)"
136
145
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))"
138
147
echo " ================================================================================"
139
148
sudo ip netns exec ns1 ping -c 4 10.0.0.3
140
149
141
- # sudo ip netns exec ns1 ping -c 1 10.0.0.3
142
150
ping_rc=$?
143
151
if [ $ping_rc -ne 0 ]; then
144
152
final_ret=6
145
153
fi
146
154
147
155
# 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
149
157
echo
150
158
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)"
152
160
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)"
154
162
echo " ================================================================================"
155
163
sudo ip netns exec ns2 ping -c 4 10.0.0.1
156
164
157
- # sudo ip netns exec ns2 ping -c 4 10.0.0.1
158
165
ping_rc=$?
159
166
if [ $ping_rc -ne 0 ]; then
160
167
final_ret=7
161
168
fi
162
169
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
+
163
251
# vw3 becomes an IBSS and then joins the "ibss1" network.
164
252
echo
165
253
echo " =============="
@@ -185,14 +273,15 @@ if [ $final_ret -eq 0 ]; then
185
273
# ping test: IBSS vw3 <--> STA vw2, should fail
186
274
echo
187
275
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) )"
189
277
echo
190
278
echo " (should fail)"
191
279
echo " (be patient, it will take some time to route...)"
192
280
echo " ================================================================================"
193
281
sudo ip netns exec ns3 ping -c 1 10.0.0.3
194
282
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
196
285
echo
197
286
echo " ================================================================================"
198
287
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
202
291
echo " ================================================================================"
203
292
sudo ip netns exec ns3 ping -c 1 10.0.0.6
204
293
205
- # ping test: IBSS vw3 <--> IBSS vw4, should success
294
+ # ping test: IBSS vw3 <--> IBSS vw4, should succeed
206
295
echo
207
296
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)"
209
298
echo
210
- echo " (should success )"
299
+ echo " (should succeed )"
211
300
echo " (be patient, it will take some time to route...)"
212
301
echo " ================================================================================"
213
302
sudo ip netns exec ns3 ping -c 1 10.0.0.5
214
303
215
- # sudo ip netns exec ns3 ping -c 1 10.0.0.5
216
304
ping_rc=$?
217
305
if [ $ping_rc -ne 0 ]; then
218
306
final_ret=8
219
307
fi
220
308
221
309
# verify TSF (in usec)
222
310
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}' )
226
314
diff=$(( tsf - uptime))
227
315
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.
229
317
if [ " ${diff# -} " -gt 500000 ]; then
230
318
final_ret=9
231
319
fi
232
320
233
321
# 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}' )
236
324
counts=1000 # do get_station 1000 times
237
325
238
326
for i in $( seq 1 1 $counts ) ; do
239
327
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}' )
241
329
echo $vw0_signal >> rssi.txt
242
330
done
243
331
@@ -248,10 +336,10 @@ if [ $final_ret -eq 0 ]; then
248
336
fi
249
337
250
338
# 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
255
343
DIFF=$( diff dump_ssid.log station_ssid.log)
256
344
if [ " $DIFF " != " " ]; then
257
345
final_ret=11
@@ -260,6 +348,7 @@ if [ $final_ret -eq 0 ]; then
260
348
done
261
349
fi
262
350
351
+
263
352
if [ $final_ret -eq 0 ]; then
264
353
stop_hostapd
265
354
remove_kmod vwifi
276
365
277
366
echo " FAILED (code: $final_ret )"
278
367
echo " ==== Test FAILED ===="
279
- exit $final_ret
368
+ exit $final_ret
0 commit comments