News:

Precision Simulator update 10.182 (25 June 2025) is now available.
Navburo update 13 (23 November 2022) is now available.
NG FMC and More is released.

Main Menu

A new PSX router "frankenrouter"

Started by macroflight, Fri, 13 Jun 2025 09:39

macroflight

As mentioned in the Worldflight 2024 thread, I have started to write a PSX router/broker in Python.

The router is now somewhat stable and documented, All addons we have tested are now working when connected through the router.

Available on GitHub

Current features (version 0.5)
- Logging of the data streams sent and received from the PSX main server, all PSX main clients and all addons.
- Allow clients to stay connected to the router even when the PSX main server is restarted.
- Keeps the clients connected and automatically reconnects to the PSX main server (or shared cockpit master sim) if disconnected
- Read-only "observer" mode (clients can read PSX variables but not update anything)
- IP-based access control
- Password authentication (e.g for shared cockpit)
- Identifies addons and PSX instances and displays those names in the status display
- Statistics for data sent/received per client, variables sent by client, ...

Dependencies: only Python for the core router (no extra modules required), psutil and pywin32 for the optional identifier script)

Thanks to Hoppie for releasing psx.py (not used in the router, but got me started with the PSX network API in the first place), Hardy (for everything, really, but in particular the simple and powerful network API) and voipmeister for testing and shared cockpit ideas. And to all of you, for making this amazing community!

voipmeister

Thanks for writing frankenrouter! It's nice to discuss ideas and features, and to test the different versions.

It will be much more efficient over the internet than the crude TCP relay  8)

Switching between PSX master instances will be easy too.
Seb - (changed QuadFan to voipmeister @ 07.06.2025)

Jeroen Hoppenbrouwers

Don't spend too much time and effort on "security." IP whitelisting and passwords are nice but once you are actually listening on the open internet you want tougher things. Maybe you should just outsource all security to a good firewall (open only for known IPs) and require a VPN to even get in.

As usual, you don't need security until a joker appears that sees you streaming online and decides this is a wonderful target to show off his manlihood.


Hoppie
running ACARS and suffering

macroflight

Quote from: Jeroen Hoppenbrouwers on Fri, 13 Jun 2025 10:49Don't spend too much time and effort on "security." IP whitelisting and passwords are nice but once you are actually listening on the open internet you want tougher things. Maybe you should just outsource all security to a good firewall (open only for known IPs) and require a VPN to even get in.
I am not looking for anything more than making it slightly more difficult for said joker to send "pleaseBeSoKindAndQuit" to the shared cockpit setup. Or for that matter, for someone who flew shared cockpit with me last week to accidentally start his sim with the same settings, connect to mine and then load his favorite situ. :)

The password idea is an alternative to IP whitelisting for people behind CGN or with an IP address that change often. In that case a router in "slave sim mode" would connect to the master sim's router and send an addon= message (or some other arbitrary key) with an authentication token/password. Until a valid token is received the connection would not be able to send or receive data from the PSX network.

There is already a firewall between the sim network and the Internet, only the PSX port on the Internet-facing IP is forwarded to the PC that runs the router (or PSX main server if not using a router).

Hardy Heinlin

Thank you for the add-on! Does the name "Frankenrouter" imply any route to the Rocky Horror Picture Show?

macroflight

Quote from: Hardy Heinlin on Fri, 13 Jun 2025 11:23Thank you for the add-on! Does the name "Frankenrouter" imply any route to the Rocky Horror Picture Show?
At some point I started calling my own sim "FrankenSim" since it was put together from so many different components (PSX, MSFS, PSX.NET.MSFS.*, BACARS, Remote CDU, Simlink, ...). So the addons that are "official enough" to need a name so far: frankenusb (alternative to the PSX native USB support), frankenfreeze (icing tweak), frankenwind (use MSFS winds aloft) and now frankenrouter.

I'll let you know when I have developed the n'furter addon :)

Hardy Heinlin

Nice collection. I like Frankenstein's monster. I just bought a Blu-ray of "The Munsters".

voipmeister

#7
Quote from: Jeroen Hoppenbrouwers on Fri, 13 Jun 2025 10:49... to show off his manlihood.
;D  ;D

You're right about not wanting the router to include the only robust security, network devices like a decent firewall/router should take care of that. Be it source IP address filtering or a VPN. Alternatives are a zerotier or hamachi setup (haven't used hamachi for ages, so don't know the current state of things).

