cURL / Mailing Lists / curl-users / Single Mail

curl-users

Timeout Behavior for Curl TFTP

From: Grant Erickson <gerickson_at_nuovations.com>
Date: Mon, 05 Jan 2009 11:09:13 -0800

Using both curl-7.18.2 and curl-7.19.2:

    # curl --version
    curl 7.19.2 (powerpc-4xx-linux-gnu) libcurl/7.19.2 OpenSSL/0.9.8g
zlib/1.2.3
    Protocols: tftp ftp http file https ftps
    Features: IPv6 Largefile NTLM SSL libz

I have noticed for TFTP that the connect-timeout, max-time and limit-rate
options do not work as expected. Conducting the following on the host and
target systems. On the host:

    % cd /export/tftp/outbound
    % for size in 8 16 32; do
    dd if=/dev/urandom of=${size}MiB bs=1M count=${size}
    done

On the target, I then attempt the following several trials:

1) Specify connect-timeout only:

    for size in 8 16 32; do
    time curl --connect-timeout 5 tftp://192.168.1.14/outbound/${size}MiB -o
/tmp/${size}MiB
    done

This typically works for the 8 Mib and 16 MiB file sizes but frequently
fails for the 32 MiB file size:

    curl: (28) Timeout was reached
    Command exited with non-zero status 28
    real 0m 5.51s
    user 0m 0.54s
    sys 0m 1.20s

2) Trying to limit the rate to ensure it fails in all cases, has no effect,
still resulting in file transfers with between 800 to 1000 KiB/s throughput:

    for size in 8 16 32; do
    time curl --connect-timeout 5 --limit-rate 256k
tftp://192.168.1.14/outbound/${size}MiB -o /tmp/${size}MiB
    done

3) Thinking that adding max-time might coax connect-time to work correctly,
connect-time still prevails in limiting the transfer:

    for size in 8 16 32; do
    time curl --connect-timeout 5 --limit-rate 256k --max-time 60
tftp://192.168.1.14/outbound/${size}MiB -o /tmp/${size}MiB
    done

    curl: (28) Timeout was reached
    Command exited with non-zero status 28
    real 0m 5.51s
    user 0m 0.54s
    sys 0m 1.20s

Is this "as-designed" behavior for TFTP or is this in error and in need of a
fix-up? For HTTP, these options behave correctly (or at least as I expect
they would).

While TFTP is not a connection-oriented (i.e. TCP) implementation making the
connect-timeout option somewhat ambiguous, my expectation is that
connect-timeout option would control the first sendto/recvfrom to/from the
server and max-time would control the entire transaction. If there's
agreement, I'll proceed with a patch.

Regards,

Grant Erickson

-------------------------------------------------------------------
List admin: http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2009-01-05