P
P
Pashka232018-08-14 07:23:20
linux
Pashka23, 2018-08-14 07:23:20

Why is SO_SNDBUF socket size set in traceroute sources?

Good afternoon!

I understand the sources of the open source traceroute ( https://github.com/openbsd/src/blob/master/usr.sbi... ). Traceroute alternately sends udp packets with increasing ttl. The code (line 830) sets the size of the outgoing socket buffer (from which udp packets will be sent) equal to the size of the sent udp packet (38 bytes). I can not understand - why is this even necessary? And can the buffer be so small (what is its minimum value anyway)?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
jcmvbkbc, 2018-08-14
@Pashka23

The code (line 830) sets the size of the outgoing socket buffer (from which udp packets will be sent) equal to the size of the sent udp packet (38 bytes). I can not understand - why is this even necessary?

To save memory, obviously. It may have been relevant at some point in time, judging by the rest of the comments in this file.
How to interpret socket options is an internal matter of the kernel. The tags are linux, linux man 7 socketsays the following:
SO_SNDBUF
     Sets  or  gets the maximum socket send buffer in bytes.  The kernel doubles this value
     (to allow space for bookkeeping overhead) when it is set using setsockopt(2), and this
     doubled value is returned by getsockopt(2).  The default value is set by the
     /proc/sys/net/core/wmem_default file and the maximum allowed value is set by the
     /proc/sys/net/core/wmem_max file.  The minimum (doubled) value for this option is 2048.

P
Pashka23, 2018-08-14
@Pashka23

To save memory, obviously. It may have been relevant at some point in time, judging by the rest of the comments in this file.
And what kind of memory? This does not affect the size of generated udp packets, but only limits the maximum allowable size of sent packets. Or are we talking about saving on the buffers themselves?
The minimum (doubled) value for this option is 2048 the minimum value of 2048 is still set.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question