|
UDP Buffer size Problems
Hi Guys,
Well I have some questions regarding the UDP buffer size.
My first question is:
1) Why the UDP/TCP Buffer size is doubled of the value pass in setsockopt? Why the user gets a UDP receive buffer size of 2X, when required is only X?
Please refer the below code (in file sock.c) snippet for your reference:
**************************
case SO_RCVBUF:
/* Don't error on this BSD doesn't and if you think
about it this is right. Otherwise apps have to
play 'guess the biggest size' games. RCVBUF/SNDBUF are treated in BSD as hints */
if (val > sysctl_rmem_max)
val = sysctl_rmem_max;
sk->userlocks |= SOCK_RCVBUF_LOCK;
/* FIXME: is this lower bound the right one? */
if ((val * 2) < SOCK_MIN_RCVBUF)
sk->rcvbuf = SOCK_MIN_RCVBUF;
else
sk->rcvbuf = (val * 2);
break;
*********************
2) Well each UDP packet acquires a size of 2336 Bytes in the Receive buffer irrespective of the size of data.
i.e. if my udp payload is 550 byte (per packet), then the space acquired is 2336 (per packet), even if the payload size is 1458 (per packet), then also the space acquired in udp receive queue is 2336 (per packet).
I guess it is something related to this code in skbuff.c in function alloc_skb
********
/* Get the DATA. Size must match skb_add_mtu(). */
size = SKB_DATA_ALIGN(size);
data = kmalloc(size + sizeof(struct skb_shared_info), gfp_mask);
if (data == NULL)
goto nodata;
/* XXX: does not include slab overhead */
skb->truesize = size + sizeof(struct sk_buff);
/* Load the data pointers. */
skb->head = data;
skb->data = data;
skb->tail = data;
skb->end = data + size;
********
Well i try to understand how this (SKB_DATA_ALIGN)aligned works but only thing i understood it is related to SMP_CACHE_BYTES.
Well any help in this matter will be highly appreciated.
Thanks
|