Dual band access points with Linux

Post Reply
User avatar
mad_ady
Posts: 9430
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 602 times
Been thanked: 673 times
Contact:

Dual band access points with Linux

Post by mad_ady »

I'm trying to set up an Odroid C2 (Ubuntu 20) as a wifi hotspot with two WIFI card 4 (which are dual-band). One card should handle 2.4GHz traffic, while the other should handle 5GHz. As far as I know you can't use only one dual-band card to set up two access points on different bands (or it may depend on the radio chipset used). So, you'll need two physical wifi cards. One is connected to the 4 port USB bus (together with a BT adapter, a printer and a USB sound card), while the other is connected to the OTG port. Yes, I'm working my C2 hard :D

I'm using create_ap from https://github.com/lakinduakash/linux-wifi-hotspot, but you can also consult the wiki page here: https://wiki.odroid.com/accessory/conne ... ss_ap_mode

The configuration file is created with something like this:

Code: Select all

create_ap --mkconfig /etc/create_ap_5.conf -m nat wlan1 eth0 MySSID "MyLongAndComplicatedPSK"
You will need to manually adjust it, to force it in 5GHz mode:

Code: Select all

IEEE80211N=1
IEEE80211AC=1
FREQ_BAND=5
For the 2.4Ghz I created a different config file and a similar startup script. Here is my 5GHz configuration as an example:

Code: Select all

CHANNEL=default
GATEWAY=192.168.12.1
WPA_VERSION=2
ETC_HOSTS=0
DHCP_DNS=192.168.1.5
NO_DNS=0
NO_DNSMASQ=0
HIDDEN=0
MAC_FILTER=0
MAC_FILTER_ACCEPT=/etc/hostapd/hostapd.accept
ISOLATE_CLIENTS=0
SHARE_METHOD=nat
IEEE80211N=1
IEEE80211AC=1
HT_CAPAB=[HT40+]
VHT_CAPAB=
DRIVER=nl80211
NO_VIRT=0
COUNTRY=
FREQ_BAND=5
NEW_MACADDR=
DAEMONIZE=0
DAEMON_PIDFILE=
DAEMON_LOGFILE=/dev/null
NO_HAVEGED=0
WIFI_IFACE=wlan1
INTERNET_IFACE=eth0
SSID=MySSID
PASSPHRASE=MyLongAndComplicatedPSK
USE_PSK=0
For the 2.4GHz network turn on:

Code: Select all

IEEE80211N=1
and if using NAT, make sure you set a different GATEWAY (like 192.168.11.1).

Here are some problems I ran into and their solutions...

In case create_ap complains when starting that...

Code: Select all

Apr 29 09:45:59 spica-c2 systemd[1]: Started Create AP Service 5GHz.                                                                                                           
Apr 29 09:45:59 spica-c2 create_ap[1375696]: WARN: Your adapter does not fully support AP virtual interface, enabling --no-virt                                                
Apr 29 09:46:00 spica-c2 create_ap[1375696]: Config dir: /tmp/create_ap.wlan1.conf.GXW48lp6                                                                                    
Apr 29 09:46:00 spica-c2 create_ap[1375696]: PID: 1375696                                                                                                                      
Apr 29 09:46:00 spica-c2 create_ap[1375696]: ERROR: Your adapter can not transmit to channel 36, frequency band 5GHz.                                                          
Apr 29 09:46:00 spica-c2 create_ap[1375696]: Doing cleanup.. done                                                                                                              
Apr 29 09:46:00 spica-c2 systemd[1]: create_ap_5.service: Main process exited, code=exited, status=1/FAILURE                                                                   
Apr 29 09:46:00 spica-c2 systemd[1]: create_ap_5.service: Failed with result 'exit-code'.   
you'll need to check that you have the right to transmit on that channel. See the output of iw list:

Code: Select all

