Skip to content

wmediumd interference mode: scan_results signal values don't update when station position changes #606

Description

@valentt

Description

When using wmediumd in interference mode, the signal values reported by wpa_cli scan_results do not update when a station's position changes via setPosition(). However, the connected AP signal (from iw link) DOES update correctly.

This makes WiFi handoff/roaming impossible to simulate because the station always sees the initial AP as "best" regardless of physical position.

Environment

Mininet-WiFi version: 2.7 (from git)
OS: Ubuntu 22.04
wmediumd: installed via Mininet-WiFi
Python: 3.10
Steps to Reproduce

#!/usr/bin/env python3
from mininet.node import Controller
from mininet.log import setLogLevel, info
from mn_wifi.net import Mininet_wifi
from mn_wifi.link import wmediumd
from mn_wifi.wmediumdConnector import interference
import time

def test():
net = Mininet_wifi(controller=Controller,
link=wmediumd, wmediumd_mode=interference)

sta1 = net.addStation('sta1', position='15,33,0', bgscan_threshold=-60,
                      s_inverval=5, l_interval=10, bgscan_module='simple')
ap1 = net.addAccessPoint('ap1', mac='00:00:00:00:00:01', ssid='test',
                         mode='g', channel='1', passwd='123456789a',
                         encrypt='wpa2', position='10,30,0', datapath='user')
ap2 = net.addAccessPoint('ap2', mac='00:00:00:00:00:02', ssid='test',
                         mode='g', channel='1', passwd='123456789a',
                         encrypt='wpa2', position='30,30,0', datapath='user')
ap3 = net.addAccessPoint('ap3', mac='00:00:00:00:00:03', ssid='test',
                         mode='g', channel='1', passwd='123456789a',
                         encrypt='wpa2', position='50,30,0', datapath='user')
c1 = net.addController('c1')

net.setPropagationModel(model='logDistance', exp=3)
net.configureNodes()
net.addLink(ap1, ap2)
net.addLink(ap2, ap3)
net.build()
c1.start()
ap1.start([c1])
ap2.start([c1])
ap3.start([c1])

time.sleep(8)

for x in [15, 35, 55]:
    sta1.setPosition(f'{x},33,0')
    time.sleep(2)

    # Connected signal (WORKS - updates with position)
    connected_sig = sta1.cmd('iw dev sta1-wlan0 link | grep signal').strip()

    # Scan signal (BROKEN - stays static)
    sta1.cmd('wpa_cli -i sta1-wlan0 scan')
    time.sleep(2)
    scan = sta1.cmd('wpa_cli -i sta1-wlan0 scan_results | grep test')

    info(f'Position x={x}:\n')
    info(f'  Connected: {connected_sig}\n')
    info(f'  Scan:\n{scan}\n')

net.stop()

if name == 'main':
setLogLevel('info')
test()
Expected Behavior

At position x=55 (5m from AP3, 45m from AP1):

Scan AP1: ~-65 dBm (far)
Scan AP2: ~-50 dBm (medium)
Scan AP3: ~-35 dBm (close, strongest)
Station should see AP3 as strongest and potentially handoff.

Actual Behavior

At ALL positions (x=15, 35, 55):

Scan AP1: -39 dBm (SAME - cached from initial)
Scan AP2: -51 dBm (SAME)
Scan AP3: -62 dBm (SAME)
Connected signal DOES change correctly:

x=15: -39 dBm
x=35: -58 dBm
x=55: -65 dBm
Analysis

Two different signal calculation paths exist:

Connected AP signal (iw link): Uses position-based calculation - WORKS
Scan results signal (wpa_cli scan_results): Uses static/cached values - BROKEN
The setPosition() method calls set_pos_wmediumd() which sends position updates to wmediumd. This correctly updates the connected AP signal but does NOT update the signal values returned during scans.

Impact

WiFi handoff/roaming cannot be simulated
bgscan triggers but never switches AP (always sees initial AP as "best")
Research on handoff optimization is blocked
handover_bgscan.py example cannot demonstrate actual handoff programmatically
Attempted Workarounds (all failed)

wpa_cli bss_flush - Clears cache but new scan shows same values
Multiple consecutive scans - Same static values
Longer wait times - No effect
Different channels - No effect
Reset node.lastpos - No effect on scan values
Possible Root Cause

The scan response in mac80211_hwsim may be generated independently of wmediumd's position-based signal calculation. Scan frames might bypass the wmediumd signal attenuation that applies to data frames.

Related Files

mn_wifi/node.py: setPosition(), set_pos_wmediumd()
mn_wifi/wmediumdConnector.py: update_pos(), w_pos class
wmediumd source: signal calculation for scan vs data frames
Additional Context

This was discovered while testing mesh routing protocol handoff using Babel/Apex on the backhaul with WiFi client mobility. We verified:

Stock handover_bgscan.py has same issue
Problem exists regardless of AP spacing (10m to 50m)
Problem exists on same-channel and different-channel configurations
Connected signal always updates correctly
Only scan signal is broken

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions