Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Protocol Definition Language

Tags:

protocols

What protocol definition do you recommend? I evaluated Google's protocol buffers, but it does not allow me to control the placement of fields in the packet being built. I assume the same is true for Thrift. My requirements are:

  1. specify the location of fields in the packet
  2. allow for bit fields
  3. conditionals: a flag (bit field) = true means that data can appear at a later location in the packet
  4. ability to define a packet structure by referring to another packet definition

Thank you.

("Flavor" on SourceForge, used for defining MPEG-4 might be a candidate, but I am looking for something that seems to have more of a community and preferably works in a .NET environment.)

like image 696
Mr. T. Avatar asked Jan 21 '10 22:01

Mr. T.


People also ask

What is a protocol simple English?

Plural. protocols. (countable) A protocol is a rule, guideline, or document about how certain activities are done.

What is protocol with example?

Protocols: It is a set of rules that need to be followed by the communicating parties in order to have successful and reliable data communication. For example - Ethernet and HTTP.

What is a protocol Give 5 examples?

Some of the examples of Standard Protocols are FTP, DNS, DHCP, SMTP, TELNET, TFTP, etc. Proprietary protocols are developed by an individual organization for their specific devices.

What is the meaning of protocol in Oxford dictionary?

/ˈprəʊtəkɒl/ /ˈprəʊtəkɑːl/ [uncountable] a system of fixed rules and formal behaviour used at official meetings, usually between governments.


2 Answers

Have a look to ASN.1 http://es.wikipedia.org/wiki/ASN.1

FooProtocol DEFINITIONS ::= BEGIN

FooQuestion ::= SEQUENCE {
    trackingNumber INTEGER,
    question       IA5String
}

FooAnswer ::= SEQUENCE {
    questionNumber INTEGER,
    answer         BOOLEAN
}

END

It seems to cover your main requirements:

- Bit detail
- ordered content
- type references
- not sure, about conditions

Is widely used, and you can find some implementations on java and python

like image 66
Clark Ku Avatar answered Oct 12 '22 00:10

Clark Ku


I'd be interested in the reasons for your requirements. Why do you need to control the position of the fields? Why are bitfields important? Conditionals?

It sounds like you have a (more or less) fixed wire format for which you need to write a parser for, and in that case none of the existing popular protocol/serialization formats (Protobufs, Thrift, JSON, Yaml, etc.) will work for you.

A somewhat unorthodox approach is to use Erlang or Haskell, both of which have good support for parsing binary protocols.

like image 22
JesperE Avatar answered Oct 12 '22 02:10

JesperE