Pattern matching vs. ETS lookups

Serge Aleynikov serge@REDACTED
Mon Feb 16 21:04:11 CET 2004


Well, the number 65536 is hypothetic.  In reality it is around 3000 
different functions (configuration, call control, signalling, etc.) of a 
hardware CSP switch (xl.com) that can be controlled through this binary 
protocol.

The functions in the protocol are identified by a two byte number 
enumerated from {0,0} to {255,255}.  Each function takes a binary 
containing it's specific parameters encoded in accordance with the 
protocol documentation.

I'd like to see if it is possible to do an elegant & maintainable 
solution that would separate protocol encoding/decoding from the user 
application (perhaps by writing a behavior).

Serge

Ulf Wiger wrote:

> On Mon, 16 Feb 2004 13:26:29 -0500, Serge Aleynikov <serge@REDACTED> 
> wrote:
> 
>> A binary protocol uses the following convention:
>> <<FunID_MSB/8, FunID_LSB/8, Body/binary>>
>>
>> {FunID_MSB, FunID_LSB} determine the FunctionID to be called, that 
>> accepts a Body/binary.
>>
>> The main question is if the number of functions is large (~ 65536), is 
>> it better to implement header/body parsing using hard-coded patterns:
> 
> 
> Do you really have 65536 different body parsing functions?
> How are they identified in the first place?
> 
> /Uffe




More information about the erlang-questions mailing list