cURL / Mailing Lists / curl-library / Single Mail

curl-library

Issue with FTP and PRETRANSFER_TIME

From: Tobias Jacobowitz <tobias_at_thousandeyes.com>
Date: Tue, 29 Mar 2016 13:17:43 -0700

Hi,

I am using libcurl for doing FTP RETR requests and have an issue with the
CURLINFO_PRETRANSFER_TIME.
I expected this time to be the time until Curl sends the RETR command, as
the documentation is stating the following for this time:
"time, in seconds, it took from the start until the file transfer is just
about to begin. This includes all pre-transfer commands and negotiations
that are specific to the particular protocol(s) involved. It does not
involve the sending of the protocol- specific request that triggers a
transfer."

Although it seems that Curl is actually meausuring the time until the
server's response to the RETR command is received. In order to understand
this behavior I used some of the debug options and got the following output:

1.62899 => Send header, 0000000024 bytes (0x00000018)
  0000: SIZE someFileName
1.79143 <= Recv header, 0000000011 bytes (0x0000000b)
  0000: 213 80000
1.79148 => Send header, 0000000024 bytes (0x00000018)
  0000: RETR someFileName
1.95394 <= Recv header, 0000000054 bytes (0x00000036)
  0000: 125 Data connection already open; Transfer starting.
1.95548 <= Recv data, 0000000000 bytes (0x00000000)

The floats at the beginning of the lines are the elapsed time in seconds
since the start of the transaction.
In this case the time information Curl gave me are as follows:

CURLINFO_PRETRANSFER_TIME 1.95398
CURLINFO_STARTTRANSFER_TIME 1.95544

As you can see, the CURLINFO_PRETRANSFER_TIME is apparently the time when
the server's "125" response was received and not the time the RETR was
send, which was 1.79148.
CURLINFO_STARTTRANSFER_TIME is the time it took until the first payload
bytes were received by Curl, which seems to be fine.

I am not sure if this is the intended behavior? If so, I think it's
violating the definition in the documentation as the transfer is just about
to begin when the RETR command is issued. Right now this time is actually
including "sending of the protocol- specific request that triggers a
transfer", although the definition states that it shouldn't.
Furthermore the timings are not very helpful the way they are now as
CURLINFO_PRETRANSFER_TIME and CURLINFO_STARTTRANSFER_TIME should be usually
extremely close in the current implementation.

I attached example code, which can be used to produce these measurements.
Just pass the URL (including credentials) as the command line argument,
like this:
./CurlPreTransferExample ftp://user:password@server/path/to/file

I used the current master of Curl's git repo.

Best regards,
Tobias Jacobowitz

-------------------------------------------------------------------
List admin: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html

Received on 2016-03-29