Post

Booster la vitesse WIFI en forçant les canaux 40 MHz dans hostapd

Booster la vitesse WIFI en forçant les canaux 40 MHz dans hostapd

Booster la vitesse WIFI en forçant les canaux 40 MHz dans hostapd

Booster la vitesse WIFI en forçant les canaux 40 MHz dans hostapd

http://blog.anthonywong.net/2015/07/19/boost-wifi-speed-raspberry-pi-hostapd/
802.11n peut doubler la largeur de bande du canal de 802.11g de 20 MHz à 40 MHz, mais ce mode de fonctionnement n’est pas recommandé dans les zones où les spectres sont saturés et risquent d’interférer avec les dispositifs WIFI et Bluetooth existants. Par conséquent, hostapd n’activera pas 40 MHz lorsqu’il découvrira que d’autres canaux sont utilisés, comme ce qui est vu dans le journal hostapd ci-dessous:

1
2
3
4
5
6
7
8
nl80211: New scan results available
nl80211: Received scan results (16 BSSes)
40 MHz affected channel range: [2397,2447] MHz
Neighboring BSS: 1c:fa:68:8e:a6:e0 freq=2412 pri=1 sec=5
Neighboring BSS: e0:05:c5:4c:e2:b6 freq=2427 pri=0 sec=0
Neighboring BSS: b0:48:7a:6a:9d:32 freq=2437 pri=6 sec=10
40 MHz pri/sec mismatch with BSS b0:48:7a:6a:9d:32 <2437,2457> (chan=6+) vs. <2412,2432>
20/40 MHz operation not permitted on channel pri=1 sec=5 based on overlapping BSSes

Nous devons forcer hostapd à allumer 40 MHz de toute façon. Mais comme hostapd n’ a pas d’options de configuration pour cela, nous devons recompiler hostapd à partir de la source. En fait, cela a été fait dans d’autres distros. Par exemple, OpenWRT et Arch ont patché leur hostapd avec le patch noscan, qui ajoute une option pour forcer le mode 40MHz quel que soit l’environnement.

Avant le passage à 40 MHz, on note l’iwconfig ,le débit binaire n’est que de 54 Mb/s:

1
2
3
4
5
6
7
8
wlan0     IEEE 802.11abgn  ESSID:"bibiworld"  
          Mode:Managed  Frequency:2.437 GHz  Access Point: C8:3A:35:C9:17:4A   
          Bit Rate=54 Mb/s   Tx-Power=15 dBm   
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Power Management:off
          Link Quality=70/70  Signal level=-32 dBm  
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:30  Invalid misc:683   Missed beacon:0

Tout d’abord vous devez ajouter une source deb-src à apt pour que nous puissions télécharger les paquets source.

1
2
3
4
5
6
7
sudo -s
echo "deb-src http://ftp.fr.debian.org/debian/ stretch main contrib non-free" >> /etc/apt/sources.list
apt-get update
exit
apt-get source hostapd            # download source of hostapd
apt-get build-dep hostapd         # download all build dependencies
cd wpa-1.0

Save the following patch into a file: — wpa-1.0.orig/src/ap/hw_features.c 2012-05-10 05:56:09.000000000 +0800 +++ wpa-1.0/src/ap/hw_features.c 2015-07-18 17:22:37.788215009 +0800 @@ -430,6 +430,7 @@ oper40 = ieee80211n_check_40mhz_2g4(iface, scan_res); wpa_scan_results_free(scan_res);

+#if 0 if (!oper40) { wpa_printf(MSG_INFO, “20/40 MHz operation not permitted on “ “channel pri=%d sec=%d based on overlapping BSSes”, @@ -439,6 +440,12 @@ iface->conf->secondary_channel = 0; iface->conf->ht_capab &= ~HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET; } +#endif

  • wpa_printf(MSG_INFO, “Force 20/40 MHz operation on “
  • “channel pri=%d sec=%d even there are overlapping BSSes”,
  • iface->conf->channel,
  • iface->conf->channel +
  • iface->conf->secondary_channel * 4);
1
2
    res = ieee80211n_allowed_ht40_channel_pair(iface);
    hostapd_setup_interface_complete(iface, !res); 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23

— wpa-1.0.orig/src/ap/hw_features.c 2012-05-10 05:56:09.000000000 +0800 +++ wpa-1.0/src/ap/hw_features.c 2015-07-18 17:22:37.788215009 +0800 @@ -430,6 +430,7 @@ oper40 = ieee80211n_check_40mhz_2g4(iface, scan_res); wpa_scan_results_free(scan_res);

