3 ms·
Good protocols are usually made in layers. You would typically want to have some state machine describing lower part of application protocol on which you build
by lmilcin 6y ago
Good protocols are usually made in layers. You would typically want to have some state machine describing lower part of application protocol on which you build higher level of your application protocol, composed of specific functions.
This way you can modify functionality without necessarily touching low level implementation.
I can give an example.
I have worked with credit card terminals and I have implemented entire application from scratch.
There is a protocol to communicate between the terminal and the acquirer's system (ISO 8583).
This protocol specifies a flow and format of messages. For example, if you send a transaction request, you will get a response. If you don't get a response you may or may not retry it, etc. If you send a transaction advice (ie. transaction has already happened) you must be retrying sending it until you get a response, but every retransmission after first must include a bit that says it is retransmission. If the request or advice has been sent and transaction was cancelled, you need to be sending cancellations until you get an acknowledgement.
Now, all those messages have a huge amount of fields that change regularly as requirements change, but the basic flow of the protocol is fairly constant and has been constant for many years.
I have implemented the protocol as a tree of state machines telling the application what to do based on events and I believe the code has not been touched in over 10 years even though the application was in constant development.