Hello Everyone,
Does anyone know any design patterns for modules meant for encoding/decoding of protocol messages. E.g. BSSMAP/LAP...
We need to write encoders and decoders for BSSMAP and BSSLAP messages for our product.
All the IE (information elements) are defined by standards, so we know everything abt every field in the message. Currently we plan to do the whole thing in 'C', but I'm convinced that a C++ OO design would be much better (for testability and extensibility). Now before I start coming up with my own design, I was wondering if someone has already done it given that it's a common problem.

Thanks
Kashyap

PS: No response at Computer Science and Software Design so trying in this forum.

Dani AI

Generated

A practical architecture separates three concerns: the wire-level parser (bytes in/out), a plain message model (a small, immutable or value-type object that holds decoded IEs), and a pluggable codec layer that knows how to map between the two. Keeping low-level byte handling isolated reduces bugs, makes unit tests straightforward, and preserves the ability to swap implementations—exactly the gain hoped for by moving toward C++.

Combine simple, well-known patterns rather than inventing a new one. Use a Registry/Factory or Strategy to pick the right codec for a message type at runtime; implement a common Codec interface with virtual encode/decode operations; apply the Template Method for shared framing or length-check logic; use the State pattern for streaming parsers; and consider Visitor/Adapter for post-decode processing. For many telecom-style protocols a table-driven TLV parser or code-generation from the spec (when available) drastically reduces human error. Example minimal interface:

struct Buffer { const uint8_t* data; size_t len; size_t pos; };
class Codec {
public:
  virtual bool decode(Buffer&, Message&) const = 0;
  virtual bool encode(const Message&, std::vector<uint8_t>&) const = 0;
  virtual ~Codec() = default;
};

Important implementation notes: handle partial/streamed input (stateful parsing), always check lengths before advancing, canonicalize endianness early, and treat optional/conditional IEs explicitly (presence flags or TLV maps). Follow the practical rule: decode leniently (accept reasonable variations) but encode strictly (produce standard-conformant frames). Make codecs stateless where possible to simplify threading; if state is needed keep it per-parser instance.

Testing and maintenance matter more than clever design. Create unit tests for every IE, round-trip encode->decode vectors, golden byte-vector tests and fuzzing. ’s Strategy idea maps neatly to the registry approach, and ’s suggestion to study real product traces is useful for finding edge cases. This composition keeps the code readable, testable, and extensible for standards like BSSMAP/LAP.

Recommended Answers

All 4 Replies

Hello Everyone,
Does anyone know any design patterns for modules meant for encoding/decoding of protocol messages. E.g. BSSMAP/LAP...
We need to write encoders and decoders for BSSMAP and BSSLAP messages for our product.
All the IE (information elements) are defined by standards, so we know everything abt every field in the message. Currently we plan to do the whole thing in 'C', but I'm convinced that a C++ OO design would be much better (for testability and extensibility). Now before I start coming up with my own design, I was wondering if someone has already done it given that it's a common problem.

Thanks
Kashyap

PS: No response at Computer Science and Software Design so trying in this forum.

I'm not too familar with the BSSMAP or BASSLAP control protocols, however, I've found by observing how other applications work one can can extract ideas based on how an exisiting product(s) works. I try to find inspiration where ever I can find it. Regarding control nformation between MTP and BASS (i.e. certain control of traffic channels), read up on how an exisiting products. Using your knowledge of C++ and ideas (hopefully written) derived from a product specifications, you can pretty much visualize a pattern, algorithms or architecture for your enconding/decoding program that convert such information to a format specific to your product. Here is a link to some exisiting products you might find useful

Note: This is just to give you some ideas incase you don't find any support or help before the deadline require for the software development process.

Good luck, Lamabott

You might want to try the networking forums of Daniweb for information regarding applications used to encode/decode BSSMAP/LAP protocol header field/octect information.

Good luck, LamaBot

I'm not too familar with the BSSMAP or BASSLAP control protocols, however, I've found by observing how other applications work one can can extract ideas based on how an exisiting product(s) works. I try to find inspiration where ever I can find it. Regarding control nformation between MTP and BASS (i.e. certain control of traffic channels), read up on how an exisiting products. Using your knowledge of C++ and ideas (hopefully written) derived from a product specifications, you can pretty much visualize a pattern, algorithms or architecture for your enconding/decoding program that convert such information to a format specific to your product. Here is a link to some exisiting products you might find useful

Note: This is just to give you some ideas incase you don't find any support or help before the deadline require for the software development process.

Good luck, Lamabott

I wasn't looking for exactly BSSMAP/LAP, it could even be TCP/IP ! Any protocol at all will do. Thanks anyways.

You might want to try the networking forums of Daniweb for information regarding applications used to encode/decode BSSMAP/LAP protocol header field/octect information.

Good luck, LamaBot

That forum seems more on network configuration mgmt. :(.

Hello,

I'm newbye on this forum and I'm insterested by finding patterns for protocol coding/decoding. The idea is to use this kind of pattern with a Strategy patten to select which coder/decoder according messages cominmg from testbed equipment.

Thanks,

Best regards,

Yann

Hello Everyone,
Does anyone know any design patterns for modules meant for encoding/decoding of protocol messages. E.g. BSSMAP/LAP...
We need to write encoders and decoders for BSSMAP and BSSLAP messages for our product.
All the IE (information elements) are defined by standards, so we know everything abt every field in the message. Currently we plan to do the whole thing in 'C', but I'm convinced that a C++ OO design would be much better (for testability and extensibility). Now before I start coming up with my own design, I was wondering if someone has already done it given that it's a common problem.

Thanks
Kashyap

PS: No response at Computer Science and Software Design so trying in this forum.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.