python-airmash
python-airmash copied to clipboard
Reverse Engineering
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 havePING/PONGfor keepalive. Should weACKnowledge every received packet?
https://github.com/Gadgetoid/python-airmash/blob/2748117d9d45c3843a8add520c8fc2cd59b663ae/airmash/packets.py#L34-L38
Player COMMAND
- Can we quantify the
comfield 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
I've spend some more time watching incoming data from the server and added some new types to disambiguate numerical values:
PlayerStatusis an Enum that tracks 0 = ALIVE and 1 = DEAD statuses (there may be more?)KeyStateis a BitField which converts the player keystate from bit-packed flags to a collection of True/False values for each key.MissileTypesis 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 -> typePLAYER_HIT -> typePLAYER_UPGRADE -> typePLAYER_POWERUP -> typeGAME_FLAG -> typeGAME_FIREWALL -> typeEVENT_REPEL -> mobs -> typeandMOB_UPDATE -> type(etc) (what are mobs?)EVENT_LEAVEHORIZON -> typeSERVER_CUSTOM -> type
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