Fix Mbps pacing overflow on long replays#989
Open
AB-Coder96 wants to merge 1 commit intoappneta:masterfrom
Open
Fix Mbps pacing overflow on long replays#989AB-Coder96 wants to merge 1 commit intoappneta:masterfrom
AB-Coder96 wants to merge 1 commit intoappneta:masterfrom
Conversation
Author
|
I noticed #982 after opening this PR. It appears to address the same overflow class and is broader because it touches both One difference: this PR uses quotient/remainder arithmetic for the next_tx_ns = (bits_sent / bps) * 1000000000;
next_tx_ns += ((bits_sent % bps) * 1000000000) / bps;#982 instead converts to nanoseconds after an earlier division, which also avoids the reproduced overflow but may lose some sub-millisecond precision due to integer truncation. I’m happy to close this if maintainers prefer #982, or adjust this PR if the quotient/remainder approach is useful. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Standards checklist:
sudo make testNote: I noticed #982 after opening this PR. #982 appears to address the same overflow class and is broader because it touches both
speed_mbpsrateandspeed_packetrate.This PR is a smaller, fix-only alternative focused on the
speed_mbpsratepath, which I independently reproduced and validated. One difference is that this PR uses quotient/remainder arithmetic, which avoids multiplying the fullbits_sentvalue by1e9while preserving the fractional remainder after division.Changes:
Fixes #974.
This fixes an overflow in the
speed_mbpsratetiming calculation for long low-rate replays.Previously,
next_tx_nscould be calculated as:For large captures,
bits_sent * 1000000000can overflowCOUNTERbefore the division. When that happens,next_tx_nscan wrap to a much smaller value, which can makeskip_lengthbecome very large. The send loop then skips sleep recalculation and can send the remaining packets too quickly near EOF.This patch computes the same value using quotient/remainder arithmetic, avoiding multiplication of the full
bits_sentvalue by1e9.Other comments:
Validated with a synthetic 22M-packet UDP pcap at
-M 10.Before fix:
-T nano: final average around 10.11 Mbps, with a near-EOF final interval burst-T gtod: final average around 10.09 Mbps, with a near-EOF final interval burstAfter fix:
-T nano: expected 1865.60s, observed 1865.60s, final average 10.00 Mbps-T gtod: expected 1865.60s, observed 1865.62s, final average 9.99 MbpsTest environment:
replay0interfaceAlso ran
sudo make testsuccessfully.