Skip to content

Network packet types

lestofante edited this page Mar 8, 2012 · 27 revisions

Overview

jSpace2d will have 2 main packet types: TCP and UDP. (you don't say :D)

TCP packets will be mainly used for two things: controlling the client connection to the game, and regularly broadcasting the map to clients.

UDP packets on the other side, are only used to update the client's world between a TCP "keyframe" and the next one. We plan on sending out 2 or 4 TCP keyframes per second, and 30 or 60 "delta UDP packets" per second. UDP packets only contain actions that may be performed by the client, so we don't need to send out absolute positions and velocities for every entity in the game (thus saving lots of bandwidth).

TCP packets

Every TCP packet has a 1 byte header to identify its type. Since java doesn't natively support unsigned bytes, we will indicate byte values that range from -128 to 127. (note: this only applies to java! If using unsigned bytes range obviously goes from 0->255)

Abstract structure

byte value
0 TCP packet type
1->... TCP packet data

TCP packet types

UDP packets

TODO

Clone this wiki locally