Board index FlightGear Development

How does the Multiplayer Protocol work?

FlightGear is opensource, so you can be the developer. In the need for help on anything? We are here to help you.
Forum rules
Core development is discussed on the official FlightGear-Devel development mailing list.

Bugs can be reported in the bug tracker.

How does the Multiplayer Protocol work?

Postby Rupert » Tue Dec 09, 2014 9:55 am

Hi,

I was wondering how the multiplayer protocol took parameters.
EG: Is the format:

altitude speed lat lon

Or maybe

speed lat lon altitude

How are online planes injected into the multiplayer system?
So far, all I've found is that the multiplayer planes are in ai/models/ in the property browser, but is that the only directory where all of that data is stored?

One more thing, after connecting to FG using telnet, if I want to create some variables, I do, for example: set foo 3
But that 3 is stored inside foo as a string. Using telnet, how do I change the variable type to an integer for the property tree to store?

Thanks for any help.
Rupert
 
Posts: 39
Joined: Fri Dec 02, 2011 4:21 am

Re: How does the Multiplayer Protocol work?

Postby Johan G » Tue Dec 09, 2014 12:12 pm

As it might help get you a better suited answer, could you explain what you are trying to understand and what you are trying to do? It might turn out that the things you are asking for is not really what you need (or of course that they indeed are). ;)
Low-level flying — It's all fun and games till someone looses an engine. (Paraphrased from a YouTube video)
Improving the Dassault Mirage F1 (Wiki, Forum, GitLab. Work in slow progress)
Johan G
Moderator
 
Posts: 5960
Joined: Fri Aug 06, 2010 5:33 pm
Location: Sweden
Callsign: SE-JG
IRC name: Johan_G
Version: 3.0.0
OS: Windows 7, 32 bit

Re: How does the Multiplayer Protocol work?

Postby Hooray » Tue Dec 09, 2014 1:19 pm

You could also try running a forum search, which should bring up quite a few related discussions, containing additional pointers: http://wiki.flightgear.org/Multiplayer_protocol

The main keywords for finding relevant discussions are these:
  • multiplayer
  • protocol
  • XDR
  • encoded
  • UDP
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11925
Joined: Tue Mar 25, 2008 8:40 am

Re: How does the Multiplayer Protocol work?

Postby Rupert » Tue Dec 09, 2014 1:34 pm

I'm just playing around with FlightGear.
What I'd like to do is inject traffic from an external source into FlightGear.
The source gives altitude, speed, heading, model type, etc and then FlightGear inserts an aircraft at that position.
The "external source" would be me, I'd like to manually insert data and see what happens/what results.

Nothing serious here, as I said before, I'm just playing around with the code. I'm just curious how you would go about doing this. :)

I was actually having a look at that same wiki page. The "data of position messages" section, with all the various input that it needs, seems quite complicated, is there a simpler way? One which only needs the basic parameters like heading, altitude, speed, etc? After all, I just want to have a look at how the system works without worrying about vectors and such.

Thanks again for the replies.

EDIT: Just tried a telnet command: telnet mpserver04.flightgear.org 5001

This returns:

Code: Select all
# This is mpserver04.flightgear.org
                                   # FlightGear Multiplayer Server v0.11.6
                                                                          # usin
g protocol version v1.1 (LazyRelay enabled)
                                           # This server is tracked: 62.112.194.
20
  # 21 pilot(s) online
                      AF2222@mpserver01: 4188141.647448 187878.462437 4790773.31
9650 49.001817 2.568545 356.251290 -1.321110 3.557633 0.434914 Aircraft/777/Mode
ls/777-200ER.xml
                thuko48@mpserver01: 4736391.046509 2823382.221423 3218773.248801
 30.441288 30.799343 39685.631547 -2.047747 -1.631852 1.421232 Aircraft/777/Mode
ls/777-300ER.xml
                __philo@mpserver01: 197161.098743 -4394321.959199 4614532.783444
 46.563399 -87.431019 27127.354516 -2.395172 0.054339 0.053436 Aircraft/il-96-40
