Skip to content
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

WiFi Radio Optimizations #54

Open
edominicci opened this issue Apr 13, 2021 · 17 comments
Open

WiFi Radio Optimizations #54

edominicci opened this issue Apr 13, 2021 · 17 comments
Labels
enhancement New feature or request

Comments

@edominicci
Copy link

Several WiFi optimizations can be done to relieve some of the performance issues due to interference or lack of bandwidth.

According to Apple's development notes, 5GHz 802.11ac is recommended for wireless CarPlay:
https://developer.apple.com/videos/play/wwdc2017/717

The transceiver contained in this module is 802.11ac compliant, and is more than capable of doing it. Security is also that we should be able to modify by using WPA2-AES instead of WPA.

/etc/hostapd.conf contains a fairly basic config, I recommend the following changes:

driver=rtl871xdrv
ieee80211ac=1
hw_mode=a
channel=36
beacon_int=100
dtim_period=1

wmm_enabled=1
wmm_ac_bk_cwmin=4
wmm_ac_bk_cwmax=10
wmm_ac_bk_aifs=7
wmm_ac_bk_txop_limit=0
wmm_ac_bk_acm=0
wmm_ac_be_aifs=3
wmm_ac_be_cwmin=4
wmm_ac_be_cwmax=10
wmm_ac_be_txop_limit=0
wmm_ac_be_acm=0
wmm_ac_vi_aifs=2
wmm_ac_vi_cwmin=3
wmm_ac_vi_cwmax=4
wmm_ac_vi_txop_limit=94
wmm_ac_vi_acm=0
wmm_ac_vo_aifs=2
wmm_ac_vo_cwmin=2
wmm_ac_vo_cwmax=3
wmm_ac_vo_txop_limit=47
wmm_ac_vo_acm=0

The WMM parameters may need a bit more work, but WMM is required for a working AC configuration.

@dmavromatis
Copy link

Nice -- do you have any before and after results to share? E.g. any noticeable improvements?

@edominicci
Copy link
Author

Not yet, I am still testing a few more things to try and figure out what causes the intermittent audio breakouts before I change these.

It could be related, but I am not entirely convinced that this is the root cause.

@CiNcH83
Copy link
Contributor

CiNcH83 commented Apr 18, 2021

What's the original hostapd.conf? I still believe the USB to be the bottleneck in terms of bandwidth...

@CiNcH83
Copy link
Contributor

CiNcH83 commented Apr 18, 2021

OK, found original hostapd.conf:

# Basic configuration

interface=wlan0
ssid=AutoBox-582f
#bridge=br0

# WPA and WPA2 configuration

macaddr_acl=0
auth_algs=3
ignore_broadcast_ssid=0
wpa=3
wpa_passphrase=12345678
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

#device_type=6-0050F204-1
# Hardware configuration

#wmm_enabled=1
#wmm_ac_bk_cwmin=4
#wmm_ac_bk_cwmax=10
#wmm_ac_bk_aifs=7
#wmm_ac_bk_txop_limit=0
#wmm_ac_bk_acm=0
#wmm_ac_be_aifs=3
#wmm_ac_be_cwmin=4
#wmm_ac_be_cwmax=10
#wmm_ac_be_txop_limit=0
#wmm_ac_be_acm=0
#wmm_ac_vi_aifs=2
#wmm_ac_vi_cwmin=3
#wmm_ac_vi_cwmax=4
#wmm_ac_vi_txop_limit=94
#wmm_ac_vi_acm=0
#wmm_ac_vo_aifs=2
#wmm_ac_vo_cwmin=2
#wmm_ac_vo_cwmax=3
#wmm_ac_vo_txop_limit=47
#wmm_ac_vo_acm=0

driver=rtl871xdrv
ieee80211n=1
#ieee80211ac=1
#hw_mode=g
#channel=1
hw_mode=a
channel=36
#require_ht=1
beacon_int=100
dtim_period=1

