Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: UDP Pacing

1 view
Skip to first unread message
Message has been deleted

Alex Fraser

unread,
Jun 30, 2009, 6:15:04 PM6/30/09
to
Vish wrote:
> I need to write a simple UDP application (language: C) for
> which I will have to pace the transmission rate. The first thing that
> comes to mind is to use nanosleep to control the rate. e.g. if i have
> to transmit at half the line rate, then i can send a burst of packets,
> measure that time, and then specify that amount of time as the
> nanosleep parameter. Can someone please suggest any other technique.

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

Pascal J. Bourguignon

unread,
Jun 30, 2009, 7:18:07 PM6/30/09
to
Vish <vah...@gmail.com> writes:
> I need to write a simple UDP application (language: C) for
> which I will have to pace the transmission rate. The first thing that
> comes to mind is to use nanosleep to control the rate. e.g. if i have
> to transmit at half the line rate, then i can send a burst of packets,
> measure that time, and then specify that amount of time as the
> nanosleep parameter. Can someone please suggest any other technique.

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__

Sjouke Burry

unread,
Jun 30, 2009, 11:09:29 PM6/30/09
to
Vish wrote:
> Hi All,

>
> I need to write a simple UDP application (language: C) for
> which I will have to pace the transmission rate. The first thing that
> comes to mind is to use nanosleep to control the rate. e.g. if i have
> to transmit at half the line rate, then i can send a burst of packets,
> measure that time, and then specify that amount of time as the
> nanosleep parameter. Can someone please suggest any other technique.
>
> Thanks,
> Vish
You might try to read the 2.5 MHZ clock, to get an accurate time.
(at least on an intel x86/amd)
0 new messages