Mar 2, 2010 at 4:57 AM
Edited Mar 2, 2010 at 4:59 AM
Hi, I'm trying to write a parser for a proprietary protocol and as a newby need a couple of pointers.
This is a brief protocol description:
The protocol uses variable length messages. All messages have a similar structure, but different messages contain different payloads (which I would like to parse too).
The basic structure of a message is:
STX (0x02), Type (1 byte), Length (1 byte), PAYLOAD (as per length), ETX (0x03)
This is sent over a TCP socket on a predefined port.
I'm trying to write a parser and need some help:
a) I've managed to register the Parser by adding a RegisterBefore tag, with the appropriate name and port. Something like [ RegisterBefore (TCP.TCPPayload.SIP,MyProtocol, 1234) ]
b) How do I verify that the first byte is an STX (0x02)? Can I discard a frame that does not start with 0x02?
c) How do I handle different message types? It almost looks like I should have nested protocols. I.e. MyProtocol hooks into the TCPPayload and then MessageA hooks into MyProtocol.Type for certain values of Type if that makes sense?
d) Would the Network Monitor automatically put different TCP packets together? I.e. what if one of my messages got split over multiple TCP packets? Would that not cause the parser to fail or are the frames assembled automatically?
Thank you in advance.