Every time I'm trying to upload a file using scp on my slow upload connection (~100kb/s), it shows something like :

test                           27% 2208KB   2.2MB/s   00:02 ETA

On the first second I started it.

Obviously, it hasn't transferred 2208KB, and it's definitely not transferring at 2.2MB/s. After few seconds, it goes down to a correct speed, but does not go back on its previous lie: instead, when the transfer finishes, it hangs for seconds (or minutes) until the transfer is really finished.

I've seen that with every scp, on every linux, everytime my transfer speed is lower than 1MB/s.

What is going on with SCP ?


scp is measuring the rate that data is passing through it.

Basically, scp reads some data from disk and passes it off over a pipe to ssh. There is a pipe buffer in the kernel, though that's fairly small. Then ssh encrypts it and passes it off to the kernel to send over the network. That buffer can be fairly large.

All the buffering is fairly transparent to the app; it just does as write call against the pipe or socket. The kernel accepts the data, and doesn't point out to the app if its sitting in a buffer or has actually been sent and acknowledged by the remote side. There are ways for the app to to ask—but that'd be hard for scp, as ssh is actually handling the socket.

What you're seeing then is that the initial fill of all the buffers (mostly the TCP send buffer) happens rapidly—and scp is displaying that as its transfer rate. At then end, scp finishes reading the file, sends it to ssh over the pipe, and waits for ssh to finish. ssh sees that scp is done sending, and waits for the kernel to finish flushing the TCP buffer. That's the pause at the end.

I think the only two solutions (other than 'ignore it') are to get a faster link or to lower your TCP send buffer size.

  • Thanks, I understand a little better what's happening now. – blue112 Mar 30 '15 at 14:28

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.