[erlang-questions] encoding packets a style+efficiency question
Tue Jul 26 17:26:00 CEST 2011
yes i know. but my question was more towards a better approach towards
writing packet encoders/decoders. may you please let me know your
thoughts on that ?
On Tue, Jul 26, 2011 at 7:08 PM, Kenneth Lundin
> I suppose you arleady know that there is a tftp implementation included in the
> Erlang/OTP distribution.
> You find the documentation here.
> /Kenneth Erlang/OTP Ericsson
> On Tue, Jul 26, 2011 at 9:36 AM, Anupam Kapoor <anupam.kapoor@REDACTED> wrote:
>> hi all,
>> i have been playing with an implementation of tftp
>> (rfc-1350). encoding/decoding tftp-pdu's is trivial with erlang's bit
>> there seem to be couple of approaches to encoding/decoding tftp-pdu's:
>> 1. use native "in-place" encode/decode
>> 2. have a 'generic' encode/decode routine which accepts
>> - a list of pdu primitives e.g. 'byte'/'string' etc. and
>> - a list of corresponding values
>> and returns the binary packet.
>> for example, encoding a tftp-data packet looks like this:
>> | %% encode data packet
>> | encode_data_pkt(BlkNum, Data) ->
>> | encode_packet([?BYTE, ?BYTE, ?RAW],
>> [?TFTP_OPCODE_DATA, BlkNum, Data]).
>> to me, approach #2 seems pretty close to rfc's packet-format
>> specification. for example, the data-packet is shown as
>> 2 bytes 2 bytes n bytes
>> | Opcode | Block # | Data |
>> can you please provide your suggestion on whether #2 might be a good
>> approach to follow for complicated protocols e.g. gtp-v2 which defines a
>> large number of messages ? also, are there better (increasing order of
>> readability, performance etc.) approaches for doing this ?
>> thank you
>> kind regards
>> ps: the attached file contains encoders for tftp messages...
>> In the beginning was the lambda, and the lambda was with Emacs, and
>> Emacs was the lambda.
>> erlang-questions mailing list
In the beginning was the lambda, and the lambda was with Emacs, and
Emacs was the lambda.
More information about the erlang-questions