openwisp/netengine

[feature] OpenWRT: extract associated WiFi stations

nemesifier opened this issue · 0 comments

This is one of the pieces of information in which openwisp users are mostly interested since it's widely used in public WiFi networks.

We can get this information with additional scripts and a custom MIB.
We could use iw or ubus (as we do in netjson-monitoring).
If we get a good result we could even send a patch to include these scripts in net-snmpd on OpenWRT by default.

Example exec net-snmpd script on on OpenWRT:

in /tmp/test:

#!/bin/sh
iwinfo

in /etc/config/snmpd:

config exec 'iwinfo'       
  option name 'iwinfo'
  option prog '/tmp/test' 
  option miboid '1.2.3.4'  

Output:

snmpwalk -v2c -c public <ip> 1.2.3.4
iso.2.3.4.1.1 = INTEGER: 1
iso.2.3.4.2.1 = STRING: "yo"
iso.2.3.4.3.1 = STRING: "/tmp/test"
iso.2.3.4.100.1 = INTEGER: 0
iso.2.3.4.101.1 = STRING: "wlan1     ESSID: \"fvgwifi-demo\""
iso.2.3.4.101.2 = STRING: "          Access Point: 46:D1:FA:4B:38:42"
iso.2.3.4.101.3 = STRING: "          Mode: Master  Channel: 1 (2.412 GHz)"
iso.2.3.4.101.4 = STRING: "          Tx-Power: 20 dBm  Link Quality: unknown/70"
iso.2.3.4.101.5 = STRING: "          Signal: unknown  Noise: -92 dBm"
iso.2.3.4.101.6 = STRING: "          Bit Rate: unknown"
iso.2.3.4.101.7 = STRING: "          Encryption: none"
iso.2.3.4.101.8 = STRING: "          Type: nl80211  HW Mode(s): 802.11bgn"
iso.2.3.4.101.9 = STRING: "          Hardware: unknown [Generic MAC80211]"
iso.2.3.4.101.10 = STRING: "          TX power offset: unknown"
iso.2.3.4.101.11 = STRING: "          Frequency offset: unknown"
iso.2.3.4.101.12 = STRING: "          Supports VAPs: yes  PHY name: phy1"
iso.2.3.4.101.13 = ""
iso.2.3.4.101.14 = STRING: "wlo1      ESSID: \"broadgee-backup\""
iso.2.3.4.101.15 = STRING: "          Access Point: 44:D1:FA:4B:38:42"
iso.2.3.4.101.16 = STRING: "          Mode: Master  Channel: 1 (2.412 GHz)"
iso.2.3.4.101.17 = STRING: "          Tx-Power: 20 dBm  Link Quality: 62/70"
iso.2.3.4.101.18 = STRING: "          Signal: -48 dBm  Noise: -92 dBm"
iso.2.3.4.101.19 = STRING: "          Bit Rate: 36.1 MBit/s"
iso.2.3.4.101.20 = STRING: "          Encryption: WPA2 PSK (CCMP)"
iso.2.3.4.101.21 = STRING: "          Type: nl80211  HW Mode(s): 802.11bgn"
iso.2.3.4.101.22 = STRING: "          Hardware: unknown [Generic MAC80211]"
iso.2.3.4.101.23 = STRING: "          TX power offset: unknown"
iso.2.3.4.101.24 = STRING: "          Frequency offset: unknown"
iso.2.3.4.101.25 = STRING: "          Supports VAPs: yes  PHY name: phy1"
iso.2.3.4.101.26 = ""
iso.2.3.4.102.1 = INTEGER: 0
iso.2.3.4.103.1 = ""

Of course the example above is naive but just explains how to get additional info on OpenWRT via SNMPd.

The important info we currently get from netjson-monitoring is:

"channel": 1,
"country": "IT",
"frequency": 2412,
"mode": "access_point",
"noise": -93,
"signal": -54,
"ssid": "SSID name",
"tx_power": 20,
"clients": [
    {
        "aid": 1,
        "assoc": true,
        "auth": true,
        "authorized": true,
        "ht": true,
        "mac": "<MACADDR>",
        "mfp": false,
        "preauth": false,
        "vht": false,
        "wds": false,
        "wmm": true,
        "wps": false
    }
]

I think we can get this info with a mixture of commands like uci get, iwinfo, iw <interface> station dumpor via ubus and jsonfilter.

We can work on this idea once we complete the first release.