Mac-Osx

如何在 linux / macos 中檢查 TCP 超時?

  • June 14, 2018

我的 MacOS 出現網路問題,需要進行故障排除。我知道 TCP 套接字有內部超時,如果遠端方沒有響應(但也沒有正常斷開連接),它將關閉連接。我可以使用任何命令/工具來檢查此超時的確切值嗎?

您可以使用以下命令查看所有系統設置的 tcp 值

$ sysctl net.inet.tcp

從 tcp_var.h、tcp_subr.c 和 tcp_timer.c 解釋:

  • net.inet.tcp.keepidle = keepalive 空閒計時器
  • net.inet.tcp.keepintvl = 發送keepalives的間隔
  • net.inet.tcp.keepinit = 建立同步超時
  • net.inet.tcp.mssdflt = 預設 TCP 最大段大小
  • net.inet.tcp.v6mssdflt = IPv6 的預設 TCP 最大分段大小
  • net.inet.tcp.minmss = 最小 TCP 最大段大小
  • net.inet.tcp.minmssoverload = 每秒允許低於 MINMSS 大小的 TCP 段數
  • net.inet.tcp.rfc1323 = 啟用 rfc1323(高性能 TCP)擴展
  • net.inet.tcp.rfc1644 = 啟用 rfc1644 (TTCP) 擴展
  • net.inet.tcp.do_tcpdrain = 在 mbufs 低時啟用 tcp_drain 常式以獲得額外幫助
  • net.inet.tcp.pcbcount = 活動 PCB 的數量
  • net.inet.tcp.icmp_may_rst = 某些 ICMP 無法到達的消息可能會中止 SYN_SENT 中的連接
  • net.inet.tcp.strict_rfc1948 = 確定是否完全遵循 RFC1948
  • net.inet.tcp.isn_reseed_interval = 重新播種 ISN 機密之間的秒數
  • net.inet.tcp.background_io_enabled = 啟用後台 IO
  • net.inet.tcp.rtt_min = 允許的最小 rtt 值
  • net.inet.tcp.randomize_ports = 隨機化 TCP 埠號
  • net.inet.tcp.tcbhashsize = TCP 控制塊雜湊表的大小
  • net.inet.tcp.msl = 最大段生命週期
  • net.inet.tcp.always_keepalive = 在所有 TCP 連接上假設 SO_KEEPALIVE
  • net.inet.tcp.broken_peer_syn_rxmit_thres = 在其余嘗試期間 TCP 禁用 rfc1323 和 rfc1644 之前重新傳輸的 SYN 數
  • net.inet.tcp.pmtud_blackhole_detection = 路徑 MTU 發現黑洞檢測
  • net.inet.tcp.pmtud_blackhole_mss = 路徑 MTU 發現黑洞檢測降低 MSS

如果設置了 SO_KEEPALIVE,我相信預設情況下將在連接關閉之前發送 8 個 keepalive。時間以毫秒為單位。

引用自:https://serverfault.com/questions/216956