Re: does putty use non-blocking sockets?



yawnmoth <terra1024@xxxxxxxxx> wrote:
In my own SSH implementation, uploads are done at half the speed of
downloads. This is especially odd given that AES encrypts (which is
what it'd mostly be doing when uploading) twice as fast as it decrypts
(ie. as it downloads).

What on earth are you talking about? My implementation of AES goes
exactly as fast one way as the other, and I just refreshed my memory
of the AES algorithm and can't see anything in the spec that
suggests such a speed imbalance. Where do you get that figure from?

The reason why it does this is because, for whatever reason, the
socket blocks longer when writing than it does when reading. I was
thinking that one way to work around this would be to use non-blocking
sockets. ie. write one packet before the last packet has been
completely written. Is this what PuTTY (which doesn't have any
slowdowns like this) does?

I think you may have completely misunderstood. Non-blocking sockets
are an implementation detail which permit a program to carry on
doing computation while waiting for a time-dependent OS resource to
become available. Unless you had a _lot_ of computation you needed
to do while waiting, which in this case I doubt, they won't be the
cause of a factor of two speed difference in SFTP: they may have
performance implications one way or the other in terms of a few
system calls cost or saved, but that won't materially affect the
speed of a network transfer, because it'll be negligible compared to
the network bandwidth and latency.

More likely, the reason why your SFTP implementation is slower on
upload than on download is because upload is where an implementation
has the opportunity to optimise network usage in the face of
latency. What is your strategy for queueing FXP_WRITE messages? Do
you just send one, wait for the reply, and then send another?

One thing I worry about, with this, is... could the servers internal
buffer get full and start silently dropping packets?

No, don't worry about that. Network stacks are carefully designed
not to do that. Every OS software layer at both ends of a network
connection will keep the next layer along fully aware of how much
buffer space it still has available, so that nobody sends more data
at any time than the next layer is prepared to cope with.

The practical upshot is that if you try to send data when too much
data is already buffered, your send() or write() call will block, or
if you're using nonblocking sockets it will instead return
EWOULDBLOCK or EAGAIN (depending on local fashion) to alert you that
all the buffers are full and you should try again later.
--
Simon Tatham "That all men should be brothers is a
<anakin@xxxxxxxxx> dream of people who have no brothers."
.



Relevant Pages

  • Problems uploading large files to some web sites (long)
    ... NATted OBSD 3.1 running pf with all internal hosts connecting via ethernet through a switch or a wireless access point connected to the switch. ... On or about the time the servers were moved to the Yahoo net I became unable to upload photos via their upload form. ... Trying the same tests on my home network, but with my desktop connected via a VPN to the office network. ...
    (comp.unix.bsd.openbsd.misc)
  • Re: Recommendation for broadband access wanted
    ... For a time I thought Tiscali would be interesting, but after having read their policy is very restrictive on downloads during peak hours I am afraid I would easily be hit by them. ... mail account ... webspace ... For a little more, you could double your upload speed as well, which would make those big uploads go past more easily... ...
    (uk.telecom.broadband)
  • Re: Trouble with uploading links to host
    ... your pdf files to your website, and write the link to where you upload them. ... Most of us find that having a separate folder for downloads on our website ...
    (microsoft.public.publisher.webdesign)
  • Re: cpu freezes only during networking operations
    ... I have a home network setup which works fine ... > unless I try to upload or download a large amount of data. ... > mpeg, it occaisionally freezes. ...
    (microsoft.public.windowsxp.network_web)
  • Re: Trouble with uploading links to host
    ... your pdf files to your website, and write the link to where you upload them. ... Most of us find that having a separate folder for downloads on our website ... Then upload the pdf files you want available for download to that folder. ...
    (microsoft.public.publisher.webdesign)

Quantcast