Overview
Flight packets handle real-time aircraft state synchronization between clients and servers. These packets are sent frequently (multiple times per second) to keep all clients synchronized.FSNETCMD_AIRPLANESTATE
Packet ID:11 | Direction: Bidirectional (Server ↔ Client)
The most important packet in YSFlight, sent to synchronize aircraft position, attitude, control surfaces, and weapons status.
Location
lib/PacketManager/packets/FSNETCMD_AIRPLANESTATE.py
Packet Versions
This packet has multiple versions with different structures:- Version 0: vh, vp, vr are 16-bit shorts
- Version 1+: vh, vp, vr are 32-bit integers appended at end
- Version 2+: Includes thrust vector, reverser, and bomb bay
- Version 3+: idOnServer is 32-bit int
- Version 4: Short version with thrust vector and bomb bay
- Version 5: Short version without thrust vector or bomb bay (most common)
Fields
Timestamp from the sending client’s simulation
Unique identifier for the aircraft in the simulation
Version number determining packet structure (typically 4 or 5)
Aircraft position in meters [x, y, z]
Aircraft attitude in radians [heading, pitch, bank]
Aircraft velocity vector [vx, vy, vz]
Angular velocity [vh, vp, vr]
Current fuel amount
Current payload weight
Current flight state (flying, on ground, crashed, etc.)
Variable geometry wing position (0.0-1.0)
Spoiler deployment (0.0-1.0)
Landing gear position (0.0-1.0)
Flap position (0.0-1.0)
Brake application (0.0-1.0)
Aircraft state flags:
ab(bool): Afterburner on/offfiring(bool): Currently firing gunssmoke(int): Smoke type (0 = off, 255 = default color)nav_lights(bool): Navigation lights on/offbeacon(bool): Beacon light on/offstrobe(bool): Strobe lights on/offlanding_lights(bool): Landing lights on/off
Remaining gun ammunition
Remaining rockets
Remaining air-to-air missiles
Remaining air-to-ground missiles
Remaining bombs
Aircraft health/damage state (0-255)
Current G-force experienced by aircraft
Throttle position (0.0-1.0)
Elevator position (-1.0 to 1.0)
Aileron position (-1.0 to 1.0)
Rudder position (-1.0 to 1.0)
Trim position (-1.0 to 1.0)
Methods
Decodes the binary packet data into object fieldsExample:
Returns a modified packet with smoke enabledReturns:
bytes - Full packet with size headerExample:Returns a modified packet with firing flag disabledReturns:
bytes - Full packet with size headerExample:Quickly extract life value from packet without full decodeParameters:
buffer(bytes): Raw packet data
int - Aircraft life/health valueExample:Creates a new AIRPLANESTATE packetParameters: All fields listed above, plus:
with_size(bool): Include size header for network transmission
bytes - Encoded packetExample:Usage Examples
Monitoring Aircraft State
Modifying Aircraft State
Tracking Positions
FSNETCMD_UNJOIN
Packet ID:12 | Direction: Client → Server
Sent when a client leaves the server voluntarily.
Location
lib/PacketManager/packets/FSNETCMD_UNJOIN.py
Fields
ID of the aircraft leaving the server
Whether to show explosion effect (unused in YSFlight)
Methods
Creates an UNJOIN packetExample:
FSNETCMD_REMOVEAIRPLANE
Packet ID:13 | Direction: Bidirectional (Server ↔ Client)
Sent by the server to notify clients that an aircraft has been removed from the simulation.
Location
lib/PacketManager/packets/FSNETCMD_REMOVEAIRPLANE.py
Fields
Identical to UNJOIN - this class extends FSNETCMD_UNJOIN.ID of the aircraft being removed
Whether to show explosion effect
Methods
Creates a REMOVEAIRPLANE packetExample:
Notes
The difference between UNJOIN and REMOVEAIRPLANE is semantic:- UNJOIN: Client-initiated disconnect
- REMOVEAIRPLANE: Server-initiated removal (kicked, crashed, etc.)
Performance Considerations
- AIRPLANESTATE packets are sent very frequently (10-30 times per second)
- Minimize processing time for these packets to avoid lag
- Use
should_decode=Falseif you only need to forward the packet - Cache commonly accessed values rather than decoding repeatedly