For Programmers: Free Programming Magazines  


Home > Archive > Unix Programming > July 2006 > UDP performance problem?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author UDP performance problem?
Valh

2006-07-18, 7:01 pm

Hello,

I have a small program that has two threads:
-one reads from the sound card and sendto() chunks of data through an UDP
socket
-the other recvrfom() from the socket and sends data to soundcard

The problem I am experiencing is poor and bursty throughput; I am wondering
why and how can I improve it. This happens only when I loop the traffic
from one thread to the other through the socket.

The socket is bind()-ed but not connected; threads are created detached.

Is there a problem if one of the threads blocks in recvfrom()? Would that
stop the other thread accessing the socket?

Thanks
a.



Nils O. Selåsdal

2006-07-18, 7:01 pm

Valh wrote:
> Hello,
>
> I have a small program that has two threads:
> -one reads from the sound card and sendto() chunks of data through an UDP
> socket
> -the other recvrfom() from the socket and sends data to soundcard
>
> The problem I am experiencing is poor and bursty throughput; I am wondering
> why and how can I improve it. This happens only when I loop the traffic
> from one thread to the other through the socket.

Buffering usually help, accumulate data before you send, and buffer on
the receiving end too.

Also, how much do you read at a time, and how much do you send at a time
? You might want non-blocking writes too, especially to the soundcard
- -as you probably don't want the write to the soundcard block for a long
period when you rather should be servicing incoming socket data.

> The socket is bind()-ed but not connected; threads are created detached.
>
> Is there a problem if one of the threads blocks in recvfrom()? Would that
> stop the other thread accessing the socket?

No. (not on proper pthread implementations)
Valh

2006-07-18, 7:01 pm

>
> Also, how much do you read at a time, and how much do you send at a time
> ? You might want non-blocking writes too, especially to the soundcard
> - -as you probably don't want the write to the soundcard block for a long
> period when you rather should be servicing incoming socket data.


I read from the soundcard the equivalent of 20ms of audio time and sent that
in an UDP packet - this makes about 50 pkts/sec. Buffering is an option I
have not tried yet - this has an impact on audio latencies.

I will see how can I make sure write to the sound card does not block - I am
using ALSA and do not know how much control I have on this.

Thanks.
a.



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com