LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 04-24-2006, 10:27 AM   #1
crazy_abt_linux
LQ Newbie
 
Registered: Apr 2006
Posts: 3

Rep: Reputation: 0
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
 
Old 04-24-2006, 10:29 AM   #2
crazy_abt_linux
LQ Newbie
 
Registered: Apr 2006
Posts: 3

Original Poster
Rep: Reputation: 0
Forget to mention the kernel version. It is:
2.4.20-31.9smp
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Questions regarding UDP Buffer Size in 2.4.20-31.9smp crazy_abt_linux Programming 1 04-25-2006 01:16 PM
calculating buffer size cynthia_thomas Programming 1 01-19-2006 10:49 PM
how to monitor kernel udp buffer usage? coontie Linux - Networking 0 11-17-2004 11:29 AM
Data buffer size MarcReing Programming 7 10-21-2004 12:51 PM


All times are GMT -5. The time now is 05:38 AM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration