-
Notifications
You must be signed in to change notification settings - Fork 24
Transport Layer
All communication between PC² modules is done by sending PC2 Packets over the network. Packets are sent and received through a software layer called the Transport Layer which exists in each module.
When the transport layer in a module receives a packet from the network, it forwards the packet up to the module’s controller, which in turn passes it to a method processPacket()
. Every module contains an instance of a class named PacketHandler
. processPacket()
invokes a method handlePacket()
in the PacketHandler
class. handlePacket()
is the place in the code where packets are “dispatched” (sent to the appropriate processing routine).
handlePacket()
contains a giant “switch” statement that directs (dispatches) packets to the appropriate place. For example, a RUN_SUBMISSION
packet gets dispatched to a method named runSubmission()
. The runSubmission()
method in the server does some preliminary checking, then tells the “contest” (model) to “accept” the run. The run also gets timestamped (updated with the current time) in runSubmission()
, and an "acknowledgement-of-receipt-of-run" packet is constructed and sent back to the team. The server then sends a packet to the Judges notifying them of the existence of the (new) run.
When a judge module’s PacketHandler
gets a packet indicating a new run, it turns around and sends a RUN_REQUEST packet to the server. The server then marks the requested run as “checked out” and returns information about the run to the requesting judge. At this point the judge can compile, execute, and validate the run, returning result information to the server, which then forwards the results (again, via a packet) to the team module.