You will probably find that when you have "sent" the packets, they will
have (mostly) only been buffered. So the measured time will be meaningless.
To limit to a specific average rate I think you can do something like:
can_send = BURST_SIZE;
t0 = now();
while (!done) {
if (can_send >= 1) {
--can_send;
send_packet();
} else {
wait_a_little_bit();
t1 = now();
can_send = min(BURST_SIZE, (t1 - t0) * RATE);
t0 = t1;
}
}
Alex
If you are on Linux, select a real-time scheduling option.
Then you will be able to send the packets at a regular frequency.
Otherwise, you will be able to do so only when your process is scheduled.
--
__Pascal Bourguignon__