I'd like to explain my dissection of a data dump hold against the code to get another opinion or to check my analysis. Is this on topic or off topic?
I'd show the data dump with markings which bytes or bits describe what in a datastructure while the frame is parsed by the code.
E.g. it might look like this ...
This is the data:
00 ff 12 01 22 01 00 00 00 01
This is the code:int version = readByte(); if (version > 1) { byte flags = readByte(); // read flags as byte } else { int len = readWord(); // read next two bytes }
1. Read version:
int version = readByte(); [00] ff 12 01 22 01 00 00 00 01 <= version
2. Read length, since this is version 0:
if (version > 1) { byte flags = readByte(); // read flags as byte } else { int len = readWord(); // read next two bytes } 00 [ff 12] 01 22 01 00 00 00 01 <= length: 0x12ff (4863)
And so on ...