cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: FTP upload speed problem and buffer size

From: Alessandro Vesely <vesely_at_tana.it>
Date: Fri, 12 Oct 2007 07:35:29 +0200

Dan Fandrich wrote:
> On Thu, Oct 11, 2007 at 06:20:53PM +0200, Alessandro Vesely wrote:
>> Looking at the single data packets sent, I could see that the system ftp
>> tool always sent 1460 bytes per TCP packet, except the last that had 1082
>> (5523 total packets sent, including 3 empty handshake ones.) Whereas curl
>> sends a packet with 324 bytes after every 11 1460 bytes packets (thus
>> totaling 5906 packets sent, including 2+2 empty ones --for passive handshake.)
>
> That's the tradeoff that --tcp-nodelay makes: reduced latency but increased
> number of packets.

I captured another transfer of the same 8058822 bytes, using no options, and
obtained the same sending pattern. IMHO it happens because cURL sends one buffer
at a time, without refilling the buffer after a partial send has taken place.

The number of buffers sent this way is 5906 = (11+1)*491 + 9+1 + 2+2:
12 buffers * 491 times + 14278 =
(11 * 1460 + 324) * 491 + 1460 * 9 + 1138,
where 1 buffer is 0x4000 bytes, see attached file.
(Curiously, this morning I had 10 packets more on the relevant capture file.)

Refilling the buffer each time gave 5523 = 5519 + 1 + 1+2:
5519*1460 + 1*1082 = 8057740 + 1082 = 8058822.

Thus, curl sent 383 data packets more. Assuming a constant time per packet,
that would result in approximately a 7% increase, roughly 1 second every 14.
That, together with the rounded time in the xferlog, more or less explains
the timings I got. Dunno what curious TCP pattern could have been triggered
to obtain the much more relevant difference that Ivan reported...

 19 0.00052 client -> server TCP D=3562 S=1773 Syn Seq=4068174890 Len=0 Win=16384 Options=<mss 1460,nop,nop,sackOK>
 21 0.00026 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4068174891 Len=0 Win=17520
 26 0.00161 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4068174891 Len=1460 Win=17520
 28 0.00111 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4068176351 Len=1460 Win=17520
 30 0.00139 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4068177811 Len=1460 Win=17520
 31 0.00122 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4068179271 Len=1460 Win=17520
 32 0.00123 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4068180731 Len=1460 Win=17520
 34 0.00117 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4068182191 Len=1460 Win=17520
 35 0.00137 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4068183651 Len=1460 Win=17520
 36 0.00123 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4068185111 Len=1460 Win=17520
 37 0.00123 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4068186571 Len=1460 Win=17520
 39 0.00143 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4068188031 Len=1460 Win=17520
 40 0.00122 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4068189491 Len=1460 Win=17520
 41 0.00037 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4068190951 Len=324 Win=17520
 44 0.00150 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4068191275 Len=1460 Win=17520
 45 0.00121 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4068192735 Len=1460 Win=17520
 46 0.00123 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4068194195 Len=1460 Win=17520
 47 0.00123 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4068195655 Len=1460 Win=17520
 48 0.00123 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4068197115 Len=1460 Win=17520
 49 0.00124 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4068198575 Len=1460 Win=17520
 50 0.00122 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4068200035 Len=1460 Win=17520
 51 0.00123 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4068201495 Len=1460 Win=17520
 54 0.00144 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4068202955 Len=1460 Win=17520
 55 0.00120 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4068204415 Len=1460 Win=17520
 56 0.00123 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4068205875 Len=1460 Win=17520
 57 0.00037 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4068207335 Len=324 Win=17520
 60 0.00152 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4068207659 Len=1460 Win=17520
 61 0.00122 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4068209119 Len=1460 Win=17520
 62 0.00122 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4068210579 Len=1460 Win=17520
 63 0.00123 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4068212039 Len=1460 Win=17520
 64 0.00123 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4068213499 Len=1460 Win=17520
 65 0.00123 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4068214959 Len=1460 Win=17520
 66 0.00123 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4068216419 Len=1460 Win=17520
 67 0.00124 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4068217879 Len=1460 Win=17520
 68 0.00122 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4068219339 Len=1460 Win=17520
 69 0.00123 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4068220799 Len=1460 Win=17520
 70 0.00122 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4068222259 Len=1460 Win=17520
 72 0.00052 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4068223719 Len=324 Win=17520

7874 0.00153 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4076186667 Len=1460 Win=17520
7875 0.00122 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4076188127 Len=1460 Win=17520
7876 0.00123 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4076189587 Len=1460 Win=17520
7877 0.00124 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4076191047 Len=1460 Win=17520
7878 0.00123 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4076192507 Len=1460 Win=17520
7880 0.00118 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4076193967 Len=1460 Win=17520
7881 0.00123 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4076195427 Len=1460 Win=17520
7882 0.00123 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4076196887 Len=1460 Win=17520
7884 0.00118 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4076198347 Len=1460 Win=17520
7885 0.00123 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4076199807 Len=1460 Win=17520
7886 0.00123 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4076201267 Len=1460 Win=17520
7888 0.00031 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4076202727 Len=324 Win=17520
7890 0.00153 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4076203051 Len=1460 Win=17520
7891 0.00122 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4076204511 Len=1460 Win=17520
7892 0.00123 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4076205971 Len=1460 Win=17520
7893 0.00124 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4076207431 Len=1460 Win=17520
7894 0.00123 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4076208891 Len=1460 Win=17520
7896 0.00118 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4076210351 Len=1460 Win=17520
7897 0.00123 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4076211811 Len=1460 Win=17520
7898 0.00123 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4076213271 Len=1460 Win=17520
7899 0.00123 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4076214731 Len=1460 Win=17520
7900 0.00123 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4076216191 Len=1460 Win=17520
7901 0.00123 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4076217651 Len=1460 Win=17520
7902 0.00036 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4076219111 Len=324 Win=17520
7906 0.00169 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4076219435 Len=1460 Win=17520
7907 0.00121 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4076220895 Len=1460 Win=17520
7908 0.00123 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4076222355 Len=1460 Win=17520
7909 0.00123 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4076223815 Len=1460 Win=17520
7910 0.00123 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4076225275 Len=1460 Win=17520
7912 0.00116 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4076226735 Len=1460 Win=17520
7913 0.00123 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4076228195 Len=1460 Win=17520
7914 0.00123 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4076229655 Len=1460 Win=17520
7916 0.00118 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4076231115 Len=1460 Win=17520
7917 0.00097 client -> server TCP D=3562 S=1773 Ack=1432200431 Seq=4076232575 Len=1138 Win=17520
7920 0.00034 client -> server TCP D=3562 S=1773 Fin Ack=1432200431 Seq=4076233713 Len=0 Win=17520
7924 0.00050 client -> server TCP D=3562 S=1773 Ack=1432200432 Seq=4076233714 Len=0 Win=17520
Received on 2007-10-12