+#if 0 if (!oper40) { wpa_printf(MSG_INFO, “20/40 MHz operation not permitted on “ “channel pri=%d sec=%d based on overlapping BSSes”, @@ -439,6 +440,12 @@ iface->conf->secondary_channel = 0; iface->conf->ht_capab &= ~HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET; } +#endif

  • wpa_printf(MSG_INFO, “Force 20/40 MHz operation on “
  • “channel pri=%d sec=%d even there are overlapping BSSes”,
  • iface->conf->channel,
  • iface->conf->channel +
  • iface->conf->secondary_channel * 4);
1
2
    res = ieee80211n_allowed_ht40_channel_pair(iface);
    hostapd_setup_interface_complete(iface, !res);

pi@raspberrypi $ patch -p1 < patch.diff 1

pi@raspberrypi $ patch -p1 < patch.diff

Because we are going to create a new hostapd package, it’d be a good practice to increment the version number by adding a new section at the top of debian/changelog, like this:

wpa (1.0-3+deb7u3) wheezy; urgency=low

  • Force 20/40 MHz.

– Anthony Wong ypwong@gmail.com Sat, 18 Jul 2015 16:30:43 +0800

wpa (1.0-3+deb7u2) wheezy-security; urgency=high … 1 2 3 4 5 6 7 8

wpa (1.0-3+deb7u3) wheezy; urgency=low

  • Force 20/40 MHz.

– Anthony Wong ypwong@gmail.com Sat, 18 Jul 2015 16:30:43 +0800

wpa (1.0-3+deb7u2) wheezy-security; urgency=high …

Now we are ready to compile the packages: pi@raspberrypi $ fakeroot debian/rules binary 1

pi@raspberrypi $ fakeroot debian/rules binary

If it succeeds, install the new package with dpkg -i.

Restart hostapd, it should now force 40 MHz mode: nl80211: New scan results available nl80211: Received scan results (23 BSSes) 40 MHz affected channel range: [2397,2447] MHz
Neighboring BSS: e0:05:c5:4c:e2:b6 freq=2427 pri=0 sec=0 Neighboring BSS: 00:d0:41:c4:25:31 freq=2437 pri=6 sec=2 40 MHz pri/sec mismatch with BSS 00:d0:41:c4:25:31 <2437,2417> (chan=6-) vs. <2412,2432> Force 20/40 MHz operation on channel pri=1 sec=5 even there are overlapping BSSes HT40: control channel: 1 secondary channel: 5 Completing interface initialization 1 2 3 4 5 6 7 8 9

nl80211: New scan results available nl80211: Received scan results (23 BSSes) 40 MHz affected channel range: [2397,2447] MHz
Neighboring BSS: e0:05:c5:4c:e2:b6 freq=2427 pri=0 sec=0 Neighboring BSS: 00:d0:41:c4:25:31 freq=2437 pri=6 sec=2 40 MHz pri/sec mismatch with BSS 00:d0:41:c4:25:31 <2437,2417> (chan=6-) vs. <2412,2432> Force 20/40 MHz operation on channel pri=1 sec=5 even there are overlapping BSSes HT40: control channel: 1 secondary channel: 5 Completing interface initialization

And my iwconfig output now shows Bit Rate is 150 Mb/s, yay! wlan0 IEEE 802.11abgn ESSID:”bibiworld”
Mode:Managed Frequency:2.412 GHz Access Point: C8:3A:35:C9:17:4A
Bit Rate=150 Mb/s Tx-Power=15 dBm
Retry short limit:7 RTS thr:off Fragment thr:off Power Management:off Link Quality=70/70 Signal level=-28 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0 Tx excessive retries:31 Invalid misc:330 Missed beacon:0 1 2 3 4 5 6 7 8

wlan0 IEEE 802.11abgn ESSID:”bibiworld”
Mode:Managed Frequency:2.412 GHz Access Point: C8:3A:35:C9:17:4A
Bit Rate=150 Mb/s Tx-Power=15 dBm
Retry short limit:7 RTS thr:off Fragment thr:off Power Management:off Link Quality=70/70 Signal level=-28 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0 Tx excessive retries:31 Invalid misc:330 Missed beacon:0

Cet article est sous licence CC BY 4.0 par l'auteur.