How to check TCP timeout in linux / macos?

Solution 1:

You can see all system-set tcp values with

$ sysctl net.inet.tcp

Interpreted from tcp_var.h, tcp_subr.c, and tcp_timer.c:

  • net.inet.tcp.keepidle = keepalive idle timer
  • net.inet.tcp.keepintvl = interval to send keepalives
  • net.inet.tcp.keepinit = timeout for establishing syn
  • net.inet.tcp.mssdflt = Default TCP Maximum Segment Size
  • net.inet.tcp.v6mssdflt = Default TCP Maximum Segment Size for IPv6
  • net.inet.tcp.minmss = Minmum TCP Maximum Segment Size
  • net.inet.tcp.minmssoverload = Number of TCP Segments per Second allowed to be under the MINMSS Size
  • net.inet.tcp.rfc1323 = Enable rfc1323 (high performance TCP) extensions
  • net.inet.tcp.rfc1644 = Enable rfc1644 (TTCP) extensions
  • net.inet.tcp.do_tcpdrain = Enable tcp_drain routine for extra help when low on mbufs
  • net.inet.tcp.pcbcount = Number of active PCBs
  • net.inet.tcp.icmp_may_rst = Certain ICMP unreachable messages may abort connections in SYN_SENT
  • net.inet.tcp.strict_rfc1948 = Determines if RFC1948 is followed exactly
  • net.inet.tcp.isn_reseed_interval = Seconds between reseeding of ISN secret
  • net.inet.tcp.background_io_enabled = Background IO Enabled
  • net.inet.tcp.rtt_min = min rtt value allowed
  • net.inet.tcp.randomize_ports = Randomize TCP port numbers
  • net.inet.tcp.tcbhashsize = Size of TCP control-block hashtable
  • net.inet.tcp.msl = Maximum segment lifetime
  • net.inet.tcp.always_keepalive = Assume SO_KEEPALIVE on all TCP connections
  • net.inet.tcp.broken_peer_syn_rxmit_thres = Number of retransmitted SYNs before TCP disables rfc1323 and rfc1644 during the rest of attempts
  • net.inet.tcp.pmtud_blackhole_detection = Path MTU Discovery Black Hole Detection
  • net.inet.tcp.pmtud_blackhole_mss = Path MTU Discovery Black Hole Detection lowered MSS

I believe by default 8 keepalives will be sent before the connection is closed if SO_KEEPALIVE is set. Times are in milliseconds.

Solution 2:

For linux you can use:

$ sysctl -a | grep net.ipv4

Solution 3:

I'm not sure if this is what you're looking for, but you can check the keep-alive value with:

$ netstat -o

Tags:

Tcp

Mac Osx