I am trying to figure an agreement protocol on an unreliable channel. Basically two parties (A and B) have to agree to do something, so it's the two generals' problem.
Since there is no bullet-proof solution, I am trying to do this.
- A continuously sends a message with sequence 1
- When B receives seq 1 it continuously replies with sequence 2
- At this point A receives seq 2 so it starts sending seq 3
- ...
My question. When can the two parties conclude that they can take the action ? Obviously I can't set a condition: "do it after receiving 10 messages" since the last sender won't have any certainty that message 10 arrived - back to square one.
How about another idea:
- Keep communicating like this for a predefined amount of time. At the end of that period both parties have an idea about the reliability of the channel. Would that be acceptable ?
You can add reliability by saving the current state of all sequences IDs that were sent (something like a calculation of a hash function or 3DES calculation or even a PKI certificate per message - the latter would cost a lot...). The 2 generals problem cannot be solved, but with more information about the problem, I think I can give you a better answer...
BTW, no matter how much time would you send message, the reliability problem would stay event after 100 hours (the probability of a bad occurance will decrease, though). That means maybe you need a third object C, that knows A and B, and can be a kind of a witness for the communication (something like PKI that I've mentioned).