Hi! It has been a while. Here's an update on my networking library EvayrNet which is available for C++ users of Leadwerks:
While implementing it into the test project in Leadwerks, I saw that the use case had some flaws which made it really hard to debug what's going on. I figured that I should be spending some time on fixing some flaws. After a few weeks I came up with the following upgrades:
- Debugging class
- Simulation mode
- More debugging information available
Here's some detailed explanation:
I was using a lot of "printf" before which made it hard to:
- Find out where it's being called
- Disable whenever I don't need it anymore
This is when I decided to make a debugging class. I replaced the printf with a custom Print function which allows you to do the same as before - except you can disable any kind of printing whenever you want (like during release builds).
I also realized that capturing data is a pretty cool feature to have, which makes it easier to visualize the data you want to debug. For that I created a SaveText function which accepts a string and a filename as arguments so you can separate data like "Pings per interval", "Bytes sent per second", etc.
Here is an example what you can do with it:
This is an interesting one that I just had to implement. A connection cannot always perfect, and it can be hard to always expect a good outcome (while you might not notice it because of your tests on localhost). This is why I introduced the manipulation of the following networking stats:
- Minimum latency (in ms)
- Random latency (in ms)
- Packet drop percentage
- Packet duplication percentage
It's also very easy to activate and deactivate. All you have to do is NetworkManager::StartSimulation(...) and StopSimulation(). Here is it in the command line when you activate it:
More debugging information available
At last I added more ways to debug the network statistics to really see what is going on. Are you not receiving data anymore? Are you flooding the network? The following information is now ready to be displayed:
- Newest ping (either to the server or from a specific client)
- Average ping (this as well^)
- Incoming amount of packets per second
- Outgoing amount of packets per second
- Packets per second lost
- Incoming data per second (in bytes)
- Outgoing data per second (in bytes)
- Current active connections (primarily for the server)
That's... quite a lot more than before! Previously you could only see if you're connected and if you're the server. I hope this information will make it easier for users to visualize traffic and debug any problems they might be having. And of course, you can mix this up with the debugging class to make cool graphs like above!
I'm still planning on making some extra information, like on specifics to see what kind of message is creating the amount of bytes send/received. This should help debugging even more. Other than that there are still some enhancements I'd like to put in such as encryption. These can be seen here.
I hope you liked this blog post! Next time I will probably be showing how to implement EvayrNet into your C++ Leadwerks project, so you can toy around with it.