4 Gotcha’s of text-based protocols Google’s protocol

 
Ran Arad

The binary of text protocols

July 16th, 2008

A while ago, Paul E. Jones, the prophet of AMS, mentioned that AMS would use XML encoding:

“We just finished a meeting yesterday. During the meeting we reached agreement to use XML for this new system. Personally, I think that’s going to be very cool. There is a huge amount of tool support for XML. We also had a person from the W3C attend who shared information on the Efficient XML Interchange (http://www.w3.org/XML/EXI/). In theory, this allows one to create a very compact binary representation of XML without losing the benefits of XML. We have to investigate this one further, but it looks promising.”

Paul seems to be catering to the masses while staying true to efficient engineering.

Got to have text

I’ve had plenty of discussions about text and binary encodings (and I wrote about them here and there). The leading argument for using text protocols always seems to be “text protocols are easier to debug”, which I fondly call “Debug Folly“.

Debug follyDebug Folly:

“The assumption that something that is easier for the programmer to do or understand is also easier to code or debug. The consequence is usually an overly complex code which is hard to debug.”

Last time I had to debug a text-based protocol, the parser was so complicated I treated the entire layer as “white noise” and waited until control came out of it. For simple protocols, like HTTP or RTSP, it works: you can read the command word, read the argument, watch them being parsed, find the bug and correct it. For complex protocols like SIP (which, ironically, started out as the simple alternative to H.323), tracing the control through the parser, parts of which were generated by software out of a rules-file, is virtually impossible.

At any cost

Textual ambiguity in text protocolsI have a live example, from a few days ago, of what makes text parsers so complicated. We were talking about SDP and the ways to represent, in text, the G.711 codec:

  • “G.711″
  • “g.711″
  • “G711″
  • “g711″
  • “G-711″
  • “g-711″
  • “711″
  • “G.711alaw”
  • “G.711a”
  • “PCMA”

There are more.

For every text scheme, there are dialects and accents, variations and gotcha’s. Why does that happen? They are so easy to debug. You just go to your code, find the specific section that deals with the specific token, make a few changes, and voila – the next person who debugs there has to deal with a code twice as complicated.

The binary of text

XML, in a way, is like writing binary in text. The schema is defined, it is case-sensitive (it is sensitive to everything), and anyway, the code throws the message at some optimized XML tool and you can’t really debug that. If there is something wrong with the message, the sender of the message should just fix his schema and everything works fine. If needed, the protocol can even move to binary encoding (e.g. for cellular networks).

Technology is always a bit like a popularity contest:

  • Popularity of the operating system (OS X, Windows, Linux)
  • Input techniques (iPhone multi touch, Blackberry QUERTY keyboard, Palm graffiti)
  • Architecture (single core, multi core, distributed)
  • Ideas (software as a service, dot-com, web 2.0).

The popular idea right now, for protocols, is that text is simpler. To get the attention of protocol developers, Paul E. Jones has to approach them with a text-based protocol.

I see through your plan, Mister – come version 2, they’ll all be sending binary!

2

Comments and trackbacks

  • 1. Todd Bradley  |  July 16th, 2008 at 12:44 pm

    In my own experience troubleshooting signaling problems with H.323 and SIP devices, I think your “debug folly” is crap. Your assertion makes it sound like the only people in your world are programmers. In the real world, for every signaling protocol programmer, there are probably five other people who have to diagnose interoperability issues (testers, programmers of the applications that sit far above the signaling layer, network engineers, etc.). These type of people can get their jobs done a lot more easily and accurately given a protocol that doesn’t take highly specialized tools and knowledge to decode.

  • 2. Ran Arad  |  July 17th, 2008 at 7:26 am

    Hi Todd

    May I be so bold as to ask how these people capture the messages going through the network? To my knowledge, they either use the logs output by one or both endpoints, or use “highly specialized tools” to capture the message from the wire, e.g. WireShark. In both ways, the binary message is displayed also as a decoded message, so there is not much problem there.

    Funny you should mention people that diagnose interoperability issues: as I mentioned in the post, there are more interoperability issues when using text protocols than there are in binary protocols.

    To sum up, the point of the last post was that XML allows sending text messages while enforcing strict message syntax. In some ways, it is enjoying both worlds: readability of text with the interoperability, robustness and efficiency of binary protocols.

    Ran

Required

Required, hidden

Notify me of followup comments via e-mail

Trackback this post  |  Subscribe to the comments via RSS Feed