Protocol Draft
Protocol Draft
Authors: William Alvero-Koski, Khoa Cao, Marco Nunez, Cole Paullin, Abhishek Raghunathan,
cVivian Wong
Revision History
Communication Overview
Communications in this game is the main way the game is implemented and are broken up into
two categories: Communication between the stations of the TRIAC and messages broadcast
from one TRIAC to all others. This document describes the protocol for both categories of
messages. From the requirements of the game, each TRIAC will broadcast a packet containing
its position at a rate of 5Hz or once every 0.2s. Each station will also send a packet to both
other stations at a rate of 5Hz. Ie every 0.2s, the ZENER will broadcast a packet and send two
packets, one to OPAMP and one to TVS. Contents of these packets are defined later in this
protocol document. ZENER is the only station that will broadcast a packet. If the TVS wants to
fire, it will send a packet to ZENER with the needed information and ZENER will include that
information in its next broadcast.
It is important to note that the data is bottlenecked on the Rx line connecting the microprocessor
to the ESP32 module. Per the specifications, that line will be at 9600 baud or 960 bytes per
second. The ZENER broadcast from each team at a rate of 5Hz will take up 600 bytes per
second of this capacity. The rest of the capacity is reserved for the station to station
communication. If too many messages are received by the ESP32 and the data transmission
rate exceeds 9600 baud, the station will not be receiving the information it needs at the correct
time. Due to the bandwidth limitations, the max number of teams able to play in a round is 7
teams.
Game Play Structure
A game begins when any TRIAC begins broadcasting its position in the Linear Region. At this
point, any other team can also begin broadcasting and join the game. Since all intra-team
communication is handled in the broadcast there should be no battles occurring unless multiple
teams are broadcasting.
A game ends when all but one team are declaring themselves dead in their broadcast.
Communication Interruptions
Dropped communications. When a ship is killed, it will continue to broadcast its position but with
the Alive/Dead flag set properly. Therefore, if you do not receive a broadcast from a team, it can
be assumed that that team has lost internet connection. This team will re-enter the battle when
their internet is re-established and the TRIAC begins broadcasting again. For team
communication, if a station is out of contact for 1 second (5 transmissions are lost) then that
station will be considered out of contact, and another station needs to assume its
responsibilities.
Hardware Requirements
Communications Hardware:
Each module is pre-programmed with a 16-bit virtual address. This allows us to direct messages
to any other module by specifying the address as part of the API command. The module uses a
WiFi connection to access the IRC server in order to communicate with other modules.
Each node on each TRIAC will be equipped with an ESP32, providing it with a unique address.
This allows for stations within a team to send directed messages to each other.
Where the:
Where the:
Where the:
Using the XBee API structure, the RF data portion of the broadcast packet will contain eleven
bytes of data with the following blocks:
Status Hull str Ship x-pos Ship x-pos Ship y-pos Ship y-pos Beam dx Beam dx Beam dy Beam dy Shield
LSB MSB LSB MSB LSB MSB LSB MSB str
Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7 Byte 8 Byte 9 Byte 10
Notice the particular arrangement of the multi-byte blocks. In order to adhere to a little endian
system (LSB first), the bytes are expected to be transmitted in increasing order.
TN<7:5> AD WF
bit 7 bit 0
HS<6:0>
bit 7 bit 0
bit 7-0 HS: The spaceship hull strength ranging from 0 to 100 in increments of 1GJ
XP<15:0>
bit 15 bit 0
bit 15-0 XP: The x-position of the spaceship measured from the upper left corner
(positive to the right) of the linear region ranging from 0 to 65535. Each unit
represents increments of 7.8125km (e.g.: 1 = 7.8125km, 2 = 15.625km,…, 65535
= 511,992.1875km).
Note: It is the user’s responsibility to ensure that the LSB goes out first during transmission.
Note: See Figure 1 for the reference frame axes.
byte <5:4>: Ship y-position
YP<15:0>
bit 15 bit 0
bit 15-0 YP: The y-position of the spaceship measured from the upper left corner
(positive down) of the linear region ranging from 0 to 65535. Each unit represents
increments of 7.8125km (e.g.: 1 = 7.8125km, 2 = 15.625km,…, 65535 =
511,992.1875km).
Note: It is the user’s responsibility to ensure that the LSB goes out first during transmission.
Note: See Figure 1 for the reference frame axes.
Figure 1: The Linear Region. The two axes, x and y, are defined as shown.
DX<15:0>
bit 15 bit 0
bit 15-0 DX: The difference between the ship’s current x-position and the x-endpoint of
the beam vector, in increments of 7.8125km. Note that this value is signed.
byte <9:8>: Beam ∆y
DY<15:0>
bit 15 bit 0
bit 15-0 DY: The difference between the ship’s current y-position and the y-endpoint of
the beam vector, in increments of 7.8125km. Note that this value is signed.
The expected behaviour for the beam’s ∆x and ∆y description may follow two scenarios as
shown in Figure 2 below.
SS<7:0>
bit 7 bit 0
bit 7-0 SS: The spaceship shield strength ranging from 0 to 200 in increments of 1GJ
Team Packet Definition
Team members will send one communications packet at 5hz to each station in their team. If this
message, or heartbeat, is not received by the other stations for a period longer than 1 second,
that station will be considered to be inactive and command can be assumed by another station.
If the Zener is inactive, broadcast of location must be taken on by another station. If the original
station comes back online, the series of events are as follows. The station returning from
inactivity should have stopped transmission after 1 second of no connectivity. It should wait for
receipt of a transmission from the station that has taken on its responsibilities. The station
returning from loss of connectivity should update its data accordingly, and send an Assume
Command transmission to the station that had taken over, on the following transmission cycle it
can once again transmit as that station. The station that had filled in should stop transmitting on
behalf of the returned station upon receipt of an assume command transmission.
Each station will send data in the same format. If a station doesn’t have information to send in a
given byte, it will send that byte with all 0s. The information will be formatted and sent as
follows.
Status Hull Beam dx Beam dx Beam dy Beam dy Weapons Navigation Weapons Shield
Strength LSB MSB LSB MSB Power Power Capacity Capacity
Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7 Byte 8 Byte 9
bit 7 bit 0
bit<7:6> Unimplemented: Read as ‘0’
bit<5> Assume Command: Indicates that command will be assumed by the station
this is transmitted from. Active high
bit <4:2> ZENER, OPAMP, TVS: bits indicate if the given transmission is coming from
that particular station. Multiple stations can be active in a given transmission. It
is important that only one station of each type be active at a time.
bit <1> Weapon Fired: High when Weapon fired.
bit <0> Ship hit: High when hit
byte <1>: Hull Strength
HS<6:0>
bit 7 bit 0
bit 6-0 HS: The integrity of the hull in GJ. It can take on values from
0-100 GJ, 0 GJ should clear the TRIAC alive flag in the broadcast.
DX<15:0>
bit 15 bit 0
bit 15-0 DX: The difference between the ship’s current x-position and the x-endpoint of
the beam vector, in increments of 7.8125km. Note that this value is signed.
DY<15:0>
bit 15 bit 0
bit 15-0 DY: The difference between the ship’s current y-position and the y-endpoint of
the beam vector, in increments of 7.8125km. Note that this value is signed.
WP<6:0>
bit 7 bit 0
bit 6-0 WP: This is the Power apportioned to TVS by the OPAMP. Weapons power and
nav power can only be apportioned in increments of 1 GW, so the range of
acceptable numbers weapons power and Navigation power can take on is 0-64
GW.
byte <7>: Navigation Power
NP<6:0>
bit 7 bit 0
bit 6-0 NP: The power apportioned to the ZENER by the OPAMP. See
note for weapons power.
WC <7:0>
bit 7 bit 0
bit 7-0 WC: The energy held in the capacitor banks for the weapons. The range
of accepted values is 0-200 GJ.
SC<7:0>
bit 7 bit 0
Bit 6-0 SC: The integrity of the shields in GJ. It can take on values
from 0-200 GJ.
Example Transmissions
If our ship is team 4, we are alive and we have fired our weapon.
Our hull strength is 100, our x-pos is 10km, y-pos is 100km, our beam delta x is 2000km, our
beam delta y is -4000km, and our shield is 150.
Status Hull str Ship x-pos Ship x-pos Ship y-pos Ship y-pos Beam dx Beam dx Beam dy Beam dy Shield
LSB MSB LSB MSB LSB MSB LSB MSB str
0b10000011 0x64 0x01 0x00 0x0C 0x00 0x00 0x01 0x00 0xFE 0x96
If this is the OPAMP sending the message, we now have 50 hull strength, 10 shield strength.
We are giving 50GW of power to Shields and and rest (14GW) of power to navigation and we do
not send any other information
Status Hull Beam dx Beam dx Beam dy Beam dy Weapons Navigation Weapons Shield
Strength LSB MSB LSB MSB Power Power Capacity Capacity
0b00001000 0x32 0x00 0x00 0x00 0x00 0x00 0x0E 0x00 0x0A