0/Models/il-96-400.xml
                      CHT0020@mpserver01: 815938.973427 -1125744.229870 6214216.
352191 77.470188 -54.065414 33088.227151 -0.360156 3.251962 0.294273 Aircraft/74
7-8i/Models/747-8i.xml
                      KA5NSK@mpserver01: 4571683.297299 138762.310152 4438074.14
9088 44.329411 1.738540 17493.901654 -2.843887 -0.353577 1.150815 Aircraft/Lockh
eed1049h/Models/Lockheed1049h.xml
                                 ox-tuy@mpserver01: -2518092.943774 -4449893.225
644 3806260.996057 36.849665 -119.504530 12062.959625 -2.055322 0.906777 -0.2337
14 Aircraft/A340-600/Models/A340-600-Models.xml
                                               DRG-38@mpserver01: 6314174.777130
 929602.099537 170344.162892 1.539169 8.375185 20962.168057 -1.793580 -0.876558
1.815687 Aircraft/777/Models/777-200.xml
                                        AA1717@mpserver01: 840771.997039 -488660
6.888561 4004173.680711 39.110814 -80.237480 11980.431416 -2.257459 -0.122272 0.
199598 Aircraft/707/Models/707.xml
                                  LEVS_TW@mpserver01: 4856243.747572 -320976.457
399 4109684.033631 40.368394 -3.781500 2267.001130 0 0 0 OpenRadar
                                                                  DJ-57@mpserver
01: -2708181.860926 -4276269.310227 3885173.044191 37.694279 -122.346276 35007.0
16125 2.294815 -3.178028 -0.715487 Aircraft/daedalus/Models/daedalus.xml
                                                                        H-ENCH@m
pserver01: 1515999.182312 -4484585.503215 4276535.645536 42.285392 -71.322347 36
214.785511 1.345484 3.838968 0.483292 Aircraft/CitationX/Models/Citation-X.xml
                                                                              D-
Avila@mpserver01: 3610101.776881 -4719527.698501 -2318734.292802 -21.447871 -52.
586591 10000.238973 0.549854 3.112813 3.154119 Aircraft/PC-12/Models/pc12.xml
                                                                             Aus
Air2@mpserver01: -2709132.809506 -4272063.921660 3871679.095767 37.614841 -122.3
80860 57.163416 -0.759294 2.319761 0.729476 Aircraft/777/Models/777-300.xml
                                                                           BA001
@mpserver01: 4002004.155144 501617.568778 4924496.006558 50.869960 7.144286 288.
506905 -2.521581 -1.163884 0.933161 Aircraft/A380/Models/A380.xml
                                                                 VH-INF@mpserver
01: 1528956.454234 -4440985.698538 4302667.984773 42.683948 -71.002278 4403.6226
20 1.628137 3.239403 1.070276 Aircraft/CitationX/Models/Citation-X.xml
                                                                      uax1@mpser
ver01: 4356924.668086 920025.776213 4556739.426183 45.851893 11.923641 13454.703
244 -3.026183 1.796831 0.980147 Aircraft/f-14b/Models/f-14b.xml
                                                               Gibbs@mpserver01:
 4617820.125567 417616.269605 4365237.422011 43.465032 5.167532 450.742148 -2.24
8084 -1.260195 1.006780 Aircraft/A-10/Models/A-10-model.xml
                                                           Mithras@mpserver01: -
2691628.378705 -4300903.762046 3852552.076954 37.395460 -122.039508 1076.563912
-1.294663 1.753754 0.125270 Aircraft/777/Models/777-200ER.xml
                                                             BR_ROM@mpserver01:
4284760.646829 -4029388.591357 -2458638.915945 -22.822704 -43.240692 41.019438 -
0.651007 -0.978344 -0.295540 Aircraft/777/Models/777-300ER.xml
                                                              callsig@mpserver01
: -2707405.956691 -4273245.184997 3871554.376254 37.613549 -122.357177 -2.314422
 1.397653 2.420326 1.375808 Aircraft/SenecaII/Models/SenecaII.xml
                                                                 Marteen@mpserve
