till213 / SkyDolly

Sky Dolly connects with Flight Simulator 2020 and records the flight path and basic instruments for replay.
MIT License
77 stars 9 forks source link

SkyDolly on Remote PC via SimConnect? #123

Closed StekuSteku closed 2 months ago

StekuSteku commented 7 months ago

Is this possible to run SkyDolly on remote networked PC via SimConnect? How to configure this? I'm flying in VR googles so I can't see the desktop of my main PC on which the sim is running. I have a networked PC on which I have some tools running and I can control it remotely and see it's desktop via AllInOneTablet VNC function by Flightsimulator.me. Would be great for me to remotely operate the SkyDolly on the networked PC.

As alternative - would it be possible to control the SkyDolly on the main PC (on which the sim is running) by buttons on the yoke, wihtout the need to have SkyDolly in focus for keyboard shortcuts?

till213 commented 7 months ago

Yes, it should be possible to establish a SimConnect connection over a network between PCs (not XBox unfortunately).

To get this disclaimer quickly out of the way:

That being said, the setup boils down to:

The exact content of those .XML and .CFG configuration files and where to place them exactly is described here:

https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/SimConnect_CFG_Definition.htm

https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/SimConnect_XML_Definition.htm

I'd be curious to know whether it'll work!

UPDATE: There exists also another configuration file for the server (MSFS), for completeness sake:

https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/SimConnect_INI_Definition.htm

till213 commented 7 months ago

As a heads-up: the upcoming Sky Dolly v0.17 will allow you to define keyboard shortcuts such as CTRL + R for the basic replay / record commands (record, stop/pause, play, …) that you can execute within MSFS itself (so Sky Dolly would simply run in the background).

Not sure how much help that would be for VR, but there you have it.

Then there is also a very early feature branch introducing a Sky Dolly toolbar that will provide the basic record/replay functionality in a dialog in MSFS itself:

https://github.com/till213/SkyDolly/tree/feature-webui

But the later is very much in the future.

till213 commented 7 months ago

Oh and yes, please let me know if you had any success with the SimConnect network configuration, whether it worked at all, any troubles you had to solve… you could perhaps even attach your configuration files (removing any „personal setup“ beforehand, such as IP addresses, even if local), as a reference for others.

:)

StekuSteku commented 7 months ago

So far my attempts to connect via SimConnect from the remote PC failed. I succeeded with connecting other apps (Axis and Ohms - there is a special option there which must be checked to allow connection over network - seems like network access must be somehow enabled) but no success yet with SkyDolly.

StekuSteku commented 7 months ago

When flying in VR the desktop of the sim PC is not visible. So it's impossible to move the mouse focus from sim window to any other app window. Any keyboard shortcuts (or even better USB/HID button bindings) must work without the need to have SkyDolly in focus, to be useful. I understand this is what will be implemented, I will gladly test it. I have the software (Axis and Ohs) running on the sim PC allowing me binding keyboard shortcut to USB/HID button, so keyboard shortcut available in the sim window in focus, should be sufficient.

jaber70599 commented 4 months ago

may I join this conversation. Being not successful in connecting remote Skydolly to FS2020 but being successful in establishing the simconnect communication between remote client and server. Here are the Configuation/Installation steps:

Precondition:

1) create or update SimConnect.xml on server side as follows (only first section was changed):

<?xml version="1.0" encoding="Windows-1252"?>

<SimBase.Document Type="SimConnect" version="1,0">
    <Descr>SimConnect Server Configuration</Descr>
    <Filename>SimConnect.xml</Filename>
    <Disabled>False</Disabled>
    <SimConnect.Comm>
     <Disabled>False</Disabled>
        <Descr>Static IP4 port</Descr>
        <Protocol>IPv4</Protocol>
        <Scope>global</Scope>
        <Address>0.0.0.0</Address>
        <Port>1500</Port>
        <MaxClients>64</MaxClients>
        <MaxRecvSize>4096</MaxRecvSize>
    <DisableNagle>false</DiableNagle>
    </SimConnect.Comm>
    <SimConnect.Comm>
        <Descr>Static IP6 port</Descr>
        <Protocol>IPv6</Protocol>
        <Scope>local</Scope>
        <Port>501</Port>
        <MaxClients>64</MaxClients>
        <MaxRecvSize>41088</MaxRecvSize>
    </SimConnect.Comm>
    <SimConnect.Comm>
        <Descr>Custom Pipe</Descr>
        <Protocol>Pipe</Protocol>
        <Scope>local</Scope>
        <Port>Custom\SimConnect</Port>
        <MaxClients>64</MaxClients>
        <MaxRecvSize>41088</MaxRecvSize>
    </SimConnect.Comm>
    <SimConnect.Comm>
        <Descr>Dynamic IP4 port</Descr>
        <Protocol>IPv4</Protocol>
        <Scope>local</Scope>
        <Port>0</Port>
        <MaxClients>64</MaxClients>
        <MaxRecvSize>41088</MaxRecvSize>
    </SimConnect.Comm>
    <SimConnect.Comm>
        <Descr>Dynamic IP6 port</Descr>
        <Protocol>IPv6</Protocol>
        <Scope>local</Scope>
        <Port>0</Port>
        <MaxClients>64</MaxClients>
        <MaxRecvSize>41088</MaxRecvSize>
    </SimConnect.Comm>
    <SimConnect.Comm>
        <Descr>Default FSX Pipe</Descr>
        <Protocol>Pipe</Protocol>
        <Scope>local</Scope>
        <Port>0</Port>
        <MaxClients>64</MaxClients>
        <MaxRecvSize>41088</MaxRecvSize>
    </SimConnect.Comm>
