Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I verify that a TCP packet has received an ACK in C#?

Tags:

c#

.net

tcp

After sending some tcp data with the blocking/non-blocking methods such as:

Socket.Send() or Socket.SendAsync()

How can I know that my data has received an ACK message?

Can .NET know if TCP data has been successfully sent?

like image 211
Justin Tanner Avatar asked Dec 07 '09 21:12

Justin Tanner


People also ask

Does TCP have ACK packets?

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).

How does TCP send ACK?

In TCP's sliding-window scheme, the receiver acknowledges the data it receives, so that the sender can advance the window and send new data. As originally specified, TCP's acknowledgements ("ACKs") are cumulative: the receiver tells the sender how much consecutive data it has received.

Can the receiver know if ACK packet is missing?

The fundamental difficulty with duplicate packets is that the receiver doesn't know whether the ACK or NAK it last sent was received correctly at the sender. Thus, it can not know a priori whether an arriving packet contains new data or is a retransmission!

What is ACK packet in TCP?

TCP uses a three-way handshake to establish a reliable connection. The connection is full duplex, and both sides synchronize (SYN) and acknowledge (ACK) each other. The exchange of these four flags is performed in three steps—SYN, SYN-ACK, and ACK—as shown in Figure 3.8.


2 Answers

The only way to know for sure is to implement some kind of application-level acknowledgement. The TCP level "ACK" packet is not exposed to the application level at all, so you have to use something more than that.

like image 168
Greg Hewgill Avatar answered Oct 25 '22 13:10

Greg Hewgill


You make the other end respond to it.

Even if TCP has Acked it, if the receiving end terminates (for good or bad reasons) before processing the message and acting on it, you still don't know, so the only way to know is for the other end to tell you.

like image 41
Simeon Pilgrim Avatar answered Oct 25 '22 12:10

Simeon Pilgrim