r01: 2953085.736895 -5531000.254194 -1191093.047495 -10.826901 -61.901558 15504.
213121 -1.184871 0.387990 0.970819 Aircraft/fokker100/Models/fokker100.xml

Connection to host lost.


The data format seems to be callsign@server: ??? ??? ??? lat lon altitude ??? ??? ??? (I'm guessing the last three could be heading/pitch/bank or something similar.) Does anyone know what the first three parameters are?
This is the data format that I'd like to experiment with, avoiding all those nasty vectors and such.
How would I send this data to FG multiplayer through telnet? (Or any other means)
Rupert
 
Posts: 39
Joined: Fri Dec 02, 2011 4:21 am

Re: How does the Multiplayer Protocol work?

Postby Hooray » Tue Dec 09, 2014 3:04 pm

There's a ton of information that you can find by doing a forum/wiki search, the terms you're using, i.e. "injecting traffic" are already pretty good search terms.
That being said, you don't necessarily have to the MP protocol for this - the MP protocol will internally just add "AI traffic" nodes to /ai - you can use the property browser to track things there.
And you could just as well use some other protocol/means to inject arbitrary "traffic" into the FG environment - which is how scripted AI traffic works, i.e. by modifying those properties directly from Nasal (think tanker.nas, fox2.nas, bombable).
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11925
Joined: Tue Mar 25, 2008 8:40 am

Re: How does the Multiplayer Protocol work?

Postby Rupert » Tue Dec 09, 2014 3:44 pm

I've actually tried adding directly to the property tree through telnet.
For example, I changed the directory to ai/models and then used: set multiplayer[5]
But when I create this new multiplayer variable, when I go to add data, it gets all the numbers I input and treats them as strings, not integers/floats/doubles.
Also, by looking at the Pilot List (Multiplayer -> Pilot List from main menu), the multiplayer aircraft that I just added doesn't exist.
I've tried using Nasal to modify the values directly but when using set-prop, I haven't found any way to specify that I want to make a new variable an integer not a string.
These are just a few reasons why I didn't go down certain routes, however, if anyone can provide solutions, I'd be happy to use them! :)
Rupert
 
Posts: 39
Joined: Fri Dec 02, 2011 4:21 am

Re: How does the Multiplayer Protocol work?

Postby Hooray » Tue Dec 09, 2014 3:55 pm

usually, you don't have to worry about typing - the property tree code can internally convert things as needed - and the C++ requiring certain "types" will call the corresponding APIs directly.
In Nasal space, you can use the props.nas wrapper which contains helpers for most needs.
So you may want to read up on the property tree, i.e. see the wiki, which contains rather comprehensive docs on the whole concept, including typing and the telnet interface in particular.
Another recent addition is a WebSockets interface that can also be used for interfacing with the property tree.
For starters, I'd still suggest to use the Nasal route, because it is built-in/integrated, so doesn't require any external/additional tools - i.e. should "just work".
For examples, you can refer to the aforementioned Nasal modules, e.g. tanker.nas, fox2.nas - or Red_Leader's recent work, which is a Nasal module for creating arbitrary AI traffic nodes that can be fully scripted.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11925
Joined: Tue Mar 25, 2008 8:40 am

Re: How does the Multiplayer Protocol work?

Postby Rupert » Tue Dec 09, 2014 4:39 pm

Though Nasal Scripting is definitely something that I'd like to look at in the future, for my purposes presently, I need something more basic and primitive.
The mp server data aforementioned will be suffice.