</SimBase.Document>

2) open firewall on server side for port 1500 for incoming requests

3) start FS2020

4) check ports on server side (open cmd terminal as admin, execute netstat, look for port 1500)

5) install "simVarsWatcher" from FS2020 SDK on client side

6) update SimConnect.cfg in installation directory of simVarsWatcher on client side as follows:

; global IPv4, use the configuration of the remote server
[SimConnect]
Protocol=IPv4
Address=xxx.xxx.xxx.xxx
Port=1500
MaxReceiveSize=4096

7) replace xxx.xxx.xxx.xxx with server IP Adress

8) open firewall on client side port 1500 for outgoing requests

9) start simvarswatcher

10) click "Connect"

11) Result: Connection is successful

12) copy SimConnect.cfg from "simVarsWatcher" to Skydolly

13) start Skydolly

14) execute one entry of Skydolly location database

15) Failed

till213 commented 2 months ago

Dear all,

Sorry for not having replied in the past! This is just to say that this issue is still "on my radar" and I will look into this while finishing the upcoming v0.17.0 release (that I have started working on again).

till213 commented 2 months ago

Any keyboard shortcuts (or even better USB/HID button bindings) must work without the need to have SkyDolly in focus, to be useful. I understand this is what will be implemented, I will gladly test it.

Yes, that's exactly how it is meant and implemented in the upcoming Sky Dolly v0.17: you define the desired keyboard shortcuts in Sky Dolly, but they are really "registered" with MSFS, so you execute those shortcuts in MSFS (which then sends the corresponding "event" to Sky Dolly).

Sky Dolly can run completely minimised.

But this just as a quick side-note...

till213 commented 2 months ago

Aha... I think I found the culprit: I am using the connection parameter:

// Open ConfigIndex parameter special value
static const DWORD SIMCONNECT_OPEN_CONFIGINDEX_LOCAL   = -1;   // ignore SimConnect.cfg settings, and force local connection

(as defined in the official SimConnect.h header)

;)

till213 commented 2 months ago

I thought I had added a comment here yesterday, but it seems I forgot to "commit" it.

Anyway, network connections (IPv4 and IPv6) will work in the upcoming Sky Dolly v0.17 - in fact, I went the extra mile and added new settings, to conventiently switch between the following "connection types":

grafik

No restart required when changing those settings: Sky Dolly will automatically try to reconnect with MSFS upon changes. In increasing intervals (that happen to be the Fibbonacci numbers in seconds - because why not ;)).

Those connection types refer to the connection settings in the SimConnect.cfg that will ship with Sky Dolly:

# This is the default Sky Dolly specific SimConnect client configuration.
# In Sky Dolly, go to File | Settings... | Flight Simulator and change
# the configuration (no restart required: Sky Dolly will reconnection
# automatically).
#
# All configurations work with the default SimConnect.xml server configuration
# that is located at:
#
# Steam: C:\Users\<user_name>\AppData\Roaming\Microsoft Flight Simulator\
# Microsoft store: C:\Users\<user_name>\AppData\Local\Packages\Microsoft.FlightSimulator_8wekyb3d8bbwe\LocalCache\
#
# However you may adjust the below IPv4 respectively IPv6 addresses and port numbers
# accordingly, in order to have MSFS and Sky Dolly run on different machines.
#
# For documentation about this SimConnect client configuration (SimConnect.cfg) also refer to:
# https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/SimConnect_INI_Definition.htm
#
# For documentation about the SimConnect server configuration (SimConnect.xml) also refer to:
# https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/SimConnect_XML_Definition.htm
#
# Please take note of the following notice:
#
# "IMPORTANT! This section relates to a legacy process intended for use with Microsoft Flight Simulator X.
# It is still valid for Microsoft Flight Simulator but may be changed or even removed at some time in the
# future and should only be used for support of legacy add-ons."

# Connection type: "Local (pipe)"
#
# This is the default connection type: MSFS and Sky Dolly run on the same local machine
[SimConnect]
Protocol=Pipe
Port=Custom/SimConnect
Address=127.0.0.1

