TwinFan / XPMP2

Multiplayer library for X-Plane 11/12 with instancing, TCAS override, and sound
https://twinfan.github.io/XPMP2/
Other
24 stars 16 forks source link

Synch aircraft across a networked multi-pc setup #22

Closed TwinFan closed 3 years ago

TwinFan commented 3 years ago

Current Situation / Problem In a networked multi-PC setup several only loosely coupled instances of X-Plane run in parallel, usually to drive different screens. Running LiveTraffic or any other XPMP2-based plugin will not guarantee that all planes are always fully aligned and placed at the exact same location. This will look ugly when planes move across screens driven by different PCs.

Suggested Solution Synchronize plane objects across the network, driven by a master. Basic design ideas:

Benefits Better looking support for a networked setup

Additional context Originally discussed as issue TwinFan/LiveTraffic#126, but now decided to be solved centrally in XPMP2 and hence moved here.

TwinFan commented 3 years ago

Technical proof of concept done: The plugin "XPMP2 Remote Client" receives aircraft information from other XPMP2-based plugins and displays planes using the same CSL model at the same location and attitude.

Some selected Log.txt lines involving the new "XPMP2 Remote Client", displaying the 3 circling planes of two XPMP2 Sample-Plugins, one locally, one remotely. Local machine is a Mac, remote machine is a Windows PC:

2:10:51.929 XPMP2_RC: XPMP2 Remote Client 0.01 starting up...
2:10:51.929 RC/XPMP2 DEBUG Remote.cpp:563/RmtRecvMain: Receiver started listening to 239.255.1.1:49788
...
2:10:54.175 XPMP2-Sample/XPMP2 DEBUG Aircraft.cpp:573/CreateInstances: Aircraft 0x000001: Instance created
2:10:54.175 XPMP2-Sample/XPMP2 DEBUG Remote.cpp:428/RmtSendMain: Listening to 239.255.1.1:49788, waiting for someone interested in our data...
2:10:54.175 XPMP2-Sample/XPMP2 DEBUG Aircraft.cpp:573/CreateInstances: Aircraft 0x123456: Instance created
2:10:54.175 XPMP2-Sample/XPMP2 DEBUG Aircraft.cpp:573/CreateInstances: Aircraft 0xABCDEF: Instance created
2:10:54.175 XPMP2-Sample/XPMP2 INFO  Remote.cpp:460/RmtSendMain: Received word from 192.168.178.71:31938, will start sending aircraft data
2:10:53.828 XPMP2_RC DEBUG Client.cpp:237/ClientProcSettings: Received settings from XPMP2-Sample (4) @ 192.168.178.36:31938
2:10:53.828 XPMP2_RC INFO  Client.cpp:248/ClientProcSettings: First data received from XPMP2-Sample @ 192.168.178.36:31938
2:10:56.076 RC/XPMP2 DEBUG Aircraft.cpp:573/CreateInstances: Aircraft 0x000001: Instance created
2:10:56.116 RC/XPMP2 DEBUG Aircraft.cpp:573/CreateInstances: Aircraft 0xABCDEF: Instance created
2:10:56.140 RC/XPMP2 DEBUG Aircraft.cpp:573/CreateInstances: Aircraft 0x123456: Instance created
...
2:11:11.184 XPMP2_RC DEBUG Client.cpp:237/ClientProcSettings: Received settings from XPMP2-Sample (5) @ 192.168.178.71:31938
2:11:11.184 XPMP2_RC INFO  Client.cpp:248/ClientProcSettings: First data received from XPMP2-Sample @ 192.168.178.71:31938
2:11:11.958 RC/XPMP2 DEBUG Aircraft.cpp:204/Create: Replaced duplicate _modeS_id 0x000001 with new unique value 0x000002
2:11:11.958 RC/XPMP2 DEBUG Aircraft.cpp:204/Create: Replaced duplicate _modeS_id 0x123456 with new unique value 0x000003
2:11:11.958 RC/XPMP2 DEBUG Aircraft.cpp:204/Create: Replaced duplicate _modeS_id 0xABCDEF with new unique value 0x000004
2:11:11.958 RC/XPMP2 DEBUG Aircraft.cpp:573/CreateInstances: Aircraft 0x000003: Instance created
2:11:11.958 RC/XPMP2 DEBUG Aircraft.cpp:573/CreateInstances: Aircraft 0x000004: Instance created
2:11:12.096 RC/XPMP2 DEBUG Aircraft.cpp:573/CreateInstances: Aircraft 0x000002: Instance created

I've also recompiled LiveTraffic (no code change necessary at all) and had it feed the busy traffic at KLAX...also works!

0:00:00.000 XPMP2_RC: XPMP2 Remote Client 0.01 starting up...
0:00:00.000 RC/XPMP2 DEBUG Remote.cpp:563/RmtRecvMain: Receiver started listening to 239.255.1.1:49788
...
0:02:05.140 XPMP2_RC DEBUG Client.cpp:237/ClientProcSettings: Received settings from LiveTraffic (3) @ 192.168.178.36:31938
0:02:05.140 XPMP2_RC INFO  Client.cpp:248/ClientProcSettings: First data received from LiveTraffic @ 192.168.178.36:31938
0:02:11.444 RC/XPMP2 DEBUG Aircraft.cpp:573/CreateInstances: Aircraft 0xA8B939: Instance created
0:02:11.444 RC/XPMP2 DEBUG Aircraft.cpp:573/CreateInstances: Aircraft 0xA97A67: Instance created

Don't worry...there's still a bit to go, especially more efficient position updates (currently it's only using full-details message for each position update) and handling of animation dataRefs, which aren't transferred at all at the moment, lot's of special situation handling (currently the planes never go away ;-) )...

TwinFan commented 3 years ago

Works, (bad quality) video available showing how planes move swiftly between screens.

@HellGL, would you be interested in Beta testing? If so, please contact me on Discord (TwinFan#7161, preferred, beta testing is coordinated in a channel of the LiveTraffic server), or via private message on X-Plane.org. I would appreciate the help!

TwinFan commented 3 years ago

Todo list after 8 hour overnight test with 2 X-Plane instances runnin a cross-feed scenario (ie. both instances send and receive: Win as Master, running LiveTraffic at KLAX, XPMP2-Sample, and XPMP2 Remote Client; Max as External Visual running XPMP2-Sample and XPMP2 Remote Client)

Logs_XPMP2_Overnight_20201118_19.zip

HellGL commented 3 years ago

I started my test yesterday with 4 clients and had massive problems in my network. After tracking the problem for one day it comes down to XPMP2 flooding the network with short (8 bytes of data, all the same) UDP multicast messages to 239.255.1.1:49788 (>100000 packets per second). Did anybody experience a similar problem? Maybe not even noticing it as a problem, because it just increases network load? Here it caused my networked hardware to loose connection which I immediately recognize.