Skip to main content

Module trace_sensor

Module trace_sensor 

Source
Expand description

Item 14: Trace mini-traceroute on the control stream + path asymmetry.

Two signals about the shape of the path, both read without a separate probe flow:

  • Mini-traceroute. The sender emits a few Trace control datagrams at ascending IP TTL (1, 2, …). A datagram whose TTL expires at an intermediate router draws an ICMP TimeExceeded back; on Linux that error is delivered on the socket’s error queue (IP_RECVERR + recvmsg(MSG_ERRQUEUE)), carrying the offending router’s address and the timestamp machinery for a per-hop RTT - a traceroute riding the transport’s own socket, no second flow. The TTL that drew each reply is the hop index.
  • Path asymmetry. The forward hop count (how many hops the peer says our packets crossed, from its Path frame) versus the reverse hop count (how many hops the peer’s feedback crossed, from our own received-TTL cmsg). A difference means the two directions are routed differently - which biases the per-hop RTT model, since a one-way delay no longer splits evenly.

The error-queue read is a Linux / BSD capability (the per-platform matrix lists no Windows path), so the traceroute half is #[cfg(target_os = "linux")]; the asymmetry half is portable (it is pure hop-count arithmetic over signals the control plane already carries).

Structs§

PathAsymmetry
Forward-vs-reverse path asymmetry. The forward hop count is what the peer reports about our packets; the reverse is what we observe about the peer’s.
TraceHop
One discovered hop on the path to the peer.

Functions§

drain_icmp_errors
Drain the socket’s error queue, returning, for each ICMP TimeExceeded found, the offending router address and the bytes of the original probe it expired (so the caller can read back the TTL it stamped and match the per-hop RTT). Linux only.
enable_icmp_errors
Enable the ICMP error queue on a socket so an expired-TTL probe’s TimeExceeded is delivered (Linux). A no-op elsewhere.
send_at_ttl
Send payload on the connected socket fd with the IP TTL set to ttl for this one datagram (via an IP_TTL cmsg, so the socket’s default TTL is untouched). The socket must already be connected to the peer - msg_name is left null, since a non-null name on a connected socket returns EISCONN. peer is used only to skip an IPv6 peer (the hop-limit cmsg is a separate spelling not needed for the netns / LAN proof). Linux only; a no-op elsewhere.