# iw list
...
        Band 2:                                                                                                                                                                
                Capabilities: 0x2f2                                                                                                                                            
                        HT20/HT40                                                                                                                                              
                        Static SM Power Save                                                                                                                                   
                        RX Greenfield                                                                                                                                          
                        RX HT20 SGI                                                                                                                                            
                        RX HT40 SGI                                                                                                                                            
                        TX STBC                                                                                                                                                
                        RX STBC 2-streams                                                                                                                                      
                        Max AMSDU length: 3839 bytes                                                                                                                           
                        No DSSS/CCK HT40                                                                                                                                       
                Maximum RX AMPDU length 65535 bytes (exponent: 0x003)                                                                                                          
                Minimum RX AMPDU time spacing: 2 usec (0x04)                                                                                                                   
                HT RX MCS rate indexes supported: 0-15, 32                                                                                                                     
                TX unequal modulation not supported                                                                                                                            
                HT TX Max spatial streams: 2                                                                                                                                   
                HT TX MCS rate indexes supported may differ                                                                                                                    
                Bitrates (non-HT):                                                                                                                                             
                        * 6.0 Mbps                                                                                                                                             
                        * 9.0 Mbps                                                                                                                                             
                        * 12.0 Mbps                                                                                                                                            
                        * 18.0 Mbps                                                                                                                                            
                        * 24.0 Mbps
                        * 36.0 Mbps
                        * 48.0 Mbps
                        * 54.0 Mbps
                Frequencies:
                        * 5180 MHz [36] (20.0 dBm) (no IR)
                        * 5190 MHz [38] (20.0 dBm) (no IR)
                        * 5200 MHz [40] (20.0 dBm) (no IR)
                        * 5210 MHz [42] (20.0 dBm) (no IR)
                        * 5220 MHz [44] (20.0 dBm) (no IR)
                        * 5230 MHz [46] (20.0 dBm) (no IR)
                        * 5240 MHz [48] (20.0 dBm) (no IR)
                        * 5250 MHz [50] (disabled)
                        * 5260 MHz [52] (20.0 dBm) (no IR, radar detection)
                        * 5270 MHz [54] (20.0 dBm) (no IR, radar detection)
                        * 5280 MHz [56] (20.0 dBm) (no IR, radar detection)
                        * 5290 MHz [58] (20.0 dBm) (no IR, radar detection)
                        * 5300 MHz [60] (20.0 dBm) (no IR, radar detection)
                        * 5310 MHz [62] (20.0 dBm) (no IR, radar detection)
...
no IR means you're not allowed to transmit and it's likely due to regulatory limits in your country. However, it's most likely the country setting is not applied. You can check with:

Code: Select all

#  iw reg get                                                                                                       
global                                                                                                                                                                         
country 00: DFS-UNSET                                                                                                                                                          
        (2402 - 2472 @ 40), (N/A, 20), (N/A)                                                                                                                                   
        (2457 - 2482 @ 20), (N/A, 20), (N/A), AUTO-BW, NO-IR                                                                                                                   
        (2474 - 2494 @ 20), (N/A, 20), (N/A), NO-OFDM, NO-IR                                                                                                                   
        (5170 - 5250 @ 80), (N/A, 20), (N/A), AUTO-BW, NO-IR                           
        (5250 - 5330 @ 80), (N/A, 20), (0 ms), DFS, AUTO-BW, NO-IR                                                                                                             
        (5490 - 5730 @ 160), (N/A, 20), (0 ms), DFS, NO-IR                                                                                                                     
        (5735 - 5835 @ 80), (N/A, 20), (N/A), NO-IR                                                                                                                            
        (57240 - 63720 @ 2160), (N/A, 0), (N/A)     
You can set your country with:

Code: Select all

#  iw reg set RO   
#  iw reg get                                                                                                           
global                                                                                                                                                                         
country RO: DFS-ETSI                                                                                                                                                           
        (2400 - 2483 @ 40), (N/A, 20), (N/A)                                                                                                                                   
        (5150 - 5250 @ 80), (N/A, 23), (N/A), NO-OUTDOOR, AUTO-BW                                                                                                              
        (5250 - 5350 @ 80), (N/A, 20), (0 ms), NO-OUTDOOR, DFS, AUTO-BW                                                                                                        
        (5470 - 5725 @ 160), (N/A, 26), (0 ms), DFS                                                                                                                            
        (5725 - 5875 @ 80), (N/A, 13), (N/A)                                                                                                                                   
        (57000 - 66000 @ 2160), (N/A, 40), (N/A) 
