Pregunta

I need to write a UDP client in C that generates traffic that will have a sending rate of Ron for a time of Ton and stop sending anything for a time Toff and repeat again. So, the cross traffic is periodic. The problem that I am having is how to make the client to send at a constant rate Ron. I thought about using the functions sendto and usleep. However, sendto does not have a way to specify at what rate you want to send data.

Thanks in advance.

¿Fue útil?

Solución

Well, sendto lets you specify the amount of data you want to send, and usleep can be used to control how often you send something, so between the two of them you can control the rate.

For example, if you call sendto to send chunks of 1kb, and pause (usleep) for 1/10th of a second between sendto() calls, you'll be sending at a rate of 10kb per second.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top