[collectd] Collectd opens UDP port

Amos Shapira amos.shapira at gmail.com
Fri Oct 8 14:24:18 CEST 2010


2010/10/8 Enrico Tröger <enrico.troeger at uvena.de>
>
> On Sun, 3 Oct 2010 06:41:14 +1000, Amos wrote:
>
> >That's the way UDP works.
>
> Thanks so far.
> But could you be so kind to explain it a little further?
> I'm not that familiar with UDP and don't see why the clients need to
> open a listening UDP port to send data to the server.

(Sorry, my previous reply was written on my mobile so it was short).

For a reference, read a little about the UDP protocol -
http://en.wikipedia.org/wiki/User_Datagram_Protocol

Basically, the packet format calls for a "source port" which must be
filled with a legitimate value. "man 7 udp" says:
"In order to receive packets, the socket can be bound to a local
address first by using bind(2).
Otherwise the socket layer will automatically assign a free local port
out of the range defined by
/proc/sys/net/ipv4/ip_local_port_range and bind the socket to INADDR_ANY."

I assume this happens when the first message is sent, if no port was
assigned yet.

So even if in this particular case there is only one-way traffic, the
sender must have a port assigned to it.

Hope this answers your question.

--Amos



More information about the collectd mailing list