Now, iw list should show those bands without "no IR":

Code: Select all

#  iw list   
...
        Band 2:                                                                                                                                                                
                Capabilities: 0x2f2                                                                                                                                            
                        HT20/HT40                                                                                                                                              
                        Static SM Power Save                                                                                                                                   
                        RX Greenfield                                                                                                                                          
                        RX HT20 SGI                                                                                                                                            
                        RX HT40 SGI                                                                                                                                            
                        TX STBC                                                                                                                                                
                        RX STBC 2-streams                                                                                                                                      
                        Max AMSDU length: 3839 bytes                                                                                                                           
                        No DSSS/CCK HT40                                                                                                                                       
                Maximum RX AMPDU length 65535 bytes (exponent: 0x003)                                                                                                          
                Minimum RX AMPDU time spacing: 2 usec (0x04)                                                                                                                   
                HT RX MCS rate indexes supported: 0-15, 32                                                                                                                     
                TX unequal modulation not supported                                                                                                                            
                HT TX Max spatial streams: 2                                                                                                                                   
                HT TX MCS rate indexes supported may differ                                                                                                                    
                Bitrates (non-HT):                                                                                                                                             
                        * 6.0 Mbps                                                                                                                                             
                        * 9.0 Mbps                                                                                                                                             
                        * 12.0 Mbps                                                                                                                                            
                        * 18.0 Mbps                                                                                                                                            
                        * 24.0 Mbps                                                                                                                                            
                        * 36.0 Mbps                                                                                                                                            
                        * 48.0 Mbps                                                                                                                                            
                        * 54.0 Mbps                                                                                                                                            
                Frequencies:                                                                                                                                                   
                        * 5180 MHz [36] (23.0 dBm)                                                                                                                             
                        * 5190 MHz [38] (23.0 dBm)                                                                                                                             
                        * 5200 MHz [40] (23.0 dBm)                                                                                                                             
                        * 5210 MHz [42] (23.0 dBm)                                                                                                                             
                        * 5220 MHz [44] (23.0 dBm)                                                                                                                             
                        * 5230 MHz [46] (23.0 dBm)                                                                                                                             
                        * 5240 MHz [48] (23.0 dBm)                                     
                        * 5250 MHz [50] (disabled)                                                                                                                             
                        * 5260 MHz [52] (20.0 dBm) (radar detection)                                                                                                           
                        * 5270 MHz [54] (20.0 dBm) (radar detection)                                                                                                           
                        * 5280 MHz [56] (20.0 dBm) (radar detection)                                                                                                           
                        * 5290 MHz [58] (20.0 dBm) (radar detection)                                                                                                           
                        * 5300 MHz [60] (20.0 dBm) (radar detection)                                                                                                           
                        * 5310 MHz [62] (20.0 dBm) (radar detection)                                                                                                           
                        * 5320 MHz [64] (20.0 dBm) (radar detection)            
...
Now, you should be able to start create_ap. But if you still run into this error:

Code: Select all

Apr 29 09:53:35 spica-c2 systemd[1]: Started Create AP Service 5GHz.                                                                                                           
Apr 29 09:53:35 spica-c2 create_ap[1396623]: WARN: Your adapter does not fully support AP virtual interface, enabling --no-virt                                                
Apr 29 09:53:35 spica-c2 create_ap[1396623]: Config dir: /tmp/create_ap.wlan1.conf.pyuGe0hz                                                                                    
Apr 29 09:53:35 spica-c2 create_ap[1396623]: PID: 1396623                                                                                                                      
Apr 29 09:53:38 spica-c2 create_ap[1396623]: Network Manager found, set wlan1 as unmanaged device... DONE                                                                      
Apr 29 09:53:38 spica-c2 create_ap[1396871]: RTNETLINK answers: Operation not possible due to RF-kill                                                                          
Apr 29 09:53:38 spica-c2 create_ap[1396623]: Doing cleanup.. done                                                                                                              
Apr 29 09:53:38 spica-c2 systemd[1]: create_ap_5.service: Main process exited, code=exited, status=1/FAILURE  
You will need to tell rfkill to unblock all radios:

