1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 <2019> 2020 2021 2022 2023 2024 2025 | Index | 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 <2019> 2020 2021 2022 2023 2024 2025 |
<== Date ==> | <== Thread ==> |
---|
Subject: | RE: Uploading a file with SFTP from an EPICS driver - Issue fixed! |
From: | Mark Rivers via Tech-talk <[email protected]> |
To: | "'Johnson, Andrew N.'" <[email protected]> |
Cc: | "[email protected]" <[email protected]> |
Date: | Tue, 19 Nov 2019 14:37:16 +0000 |
I removed my private key to eliminate failed private/public key negotiation failure from possibly slowing things down.
This is the comparison of curl and curl_gen, which is the code that curl generated with the –libcurl option. corvette:motorNewport/newportApp/src>time curl -k -s -u Administrator:Administrator -T TrajectoryScan.trj --verbose scp://164.54.160.71/Admin/Public/Trajectories/ * Trying 164.54.160.71... * TCP_NODELAY set * Connected to 164.54.160.71 (164.54.160.71) port 22 (#0) * SSH MD5 fingerprint: 8de67ccf8c2f9b3b584c703b9fb749f6 * SSH authentication methods available: publickey,password,keyboard-interactive * Using SSH private key file '' * SSH public key authentication failed: Unable to extract public key from private key file: Unable to open private key file * Initialized password authentication * Authentication complete * SSH CONNECT phase done } [5149 bytes data] * We are completely uploaded and fine * Connection #0 to host 164.54.160.71 left intact 0.009u 0.005s 0:00.12 0.0% 0+0k 0+0io 0pf+0w corvette:motorNewport/newportApp/src>time ../../../../bin/linux-x86_64/curl_gen < TrajectoryScan.trj * About to connect() to 164.54.160.71 port 22 (#0) * Trying 164.54.160.71... * Connected to 164.54.160.71 (164.54.160.71) port 22 (#0) * SSH MD5 fingerprint: 8de67ccf8c2f9b3b584c703b9fb749f6 * SSH authentication methods available: publickey,password,keyboard-interactive * Using SSH private key file '' * SSH public key authentication failed: Unable to extract public key from private key file: Unable to open private key file * Initialized password authentication * Authentication complete * SSH CONNECT phase done * We are completely uploaded and fine * Connection #0 to host 164.54.160.71 left intact 0.007u 0.005s 0:00.31 0.0% 0+0k 0+0io 0pf+0w Note that there is still a large difference in time, curl takes 120 ms, curl_gen takes 310 ms. The messages from libcurl are identical for both commands
except that curl has the message “TCP_NODELAY set”. I then modified curl_gen.c to add this line: curl_easy_setopt(hnd, CURLOPT_TCP_NODELAY, 1L); That fixed the issue! corvette:motorNewport/newportApp/src>time ../../../../bin/linux-x86_64/curl_gen < TrajectoryScan.trj * About to connect() to 164.54.160.71 port 22 (#0) * Trying 164.54.160.71... * TCP_NODELAY set * Connected to 164.54.160.71 (164.54.160.71) port 22 (#0) * SSH MD5 fingerprint: 8de67ccf8c2f9b3b584c703b9fb749f6 * SSH authentication methods available: publickey,password,keyboard-interactive * Using SSH private key file '' * SSH public key authentication failed: Unable to extract public key from private key file: Unable to open private key file * Initialized password authentication * Authentication complete * SSH CONNECT phase done * We are completely uploaded and fine * Connection #0 to host 164.54.160.71 left intact 0.011u 0.003s 0:00.12 8.3% 0+0k 0+0io 0pf+0w Now curl_gen also takes only 120 ms. I don’t know why curl –libcurl curl_gen.c was not putting that line in curl_gen.c, since it is clearly required to reproduce the behavior of the curl command I used. This is the documentation for CURLOP_TCP_NODELAY
https://curl.haxx.se/libcurl/c/CURLOPT_TCP_NODELAY.html Pass a long specifying whether the TCP_NODELAY option is to be set or cleared (1L = set, 0 = clear). The option is set by default. This will have no effect after the connection
has been established.
Setting this option to 1L will disable TCP's Nagle algorithm on this connection. The purpose of this algorithm is to try to minimize the number of small packets on the network (where "small packets" means TCP segments less than the
Maximum Segment Size (MSS) for the network).
Maximizing the amount of data sent per TCP segment is good because it amortizes the overhead of the send. However, in some cases small segments may need to be sent without delay. This is less efficient than sending larger amounts of
data at a time, and can contribute to congestion on the network if overdone. Note that the documentation appears to be wrong. It says that the option is set by default. This appears to be true for the curl command, but not for libcurl. I had to explicitly set the option. Thanks, Mark From: Johnson, Andrew N. <[email protected]>
So if you aren’t using the public/private key-pair for the SFTP transfer that might be a cause of the slow-up. Try removing it, or adjusting the .ssh/config file so it won’t be used for that host to see if that
changes the timing. - Andrew -- Sent from my iPad
|