jeudi 25 juillet 2019

What is a good design of a custom communication protcol?

I have to implement a communication protocol stack. There exists already an outlining design. The stack consist of 3 layers (connection-control, security, fragmentation). The functionality of these layers is not relevant here. The idea is, that each layer processes an incoming/outgoing telegram according to its responsibility and hands it to the next layer in the stack. I thinks that’s the usual idea of a stack.

My question is, what a good design is and how are the dependencies of the various items of each layer.

I have thought of two approaches:

  1. A chain like implementation: For an incoming telegram, a process-in data function of the connection control item is called by a preceding item (not in the scope of this post). Then the connection control does something with the telegram and then calls the security items process-in data function, then the security item does something and forwards the telegram to the fragmentation item. The same idea applies for outgoing telegrams, in a reversed direction by calling process-out data functions.

  2. A central control item implementation: In this approach a central control gets the an incoming telegram, it then calls the process-in data function of the connection-control which returns the telegram after doing something. Then the central control item calls the process-in data function of the security item and so on. Maybe this central control item could be implemented as a state-machine, where each state represents one of the communication protocol layers mentioned above.

Aucun commentaire:

Enregistrer un commentaire