Skip to content

Commit c142feb

Browse files
Store GI in cfg80211_bitrate_mask, add spatial stream index, enhance MCS documentation, and update 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 c142feb

File tree

2 files changed

+275
-50
lines changed

2 files changed

+275
-50
lines changed

scripts/test_vwifi_bitrates.sh

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
#!/bin/bash
2+
3+
# test_vwifi_bitrates.sh
4+
5+
# Set up log file with timestamp
6+
LOG_DIR="/var/log/vwifi"
7+
LOG_FILE="$LOG_DIR/test_$(date +%F_%H-%M-%S).log"
8+
mkdir -p "$LOG_DIR"
9+
chmod 777 "$LOG_DIR"
10+
exec > >(tee -a "$LOG_FILE") 2>&1
11+
12+
echo "vwifi Bitrate Test Log - $(date)"
13+
echo "Testing MCS 0-31 with lgi-2.4 and sgi-2.4 on vw1"
14+
15+
# Expected bitrates (Mbps) for MCS 0-31
16+
# lgi-2.4 and sgi-2.4
17+
EXPECTED_BITRATES_LGI=(
18+
6.5 13.0 19.5 26.0 39.0 52.0 58.5 65.0 # MCS 0-7
19+
13.0 26.0 39.0 52.0 78.0 104.0 117.0 130.0 # MCS 8-15
20+
19.5 39.0 58.5 78.0 117.0 156.0 175.5 195.0 # MCS 16-23
21+
26.0 52.0 78.0 104.0 156.0 208.0 234.0 260.0 # MCS 24-31
22+
)
23+
EXPECTED_BITRATES_SGI=(
24+
7.2 14.4 21.7 28.9 43.3 57.8 65.0 72.2 # MCS 0-7
25+
14.4 28.9 43.3 57.8 86.7 115.6 130.0 144.4 # MCS 8-15
26+
21.7 43.3 65.0 86.7 130.0 173.3 195.0 216.7 # MCS 16-23
27+
28.9 57.8 86.7 115.6 173.3 231.1 260.0 288.9 # MCS 24-31
28+
)
29+
30+
# Clean up existing setup
31+
sudo rmmod vwifi 2>/dev/null
32+
sudo killall hostapd wpa_supplicant 2>/dev/null
33+
sudo ip netns del ns0 2>/dev/null
34+
sudo ip netns del ns1 2>/dev/null
35+
sudo ip netns del ns2 2>/dev/null
36+
37+
# Set up namespaces and interfaces
38+
sudo ip netns add ns0
39+
sudo ip netns add ns1
40+
sudo ip netns add ns2
41+
sudo insmod /home/dingsen/linux/vwifi/vwifi.ko station=3
42+
sudo iw phy vw_phy0 set netns name ns0
43+
sudo iw phy vw_phy1 set netns name ns1
44+
sudo iw phy vw_phy2 set netns name ns2
45+
sudo ip netns exec ns0 ip addr add 10.0.0.1/24 dev vw0
46+
sudo ip netns exec ns1 ip addr add 10.0.0.2/24 dev vw1
47+
sudo ip netns exec ns2 ip addr add 10.0.0.3/24 dev vw2
48+
sudo ip netns exec ns0 ip link set vw0 up
49+
sudo ip netns exec ns1 ip link set vw1 up
50+
sudo ip netns exec ns2 ip link set vw2 up
51+
52+
# Start hostapd and wpa_supplicant
53+
sudo ip netns exec ns0 hostapd -i vw0 -B scripts/hostapd.conf
54+
sudo ip netns exec ns1 wpa_supplicant -i vw1 -B -c scripts/wpa_supplicant.conf
55+
sudo ip netns exec ns2 wpa_supplicant -i vw2 -B -c scripts/wpa_supplicant.conf
56+
sleep 2 # Wait for setup to stabilize
57+
58+
# Test function for a single MCS and GI
59+
test_bitrate() {
60+
local mcs=$1
61+
local gi=$2
62+
local expected_bitrate=$3
63+
local max_retries=3
64+
local retry=0
65+
local success=false
66+
67+
echo "----------------------------------------"
68+
echo "Testing MCS $mcs with $gi on vw1"
69+
70+
# Set GI string for logging
71+
if [ "$gi" = "sgi-2.4" ]; then
72+
echo "Set GI to short (0.4 µs)"
73+
else
74+
echo "Set GI to long (0.8 µs)"
75+
fi
76+
77+
while [ $retry -lt $max_retries ]; do
78+
# Set bitrate
79+
sudo ip netns exec ns1 iw dev vw1 set bitrates ht-mcs-2.4 $mcs $gi
80+
sleep 1 # Ensure bitrate applies
81+
82+
# Check connection
83+
output=$(sudo ip netns exec ns1 iw dev vw1 link)
84+
if echo "$output" | grep -q "Connected to"; then
85+
echo "$output"
86+
# Extract bitrate
87+
rx_bitrate=$(echo "$output" | grep "rx bitrate" | awk '{print $3}')
88+
rx_mcs=$(echo "$output" | grep "rx bitrate" | grep -o "MCS [0-9]\+")
89+
tx_bitrate=$(echo "$output" | grep "tx bitrate" | awk '{print $3}')
90+
tx_mcs=$(echo "$output" | grep "tx bitrate" | grep -o "MCS [0-9]\+")
91+
if [ "$rx_bitrate" = "$tx_bitrate" ] && [ "$rx_mcs" = "MCS $mcs" ] && [ "$tx_mcs" = "MCS $mcs" ]; then
92+
echo "Success: MCS $mcs $gi bitrate $rx_bitrate Mbps matches expected $expected_bitrate Mbps"
93+
success=true
94+
break
95+
fi
96+
fi
97+
retry=$((retry + 1))
98+
sleep 2 # Increase retry delay for stability
99+
done
100+
101+
if [ "$success" = false ]; then
102+
echo "Failed: MCS $mcs $gi did not connect or bitrate mismatch after $max_retries retries"
103+
fi
104+
echo "----------------------------------------"
105+
}
106+
107+
# Test MCS 0-31 for lgi-2.4
108+
for mcs in {0..31}; do
109+
test_bitrate $mcs "lgi-2.4" "${EXPECTED_BITRATES_LGI[$mcs]}"
110+
done
111+
112+
# Test MCS 0-31 for sgi-2.4
113+
for mcs in {0..31}; do
114+
test_bitrate $mcs "sgi-2.4" "${EXPECTED_BITRATES_SGI[$mcs]}"
115+
done
116+
117+
# Clean up
118+
sudo ip netns exec ns1 iw dev vw1 set bitrates ht-mcs-2.4 0 lgi-2.4 # Reset to default
119+
120+
if ip netns exec $NAMESPACE1 ip link set $IFACE1 down 2>> "$LOG_FILE"; then
121+
echo "Interface $IFACE1 set down" >> "$LOG_FILE"
122+
else
123+
echo "Warning: Failed to set $IFACE1 down" >> "$LOG_FILE"
124+
fi
125+
killall wpa_supplicant 2>/dev/null
126+
if [ -f "$WPA_LOG" ]; then
127+
echo "Appending final wpa_supplicant logs" >> "$LOG_FILE"
128+
cat "$WPA_LOG" >> "$LOG_FILE"
129+
fi
130+
131+
echo "Test completed. Results in $LOG_FILE"
132+
cat "$LOG_FILE"

0 commit comments

Comments
 (0)