Saturday, January 9, 2016

Finally! Network Portion is Beta

Networking is finally solid enough to warrant it as beta.  It has been grueling and many challenges arose during the design.  Some challenges I had to deal with were:
  • Design the Network side to be easily maintainable and enough room to incorporate per connection encryption that would secure logins and other important messages.  Pretty much enough configuration of the core protocol without risking message reliability.
  • Protocol: TCP or UDP?  I use both but since TCP is pretty reliable then the design had to allow messages to be classed as Reliable or Unreliable, unreliable would go through the UDP channel.
  • Dropped Messages: The challenge here was ensuring messages do arrive even if they are a little late.  The answer was to use a ACK message that was compact to conserve bandwidth but had enough information to allow the Sender to know which message it was referring to.
  • Synchronicity: Synchronized messages would need to be self-aware across two different machines whether they were the newest message or not.  To do that I created a sort of backlog of network traffic on both ends that would be reviewed by the Receiver when a message arrived to determine if that message was the newest or not.  If it wasn't then it was dropped by the Sender and no other messages would be sent.
  • Bandwidth Concerns:  It isn't a good idea to just throw everything out there on the network without a care about the user's bandwidth.  To address that I had to design a limiter that would only allow a certain amount of data per second and if that limit was hit then it would pause outgoing messages to be sent later.  Some messages ignore this since they are important and small enough to be sent.  The limiter would be set to a reasonable amount that allows important messages to be sent without hogging the bandwidth.  Another in progress feature of the limiter is to make it dynamically able to increase or decrease bandwidth based on history.  That feature isn't priority since tests are done locally but it is on the TODO.
  • Message Serialization:  The serialization portion is a little tedious in a way because you pretty much have to code in what fields of an object are written and read for every message.  The good thing about that is messages can be fine tuned to use as little bandwidth as possible.  Extra code versus more bandwidth usage, I'll take extra code any day.
  • Latency Detection:  This was a fairly easy challenge because all it required to be done was to simulate latency for tests.  Lets just say that my expectations were satisfied due to all of the above.  Certain messages also attach a timestamp that is compressed before being sent out so that the Receiver can use it to interpolate movement, as an example, and with a backlog of previous messages the interpolation is quite easy to determine.
The graphics portion is next.  I dropped it due to conflicting priorities but now it will be addressed.  All these troubles for a Space Station 13 like game.  I love that game.

No comments :

Post a Comment