python-airmash icon indicating copy to clipboard operation
python-airmash copied to clipboard

Reverse Engineering

Open Gadgetoid opened this issue 7 years ago • 2 comments

I've got the majority of the Airmash protocol figured out- enough to connect to a server, receive and parse data, and pilot a ship. However, I would very much like to build out Enum types for things like "protocol" and other ambiguous attributes in some of the packets.

I'm in the process of adding "TODO" notes into the code where it's unclear to me what a packet, or part of a packet, does, or what its expected ranges and human-readable values might be.

Player Commands (Client -> Server)

Player LOGIN

  • What are the values for protocol?
  • What's the minimum/maximum allowed range for horizonX and horizonY and what effect does it have
  • What are the available flag types/supported two-letter country codes?

https://github.com/Gadgetoid/python-airmash/blob/2748117d9d45c3843a8add520c8fc2cd59b663ae/airmash/packets.py#L4-L18

Player BACKUP

  • What does this do? Is this an alternate to "LOGIN" that allows us to resume a session with a particular token?

https://github.com/Gadgetoid/python-airmash/blob/2748117d9d45c3843a8add520c8fc2cd59b663ae/airmash/packets.py#L20-L24

Player ACK

  • Under what circumstances do we need to reply to the server with an ACK? It seems we have PING/PONG for keepalive. Should we ACKnowledge every received packet?

https://github.com/Gadgetoid/python-airmash/blob/2748117d9d45c3843a8add520c8fc2cd59b663ae/airmash/packets.py#L34-L38

Player COMMAND

  • Can we quantify the com field with all available commands?

https://github.com/Gadgetoid/python-airmash/blob/2748117d9d45c3843a8add520c8fc2cd59b663ae/airmash/packets.py#L56-L63

Player LOCALPING

  • What is this for?

https://github.com/Gadgetoid/python-airmash/blob/2748117d9d45c3843a8add520c8fc2cd59b663ae/airmash/packets.py#L103-L107

Gadgetoid avatar Dec 21 '17 22:12 Gadgetoid

I've spend some more time watching incoming data from the server and added some new types to disambiguate numerical values:

  • PlayerStatus is an Enum that tracks 0 = ALIVE and 1 = DEAD statuses (there may be more?)
  • KeyState is a BitField which converts the player keystate from bit-packed flags to a collection of True/False values for each key.
  • MissileTypes is an Enum that identifies different missile types. This may be wrong but it seems ships currently have their own set of types (actually the Tornado is the only ship with two types of missile) and type 4 seems to be MIA (haven't observed any types >7 yet)

Types still to document:

  • COMMAND_REPLY -> type
  • PLAYER_HIT -> type
  • PLAYER_UPGRADE -> type
  • PLAYER_POWERUP -> type
  • GAME_FLAG -> type
  • GAME_FIREWALL -> type
  • EVENT_REPEL -> mobs -> type and MOB_UPDATE -> type (etc) (what are mobs?)
  • EVENT_LEAVEHORIZON -> type
  • SERVER_CUSTOM -> type

Gadgetoid avatar Dec 22 '17 21:12 Gadgetoid

It looks like mobs are both projectiles and collectables. I have enumerated mob types (with some guesses yet to be tested/verified), created a new Mob class to store mob telemetry and implemented the mob update commands in test.py

Gadgetoid avatar Dec 23 '17 00:12 Gadgetoid