Quote from: macroflight on Fri, 13 Jun 2025 12:28At some point I started calling my own sim "FrankenSim" since it was put together from so many different components (PSX, MSFS, PSX.NET.MSFS.*,

It was today when I noticed the 'Worldfright' and Frankenstein logo on the checklist, when I got it printed and laminated ;D
Seb - (changed QuadFan to voipmeister @ 07.06.2025)

macroflight

A little teaser of the router status output:

12:34:42: [192.168.86.12:10747] 14 clients, 2485 keywords
12:34:42:                                     Local           Lines  Lines    Bytes    Bytes
12:34:42: id Identifier       Client IP        Port   Access   sent  recvd     sent    recvd
12:34:42:  1 localhost        127.0.0.1       53858     full  23933     83  1322811      720
12:34:42:  2 L:PSX Sounds     127.0.0.1       53904     full  23410    603  1315341     7843
12:34:42:  3 L:FrankenUSB     127.0.0.1       53913     full  22483   1499  1301307    19359
12:34:42:  4 localhost        127.0.0.1       53948     full  23865     33  1276773     1471
12:34:42:  5 localhost        127.0.0.1       53959     full  23816     45  1274663     1061
12:34:42:  6 localhost        127.0.0.1       53983     full  23791     30  1270674     1857
12:34:42:  7 localhost        127.0.0.1       53991     full  23774     23  1268774     1657
12:34:42:  8 localhost        127.0.0.1       54022     full  23629    131  1265317     2169
12:34:42:  9 localhost        127.0.0.1       54125     full  23515      0  1246158        0
12:34:42: 10 localhost        127.0.0.1       54212     full  23406      2  1236614       24
12:34:42: 12 CDUPAD           192.168.86.8    49853     full  23147     45  1219337      387
12:34:42: 13 L:EFB1           127.0.0.1       54789     full  20593      3  1069452       86
12:34:42: 20 localhost        127.0.0.1       56052     full   8758      1   389848       13
12:34:42: 21 R:voipmeister    REDACTED        59980     full   7211     56   312744     1065
The "identifier" can either come from the IP address whitelisting, or be learned (L: prefix) based on name= keywords sent by that addon or other some clever deduction. The R: prefix is used for another frankenrouter acting as a remote client to this one (and behind that one can a full PSX sim be hidden.

macroflight

Today the frankenrouter learned:
- measuring the round trip delay to other frankenrouters
- measuring the output delay (the time taken for asyncio write+drain, which I hope might give a hint if a client is slow or on a bad network)
- connecting to another frankenrouter with in-band (password) authentication.
- almost-read-only access (I allow demand= to be sent since that could in theory be a problem otherwise)

17:31:27: --------------------------------------------------------------------------------------------------------------
17:31:27: Frankenrouter FrankenSim listening on 10748, 2473 keywords cached
17:31:27: SERVER 127.0.0.1:10747 unknown, average output delay 0.000036 s
17:31:27: 2 clients, pwd: gl3IrWKEFz7UvXAST4                 Local     ines  Lines  Bytes  Bytes    ping  Output
17:31:27: id Identifier       Client IP        Port   Access Clients   sent  recvd   sent  recvd  RTT(s) delay(s)
17:31:27:  1 localhost        127.0.0.1       47002     full       0   2469      0  48071      0       - 0.000009
17:31:27:  5 unknown          192.168.86.2    39128 noaccess       0      0      0      0      0       -   NODATA
17:31:27: --------------------------------------------------------------------------------------------------------------
17:31:27: Client ('192.168.86.2', 39128) identified as frankenrouter Kurt
17:31:29: Client R:Kurt has authenticated
17:31:32: --------------------------------------------------------------------------------------------------------------
17:31:32: Frankenrouter FrankenSim listening on 10748, 2473 keywords cached
17:31:32: SERVER 127.0.0.1:10747 unknown, average output delay 0.000036 s
17:31:32: 2 clients, pwd: gl3IrWKEFz7UvXAST4                 Local     Lines  Lines  Bytes  Bytes    ping  Output
17:31:32: id Identifier       Client IP        Port   Access Clients   sent  recvd   sent  recvd  RTT(s) delay(s)
17:31:32:  1 localhost        127.0.0.1       47002     full       0   2469      0  48071      0       - 0.000009
17:31:32:  5 R:Kurt           192.168.86.2    39128     full       0   2471      4  48165    187   0.000 0.000008
17:31:32: --------------------------------------------------------------------------------------------------------------

macroflight

#10
EDIT: contact me if you want a binary version. If you have Python installed, you can just grab the latest version of the frankenrouter.py from the testing branch of the repo at https://github.com/macroflight/psxhacks/tree/testing

Note: I still haven't figured out why BACARS and (more importantly) PSX.NET.Router does not work when connected through frankenrouter. Many hours, many theories, many failures... For my test setup, I simply configure BACARS and PSX.NET.Router to connect directly to the PSX main server.

The router itself seems stable, I have flown several multi-hour flights, including shared cockpit, using it.

For shared cockpit the idea is to have one router in the "slave sim" that makes one connection to the router in the master sim (and that connection can use password authentication). But for stress test purposes, I've daisy-chained 11 frankenrouters with a PSX instance in each end - still works. :)

There's also some rudimentary performance monitoring: if two routers are connected, they will send "ping" packages over the PSX network between them to measure latency.

Logging of all traffic can be enabled. The current log format is one file with all data streams, but that can of course be changed. Example:

2025-06-22T17:35:37.475151 <<< [PSX main server] Qi274=312
2025-06-22T17:35:37.475663 >>> [clients 1,2,...] Qi274=312
2025-06-22T17:35:37.550131 <<< [PSX main server] Qs121=-363;0;5.594834030705165;502532;0;1.0066104660996515;0.2146289269610886
2025-06-22T17:35:37.550664 >>> [clients 1,2,...] Qs121=-363;0;5.594834030705165;502532;0;1.0066104660996515;0.2146289269610886
2025-06-22T17:35:37.721959 <<< [client 6       ] Qi198=50690
2025-06-22T17:35:37.721959 >>> [PSX main server] Qi198=50690
2025-06-22T17:35:37.721959 >>> [clients 1,2,...] Qi198=50690
2025-06-22T17:35:37.761746 <<< [PSX main server] Qs121=-337;0;5.594834030705165;502775;0;1.0066104660996515;0.2146289269610886
2025-06-22T17:35:37.762264 >>> [clients 1,2,...] Qs121=-337;0;5.594834030705165;502775;0;1.0066104660996515;0.2146289269610886
2025-06-22T17:35:37.973525 <<< [PSX main server] Qs121=-313;0;5.594834030705165;502961;0;1.0066104660996515;0.2146289269610886
2025-06-22T17:35:37.974036 >>> [clients 1,2,...] Qs121=-313;0;5.594834030705165;502961;0;1.0066104660996515;0.2146289269610886
2025-06-22T17:35:38.165506 <<< [PSX main server] Qs562=b313;540;
2025-06-22T17:35:38.165506 >>> [clients 1,2,...] Qs562=b313;540;
2025-06-22T17:35:38.165506 <<< [PSX main server] Qs483=0;225;225;136;1;40;
2025-06-22T17:35:38.166018 >>> [clients 1,2,...] Qs483=0;225;225;136;1;40;
2025-06-22T17:35:38.184852 <<< [PSX main server] Qs121=-290;0;5.594834030705165;503141;0;1.0066104660996515;0.2146289269610886
2025-06-22T17:35:38.184852 >>> [clients 1,2,...] Qs121=-290;0;5.594834030705165;503141;0;1.0066104660996515;0.2146289269610886
2025-06-22T17:35:38.228476 <<< [client 6       ] Qi198=50690

Apart from the traffic logging, the router prints regular status information which is also saved to a log file. Example:

14:56:55: --------------------------------------------------------------------------------------------------------------
14:56:55: Frankenrouter inception-8 port 10008, 2465 keywords cached, uptime 122 s, server connects 1, self restarts 0
14:56:55: Password: None Read-only: None
14:56:55: SERVER 127.0.0.1:10009 R:inception-9, RTT mean/max: 0.2/1.0 ms, output delay avg/max 0.0/0.1 ms
14:56:55: 1 clients                             Local                   Lines  Lines  Bytes  Bytes FRDP ms   Delay us
14:56:55: id Identifier         Client IP        Port   Access Clients   sent  recvd   sent  recvd mean  max mean  max
14:56:55:  1 R:inception-7      127.0.0.1       48596     full       1   5297    270 201702  12320  0.2  1.0  0.0  0.0
14:56:55: --------------------------------------------------------------------------------------------------------------
14:56:55: pitch=0.3 bank=0.0 heading=302 altitude_true=37290 TAS=487 lat=48.170512 lon=1.208847
14:57:55: --------------------------------------------------------------------------------------------------------------
14:57:55: Frankenrouter inception-8 port 10008, 2465 keywords cached, uptime 182 s, server connects 1, self restarts 0
14:57:55: Password: None Read-only: None
14:57:55: SERVER 127.0.0.1:10009 R:inception-9, RTT mean/max: 0.2/1.1 ms, output delay avg/max 0.0/0.1 ms
14:57:55: 1 clients                             Local                   Lines  Lines  Bytes  Bytes FRDP ms   Delay us
[...]

voipmeister

I've been running frankenrouter in my sim from the start, both for shared and non-shared cockpit flights. It works with my home made script for my radio (an Arduino connected via USB and a python script on the host). PSX.NET.MSFS.Router is a bit problematic indeed, hope we find the culprit. I haven't had any issues during the flights I made so far. Good stuff!  8)
Seb - (changed QuadFan to voipmeister @ 07.06.2025)

macroflight

Version 0.5 is now released (download from first post in thread). This version works well in my sim. Finally all my addons can be used through the router. :)

voipmeister

Testing as I'm writing this - good stuff!  8)
Seb - (changed QuadFan to voipmeister @ 07.06.2025)