I want to know the maximum size of receive buffer of network layer or TCP/IP layer. Can anyone help on this?
Asked
Active
Viewed 3,268 times
0
-
For what O/S do you need to know? – Joe Jul 09 '14 at 08:26
-
1The answer is "it depends". The real question is "Why do you want to know"? – CodeCaster Jul 09 '14 at 08:26
-
For windows, iOS, OSX, Android, Linux. I want to know what is the highest size of receive buffer in socket layer? – Naseef Chowdhury Jul 09 '14 at 08:30
-
2What problem will the answer to your question solve? What are you going to do when the answer is "512 bytes"? What if it is "32K"? It sounds like XY problem of you not wanting to use or design a framing protocol, like [every time](http://stackoverflow.com/questions/2811006/what-is-a-good-buffer-size-for-socket-programming) [it is asked](http://stackoverflow.com/questions/12931528/c-socket-programming-max-size-of-tcp-ip-socket-buffer) – CodeCaster Jul 09 '14 at 08:32
-
2It is not only platform- but also system-dependent, as it can be changed by configuration. But there isn't much advantage beyond the usual sizes of up to 64k. – user207421 Jul 09 '14 at 08:32
-
suppose I am using SO_RCVBUFFORCE to configure the size, how much I can set the size? – Naseef Chowdhury Jul 09 '14 at 08:34
-
I can only suggest you try it. Use getsockopt() to find out what size the system actually gave you. – user207421 Jul 09 '14 at 08:40
-
1Key point: you are likely to receive your data in pieces, not in one big block. Iow, you only need a fairly small buffer anyway because of the way a socket will hand you the data. I use a huge buffer of 128k because I stream large images and that helps with packet boundary problems and performance. In the end I still need to reassemble the whole thing because the images are far bigger. – Mickey Kawick Jul 10 '14 at 15:07
-
@MickeyKawick: No. The larger the socket receive buffer the better, up to the bandwidth-delay product. – user207421 Jul 14 '14 at 09:41
1 Answers
-2
What is the socket type?
If the socket is TCP then I would like to prefer you to set the buffer size to 8K.
For UDP you can also set the buffer size to 8k. It is not actually important for UDP. Because in UDP a whole packet is transmitted at a time. For this reason, you do not need to save much data in the socket for longer period of time.
But in TCP, data comes as a stream. You cannot afford data loss here because it will result in several parsing related issues.

user3859309
- 27
- 7
-
I would prefer you to set it to several times 8k. This was the Windows default for years and it was never adequate. Ten years ago the defaults on Unix and Linux were up around 50k. Basically it needs to equal the bandwidth-delay product. – user207421 Aug 02 '14 at 05:28