You are here: Home / Software / Linux Wifi

Linux Wifi

Setup linux wifi using iwd and systemd networkd

i had to switch my desktop from a wired gigbit connection to a wifi connection. Wifi uses a fritzbox 7530 ax, and a tp-link ax 3000.

Setup

iwd will do the wifi encryption and establish the link (layer 2). It’s written by intel and a more modern replacement of wpa_supplicant.

Install iwd (pacman -S iwd), enable and start service (systemctl enable --now iwd). Run an interactive configuration iwctl

# list devices/adapters
[iwd]# device list
                                    Devices
--------------------------------------------------------------------------------
  Name                Address             Powered   Adapter   Mode
--------------------------------------------------------------------------------
  wlan0               1c:c1:0c:30:xx:xx   on        phy0      station

# update list of access points and show them
[iwd]# station wlan0 scan
[iwd]# station wlan0 get-networks
                               Available networks
--------------------------------------------------------------------------------
    Network name                    Security          Signal
--------------------------------------------------------------------------------
  > ssid1                           psk               ****
    Granola                         psk               ****
    devolo-999                      psk               ****

# connect to ssid1
[iwd]# station wlan0 connect ssid1
Type the network passphrase for ssid1 psk.
Passphrase: *************

# done.
# connection info of for the access point/station we are connected to
[iwd]# station wlan0 show

From now on, we will autoconnect to ssid1. Password is saved in /var/lib/iwd as a clear text.

networkd will configure the ip (layer 3).

Create a config file /etc/systemd/network/25-wireless.network

[Match]
Name=wlan0

[Network]
DHCP=yes

and reload networkd systemctl reload systemd-networkd

Theory

query the device about the connection info iw dev wlan0 station dump

Station dc:15:c8:1c:xx:xx (on wlan0)
      inactive time:  0 ms
      rx bytes:       378033674
      rx packets:     3437343
      tx bytes:       18475174117
      tx packets:     435543
      tx retries:     4598
      tx failed:      0
      beacon loss:    0
      beacon rx:      47481
      rx drop misc:   159
      signal:         -51 [-51, -58] dBm
      signal avg:     -51 dBm
      beacon signal avg:      -50 dBm
      tx bitrate:     960.7 MBit/s 80MHz HE-MCS 9 HE-NSS 2 HE-GI 0 HE-DCM 0
      tx duration:    0 us
      rx bitrate:     960.7 MBit/s 80MHz HE-MCS 9 HE-NSS 2 HE-GI 0 HE-DCM 0
      rx duration:    0 us
      authorized:     yes
      authenticated:  yes
      associated:     yes
      preamble:       long
      WMM/WME:        yes
      MFP:            no
      TDLS peer:      no
      DTIM period:    1
      beacon interval:100
      short slot time:yes
      connected time: 4901 seconds
      associated at [boottime]:       732.337s
      associated at:  1655628087914 ms
      current time:   1655632988960 ms

The tx/rx bitrates and the signal are the interesting values.

For sending and receiving we use a 80Mhz wide frequency, that is we use a wifi channel with a base frequency (for example 5ghz channel 48 which is at 5240 Mhz) and spread our signal +/- 40 Mhz, which means we overlap with the neighbouring channels. Limited by the fritzbox

Our data is encoded in a specific way (MCS = Modulation and Coding Scheme) resulting in 480 Mbit (see wikipedia wifi 6).

We are using two stream (NSS = Number of spatial streams). Limited by the two antennas on the wifi client.

As a result we get 2 * 480 = 960 Mbit.

So why is tp-link writing something about 2400 Mbit? Best scanario 160Mhz wide, MCS encoding 11, two channels is 2 * 1201 = 2400

Performance

I tested ping flooding and iperf with a local server on the same subnet.

Connection

ping (min/avg/max/dev)

iperf

wired

0.061/0.073/6.811/0.022

941 Mbits/sec

wireless

0.773/1.046/42.266/0.248

830 Mbits/sec

Comparing to a wired connection, Bandwidth is fine with a loss of about 12 percent. Ping is a lot slower with a factor of 15. But one millisecond is only one millisecond. As long as i don’t start competitive online gaming…

Monitoring

To figure out the placement of the external antenna i want to monitor the damping and the bandwith. Beware that powersaving will automaticly fiddle around with the bandwith and encoding. Keeping a iperf running prevents it. Running interactive iwctl

[iwd]# station wlan0 show
                               Station: wlan0
 --------------------------------------------------------------
   Settable  Property            Value
 --------------------------------------------------------------
          Scanning            no
          State               connected
          Connected network   ssid1
          IPv4 address        192.168.1.42
          ConnectedBss        dc:15:c8:1c:xx:xx
          Frequency           5240
          Security            WPA2-Personal
          RSSI                -54                  dBm
          AverageRSSI         -55                  dBm
          RxMode              802.11ax
          RxMCS               10
          TxMode              802.11ax
          TxMCS               10
          TxBitrate           1080600              Kbit/s
          RxBitrate           1080600              Kbit/s

iwd is live updating these values. A bit more fance cli with ascii art is wavemon