Skip to content

nmap C→Rust — M1: core::timing (RTT estimator + -T0..-T5 templates) - #5

Merged
kj299 merged 1 commit into
masterfrom
claude/m1-timing
Jul 9, 2026
Merged

kj299 merged 1 commit into
masterfrom
claude/m1-timing

Conversation

@kj299

@kj299 kj299 commented Jul 9, 2026

Copy link
Copy Markdown
Owner

What this is

Milestone 1 module core::timing — the Rust port of nmap's timing.cc (adjust_timeouts2 / initialize_timeout_info) and the timing-template table (nmap.cc / NmapOps.cc). Supplies the connect scan's per-probe timeout, parallelism, and scan-delay knobs.

Changes

  • TimeoutInfo — the Jacobson/Karels RTT smoother in fixed-point microseconds (i64, no floats): srtt/rttvar seed on the first sample, then smooth via >>3 / >>2; implausible samples (≥8 s, negative, or bogus deltas) are ignored exactly as the C does; the timeout is clamped to the template's [min, max] RTT window.
  • TimingTemplate (Paranoid…Insane) + TimingParams — the -T0..-T5 table with nmap's exact setInitial/Max/MinRttTimeout sibling-bound interactions (e.g. -T0 raising max to 300 s, -T4 = min 100 / max 1250 / initial 500 ms). -T3 defaults from MIN/MAX/INITIAL_RTT_TIMEOUT. Includes parallelism, scan-delay, and retransmission knobs.
  • box_clamp mirrors nmap's box() (returns min when min > max, no panic).

Verified

  • fmt + clippy(-D warnings) + 41 unit tests + unsafe-audit (0 undocumented) — all green.
  • Tests assert fidelity to the C: first-sample init, >>3 smoothing step, min-timeout clamp, bogus-sample rejection, the small-negative→10 ms rule, and the exact per-template RTT/parallelism/retransmission values for T0/T3/T4/T5.

Pure #[forbid(unsafe_code)] math — no I/O, no unsafe.

🤖 Generated with Claude Code


Generated by Claude Code

Rust port of timing.cc (adjust_timeouts2 / initialize_timeout_info) and the
timing-template table in nmap.cc / NmapOps.cc:
- TimeoutInfo: Jacobson/Karels RTT smoothing in fixed-point microseconds
  (srtt/rttvar init to -1; first sample seeds; subsequent smooth via >>3/>>2;
  bogus samples ignored; timeout clamped to the template's [min,max] RTT).
- TimingParams + TimingTemplate: Paranoid..Insane with nmap's exact
  set{Initial,Max,Min}RttTimeout sibling-bound interactions; -T3 defaults from
  MIN/MAX/INITIAL_RTT_TIMEOUT. Parallelism/scan-delay/retransmission knobs.
- box_clamp mirrors nmap's box() (no panic when min>max).

Pure #![forbid(unsafe_code)] math, no floats. Gates: fmt + clippy(-D) + 41 tests
+ unsafe-audit(0). progress: timing -> ported.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JfEzHqD7a7TKDuUs5GwZ2w
@kj299
kj299 marked this pull request as ready for review July 9, 2026 18:46
@kj299
kj299 merged commit bfa301c into master Jul 9, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants