Fix ICMP Ping Bursts via Randomized Jitter - #74
Conversation
This introduces a cryptographically secure random delay between 0 and `ping_interval` when starting a new pinger. This staggers initial pings evenly across the ping interval, rather than all pingers starting after a hardcoded 1-second delay, effectively preventing massive ping bursts and rate limiter congestion on large network segments. Co-authored-by: kljama <176691597+kljama@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
Pull request overview
This PR addresses synchronized ICMP traffic bursts caused by the reconciliation loop starting many pingers at once with the same initial delay. It introduces a per-pinger randomized initial delay (“jitter”) so first pings are spread uniformly across the configured ping_interval, helping keep subsequent pings naturally staggered rather than clumped.
Changes:
- Add a randomized initial delay in
StartPinger(0..interval) to spread out first ping execution across the interval. - Log a warning and fall back to a 1-second initial delay if secure random generation fails.
When scanning large subnets and bringing thousands of IP addresses online at once, the 5-second state reconciliation loop would start all new pingers simultaneously. Each pinger waited a hardcoded 1 second before firing, resulting in all devices emitting pings in a concentrated burst every 60 seconds (or configured interval).
This change generates a random jitter between 0 and
ping_intervalfor the first timer. This spreads the first executions uniformly across the interval time, ensuring that subsequent timer resets maintain an even, staggered distribution of network traffic, rather than clumping.PR created automatically by Jules for task 15163625152998214400 started by @kljama