Code: Select all
    # This is mpserver04.flightgear.org
                                       # FlightGear Multiplayer Server v0.11.6
                                                                              # usin
    g protocol version v1.1 (LazyRelay enabled)
                                               # This server is tracked: 62.112.194.
    20
      # 21 pilot(s) online
                          AF2222@mpserver01: 4188141.647448 187878.462437 4790773.31
    9650 49.001817 2.568545 356.251290 -1.321110 3.557633 0.434914 Aircraft/777/Mode
    ls/777-200ER.xml
                    thuko48@mpserver01: 4736391.046509 2823382.221423 3218773.248801
     30.441288 30.799343 39685.631547 -2.047747 -1.631852 1.421232 Aircraft/777/Mode
    ls/777-300ER.xml
                    __philo@mpserver01: 197161.098743 -4394321.959199 4614532.783444
     46.563399 -87.431019 27127.354516 -2.395172 0.054339 0.053436 Aircraft/il-96-40
    0/Models/il-96-400.xml
                          CHT0020@mpserver01: 815938.973427 -1125744.229870 6214216.
    352191 77.470188 -54.065414 33088.227151 -0.360156 3.251962 0.294273 Aircraft/74
    7-8i/Models/747-8i.xml
                          KA5NSK@mpserver01: 4571683.297299 138762.310152 4438074.14
    9088 44.329411 1.738540 17493.901654 -2.843887 -0.353577 1.150815 Aircraft/Lockh
    eed1049h/Models/Lockheed1049h.xml
                                     ox-tuy@mpserver01: -2518092.943774 -4449893.225
    644 3806260.996057 36.849665 -119.504530 12062.959625 -2.055322 0.906777 -0.2337
    14 Aircraft/A340-600/Models/A340-600-Models.xml
                                                   DRG-38@mpserver01: 6314174.777130
     929602.099537 170344.162892 1.539169 8.375185 20962.168057 -1.793580 -0.876558
    1.815687 Aircraft/777/Models/777-200.xml
                                            AA1717@mpserver01: 840771.997039 -488660
    6.888561 4004173.680711 39.110814 -80.237480 11980.431416 -2.257459 -0.122272 0.
    199598 Aircraft/707/Models/707.xml
                                      LEVS_TW@mpserver01: 4856243.747572 -320976.457
    399 4109684.033631 40.368394 -3.781500 2267.001130 0 0 0 OpenRadar
                                                                      DJ-57@mpserver
    01: -2708181.860926 -4276269.310227 3885173.044191 37.694279 -122.346276 35007.0
    16125 2.294815 -3.178028 -0.715487 Aircraft/daedalus/Models/daedalus.xml
                                                                            H-ENCH@m
    pserver01: 1515999.182312 -4484585.503215 4276535.645536 42.285392 -71.322347 36
    214.785511 1.345484 3.838968 0.483292 Aircraft/CitationX/Models/Citation-X.xml
                                                                                  D-
    Avila@mpserver01: 3610101.776881 -4719527.698501 -2318734.292802 -21.447871 -52.
    586591 10000.238973 0.549854 3.112813 3.154119 Aircraft/PC-12/Models/pc12.xml
                                                                                 Aus
    Air2@mpserver01: -2709132.809506 -4272063.921660 3871679.095767 37.614841 -122.3
    80860 57.163416 -0.759294 2.319761 0.729476 Aircraft/777/Models/777-300.xml
                                                                               BA001
    @mpserver01: 4002004.155144 501617.568778 4924496.006558 50.869960 7.144286 288.
    506905 -2.521581 -1.163884 0.933161 Aircraft/A380/Models/A380.xml
                                                                     VH-INF@mpserver
    01: 1528956.454234 -4440985.698538 4302667.984773 42.683948 -71.002278 4403.6226
    20 1.628137 3.239403 1.070276 Aircraft/CitationX/Models/Citation-X.xml
                                                                          uax1@mpser
    ver01: 4356924.668086 920025.776213 4556739.426183 45.851893 11.923641 13454.703
    244 -3.026183 1.796831 0.980147 Aircraft/f-14b/Models/f-14b.xml
                                                                   Gibbs@mpserver01:
     4617820.125567 417616.269605 4365237.422011 43.465032 5.167532 450.742148 -2.24
    8084 -1.260195 1.006780 Aircraft/A-10/Models/A-10-model.xml
                                                               Mithras@mpserver01: -
    2691628.378705 -4300903.762046 3852552.076954 37.395460 -122.039508 1076.563912
    -1.294663 1.753754 0.125270 Aircraft/777/Models/777-200ER.xml
                                                                 BR_ROM@mpserver01:
    4284760.646829 -4029388.591357 -2458638.915945 -22.822704 -43.240692 41.019438 -
    0.651007 -0.978344 -0.295540 Aircraft/777/Models/777-300ER.xml
                                                                  callsig@mpserver01
    : -2707405.956691 -4273245.184997 3871554.376254 37.613549 -122.357177 -2.314422
     1.397653 2.420326 1.375808 Aircraft/SenecaII/Models/SenecaII.xml
                                                                     Marteen@mpserve
    r01: 2953085.736895 -5531000.254194 -1191093.047495 -10.826901 -61.901558 15504.
    213121 -1.184871 0.387990 0.970819 Aircraft/fokker100/Models/fokker100.xml

    Connection to host lost.


