My recent work for improving the game and entity code
turned out to have a large effect on the networking layer in the Cafu Engine as well: Moving the serialization and deserialization of entity state from the management code into the entities themselves is the first key step to achieve the desired improvements in code design, as it cleanly separates entity from network implementation details.
During my work in this regard, I found it highly useful to employ Wireshark
for analyzing the network packets that a Cafu client and server actually exchange. In the past, when the Cafu network protocol was initially developed, we used Wireshark only for capturing the network traffic, optionally prefiltering it, and to save it to disk. Then we used our own, hand-written C++ program "ReadDump" for analyzing the resulting dump file.
However, it turned out that both maintaining and even using the "ReadDump" program was very inconvenient and in fact rather painful - and it took not long until it became outdated: not able to read the latest version of the Cafu network messages, and thus useless.
As a result, last week I dug myself into Wireshark
again, and much to my joy found that they have a (relatively) new feature that allows to write dissectors for analyzing any given protocol in our favorite scripting language Lua
As a result, we can have the Cafu Engine network protocol dissected and analyzed directly in Wireshark. Even though my first attempt at such a dissector is probably somewhat clumsy and certainly still incomplete, it already turned out to be a lot
more convenient to use than our previous tool, leads to insights much faster, and as a result, is a lot more helpful.
Here is an example screenshot from one of my sessions:
If you would like to see the related Wireshark dissector itself, here is the script file (which also has additional links if you're interesting in further technical details):http://trac.cafu.de/browser/cafu/trunk/ ... k-cafu.lua
In summary, a Cafu-specific dissector for Wireshark helped me a lot with making the changes to the network protocol that we need to advance our game code. I've finished many of these changes already, and will commit them to our code repository in the next few days.