#ht_capab=[HT40+]
ht_capab=[SHORT-GI-20][SHORT-GI-40][HT40+]
device_name=RTL8822BS
#device_name=RTL8188EU
manufacturer=Realtek

@CiNcH83
Copy link
Contributor

CiNcH83 commented Apr 22, 2021

Just some additional info on 802.11n vs. 802.11ac. On the Carlinkit/CPLAY2air dongles, we have a 2x2 antenna configuration. On 40MHz wide channels, this means up to 300mbps on N and 400mbps on AC (net speed is around half of that). For 80MHz wide channels, vht_capab has to be set.

@CiNcH83
Copy link
Contributor

CiNcH83 commented May 4, 2021

Security is also that we should be able to modify by using WPA2-AES instead of WPA.

The given configuration supports both, WPA(TKIP) and WPA2(CCMP-AES). All CarPlay enabled iPhones connect with WPA2. So it may be safe to disable WPA altogether.

Not yet, I am still testing a few more things to try and figure out what causes the intermittent audio breakouts before I change these.

Since screen and control data have higher priority with WMM enabled (for better touchscreen reaction times), media audio may starve a bit. So you may have to increase Media Delay in the adapter's settings:
grafik

1000ms is the default. You may try 1500ms. I actually hoped that the higher transfer speeds of 802.11ac would compensate for the higher priority touchscreen data.

(Also making phone calls benefits from WMM. So there may be less delay.)

Another possible enhancement... uapsd_advertisement_enabled=1 may help reducing the iPhone's power consumption during a CarPlay session. It is recommended by Apple to be enabled.

@dmavromatis
Copy link

Have you tested these changes on the device yet? I'm willing to do it on a dev dongle I have, but want to make sure it doesn't brick the unit due to WiFi not working after making the modifications.

@CiNcH83
Copy link
Contributor

CiNcH83 commented May 4, 2021

I am not on a custom FW. I am just familiar with Wi-Fi and hostapd.

Replacing hostapd.conf shouldn't be much of a problem though when using custom FW. It can be done via USB stick and U2W.sh. If the config doesn't work, the original hostapd.conf can be restored.

@hassankhan
Copy link
Contributor

@CiNcH83 can you look over the following and check if it looks good to you? Just want to make sure I'm not missing anything from the discussion above 😀

# Basic configuration

interface=wlan0
ssid=AutoBox-582f
#bridge=br0

# WPA and WPA2 configuration

macaddr_acl=0
auth_algs=3
ignore_broadcast_ssid=0
wpa=3
wpa_passphrase=12345678
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

#device_type=6-0050F204-1
# Hardware configuration

# https://github.com/ludwig-v/wireless-carplay-dongle-reverse-engineering/issues/54#issue-857282109

driver=rtl871xdrv
ieee80211ac=1
channel=36
hw_mode=a
channel=36
#require_ht=1
beacon_int=100
dtim_period=1

wmm_enabled=1
wmm_ac_bk_cwmin=4
wmm_ac_bk_cwmax=10
wmm_ac_bk_aifs=7
wmm_ac_bk_txop_limit=0
wmm_ac_bk_acm=0
wmm_ac_be_aifs=3
wmm_ac_be_cwmin=4
wmm_ac_be_cwmax=10
wmm_ac_be_txop_limit=0
wmm_ac_be_acm=0
wmm_ac_vi_aifs=2
wmm_ac_vi_cwmin=3
wmm_ac_vi_cwmax=4
wmm_ac_vi_txop_limit=94
wmm_ac_vi_acm=0
wmm_ac_vo_aifs=2
wmm_ac_vo_cwmin=2
wmm_ac_vo_cwmax=3
wmm_ac_vo_txop_limit=47
wmm_ac_vo_acm=0

#ht_capab=[HT40+]
ht_capab=[SHORT-GI-20][SHORT-GI-40][HT40+]
device_name=RTL8822BS
#device_name=RTL8188EU
manufacturer=Realtek

