Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I explicitly wait for a TCP ACK before proceeding?

Tags:

c

tcp

sockets

Is there a way to get send() to wait until all the data that has been sent has been ACK-ed (or return -1 if the timeout for an ACK has been reached), or is there some other mechanism to wait for the ACK after the send() but before doing something else?

I am using the standard Unix Berkeley sockets API.

I know I could implement an application-layer ACK, but I'd rather not do that when TCP's ACK serves the purpose perfectly well.

like image 728
HighCommander4 Avatar asked Nov 21 '11 21:11

HighCommander4


People also ask

Does TCP wait for ACK before sending next packet?

If both segments should be sent together, then the application should not be setting PSH on the data in 14910. So the summary is if we do PSH into the current window TCP will never send the next packet until the ACK for the first is received (until it is filled or time to send triggers).

What is the best reason why TCP uses delayed acknowledgement?

TCP delayed acknowledgment or Delayed ACK is another technique used by some implementations of the TCP in an effort to improve network performance and reduce congestion. Delayed ACK was invented to reduce the number of ACKs required to acknowledge the segments and reduce the protocol overhead.

Does TCP always send ACK?

SYN starts a connection; you'll usually only see it when the connection's being established. But all data being sent via TCP requires an ACK. Every byte sent must be accounted for, or it will be retransmitted (or the connection reset (closed), in severe cases).

What is ACK in TCP?

ACK is short for "acknowledgement." An ACK packet is any TCP packet that acknowledges receiving a message or series of packets. The technical definition of an ACK packet is a TCP packet with the "ACK" flag set in the header.


2 Answers

AFAIK there is no way.

Also, it wouldn't be reliable, the ACK means only that the kernel received the data, in the meantime the client or its machine could have crashed. You would think the client received the data, but actually it never processed it.

like image 100
Karoly Horvath Avatar answered Sep 22 '22 18:09

Karoly Horvath


Unfortunately standard API doesn't reserve any appropriate way to do this. There could be a way to query the current TCP send window size/usage, but unfortunately it may not be queried by the standard means.

Of course there are tricky ways to achieve what you want. For instance on Windows one may create a network filter driver to monitor packet-level trafic.

like image 43
valdo Avatar answered Sep 23 '22 18:09

valdo