Re: udp packet loss even with large socket buffer

From: Paulo Marques
Date: Tue Mar 02 2004 - 08:02:38 EST


johnny zhao wrote:

hi,

Since my program is coping with MSN, it's not easy to post a small example. But I will try :)

I use the following code to initialize the socket:

*****************************
session->rtp.loc_addr.sin_family = AF_INET;
session->rtp.loc_addr.sin_addr.s_addr = INADDR_ANY;
session->rtp.loc_addr.sin_port = htons (port);
session->rtp.socket = socket (PF_INET, SOCK_DGRAM, 0);

^^^
This should really be IPPROTO_UDP as defined in <netinet/in.h>


g_return_val_if_fail (session->rtp.socket > 0, -1);
err = bind (session->rtp.socket,
(struct sockaddr *) &session->rtp.loc_addr,
sizeof (struct sockaddr_in));
/* set the address reusable */
err = setsockopt (session->rtp.socket, SOL_SOCKET, SO_REUSEADDR,
(void*)&optval, sizeof (optval));

optval = 8388608;


You are right, this is really a huuuuuge buffer. If you are getting a 1.5kb packet every 80 ms on average, this is about 20kb/second. Even a 64kb buffer should be much more than enough.

My advice is just request a 64kb buffer, and stop messing with the rmem_default and rmem_max parameters.


--
Paulo Marques - www.grupopie.com
"In a world without walls and fences who needs windows and gates?"

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/