Hi,
I am working on a simple protocol stack for a small embedded system (multidrop, rs485 type stuff). In this stack, losely models after OSI layers:
- Application
- Network
- Datalink
- physical (serial driver)
Each layer has its own header / footer portion that wraps the payload of the layer above it.
I will be using my own buffer pool of statically allocated fixed sized blocks to store the binary packets. (No malloc / free in this app.)
In other API's I have seen that the data is usually passed as a const pointer with an associated length. In this way the data would need a copy operation at each layer as the payload of the layer above is placed in a newly allocated buffer for the current layer.
For a three layer stack this would be 2 copy operations and 3 allocated buffers.
Is there a better way to do this and still maintain clean separation of the protocol layers?
To better anchor the discussion, lets say the packets are typically around 2k and the processor is a small 8 bit micro running at 8Mhz.