# Connection type: "Network 1 (IPv4)"
#
# This is the network configuration with IPv4: MSFS and Sky Dolly may run on the same local
# machine (local address 127.0.0.1), or on different machines. In the later case adjust the
# 'Address' with the corresponding IPv4 address of the server (running MSFS).
[SimConnect.1]
Protocol=IPv4
Address=127.0.0.1
Port=500
MaxReceiveSize=41088

# Connection type: "Network 2 (IPv6)"
#
# This is the network configuration with IPv6: MSFS and Sky Dolly may run on the same local
# machine (local address ::1), or on different machines. In the later case adjust the
# 'Address' with the corresponding IPv6 address of the server (running MSFS).
[SimConnect.2]
Protocol=IPv6
Address=::1
Port=500
MaxReceiveSize=41088

Those settings will work "out of the box" with the automatically generated SimConnect.xml server configuration. For an actual network configuration with two PCs one needs to edit the above SimConnect.cfg and adjust IP addresses (and port numbers) as needed. Just as outlined in a previous post above.

till213 commented 2 months ago

Sky Dolly v0.17 has just been released. I would be curious how it goes with setting up an actual network connection :)

jaber70599 commented 2 months ago

Tested the remote feature steps: 1) installed skydolly 0.17 on a notebook 2) Setup skydolly (see below) 3) Setup fs2020 (used this simconnect cfg and xml: https://github.com/till213/SkyDolly/issues/123#issuecomment-1942144175) 4) Result: Remote connection to fs2020 was successful only when choosing connection type = local. Connection type= network1 failed. 5) Successfully tested location/teleport 6) Successfully tested recording 7) Successfully tested replay 8) Note: in replay mode there are some microstutters in fs2020. Especially seen when banking the plane. when recording there are no microstutters.

till213 commented 2 months ago

Thank you for your quick reply!

Issue 1 - SimConnect.cfg Client Configuration

4. Result: Remote connection to fs2020 was successful only when choosing connection type = local.  Connection type= network1 failed.

This is totally to be expected ;)

The three options in Sky Dolly refer to the three sections in the SimConnect.cfg as provided by Sky Dolly - as documented in that very file ;)

So you need to edit one of those three sections accordingly:

# Connection type: "Local (pipe)"
#
# This is the default connection type: MSFS and Sky Dolly run on the same local machine
[SimConnect]
... setup for pipe (local) related connection with (implicit) index 0 goes here...

# Connection type: "Network 1 (IPv4)"
#
# This is the network configuration with IPv4: MSFS and Sky Dolly may run on the same local
# machine (local address 127.0.0.1), or on different machines. In the later case adjust the
# 'Address' with the corresponding IPv4 address of the server (running MSFS).
[SimConnect.1]
... setup for IPv4 related connection with index 1 goes here...

# Connection type: "Network 2 (IPv6)"
#
# This is the network configuration with IPv6: MSFS and Sky Dolly may run on the same local
# machine (local address ::1), or on different machines. In the later case adjust the
# 'Address' with the corresponding IPv6 address of the server (running MSFS).
[SimConnect.2]
... setup for IPv6 related connection with index 1 goes here...

In fact, the dropdown list in Sky Dolly merely sets the "configuration index 0, 1 or 2" (refering to the exact above configuration setup with three sections, indexed 0, 1 and 2) and passes that index to the SimConnect "connect" function - that's all.

Of course you are free to setup those three sections as you want - or only use one section (as you did in your example). But those sections possibly won't match with the (hardcoded) assumttion that "section 0 is a pipe, section 1 is IPv4 and section 2 is IPv6".

Well, I think you are seeing my point now ;)

Of course a more elegant solution would have been that Sky Dolly actually parses the SimConnect.cfg upon startup itself, auto-detects the connection type (e.g. according to the Protocol) and dynamically populates the dropdown list. That would be doable, but given my humble assumption that probably only few people will make use of this feature and that the whole network part is "deprectated" anyway (by Asobo) I thought that providing a "ready to adapt" sample SimConnect.cfg and "hard-coded" support for three configuration sections would sufice - for now :)

Issue 2 - Delay (aka "Stutters") over TCP/IP

8. Note: in replay mode there are some microstutters in fs2020. Especially seen when banking the plane. when recording there are no microstutters.

This is somewhat expected. ;)

First, naturally there is a higher "time difference" between MSFS sending the "simulated frame" event and Sky Dolly responding with the corresponding aircraft parameters (position, attitude, ... and all the other "simulation variables"). TCP/IP has a somewhat higher overhead than a "pipe", which is "in-memory" process communication (extremely little to no overhead). Especially if the given data packet has to run down and up again the entire TCP/IP stack (in a "real" computer-to-computer communication scenario, that is).