Could you (or anyone) tell me how to send data in this format above into FG, inject it so to speak, either through telnet or any other means (avoiding nasal, if possible)? Preferably telnet.

Appreciate all the replies, thanks in advance.
Rupert
 
Posts: 39
Joined: Fri Dec 02, 2011 4:21 am

Re: How does the Multiplayer Protocol work?

Postby Hooray » Tue Dec 09, 2014 4:51 pm

if you're using the MP protocol, you need to create valid MP packets obviously - if you're using just the property tree, you only need to create valid property hierarchies, i.e. those expected by the AI/MP code - the Nasal modules I mentioned demonstrate how to do this - there's not much involved in terms of coding, it's mainly setprop() stuff - i.e. setting a bunch of properties to create a valid AI node.
To FlightGear, it doesn't matter if you're using Nasal, the built-in property browser, the AI traffic system, a web browser or the telnet server to create these ai nodes - they just need to contain valid data.
Thus, I am afraid, you'll have to do some reading - you've been provided with quite a few pointers already. However, if I were completely new to this, I'd probably just run FG once with MP enabled, and then use debug.dump() to dump a complete AI/MP node to the console and then use that to populate the AI tree procedurally in offline mode.
Note that you can also use props.nas to obtain a copy of a sub-tree and save that to an XML file using the APIs in io.nas (e.g. io.write_properties IIRC)

This would involve very little in terms of Nasal scripting, i.e. only for debugging/inspection purposes - once you have got an XML file with said data, you can use that as a template to create arbitrary AI nodes.

Overall, I'd still suggest to consider the Nasal route though - anything else is unlikely to be as full-featured in comparison to Nasal - even the C/C++ code we have doing this kind of thing is more complex than a handful of lines of Nasal code.

Creating a bunch of AI nodes is relatively straightforward and simple meanwhile: http://wiki.flightgear.org/Scripted_AI_Objects
Image
Image

All of these are simple AI nodes "injected" into FlightGear and animated/updated using a few lines of Nasal code.
While you could accomplish the same thing using telnet/httpd or other means, Nasal works exceptionally well here.
Given the nature of your questions, and the fact that those seem to suggest that you haven't yet worked through the corresponding property tree docs, Nasal would also seem to be the fastest way to get the results you're looking for.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11925
Joined: Tue Mar 25, 2008 8:40 am

Re: How does the Multiplayer Protocol work?

Postby AndersG » Tue Dec 09, 2014 10:03 pm

Rupert wrote in Tue Dec 09, 2014 4:39 pm:Could you (or anyone) tell me how to send data in this format above into FG, inject it so to speak, either through telnet or any other means (avoiding nasal, if possible)? Preferably telnet.

Appreciate all the replies, thanks in advance.


You don't, as the output you got there is just the fgms status report. The actual MP data flows in UDP packets - you can find the encoding in src/MultiPlayer/* in the FlightGear source.
Callsign: SE-AG
Aircraft (uhm...): Submarine Scout, Zeppelin NT, ZF Navy free balloon, Nordstern, Hindenburg, Short Empire flying-boat, ZNP-K, North Sea class, MTB T21 class, U.S.S. Monitor, MFI-9B, Type UB I submarine, Gokstad ship, Renault FT.
AndersG
 
Posts: 2477
Joined: Wed Nov 29, 2006 9:20 am
Location: Göteborg, Sweden
Callsign: SE-AG
OS: Debian GNU Linux


Return to Development

Who is online

Users browsing this forum: Bing [Bot] and 1 guest