Ticket #41 (closed enhancement: fixed)
Improve packet timing method
| Reported by: | aturner | Owned by: | aturner |
|---|---|---|---|
| Priority: | high | Milestone: | 3.3 |
| Component: | tcpreplay | Version: | 3.0.beta7 |
| Keywords: | Cc: | ||
| Operating System: | Add to FAQ?: | no | |
| Hardware: | All | ||
| Output of tcpreplay -V: | |||
Description (last modified by aturner) (diff)
Create another timing method to replace gettimeofday() and nanosleep() which aren't very granular fast on many platforms.
So I've determined the biggest problem: 1usec resolution is not enough. Some simple math shows that @ 125,000pps, the interval is 8usec. But at 130,000pps, we're looking at 7.7usec. Integer math converts that to 7usec and we end up doing around 141,000pps.
The answer seems to be that use floating point math and then for every 1/10 of a usec above the integer value, you sleep for an extra 1usec. Using the 130Kpps example of 7.7usec, I'd sleep for 7usec 3 times and 8usec 7 times, thus averaging 7.7usec. This seems to be pretty simple for calculating pps, but I still need to come up with an algorithm for more dynamic timing models (Mbps and multipliers). Rounding might be the easiest/best I can do.
