* How to Autoconnect Two WiFi Cards?
@ 2024-01-16 16:48 Fabian Herb
2024-01-16 17:15 ` James Prestwood
0 siblings, 1 reply; 11+ messages in thread
From: Fabian Herb @ 2024-01-16 16:48 UTC (permalink / raw)
To: iwd@lists.linux.dev
Dear iwd users and developers,
I have a setup with two identical Intel AX210 WiFi cards. I want to connect each to a different SSID. Automatically if possible. But I can’t figure out a way to do that. Even if I connect each one to their network manually, the next time the signal is lost and a card reconnects, there is a good chance that it connects to the wrong network again.
There is no option in the network configuration files to limit a network to a certain interface as far as I can see. I also tried running two instances of iwd, each with a different „—phys“ parameter and STATE_DIRECTORY variable. But the second instance fails with „Name request failed“ (something D-Bus-related?). I also can’t see a way to tell iwctl to which iwd instance to connect to. I also tried using NetworkManager to control iwd, but that worked even worse.
So how can I force each WiFi card on a different SSID? One of the SSIDs is on 2.4 GHz and the other is on 5 GHz. Does that help somehow?
Thanks in advance!
Fabian
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: How to Autoconnect Two WiFi Cards?
2024-01-16 16:48 How to Autoconnect Two WiFi Cards? Fabian Herb
@ 2024-01-16 17:15 ` James Prestwood
2024-01-18 11:51 ` Fabian Herb
0 siblings, 1 reply; 11+ messages in thread
From: James Prestwood @ 2024-01-16 17:15 UTC (permalink / raw)
To: Fabian Herb, iwd@lists.linux.dev
Hi Fabian,
On 1/16/24 8:48 AM, Fabian Herb wrote:
> Dear iwd users and developers,
>
> I have a setup with two identical Intel AX210 WiFi cards. I want to connect each to a different SSID. Automatically if possible. But I can’t figure out a way to do that. Even if I connect each one to their network manually, the next time the signal is lost and a card reconnects, there is a good chance that it connects to the wrong network again.
>
> There is no option in the network configuration files to limit a network to a certain interface as far as I can see. I also tried running two instances of iwd, each with a different „—phys“ parameter and STATE_DIRECTORY variable. But the second instance fails with „Name request failed“ (something D-Bus-related?). I also can’t see a way to tell iwctl to which iwd instance to connect to. I also tried using NetworkManager to control iwd, but that worked even worse.
>
> So how can I force each WiFi card on a different SSID? One of the SSIDs is on 2.4 GHz and the other is on 5 GHz. Does that help somehow?
You can't easily force this in general. IWD doesn't have any
user-configurable network priority, it just picks the "best" network.
Nor does it have per-phy network profiles which is really what you want
here.
Without implementing a new feature with per-phy profiles about the only
thing you could do would be:
- Create a network namespace (e.g. ns0)
- Move one of the phys into ns0
- Start dbus in ns0
- Start IWD in ns0 (specifying a different state and/or config directory)
And you'd of course have to deal with the routing to actually get
traffic passed between namespaces and your host.
What exactly are you trying to accomplish by connecting to separate SSID's?
Thanks,
James
>
> Thanks in advance!
> Fabian
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: How to Autoconnect Two WiFi Cards?
2024-01-16 17:15 ` James Prestwood
@ 2024-01-18 11:51 ` Fabian Herb
2024-01-18 12:18 ` James Prestwood
0 siblings, 1 reply; 11+ messages in thread
From: Fabian Herb @ 2024-01-18 11:51 UTC (permalink / raw)
To: James Prestwood; +Cc: iwd@lists.linux.dev
Hello James,
> Without implementing a new feature with per-phy profiles about the only thing you could do would be:
>
> - Create a network namespace (e.g. ns0)
Thanks! I’ll look into that idea. At a first glance it looks quite cumbersome though. Maybe this could be done with LXC or Docker...
> What exactly are you trying to accomplish by connecting to separate SSID’s?
That’s for redundancy. The machine is moving around quite a bit, so there’s lots of roaming. Reception can be bad in some areas. And with two WiFi connections and 802.11r Fast Transition if possible, I hope to get network interruptions close to zero. Redundancy itself is done on application level.
Best regards,
Fabian
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: How to Autoconnect Two WiFi Cards?
2024-01-18 11:51 ` Fabian Herb
@ 2024-01-18 12:18 ` James Prestwood
2024-01-23 13:36 ` Fabian Herb
0 siblings, 1 reply; 11+ messages in thread
From: James Prestwood @ 2024-01-18 12:18 UTC (permalink / raw)
To: Fabian Herb; +Cc: iwd@lists.linux.dev
On 1/18/24 3:51 AM, Fabian Herb wrote:
> Hello James,
>
>> Without implementing a new feature with per-phy profiles about the only thing you could do would be:
>>
>> - Create a network namespace (e.g. ns0)
> Thanks! I’ll look into that idea. At a first glance it looks quite cumbersome though. Maybe this could be done with LXC or Docker...
Yeah I actually hesitated to even suggest it :) Though once you've done
it its not _that_ bad. We do this in our autotests framework to simulate
networks, and run multiple instances of IWD. You may be able to do it
with a container as well.
>
>> What exactly are you trying to accomplish by connecting to separate SSID’s?
> That’s for redundancy. The machine is moving around quite a bit, so there’s lots of roaming. Reception can be bad in some areas. And with two WiFi connections and 802.11r Fast Transition if possible, I hope to get network interruptions close to zero. Redundancy itself is done on application level.
So this very same thing is being added in WiFi 7, called Multi-Link
Operation (MLO). It doesn't help you now as IWD doesn't have any logic
for it but just putting it out there (and maybe AP support is also
needed). They've been working on this feature in the kernel for quite
some time now.
>
> Best regards,
> Fabian
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: How to Autoconnect Two WiFi Cards?
2024-01-18 12:18 ` James Prestwood
@ 2024-01-23 13:36 ` Fabian Herb
2024-01-23 14:15 ` James Prestwood
2024-01-23 16:15 ` Denis Kenzior
0 siblings, 2 replies; 11+ messages in thread
From: Fabian Herb @ 2024-01-23 13:36 UTC (permalink / raw)
To: James Prestwood; +Cc: iwd@lists.linux.dev
Hi James,
> Am 18.01.2024 um 13:18 schrieb James Prestwood <prestwoj@gmail.com>:
>
> On 1/18/24 3:51 AM, Fabian Herb wrote:
>>
>>> Without implementing a new feature with per-phy profiles about the only thing you could do would be:
>>>
>>> - Create a network namespace (e.g. ns0)
>> Thanks! I’ll look into that idea. At a first glance it looks quite cumbersome though. Maybe this could be done with LXC or Docker...
> Yeah I actually hesitated to even suggest it :) Though once you've done it its not _that_ bad. We do this in our autotests framework to simulate networks, and run multiple instances of IWD. You may be able to do it with a container as well.
I tried with systemd-nspawn, but that didn't work so well. For one you can’t put the phy into the container with the provided tools because it’s not a regular network interface (setting the ns manually works though). And also starting iwd inside the container gives me a „Module rfkill failed to start: -2“, even if I bind /dev/rfkill into the container…
I’m starting to think that it might be easier to add a feature to iwd that does what I want :). But I’m still a bit lost in the source code.
>>
>>> What exactly are you trying to accomplish by connecting to separate SSID’s?
>> That’s for redundancy. The machine is moving around quite a bit, so there’s lots of roaming. Reception can be bad in some areas. And with two WiFi connections and 802.11r Fast Transition if possible, I hope to get network interruptions close to zero. Redundancy itself is done on application level.
> So this very same thing is being added in WiFi 7, called Multi-Link Operation (MLO). It doesn't help you now as IWD doesn't have any logic for it but just putting it out there (and maybe AP support is also needed). They've been working on this feature in the kernel for quite some time now.
Yes, WiFi 7 is certainly interesting. You can already buy WiFi-7-capable hardware now. UniFi promises MLO support to be available in February with a firmware update for example.
Is there a time frame when MLO support might be added to iwd? Or is the work on kernel support still ongoing?
Best regards,
Fabian
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: How to Autoconnect Two WiFi Cards?
2024-01-23 13:36 ` Fabian Herb
@ 2024-01-23 14:15 ` James Prestwood
2024-01-23 16:15 ` Denis Kenzior
1 sibling, 0 replies; 11+ messages in thread
From: James Prestwood @ 2024-01-23 14:15 UTC (permalink / raw)
To: Fabian Herb; +Cc: iwd@lists.linux.dev
Hi Fabian,
On 1/23/24 5:36 AM, Fabian Herb wrote:
> Hi James,
>
>> Am 18.01.2024 um 13:18 schrieb James Prestwood <prestwoj@gmail.com>:
>>
>> On 1/18/24 3:51 AM, Fabian Herb wrote:
>>>> Without implementing a new feature with per-phy profiles about the only thing you could do would be:
>>>>
>>>> - Create a network namespace (e.g. ns0)
>>> Thanks! I’ll look into that idea. At a first glance it looks quite cumbersome though. Maybe this could be done with LXC or Docker...
>> Yeah I actually hesitated to even suggest it :) Though once you've done it its not _that_ bad. We do this in our autotests framework to simulate networks, and run multiple instances of IWD. You may be able to do it with a container as well.
> I tried with systemd-nspawn, but that didn't work so well. For one you can’t put the phy into the container with the provided tools because it’s not a regular network interface (setting the ns manually works though). And also starting iwd inside the container gives me a „Module rfkill failed to start: -2“, even if I bind /dev/rfkill into the container…
I only ever did this with low level namespaces, but yeah, its a quirky
setup to achieve what you want.
>
> I’m starting to think that it might be easier to add a feature to iwd that does what I want :). But I’m still a bit lost in the source code.
>
>>>> What exactly are you trying to accomplish by connecting to separate SSID’s?
>>> That’s for redundancy. The machine is moving around quite a bit, so there’s lots of roaming. Reception can be bad in some areas. And with two WiFi connections and 802.11r Fast Transition if possible, I hope to get network interruptions close to zero. Redundancy itself is done on application level.
>> So this very same thing is being added in WiFi 7, called Multi-Link Operation (MLO). It doesn't help you now as IWD doesn't have any logic for it but just putting it out there (and maybe AP support is also needed). They've been working on this feature in the kernel for quite some time now.
> Yes, WiFi 7 is certainly interesting. You can already buy WiFi-7-capable hardware now. UniFi promises MLO support to be available in February with a firmware update for example.
>
> Is there a time frame when MLO support might be added to iwd? Or is the work on kernel support still ongoing?
It very much seems like its in active development in the
kernel/wpa_supplicant. There time-frame to add it to IWD but at the very
least we'd want the kernel support to be stable. Another factor to
adding larger features, simply put, is corporate agendas. Unfortunately,
gone are the days of us IWD devs getting paid to add whatever we want,
whenever we want (that's at least my situation).
So as for MLO yes I could see it being added at some point, but its not
really a priority. My company is just now starting to add WiFi 6e. When
WiFi 7 becomes more widespread I could probably get MLO support on the
agenda as it seems like it would add connection reliability but I won't
lie, its a long way off. Anyone else is welcome to implement before then
though :)
Thanks,
James
>
> Best regards,
> Fabian
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: How to Autoconnect Two WiFi Cards?
2024-01-23 13:36 ` Fabian Herb
2024-01-23 14:15 ` James Prestwood
@ 2024-01-23 16:15 ` Denis Kenzior
2024-01-24 12:34 ` Fabian Herb
1 sibling, 1 reply; 11+ messages in thread
From: Denis Kenzior @ 2024-01-23 16:15 UTC (permalink / raw)
To: Fabian Herb, James Prestwood; +Cc: iwd@lists.linux.dev
Hi Fabian,
>
> I’m starting to think that it might be easier to add a feature to iwd that does what I want :). But I’m still a bit lost in the source code.
Can you elaborate on what you're trying to accomplish?
Do you want iwd to connect to two SSIDs? Two different BSSes within the same
SSID? Something else?
I do like the idea of having iwd support multiple wifi cards out of the box.
Right now we do so, but it isn't terribly useful, e.g. both phys will happily
connect to the same SSID on the same frequency.
Having the ability for iwd to natively support connecting to multiple APs with
multiple cards would be nice. Then we can use something like mptcp to run
multiple flows for redundancy / throughput. Shouldn't be all that hard to have
something working, mostly a matter of updating autoconnect logic to take
multi-phy scenario into account.
Obligatory: patches are always welcome :)
>
> Yes, WiFi 7 is certainly interesting. You can already buy WiFi-7-capable hardware now. UniFi promises MLO support to be available in February with a firmware update for example.
MLO only works to the same AP though, just different band. You mentioned using
a different SSID earlier?
Regards,
-Denis
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: How to Autoconnect Two WiFi Cards?
2024-01-23 16:15 ` Denis Kenzior
@ 2024-01-24 12:34 ` Fabian Herb
2024-01-24 15:21 ` Denis Kenzior
0 siblings, 1 reply; 11+ messages in thread
From: Fabian Herb @ 2024-01-24 12:34 UTC (permalink / raw)
To: Denis Kenzior; +Cc: iwd@lists.linux.dev
Hello Denis,
>
>> I’m starting to think that it might be easier to add a feature to iwd that does what I want :). But I’m still a bit lost in the source code.
>
> Can you elaborate on what you're trying to accomplish?
>
> Do you want iwd to connect to two SSIDs? Two different BSSes within the same SSID? Something else?
I want each WiFi card to connect to a different SSID (each consisting of multiple BSSIDs). Ideally I want to add an entry to each network file to limit it to a certain interface. Maybe even better, but less general: If I could limit the frequency band of each interface, I could save a bit of time during channel scans.
But I couldn’t find the spot in the code where such a decision would be made. So instead, I added a command line option for the D-Bus name iwd registers as, so I could run two instances of iwd, each handling a different phy. WIP is here: https://github.com/cmdrf/iwd/tree/dbus-name-option. It’s not finished, and I’m not even sure it would work in the end or if there are more clashes between two iwd instances.
> MLO only works to the same AP though, just different band. You mentioned using a different SSID earlier?
Using multiple SSIDs and doing the redundancy on application level is only done out of necessity. I’d happily use MLO if it does what I need instead. But yes, after reading a bit further, I also noticed that it only works on a single AP. Waiting for WiFi 8 then…
Best regards,
Fabian
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: How to Autoconnect Two WiFi Cards?
2024-01-24 12:34 ` Fabian Herb
@ 2024-01-24 15:21 ` Denis Kenzior
2024-01-24 16:07 ` Fabian Herb
0 siblings, 1 reply; 11+ messages in thread
From: Denis Kenzior @ 2024-01-24 15:21 UTC (permalink / raw)
To: Fabian Herb; +Cc: iwd@lists.linux.dev
Hi Fabian,
On 1/24/24 06:34, Fabian Herb wrote:
> Hello Denis,
>
>>
>>> I’m starting to think that it might be easier to add a feature to iwd that does what I want :). But I’m still a bit lost in the source code.
>>
>> Can you elaborate on what you're trying to accomplish?
>>
>> Do you want iwd to connect to two SSIDs? Two different BSSes within the same SSID? Something else?
>
> I want each WiFi card to connect to a different SSID (each consisting of multiple BSSIDs). Ideally I want to add an entry to each network file to limit it to a certain interface. Maybe even better, but less general: If I could limit the frequency band of each interface, I could save a bit of time during channel scans.
The first part should be fairly easy actually. A very rough approach would be
to add some logic inside src/station.c station_autoconnect_next():
- When considering a network, first check whether a network with the same
SSID/security type is being connected to by other stations managed by iwd
- This should be easy to do by looping of the station_list and checking
connected_network / connected_bss members of struct station.
- If the networks match, just skip it and continue on to the next autoconnect
target.
- This should result in each station object connecting to a different SSID.
Once latched onto the SSID, station will try to roam only within that network.
If you want to make it more fancy like adding additional scanning policies it
would take a bit more effort and probably require a policy file format of some sort.
>
> But I couldn’t find the spot in the code where such a decision would be made. So instead, I added a command line option for the D-Bus name iwd registers as, so I could run two instances of iwd, each handling a different phy. WIP is here: https://github.com/cmdrf/iwd/tree/dbus-name-option. It’s not finished, and I’m not even sure it would work in the end or if there are more clashes between two iwd instances.
Well, it could work, but you'd be running multiple dbus instances and there
wouldn't be any coordination between iwds. Also, you'd have to make sure each
iwd instance runs with a different state directory and probably different config
file (for band preferences). See 'man 8 iwd' for details on how to do that.
Another hint, ell already honors DBUS_SYSTEM_BUS_ADDRESS environment variable.
So you can start multiple dbus instances, record the address and point each iwd
to the dbus instance via DBUS_SYSTEM_BUS_ADDRESS environment variable. No need
to change any code inside iwd.
>
>> MLO only works to the same AP though, just different band. You mentioned using a different SSID earlier?
>
> Using multiple SSIDs and doing the redundancy on application level is only done out of necessity. I’d happily use MLO if it does what I need instead. But yes, after reading a bit further, I also noticed that it only works on a single AP. Waiting for WiFi 8 then…
Fair enough.
Please report back your findings. I'm curious since I can foresee a similar
setup (but on the same SSID / different band / different AP) being useful in the
future.
Regards,
-Denis
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: How to Autoconnect Two WiFi Cards?
2024-01-24 15:21 ` Denis Kenzior
@ 2024-01-24 16:07 ` Fabian Herb
2024-01-24 16:18 ` Denis Kenzior
0 siblings, 1 reply; 11+ messages in thread
From: Fabian Herb @ 2024-01-24 16:07 UTC (permalink / raw)
To: Denis Kenzior; +Cc: iwd@lists.linux.dev
Hi Denis,
> - When considering a network, first check whether a network with the same SSID/security type is being connected to by other stations managed by iwd
> - This should be easy to do by looping of the station_list and checking connected_network / connected_bss members of struct station.
> - If the networks match, just skip it and continue on to the next autoconnect target.
> - This should result in each station object connecting to a different SSID. Once latched onto the SSID, station will try to roam only within that network.
Thanks for the hint! But wouldn’t that mean that it’s basically random which interface connects to which SSID? Right now I’m configuring IPs and routing via systemd-networkd for each interface, and that would stop working if the two interfaces are connected the wrong way around. The approach also screams for race conditions :D.
I was thinking about something like this:
- Add a configuration option to the network file format which holds an interface name
- When iterating the list of networks to autoconnect to, skip the entries for which the interface name is set AND it does not match the current interface.
> Well, it could work, but you'd be running multiple dbus instances and there wouldn't be any coordination between iwds. Also, you'd have to make sure each iwd instance runs with a different state directory and probably different config file (for band preferences). See 'man 8 iwd' for details on how to do that. Another hint, ell already honors DBUS_SYSTEM_BUS_ADDRESS environment variable. So you can start multiple dbus instances, record the address and point each iwd to the dbus instance via DBUS_SYSTEM_BUS_ADDRESS environment variable. No need to change any code inside iwd.
I’ll give DBUS_SYSTEM_BUS_ADDRESS a try, thanks!
Fabian
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: How to Autoconnect Two WiFi Cards?
2024-01-24 16:07 ` Fabian Herb
@ 2024-01-24 16:18 ` Denis Kenzior
0 siblings, 0 replies; 11+ messages in thread
From: Denis Kenzior @ 2024-01-24 16:18 UTC (permalink / raw)
To: Fabian Herb; +Cc: iwd@lists.linux.dev
Hi Fabian,
On 1/24/24 10:07, Fabian Herb wrote:
> Hi Denis,
>
>> - When considering a network, first check whether a network with the same SSID/security type is being connected to by other stations managed by iwd
>> - This should be easy to do by looping of the station_list and checking connected_network / connected_bss members of struct station.
>> - If the networks match, just skip it and continue on to the next autoconnect target.
>> - This should result in each station object connecting to a different SSID. Once latched onto the SSID, station will try to roam only within that network.
>
> Thanks for the hint! But wouldn’t that mean that it’s basically random which interface connects to which SSID? Right now I’m configuring IPs and routing via systemd-networkd for each
Yes, but if your cards are identical, does it matter? If your cards have
asymmetric capabilities, things are a bit trickier, but that would be the realm
of defining a policy iwd can follow.
interface, and that would stop working if the two interfaces are connected the
wrong way
Make your policy smarter. For example, have it consider the SSID instead of the
interface name?
around. The approach also screams for race conditions :D.
Not really. There would be corner cases of course, for example if there's only
a single SSID to connect to the second card will never connect.
>
> I was thinking about something like this:
> - Add a configuration option to the network file format which holds an interface name
interface names are made up by iwd itself, and are not static across things like
hardware hotplug/unplug. Yes you can beat iwd into honoring the name coming in
from the kernel, or with some care, from udev renaming, but even those are not
guaranteed to be static. What you really want to take into account is the
underlying hardware capabilities.
> - When iterating the list of networks to autoconnect to, skip the entries for which the interface name is set AND it does not match the current interface.
Yeah, NM does something similar. But see above.
Regards,
-Denis
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2024-01-24 16:18 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-16 16:48 How to Autoconnect Two WiFi Cards? Fabian Herb
2024-01-16 17:15 ` James Prestwood
2024-01-18 11:51 ` Fabian Herb
2024-01-18 12:18 ` James Prestwood
2024-01-23 13:36 ` Fabian Herb
2024-01-23 14:15 ` James Prestwood
2024-01-23 16:15 ` Denis Kenzior
2024-01-24 12:34 ` Fabian Herb
2024-01-24 15:21 ` Denis Kenzior
2024-01-24 16:07 ` Fabian Herb
2024-01-24 16:18 ` Denis Kenzior
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox