3

I have to implement a high performance Java client of an existing binary protocol. I will use Netty. However since the protocol is complex (many message types with many fields) I would like to separate netty code from parsing code and generate a parser of this protocol from a document describing this protocol in a higher abstraction. Similar like it is done in Google's Protocol Buffers. Unfortunately it seems I cannot use protobuf as my protocol is in a different binary wire format. Any suggestions?

1 Answer 1

2

I haven't tried it myself, but I think you might be looking for the java binary block parser

Here's an example form the official readme that shows how it can be used to parse the structure of a TCP header using a high level DSL:

final JBBPParser tcpParser = JBBPParser.prepare(
          "skip:34; // skip bytes till the frame\n"
          + "ushort SourcePort;"
          + "ushort DestinationPort;"
          + "int SequenceNumber;"
          + "int AcknowledgementNumber;"

          + "bit:1 NONCE;"
          + "bit:3 RESERVED;"
          + "bit:4 HLEN;"

          + "bit:1 FIN;"
          + "bit:1 SYN;"
          + "bit:1 RST;"
          + "bit:1 PSH;"
          + "bit:1 ACK;"
          + "bit:1 URG;"
          + "bit:1 ECNECHO;"
          + "bit:1 CWR;"

          + "ushort WindowSize;"
          + "ushort TCPCheckSum;"
          + "ushort UrgentPointer;"
          + "byte [$$-34-HLEN*4] Option;"
          + "byte [_] Data;"
  );

final JBBPFieldStruct result = pngParser.parse(tcpFrameStream);
Sign up to request clarification or add additional context in comments.

1 Comment

Yes! Thank you Malt that looks like the library I am looking for.

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.