[Winpcap-users] Efficient sending huge number of UDP packets at a fixed specified rate

Guy Harris guy at alum.mit.edu
Mon Apr 11 17:38:29 PDT 2011


On Apr 9, 2011, at 3:33 PM, Fish (David B. Trout) wrote:

> Just change the millisecond Sleep()'s to function calls that delay for a
> specified number of microseconds instead:

	...

>  // SetWaitableTimer argument is #of 100-nanosecond intervals.
>  // Positive values indicate absolute UTC time. Negative values
>  // indicate relative time. The actual timer accuracy depends
>  // on the capability of your hardware.

As per what Gianluca said, note the last sentence of the comment in question (which comes from the MSDN documentation for SetWaitableTimer()).  If Windows implements waitable timers from a system "lightning bolt" timer (i.e., from periodic interrupts), the timer accuracy could be even lower than the precision of any interrupting timer hardware on your machine.

Note also that an indeterminate amount of time could take place between the point at which the timer delivers the wakeup and the userland code right after the WaitForSingleObject() call executes (or between the SetWaitableTimer() and the WaitForSingleObject() call, or between the code right after the WaitForSingleObject() call and the code that sends the packet).

And, yes, the same caveats apply to UN*X and to UN*X APIs such as select()/poll()/kevent()/setitimer()-and-pause()/etc..


More information about the Winpcap-users mailing list