paramiko/paramiko — pull request #63 by dlitz (2012-03-25 19:12:22+00:00)
Title: Fix SSHException when re-keying over a fast connection

When Paramiko initiates a re-key request over a high-bandwidth, medium-latency
connection, it erroneously terminates the connection with the error,
"SSHException: Remote transport is ignoring rekey requests". This is due to
the hard-coded limit of 20 packets that may be received after a re-key request
has been sent.

See, for example, this bug report:

"Transfer fails at 1GB: rekey window too small, hard-coded"
https://github.com/paramiko/paramiko/issues/49

This patch changes paramiko's behaviour as follows:

- Decrease the threshold for starting re-keying from 2**30 to 2**29 bytes.
- Decrease the threshold for starting re-keying from 2**30 to 2**29 packets.
- Increase the limit of received packets between re-key request & completion
from 20 packets to 2**29 packets.
- Add a limit of 2**29 received bytes between re-key request & completion.

In other words, we re-key more often in order to allow more data to be
in-transit during re-keying.

NOTE: It looks like Paramiko disables the keep-alive mechanism during
re-keying. This patch does not change that behaviour.