# https://github.com/ludwig-v/wireless-carplay-dongle-reverse-engineering/issues/54#issuecomment-831874170

uapsd_advertisement_enabled=1

@dmavromatis
Copy link

dmavromatis commented May 5, 2021

Yup -- looks good to me... however @CiNcH83 & @hassankhan, I can try it out on my dev Carlinkit 2 dongle running latest CFW if you'd like.

@CiNcH83
Copy link
Contributor

CiNcH83 commented May 5, 2021

@CiNcH83 can you look over the following and check if it looks good to you?

Here are some changes and additions from my side:

# WPA2 only
auth_algs=1
wpa=2
wpa_key_mgmt=WPA-PSK
wpa_passphrase=12345678
rsn_pairwise=CCMP

# VHT80
vht_capab=[SHORT-GI-80]
vht_oper_chwidth=1

The channel is twice in your config.

@CiNcH83
Copy link
Contributor

CiNcH83 commented May 5, 2021

It looks like Realtek isn't really a good choice for a Linux AP, see here. hostapd-rtl871xdrv seems to be really old sh** which probably doesn't allow for AC/VHT. That's probably why Carlinkit is considering switching to Broadcom. There are however also newer nl80211 based drivers around for RTL8822BS.

@hassankhan
Copy link
Contributor

@dmavromatis Awesome, please do post back if it works, definitely would be interesting if there is a noticeable improvement.

@CiNcH83
Copy link
Contributor

CiNcH83 commented May 18, 2021

I just realized that they are trying to enable 802.11ac and WMM for BCM4354 based models:

# Basic configuration

interface=wlan0
ssid=AutoBox-582f

# WPA and WPA2 configuration

macaddr_acl=0
auth_algs=3
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=12345678
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

driver=nl80211
ieee80211n=1
ieee80211ac=1
wmm_enabled=1
#hw_mode=g
#channel=11
hw_mode=a
channel=36
require_ht=1
require_vht=1

#ht_capab=[SHORT-GI-20]
#ht_capab=[SHORT-GI-20][SHORT-GI-40][HT40+]
#ht_capab=[SHORT-GI-20][SHORT-GI-40][HT40-]
#vht_capab=[SHORT-GI-80][SHORT-GI-160]

So they might be abandoning Realtek because of the bad Linux soft AP driver.

@simps100
Copy link

Did anyone get chance to test this out? Device works fairly well but any improvement on latency particularly phone calls would be most welcome!

@ludwig-v ludwig-v added the enhancement New feature or request label Sep 4, 2021
@Ar4erR07
Copy link

Seems hostapd compiled without AC support:
random: Trying to read entropy from /dev/random Configuration file: /mnt/UPAN/hostapdORIMOD.conf Line 64: unknown configuration item 'ieee80211ac' Line 70: unknown configuration item 'vht_capab' Line 71: unknown configuration item 'vht_oper_chwidth' 3 errors found in configuration file '/mnt/UPAN/hostapdORIMOD.conf'

@dmi97
Copy link

dmi97 commented Feb 25, 2023

Replacing hostapd.conf shouldn't be much of a problem though when using custom FW. It can be done via USB stick and U2W.sh. If the config doesn't work, the original hostapd.conf can be restored.

Can it be replaced when using the original firmware? I have a Carlinkit A2A (AndroidAuto) dongle and I need to change the default 5Ghz wifi channel because at channel 36 I get occasional stuttering especially in highly populated areas. Carlinkit support also confirmed that's the issue but their way of changing the wifi channel did not work.

They told me to flash the firmware with a file named default_wifi_channel and the channel number inside, but that doesn't work the device gets flashed but the channel stays at 36.

So I am trying to unpack the img file to change this setting directly on the firmware. But can't figure out how, the img file cannot be mounted or extracted, it shows a "corrputed file" error. What am I missing?
O2W_AUTOKIT_Update.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

8 participants