Subject: Re: libssh2 32500 bytes packet size limit

Re: libssh2 32500 bytes packet size limit

From: Peter Stuge <>
Date: Fri, 11 Jun 2010 19:01:20 +0200

Daniel Stenberg wrote:
>> I believe there's a disconnect between the buffer size used by the
>> calling app and packets that are generated by the library.
> The buffer size of the app doesn't really matter now

I think they do, in the sense that if an app gives libssh2 a 64kb
buffer then I think that should be the payload of a single SSH

As an interim solution I really like your latest SFTP fix, but in
principle I consider it to be the wrong solution.

> libssh2_sftp_write() will only read as many bytes as it stuffs into
> a single packet and pushes down the stream and it will return that
> amount. The app will of course call libssh2_sftp_write() again when
> it returns short.

Yep, and it'll work, but packet size is still stuck at the
(32k-overhead) limit in the transport layer, which I think is the
real problem.

Alexander Lamaison wrote:
> Out of curiosity, where does this 32,500 byte limit come from? Is
> it a protocol limit?

Not at all. It's a stupid limit in the libssh2 transport layer code
for generating packets. There is a 32768 byte buffer, and the SSH
protocol adds some bytes overhead. 32500 has been verified to leave
enough bytes during all testing so far, but I can't guarantee that it
is a safe value, I don't know how much padding, if any, libssh2 can
end up appending to outgoing packets.

Received on 2010-06-11