1

Say I have an SSH tunnel from my local machine to a database on a remote server.

If I send a query into the tunnel, it comes out on the other side, but halfway through sending the query or receiving the result the Database triggers a TCP RST, how does SSH handle that?

Does it:

  1. Wait to ACK packets on either side until it has received an ACK from the endpoints?
  2. Buffer application level data and resend until successful?
  3. Other?

My worry is that if the tunnel ACKs before the other side ACKs, and the other side instead sends a RST then there is no way to propagate that RST back. Both sides will just hang.

  • ACKs are handled by the TCP layer, not the application. – Barmar Mar 7 '18 at 21:02
0

How will "both sides will just hang"? Do you actually observe that?

Quoting from "TCP/IP Illustrated, Volume 1, 2nd edition" p. 628:

The reset segment contains a sequence number and acknowledgement number. Also notice that the reset segment elicits no response from the other end—it is not acknowledged at all. The receiver of the reset aborts the connection and advises the application that the connection was reset. This often results in the error indication "Connection reset by peer" or a similar message.

And on the previous page:

Aborting a connecting provides two features...any queued data is thrown away and a reset segment is sent immediately...the receiver of the reset can tell that the other end did an abort instead of a normal close.

(You may also want to review the socket option SO_LINGER that may be used by the listening socket of your application.)

  • Not so much a TCP question, but a "how does the tunnel handle TCP". Does it ACK all packets coming in before replaying them on the other side? Does it pass the TCP sequence through transparently and replay both sides? Am I guaranteed to have the same sequence numbers on either side of the tunnel? – Breedly Mar 7 '18 at 20:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.