Code: Select all

#  rfkill list all
0: hci0: Bluetooth
        Soft blocked: no
        Hard blocked: no
1: phy0: Wireless LAN
        Soft blocked: yes
        Hard blocked: no
2: phy1: Wireless LAN
        Soft blocked: yes
        Hard blocked: no
#  rfkill unblock all
#  rfkill list all
0: hci0: Bluetooth
        Soft blocked: no
        Hard blocked: no
1: phy0: Wireless LAN
        Soft blocked: no
        Hard blocked: no
2: phy1: Wireless LAN
        Soft blocked: no
        Hard blocked: no
In case you're trying to bridge the wifi adapter to an existing bridge (br0) and getting this error:

Code: Select all

Apr 29 11:43:08 spica-c2 systemd[1]: Started Create AP Service 5GHz.
Apr 29 11:43:08 spica-c2 create_ap[1575330]: WARN: Your adapter does not fully support AP virtual interface, enabling --no-virt
Apr 29 11:43:08 spica-c2 create_ap[1575330]: Config dir: /tmp/create_ap.wlan1.conf.suYW8zid
Apr 29 11:43:08 spica-c2 create_ap[1575330]: PID: 1575330
Apr 29 11:43:11 spica-c2 create_ap[1575330]: Network Manager found, set wlan1 as unmanaged device... DONE
Apr 29 11:43:11 spica-c2 create_ap[1575330]: Sharing Internet using method: bridge
Apr 29 11:43:11 spica-c2 create_ap[1575330]: hostapd command-line interface: hostapd_cli -p /tmp/create_ap.wlan1.conf.suYW8zid/hostapd_ctrl
Apr 29 11:43:11 spica-c2 create_ap[1575570]: Configuration file: /tmp/create_ap.wlan1.conf.suYW8zid/hostapd.conf
Apr 29 11:43:11 spica-c2 create_ap[1575570]: nl80211: Failed to add interface wlan1 into bridge br0: Unknown error 524
Apr 29 11:43:11 spica-c2 create_ap[1575570]: nl80211: deinit ifname=wlan1 disabled_11b_rates=0
Apr 29 11:43:11 spica-c2 create_ap[1575570]: nl80211 driver initialization failed.
Apr 29 11:43:11 spica-c2 create_ap[1575570]: wlan1: interface state UNINITIALIZED->DISABLED
Apr 29 11:43:11 spica-c2 create_ap[1575570]: wlan1: AP-DISABLED
Apr 29 11:43:11 spica-c2 create_ap[1575570]: wlan1: CTRL-EVENT-TERMINATING
Apr 29 11:43:11 spica-c2 create_ap[1575570]: hostapd_free_hapd_data: Interface wlan1 wasn't started
Apr 29 11:43:11 spica-c2 create_ap[1575330]: Error: Failed to run hostapd, maybe a program is interfering.
Apr 29 11:43:12 spica-c2 create_ap[1575330]: If an error like 'n80211: Could not configure driver mode' was thrown
Apr 29 11:43:12 spica-c2 create_ap[1575330]: try running the following before starting create_ap:
Apr 29 11:43:12 spica-c2 create_ap[1575330]:     nmcli r wifi off
Apr 29 11:43:12 spica-c2 create_ap[1575330]:     rfkill unblock wlan
Apr 29 11:43:12 spica-c2 create_ap[1575330]: Doing cleanup.. done

... let me know if you can fix it - I haven't found a way. Though for the first test I did manage to bridge it to br0, so it should work...
For now I'll have to use nat.

I've put these commands in my service - at /etc/systemd/system/create_ap_5.service:

Code: Select all

[Unit]
Description=Create AP Service 5GHz
After=network.target

[Service]
Type=simple
ExecStartPre=/sbin/iw reg set RO
ExecStartPre=/usr/sbin/rfkill unblock all
ExecStart=/usr/bin/create_ap --config /etc/create_ap_5.conf
KillSignal=SIGINT
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target

I was surprised to find that running both APs (on different interfaces) was not an issue. Note that if you are using different wifi cards (e.g. only one of them supports 5GHz), you'll have problems on reboot because the card names may change. You'll need to add udev rules to force a name based on MAC address.

