Multiplayer protocol: Difference between revisions

Jump to navigation Jump to search
Line 50: Line 50:


== Data types ==
== Data types ==
{{Warning|if an aircraft defines all possible properties in the protocol, it tries to send 14988 bytes per packet, almost 12.5 times the allowed limit! Your idea of sending properties in a round-robin fashion is good IMHO but good MP debugging tools are necessary for aircraft developers.<ref>{{cite web
{{Warning|if an aircraft defines all possible properties in the protocol, it tries to send 14988 bytes per packet, almost 12.5 times the allowed limit. Until the protocol is fixed to handle this it is the responsibility of the aircraft modeler to resolve '''Multiplayer packet truncated''' errors. <ref>{{cite web
   |url    =  https://sourceforge.net/p/flightgear/mailman/message/35441502/  
   |url    =  https://sourceforge.net/p/flightgear/mailman/message/35441502/  
   |title  =  <nowiki> Re: [Flightgear-devel] C172 MP alert on console </nowiki>  
   |title  =  <nowiki> Re: [Flightgear-devel] C172 MP alert on console </nowiki>  
Line 59: Line 59:
   }}</ref>
   }}</ref>
}}
}}
The data is XDR encoded as the following types:


{{Caution|Due to a bug, all bytes in the <tt>STRING</tt> field are sent as '''4-byte ints''' (not in the header or the position message). So STR has length (LEN * 4) bytes and padding ((4 - LEN%4) * 4) bytes, if LEN%4 is not 0.}}
{{Caution|Prior to V2017.2 all bytes in the <tt>STRING</tt> field are sent as '''4-byte ints''' (not in the header or the position message). So STR has length (LEN * 4) bytes and padding ((4 - LEN%4) * 4) bytes, if LEN%4 is not 0.}}
 
When running with 2017.2 there is a '''Transmit As''' mapping to allow more efficient usage of the limited space in the packet. This mapping is defined in the property map.
 
The data is XDR encoded in two different methods, compatible or 2017.2. This only affects the properties, with the impact that clients prior to 2017.2 will only be able to receive properties using compatible encoding, which can result in missing animations and no receipt of chat messages.
 
 
=== Compatible encoding ===
Prior to 2017.2 the following types are available.


{| class="wikitable"
{| class="wikitable"
Line 85: Line 92:
PAD: (n * 4) bytes, padding<br/>
PAD: (n * 4) bytes, padding<br/>
|}
|}
=== 2017.2 encoding ===
All properties are transmitted unconditionally in each frame at the rate specified.
{| class="wikitable"
! Type !! Size !! Remarks
|-
| int
| 4 bytes
|-
| short int
| 2 bytes
|-
| float
| 4 bytes
|-
| Short_float_norm
| 2 bytes
| -1 .. 1 encoded into a short int
|-
| Short_float_1
| 2 bytes
| range -3276.7 .. 3276.7  float encoded into a short int (16 bit)
|-
| Short_float_2
| 2 bytes
| range -327.67 .. 327.67  float encoded into a short int (16 bit)
|-
| Short_float_3
| 2 bytes
| range -32.767 .. 32.767  float encoded into a short int (16 bit)
|-
| Short_float_4
| 2 bytes
| range -3.2767 .. 3.2767  float encoded into a short int (16 bit)
|-
| bool
| 4 bytes
|-
| string
| (LEN + STR) bytes
|
LEN: 2 bytes, length of the string<br/>
STR: char[LEN] bytes<br/>
|}
Also with 2017.2 the property ID for short int and strings is transmitted in 16bits.


== Messages ==
== Messages ==
308

edits

Navigation menu