@@ -5,6 +5,14 @@ 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
+
8
16
probe_kmod cfg80211
9
17
if [ $? -ne 0 ]; then
10
18
final_ret=1
@@ -21,7 +29,7 @@ if [ $? -ne 0 ]; then
21
29
fi
22
30
23
31
if [ $final_ret -eq 0 ]; then
24
- # to avoid device or resource busy error
32
+ # To avoid device or resource busy error
25
33
sleep 0.5
26
34
27
35
# set transmit power (mBm)
@@ -49,7 +57,7 @@ if [ $final_ret -eq 0 ]; then
49
57
sudo ip netns add ns4
50
58
sudo ip netns add ns5
51
59
52
- # add each phy (interface) to separate network namesapces
60
+ # add each phy (interface) to separate network namespaces
53
61
sudo iw phy $vw0_phy set netns name ns0
54
62
sudo iw phy $vw1_phy set netns name ns1
55
63
sudo iw phy $vw2_phy set netns name ns2
@@ -77,7 +85,7 @@ if [ $final_ret -eq 0 ]; then
77
85
sudo ip netns exec ns5 ip link set vw5 up
78
86
sudo ip netns exec ns5 ip link set lo up
79
87
80
- # assing IP address to each interface
88
+ # assign IP address to each interface
81
89
sudo ip netns exec ns0 ip addr add 10.0.0.1/24 dev vw0
82
90
sudo ip netns exec ns1 ip addr add 10.0.0.2/24 dev vw1
83
91
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
91
99
echo " ================================================================================"
92
100
echo " Ping Test: STA vw1 (10.0.0.2) (not connected) <--> STA vw2 (10.0.0.3) (not connected)"
93
101
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))"
95
103
echo " (be patient, it will take some time to route...)"
96
104
echo " ================================================================================"
97
105
sudo ip netns exec ns1 ping -c 1 10.0.0.3
98
106
99
107
# STA vw1 performs scan and connect to TestAP
100
108
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
102
110
sudo ip netns exec ns1 iw dev vw1 connect test
103
111
sudo ip netns exec ns1 iw dev vw1 link | grep -o -E ' ([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}' > connected.log
104
112
@@ -114,7 +122,7 @@ if [ $final_ret -eq 0 ]; then
114
122
115
123
# STA vw2 performs scan and connect to TestAP
116
124
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
118
126
sudo ip netns exec ns2 iw dev vw2 connect test
119
127
sudo ip netns exec ns2 iw dev vw2 link | grep -o -E ' ([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}' > connected.log
120
128
@@ -129,37 +137,115 @@ if [ $final_ret -eq 0 ]; then
129
137
echo " =================================="
130
138
131
139
# 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)
133
141
echo
134
142
echo " ================================================================================"
135
143
echo " Ping Test: STA vw1 (10.0.0.2) (connected) <--> STA vw2 (10.0.0.3) (connected)"
136
144
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))"
138
146
echo " ================================================================================"
139
147
sudo ip netns exec ns1 ping -c 4 10.0.0.3
140
148
141
- # sudo ip netns exec ns1 ping -c 1 10.0.0.3
142
149
ping_rc=$?
143
150
if [ $ping_rc -ne 0 ]; then
144
151
final_ret=6
145
152
fi
146
153
147
154
# 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
149
156
echo
150
157
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)"
152
159
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)"
154
161
echo " ================================================================================"
155
162
sudo ip netns exec ns2 ping -c 4 10.0.0.1
156
163
157
- # sudo ip netns exec ns2 ping -c 4 10.0.0.1
158
164
ping_rc=$?
159
165
if [ $ping_rc -ne 0 ]; then
160
166
final_ret=7
161
167
fi
162
168
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
+
163
249
# vw3 becomes an IBSS and then joins the "ibss1" network.
164
250
echo
165
251
echo " =============="
@@ -192,7 +278,7 @@ if [ $final_ret -eq 0 ]; then
192
278
echo " ================================================================================"
193
279
sudo ip netns exec ns3 ping -c 1 10.0.0.3
194
280
195
- # ping test: IBSS vw3 <--> IBSS vw5, should fail
281
+ # ping test: IBSS test: - vw3 <--> IBSS vw5, should fail
196
282
echo
197
283
echo " ================================================================================"
198
284
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
202
288
echo " ================================================================================"
203
289
sudo ip netns exec ns3 ping -c 1 10.0.0.6
204
290
205
- # ping test: IBSS vw3 <--> IBSS vw4, should success
291
+ # ping test: IBSS vw3 <--> IBSS vw4, should succeed
206
292
echo
207
293
echo " ================================================================================"
208
294
echo " Ping Test: IBSS vw3 (10.0.0.4) (in ibss1) <--> IBSS vw4 (10.0.0.5) (in ibss1)"
209
295
echo
210
- echo " (should success )"
296
+ echo " (should succeed )"
211
297
echo " (be patient, it will take some time to route...)"
212
298
echo " ================================================================================"
213
299
sudo ip netns exec ns3 ping -c 1 10.0.0.5
214
300
215
- # sudo ip netns exec ns3 ping -c 1 10.0.0.5
216
301
ping_rc=$?
217
302
if [ $ping_rc -ne 0 ]; then
218
303
final_ret=8
@@ -223,16 +308,15 @@ if [ $final_ret -eq 0 ]; then
223
308
tsf=$( cat scan_result.log | grep " TSF" | tail -n 1 | awk ' {print $2}' )
224
309
uptime=$( cat /proc/uptime | awk ' {print $1}' )
225
310
uptime=$( echo " $uptime *1000000" | bc | awk -F " ." ' {print $1}' )
226
- diff=$(( tsf - uptime))
227
311
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.
229
313
if [ " ${diff# -} " -gt 500000 ]; then
230
314
final_ret=9
231
315
fi
232
316
233
317
# 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}' )
236
320
counts=1000 # do get_station 1000 times
237
321
238
322
for i in $( seq 1 1 $counts ) ; do
276
360
277
361
echo " FAILED (code: $final_ret )"
278
362
echo " ==== Test FAILED ===="
279
- exit $final_ret
363
+ exit $final_ret
0 commit comments