There was a need to organize a specific protocol on top of TCP, which works on the principle:
1) Side A sends data to side B (int, char, double, not important);
2) Side A expects 1 byte - confirmation that the data is received and processed on side B, rather than lying in the internal system buffer on side A (or even on side B).
The problem is that party B can disrupt the logical consistency of actions, for example, with the goal of side A. collapse.
Side B in response to incoming data can send not 1 byte with confirmation, but two or more. Or even send one byte immediately, but somewhere after receiving a byte on side A, but before sending the next data on side A, send more.
Thus, there will be a mismatch, and I do not understand how to control him on the side of A.
For the sake of simplicity, we can assume that A sends data and B sends confirmation that it is a one-way data sending channel.
For example, how is this problem solved in protocols such as SIP? How is it controlled that the answer came precisely from "ACK", and not from "ACK ^ 53"?
I hope I managed to describe the essence of the problem quite clearly.