Now your asking me why do I write this article well, its because its simple, to many people overlook the core principles of this.
Packets:
A packet is a set of information it has a header to identify it and a series of commands then data for example:
[ID][ID][CMD][DATA]…[checksum]
This is a typical fixed length packet.
The packet ID will be 2 parts the first ID will be the type of packet typicall 4 types will exist in a secure online game data, command, encrypted.data and encrypted.command.
The 2nd ID will be the packet type what processing part it should be sent to, typically if there is a server application it will be split between player, enemy and data controls.
The CMD will be the function it is headed for some functions will require multiple CMD bytes to identify the function the packet DATA is for.
The checksum isnt always used but sometimes a player can manipulate packet information so this is used as a extra barrier for this the checksum function itself often obfuscated in a way they it is near impossible for the player to get at so cheating on the game is even harder.
Now the main point of all this IS security! Packet security is the most important aspect in a online/network game if you wish to stay away from cheats here are the simple examples you can follow:
Process anything that can affect the outcome server side.
Encrypt packets using a xor mask or similar method.
Compress large packets with a custom packing routine then encrypt too.
Encrypt the game program in memory using a executable packer.
Use anti debugger code.
Scan memory for finger prints and names of programs that can be used to hack your game.
Check the integrity of ure game files randomly, the server can send a check and the client will send back a hash to the server of the file the server asked to check.
Make encryption of a key part dependent on the machine ID for the client side the server can set this up when you first run the game ie. a file that lists all the creatures ingame, the game cant run without it, the computer the first time it runs sends certain information about the computer it is running on to the patch server and the patch server sends back a uniquely packed file it takes a split second for a machine to pack this kind of file and it can be stored as a hash server side for the file integrity check.
Keep your packet commands simple but also you can alternate the CMD byte for some functions to confuse people who are packet sniffing.
Basically, keep it simple and unpredictable.
