Про квитирование. Вот нашел в RFC916, думаю должно подойти:
2.3. Sequence Numbers
Sequence numbers work with acknowledge numbers to inform the
sender that his last data packet was received, and to inform the
receiver of the sequence number of the next data packet it expects
to see. When the ACK flag is set in a packet the AN field
contains the sequence number of the next data packet it expects
from the sender. The sender looks at the AN field and by
implication knows that the packet he just sent should have had a
sequence number of:
If it did have that number that packet is considered to have been
acknowledged.
Similarly, the receiver expects the next data packet it sees to
have an SN field value equal to the AN field of the last
acknowledge message it sent. If this is not the case then the
receiver assumes that it is receiving a duplicate of a data packet
it earlier acknowledged. This implies that the packet containing
the acknowledgment did not arrive and therefor the packet that
contained the acknowledgment should be retransmitted. The
duplicate data packet is discarded.
The only packets which require acknowledgment are packets
containing status flags (SYN, RST, FIN, or SO) or data. A packet
which contains only an acknowledgment, i.e. , does
not require a response (it contains no status flags or data).
Both the AN and SN fields are a single bit wide. Since at most
one packet is in the process of being sent/acknowledged in a
particular direction at any one time a single bit is sufficient to
provide a method of duplicate packet detection and removal of a
packet from the retransmission queue. The arithmetic to advance
these numbers is modulo 2. Thus when a data packet has been
acknowledged the sender's next sequence number will be the current
one, plus one modulo 2:
The individual acknowledgment of each packet containing data can
mislead one into thinking that side A of a connection cannot send
data to side B until it receives a packet from B. That only then
can it acknowledge B's packet and place in the acknowledging
packet some data of its own. This is not the case.
As long as its last packet sent requiring a response has been
acknowledged each side of a connection is free to send a data
packet whenever it wishes. Naturally, if one side is sending a
data packet and it also must acknowledge receipt of a data packet
from the other side, it is most efficient to combine both
functions in a single packet.