piker icon indicating copy to clipboard operation
piker copied to clipboard

Roaming support, general real-time network measurements

Open goodboy opened this issue 3 years ago • 1 comments

This issue demands a networking tool-set driven by 2 sets of requirements:

  • as per ib backend work in #321, we need an event oriented task that will request a data re-connection whenever the network status changes, usually most importantly when the user changes networks aka they are roaming.

  • we need a set of network diagnostics tools which can generate real-time measurements that can be recorded alongside market charts to display connectivity performance per-provider.


Breakdown per bullet:

RE: Roaming

More or less the ideal UX is when a user reconnects a live running pikerd session, we are able to detect this and fire requests to reconnect the gateway with a faster timeout then the default :joy:.

Some brief web searching says start digging in these on linux:

  • https://github.com/svinota/pyroute2
    • btw this is probably useful for the ip rule stuff we need as per #329
    • nftables example: https://github.com/svinota/pyroute2/blob/master/examples/nftables.py
    • also see the website
    • example for monitoring Netlink events: https://github.com/svinota/pyroute2/blob/master/examples/iproute/ip_monitor.py
  • https://github.com/seveas/python-networkmanager

RE: connectivity metrics

A set of trio native network probe tools would be most ideal to be able to (dynamically) spawn tasks which record measurements using the same subsystems as FSP and data feeds. Likely we'll have to compromise to start with some kinda asyncio lib wrapping...

  • [ ] mtr is the classic tool with most of the functionality for all this: https://github.com/traviscross/mtr

    • [ ] there's a asyncio based wrapper py lib: https://github.com/matt-kimball/mtr-packet-python
  • [ ] there is the https://www.ip2location.com/ service which has free dbs for certain sets of geo data:

    • docs on the free dbs:
      • https://lite.ip2location.com/database/ip-country
      • https://lite.ip2location.com/database/px1-ip-country
    • their GH org: https://github.com/ip2location
    • a traceroute tool with python impl: https://www.ip2location.com/free/traceroute-application
    • official GH lib: https://github.com/ip2location/ip2trace-python
    • 3rd party foss client which levers the free dbs: https://github.com/chrislim2888/IP2Location-Python

goodboy avatar Jun 05 '22 01:06 goodboy

found a small script that seems to work with iproute2 pretty well, slightly modified from this one:

'''
Simplest example to monitor Netlink events with a Python script.
'''

from pyroute2 import IPRSocket
from pprint import pprint

ip = IPRSocket()
ip.bind()

while True:
    pprint(ip.get())

ip.close()

goodboy avatar Jun 06 '22 15:06 goodboy