Skip to content

Implement dynamic MCS selection based on signal strength in vWIFI driver #80

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
88 changes: 88 additions & 0 deletions scripts/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ source $ROOT/scripts/common.sh

final_ret=0

# Added logging setup from test_vwifi_bitrates
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider avoiding the use of a date in the log filename (e.g., test_2025-06-27.log). While timestamped filenames help preserve historical logs, they can also lead to unnecessary log accumulation and storage issues if not managed properly.

Since this log is intended to capture the latest test output, a static filename like vwifi_test.log might be more appropriate. It automatically overwrites old logs, keeping the system clean and avoiding the need for log rotation or manual cleanup.

LOG_DIR="/var/log/vwifi"
LOG_FILE="$LOG_DIR/vwifi_test.log"
mkdir -p "$LOG_DIR"
chmod 777 "$LOG_DIR"
exec > >(tee -a "$LOG_FILE") 2>&1
echo "vwifi Verification and Bitrate Test Log - $(date)" >> "$LOG_FILE"

probe_kmod cfg80211
if [ $? -ne 0 ]; then
final_ret=1
Expand Down Expand Up @@ -160,6 +168,86 @@ if [ $final_ret -eq 0 ]; then
final_ret=7
fi

# Bitrate testing from test_vwifi_bitrates
echo "Testing MCS 0-31 with lgi-2.4 and sgi-2.4 on vw1" >> "$LOG_FILE"
# Expected bitrates (Mbps) for MCS 0-31 for lgi-2.4 and sgi-2.4
EXPECTED_BITRATES_LGI=(
6.5 13.0 19.5 26.0 39.0 52.0 58.5 65.0 # MCS 0-7
13.0 26.0 39.0 52.0 78.0 104.0 117.0 130.0 # MCS 8-15
19.5 39.0 58.5 78.0 117.0 156.0 175.5 195.0 # MCS 16-23
26.0 52.0 78.0 104.0 156.0 208.0 234.0 260.0 # MCS 24-31
)
EXPECTED_BITRATES_SGI=(
7.2 14.4 21.7 28.9 43.3 57.8 65.0 72.2 # MCS 0-7
14.4 28.9 43.3 57.8 86.7 115.6 130.0 144.4 # MCS 8-15
21.7 43.3 65.0 86.7 130.0 173.3 195.0 216.7 # MCS 16-23
28.9 57.8 86.7 115.6 173.3 231.1 260.0 288.9 # MCS 24-31
)

# Function to test bitrate for a single MCS and GI
test_bitrate() {
local mcs=$1
local gi=$2
local expected_bitrate=$3
local max_retries=3
local retry=0
local success=false

echo "----------------------------------------"
echo "Testing MCS $mcs with $gi on vw1"

# Set GI string for logging
if [ "$gi" = "sgi-2.4" ]; then
echo "Set GI to short (0.4 µs)"
else
echo "Set GI to long (0.8 µs)"
fi

while [ $retry -lt $max_retries ]; do
# Set bitrate
sudo ip netns exec ns1 iw dev vw1 set bitrates ht-mcs-2.4 $mcs $gi
sleep 1 # Ensure bitrate applies

# Check connection
output=$(sudo ip netns exec ns1 iw dev vw1 link)
if echo "$output" | grep -q "Connected to"; then
echo "$output"
# Extract bitrate
rx_bitrate=$(echo "$output" | grep "rx bitrate" | awk '{print $3}')
rx_mcs=$(echo "$output" | grep "rx bitrate" | grep -o "MCS [0-9]\+")
tx_bitrate=$(echo "$output" | grep "tx bitrate" | awk '{print $3}')
tx_mcs=$(echo "$output" | grep "tx bitrate" | grep -o "MCS [0-9]\+")
if [ "$rx_bitrate" = "$tx_bitrate" ] && [ "$rx_mcs" = "MCS $mcs" ] && [ "$tx_mcs" = "MCS $mcs" ] && [ "$rx_bitrate" = "$expected_bitrate" ]; then
echo "Success: MCS $mcs $gi bitrate $rx_bitrate Mbps matches expected $expected_bitrate Mbps"
success=true
break
fi
fi
retry=$((retry + 1))
sleep 2 # Increase retry delay for stability
done

if [ "$success" = false ]; then
echo "Failed: MCS $mcs $gi did not connect or bitrate mismatch after $max_retries retries"
final_ret=12 # New error code for bitrate test failure
fi
echo "----------------------------------------"
}

# Test MCS 0-31 for lgi-2.4
for mcs in {0..31}; do
test_bitrate $mcs "lgi-2.4" "${EXPECTED_BITRATES_LGI[$mcs]}"
done

# Test MCS 0-31 for sgi-2.4
for mcs in {0..31}; do
test_bitrate $mcs "sgi-2.4" "${EXPECTED_BITRATES_SGI[$mcs]}"
done

# Reset bitrate to default
sudo ip netns exec ns1 iw dev vw1 set bitrates ht-mcs-2.4 0 lgi-2.4
echo "Bitrate reset to default MCS 0 lgi-2.4"

# vw3 becomes an IBSS and then joins the "ibss1" network.
echo
echo "=============="
Expand Down
Loading