I actually tested both IPv4 and IPv6 in a local setup - "localhost" respectively IPv6 address :1 that also refers to the "localhost" - and I did not observe more stutters than I usually have anyway. But of course that very much also depends on your actual "horsepower" (for instance I do have an iMac 27" from 2020 with some Intel i9 and an AMD GPU that barely qualifies as "mid-range PC" - so I am used to some stutters every then and when anyway).

But I noticed something else that I was about to mention before already: in your server configuration - SimConnect.xml - you actually keep the Nagle's Algorithm enabled - why? Is there a particular reason, or did you just copy this SimConnect.xml configuration from somewhere else (possibly some older FS X setup perhaps)?

Because while I am not sure what the default value would be, explicitly having an entry like

<DisableNagle>false</DiableNagle>

will actually keep it enabled (yes, that's a double-negation: disable = false -> enable ;)) So to reduce lag you should definitively set this option to true.

Nagle's Algorithm

In case you have never heard about the Nagle's Algorithm: it holds data packets back until there is enough data in total to "send over the TCP/IP wire", or until some time delay threshold has been reached - in any case there is usually some delay introduced. And this is exaclty a wanted effect, because it reduces the TCP/IP overhead per actual data payload. So not each and every tiny bit of data is put into its own TCP/IP envelope and possibly congesting the transmission medium.

So this little delay is typically not relevant for "normal TCP/IP traffic", but certainly undesired for "real-time traffic" - especially also in multiplayer games and any other time-critical app like SimConnect where the smallest data packet is best sent as fast as possible - and pronto, please! ;))

Also your "maximum receive size" (4096) is way smaller than in the default generated SimConnect.xml (where it is set to 41088), but not sure how much impact this has:

<MaxRecvSize>4096</MaxRecvSize>

Also refer to the default SimConnect.xml available here: https://docs.flightsimulator.com/html/assets/Files/SimConnect/SimConnect.xml

By the way: you can move the SimConnect.xml to another place, restart MSFS and a new SimConnect.xml will be generated in your MSFS data folder.

Here is mine (unchanged), for reference:

Default SimConnect.xml:

<?xml version="1.0" encoding="Windows-1252"?>

<SimBase.Document Type="SimConnect" version="1,0">
    <Descr>SimConnect Server Configuration</Descr>
    <Filename>SimConnect.xml</Filename>
    <SimConnect.Comm>
        <Descr>Static IP4 port</Descr>
        <Protocol>IPv4</Protocol>
        <Scope>local</Scope>
        <Port>500</Port>
        <MaxClients>64</MaxClients>
        <MaxRecvSize>41088</MaxRecvSize>
    </SimConnect.Comm>
    <SimConnect.Comm>
        <Descr>Static IP6 port</Descr>
        <Protocol>IPv6</Protocol>
        <Scope>local</Scope>
        <Port>501</Port>
        <MaxClients>64</MaxClients>
        <MaxRecvSize>41088</MaxRecvSize>
    </SimConnect.Comm>
    <SimConnect.Comm>
        <Descr>Custom Pipe</Descr>
        <Protocol>Pipe</Protocol>
        <Scope>local</Scope>
        <Port>Custom\SimConnect</Port>
        <MaxClients>64</MaxClients>
        <MaxRecvSize>41088</MaxRecvSize>
    </SimConnect.Comm>
    <SimConnect.Comm>
        <Descr>Dynamic IP4 port</Descr>
        <Protocol>IPv4</Protocol>
        <Scope>local</Scope>
        <Port>0</Port>
        <MaxClients>64</MaxClients>
        <MaxRecvSize>41088</MaxRecvSize>
    </SimConnect.Comm>
    <SimConnect.Comm>
        <Descr>Dynamic IP6 port</Descr>
        <Protocol>IPv6</Protocol>
        <Scope>local</Scope>
        <Port>0</Port>
        <MaxClients>64</MaxClients>
        <MaxRecvSize>41088</MaxRecvSize>
    </SimConnect.Comm>
    <SimConnect.Comm>
        <Descr>Default FSX Pipe</Descr>
        <Protocol>Pipe</Protocol>
        <Scope>local</Scope>
        <Port>0</Port>
        <MaxClients>64</MaxClients>
        <MaxRecvSize>41088</MaxRecvSize>
    </SimConnect.Comm>
</SimBase.Document>

And coincidentally the client SimConnect.cfg as shipped with Sky Dolly will work "out of the box" with this very default setup - on the same "localhost", that is.

Summary:

<DisableNagle>true</DiableNagle>

But it really looks that networking per se actually works now, I am glad to hear that - thanks again for your confirmation :)

jaber70599 commented 2 months ago

Thank you for your thorough explanations.

You are right I just copied my network config from other sources. I will comply with your recommendations.

Best Regards from Bawü jaber70599 aka DocDressler