I'm getting around 65Mbps upload/download in the 5GHz spectrum (though the C2 has a 100Mbps uplink in my case) and about 40Mbps in the 2.4GHz. So, not bad. Let's see how the stability goes.
Let me know if you can recommend other tweaks to improve performance/stability.
These users thanked the author mad_ady for the post:
odroid (Thu Apr 29, 2021 6:21 pm)

User avatar
rooted
Posts: 8517
Joined: Fri Dec 19, 2014 9:12 am
languages_spoken: english
Location: Gulf of Mexico, US
Has thanked: 740 times
Been thanked: 345 times
Contact:

Re: Dual band access points with Linux

Post by rooted »

Only thing I can think of is make sure powersave is turned off.

User avatar
mad_ady
Posts: 9430
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 602 times
Been thanked: 673 times
Contact:

Re: Dual band access points with Linux

Post by mad_ady »

Great idea. I'll look into it!

User avatar
rooted
Posts: 8517
Joined: Fri Dec 19, 2014 9:12 am
languages_spoken: english
Location: Gulf of Mexico, US
Has thanked: 740 times
Been thanked: 345 times
Contact:

Re: Dual band access points with Linux

Post by rooted »

Normally you would do it like this.

Disable power save:

Code: Select all

sudo vi /etc/NetworkManager/conf.d/default-wifi-powersave-on.conf
Change the 3 (enabled) to 2 (disabled) and reboot.

User avatar
mad_ady
Posts: 9430
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 602 times
Been thanked: 673 times
Contact:

Re: Dual band access points with Linux

Post by mad_ady »

Ok, I've been testing this for a while and I'm not extremely happy with the stability. After a few days the 2.4GHz AP won't authenticate users, and the 5GHz one (which is on microusb) fails after a few hours with this message:

Code: Select all

May 13 13:32:46 spica-c2 create_ap[378154]: handle_probe_req: send failed
Technically the process still runs, but it doesn't send any more beacons.

So, here's what I did to improve things:
1. Bound the wifi cards to specific usb ports:

Code: Select all

$  cat /etc/udev/rules.d/70-persistent-net-names.rules 
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="7C:DD:90:EB:F8:E8", ATTR{dev_id}=="0x0", ATTR{type}=="1", NAME="wlan0"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="7C:DD:90:9F:95:8C", ATTR{dev_id}=="0x0", ATTR{type}=="1", NAME="wlan1"
Now I know that wlan0 is on the 4 port hub, and handles 2.4GHz, while wlan1 is on the microusb port and handles 5GHz.

2. Created a watchdog script for the 5GHz card to restart it (and reset the USB hub*) periodically in case there are no connected clients (it's possible to reset the 4 port usb hub too, but I have a sound card connected, and when resetting it, it makes some annoying pops, so I'd rather not reset that one):

Code: Select all

$ cat /usr/local/bin/usbwatchdog.sh
#!/bin/bash
usb_reset () {
        logger -s -t $0 "Resetting USB bus"
        echo 0 > /sys/class/gpio/gpio127/value
        sleep 1
        echo 1 > /sys/class/gpio/gpio127/value
        sleep 1
}


logger -s -t $0 "Checking to see if there are any clients connected to wifi1"
active_clients=`arp -an | grep wlan1 | grep -v incomplete | wc -l`

if [ "$active_clients" -eq "0" ]; then
        usb_reset
        service create_ap_5 restart
else
        logger -s -t $0 "There are active clients on wlan1. Skipping reset"
fi
$ sudo chmod a+x /usr/local/bin/usbwatchdog.sh
$ sudo crontab -l
*/10 * * * * /usr/local/bin/usbwatchdog.sh >/dev/null 2>&1
1 6,10,13,16,20 * * * /usr/sbin/service create_ap_24 restart

* Instructions about resetting the microusb port on the C2 in this thread: viewtopic.php?f=139&t=29760

Let's see how it goes...

Post Reply

Return to “Ubuntu (All Linux'es)”

Who is online

Users browsing this forum: No registered users and 0 guests