Subject: Re: SFTP slow read in libssh2 compared to SecureCRT

Re: SFTP slow read in libssh2 compared to SecureCRT

From: Lars Nordin <Lars.Nordin_at_sdlabs.se>
Date: Wed, 25 Mar 2015 23:29:33 +0100

Hi again,

I have enabled trace and gets a bunch of
[libssh2] 4.816541 SFTP: Marking request ID 63 as a zombie request
[libssh2] 4.816541 SFTP: Marking request ID 64 as a zombie request
[libssh2] 4.816541 SFTP: Marking request ID 65 as a zombie request

up to ID 266. I don't see any ID on the packages received, just:
[libssh2] 0.675533 SFTP: Received packet 103 (len 2009)

and then some
[libssh2] 4.826541 SFTP: recv packet
[libssh2] 4.826541 SFTP: Data begin - Packet Length: 28
[libssh2] 4.826541 SFTP: Received packet 101 (len 28)
[libssh2] 4.826541 SFTP: Removing request ID 63 from the list of zombie
requests

The code to read is:
do {
             /* read in a loop until we block */
             rc = libssh2_sftp_read(sftp_handle, mem, amount);

             NOTE("libssh2_sftp_read returned %d\n", rc);

             if(rc > 0) {
                 fwrite(mem, 1, rc, local);
                 got += rc;
                 NOTE("got = %d\n", got);
             }
         } while (rc > 0);

and I get 2000 bytes each time. The testfile is 116K.

Any thoughts? I will try to dig into the sftp-code...

/Lars

On 2015-03-23 14:52, Lars Nordin wrote:
> Hi,
>
> I'm using libssh2 for different purpose, one of them is write/read
> files using SFTP. I just start using version 1.5.0 and I can't get the
> SFTP-read up to speed. I'm testing with a 76M file and using SecureCRT
> SFTP I get 81s for the download, with libssh2 SFTP 44 minutes!!!
>
> If a use SCP I get download in 12s!!
>
> The libssh2_sftp_read() always return 2000, despite I call it with a
> buffer of 100k.
>
> If a look at the network with wireshark and compare the data on the
> network, I notice that
> o with SecureCRT SFTP the server send data in 1460 sized packages,
> at least 10 packets before the client send some data (up to 32 packets
> I notice)
> o with libssh2 the server send data in different sizes (1460 and
> less, many times 1460 followed by 592) and 1-4 packets before the
> client send something.
>
> The test is done using a OpenSSH sshd in a Linux virtual machine.
> Client is Windows7
>
> I copied the sftp_RW_nonblock example.
>
> Can I change something?
>
> /Lars
>
>
> _______________________________________________
> libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2015-03-25