Lors d’un diagnostic d’un lien réseau, cURL propose des options très informatives qu’il serait dommage de ne pas profiter. Grâce à elles, on va pouvoir mesurer les différentes étapes d’établissement de la connexion. La version utilisée de cURL est curl 8.5.0.
$ curl -o /dev/null -s -w 'Time lookup: %{time_namelookup}s\nTime redirect: %{time_redirect}s\nTime connect: %{time_connect}s\nTime appconnect: %{time_appconnect}\nTime pretransfer: %{time_pretransfer}\nTTFB: %{time_starttransfer}s\nTotal: %{time_total}s\n' HOSTNAME| Étape | Variable | Description |
|---|---|---|
| 1 | time_namelookup | Résolution DNS du nom de domaine |
| 2 | time_redirect | Temps passé sur les redirections éventuelles |
| 3 | time_connect | Établissement du handshake TCP en 3 étapes (SYN → SYN-ACK → ACK) |
| 4 | time_appconnect | Handshake TLS/SSL terminée (échange de certificats, négociation du chiffrement). 0 pour HTTP simple |
| 5 | time_pretransfer | Toute la configuration au niveau protocolaire est terminée ; cURL est prêt à envoyer le premier octet de la requête |
| 6 | time_starttransfer | (TTFB) Le premier octet de la réponse est reçu |
| 7 | time_total | Le transfert entier est terminé, connexion fermée |
Documentation (man curl)
time_appconnect
The time, in seconds, it took from the start until the SSL/SSH/etc connect/handshake to the remote host was completed.
time_connect The time, in seconds, it took from the start until the TCP connect to the remote host (or proxy) was completed.
time_namelookup
The time, in seconds, it took from the start until the name resolving was completed.
time_pretransfer
The time, in seconds, it took from the start until the file transfer was just about to begin. This includes all pre-transfer
commands and negotiations that are specific to the particular protocol(s) involved.
time_redirect The time, in seconds, it took for all redirection steps including name lookup, connect, pretransfer and transfer before the
final transaction was started. time_redirect shows the complete execution time for multiple redirections.
time_starttransfer
The time, in seconds, it took from the start until the first byte is received. This includes time_pretransfer and also the
time the server needed to calculate the result.