IP地址检测
视频播放器
输入关键词搜索
登录
正确计算网络延迟的方法

正确计算网络延迟的方法

2023-11-11
暂无分类

大部分人想到的网络延迟计算方法就是ping命令,其实ping命令并不是用来计算网络延迟的,它是用来判断某个ip通不通

curl

# 测试命令
curl -sSL -o /dev/null --connect-timeout 5 --write-out \
"\n--------------REQUEST TIME TABLE-----------------\n
   time_namelookup:  %{time_namelookup}s\n
      time_connect:  %{time_connect}s\n
   time_appconnect:  %{time_appconnect}s\n
  time_pretransfer:  %{time_pretransfer}s\n
     time_redirect:  %{time_redirect}s\n
time_starttransfer:  %{time_starttransfer}s\n
                     ----------\n
        time_total:  %{time_total}s\n\n" \
https://facebook.com

  • time_namelookup DNS查找IP
  • time_connect TCP三次握手完成
  • time_appconnect SSL三次握手完成
  • time_pretransfer 客户端开始向服务器发送HTTP报文
  • (服务器从报文中发现请求头中的url需要重定向,time_redirect就是重定向的时间,值0表示不需要重定向)
  • time_starttransfer 服务器开始向客户端发送response数据
  • total_time HTTP总耗时

总结

time_appconnect代表tcp耗时,total_time代表http耗时

经验之谈:网络延迟主要发生在ssl握手、重定向、数据传输,这三个阶段

Chrome

Stalled:表示请求或响应被暂停或延迟

Initial connection:TCP三次握手和SSL三次握手的总时间

TTFB(Time To First Byte):它是指从浏览器发起请求到接收到服务器第一个字节的时间间隔

THE END
0/500
暂无评论
📢网站公告
欢迎来到这里
⚙️实用工具
html转pdfmarkdown编辑器
本站推荐:腾讯云服务器仅需2.3折 (点击直达)
用户协议
隐私政策
Build Time: 2025-02-06 16:15:33