使用curl测试网络通信
Linux 工具命令
使用curl测试网络通信
#!/bin/bash
cnt_pos=1
while true
do
echo "--------------- the $cnt_pos requet ------------"
echo "Start time: "`date +"%Y-%m-%d %H:%M:%S"`
t0=`date +%s`
req_url="https://www.baidu.com"
echo "$req_url"
curl -w "@./curl-cfg.txt" -X get -i --connect-timeout 200 -m 200 "$req_url"
t1=`date +%s`
let s_t2=t1-t0
if [ $s_t2 -gt 3 ]
then
break
fi
let cnt_pos=cnt_pos+1
sleep 1s
done
curl-cfg.txt
\n
remote_ip: %{remote_ip}\n
remote_port: %{remote_port}\n
local_ip: %{local_ip}\n
local_port: %{local_port}\n
http_code: %{http_code}\n
dns: %{time_namelookup}s\n
redirect: %{time_redirect}s\n
time_connect: %{time_connect}s\n
time_appconnect: %{time_appconnect}s\n
time_pretransfer: %{time_pretransfer}s\n
time_starttransfer: %{time_starttransfer}s\n
size_download: %{size_download}bytes\n
speed_download: %{speed_download}B/s\n
----------\n
time_total: %{time_total}s\n
\n