Reputation: 19975
I have a packet, when viewed in hex is:
0A 00 2C 01 23 00 0C 00 B3 01
0A 00
is the length which is 10.
2C 01
is a identifier 12c
or could be a decimal packet id.
23 00
is a version of dec 35.
0C 00
is another version which is dec 12.
b3 01
is 435.
Now I am using packet for nodejs.
http://bigeasy.github.io/node-packet/
I currently have this code,
parser.extract("b16 => length, b16 => id, b16 => clientVersion, b16 => updateVersion, b16 => dateVersion", function (record) {
console.log(record);
});
parser.parse(data);
These are the issues here, the extract returns
length: 2560, version: 11265... etc. ( which is all wrong )
Question is what is going wrong?
changing everything to b8
still gives me the correct length which is 10
but everything else is still wrong.
Upvotes: 0
Views: 900
Reputation: 161447
You have specified the Endianness
of your values incorrectly. 0A 00
is 10
in little-endian form, but you have specified it as b16
(the b
meaning big-endian).
parser.extract(
"l16 => length, " +
"l16 => id, " +
"l16 => clientVersion, " +
"l16 => updateVersion, " +
"l16 => dateVersion",
function (record) {
Upvotes: 1