0

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.

1 Answer 1

1

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) {
Sign up to request clarification or add additional context in comments.

1 Comment

oh, I actually thought it was big endian. My mistake. anyways. Thank you very much,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.