Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 30 Apr 2007 14:09:32 +0100
From:      "Bruce M. Simpson" <bms@incunabulum.net>
To:        "Abraham K. Mathen" <akmathen@hotmail.com>
Cc:        freebsd-net@freebsd.org
Subject:   Re: Why can't I sendto() to 127.255.255.255
Message-ID:  <4635EA8C.1090404@incunabulum.net>
In-Reply-To: <BAY121-F177CD9A9B001734EFB8DB3DE4C0@phx.gbl>
References:  <BAY121-F177CD9A9B001734EFB8DB3DE4C0@phx.gbl>

next in thread | previous in thread | raw e-mail | index | archive | help
Abraham K. Mathen wrote:
>
>  Is it possible to successfully sendto() on a UDP socket
> with 127.255.255.255 as the destination address? If yes,
> how can that be done. 

No, because in FreeBSD, lo(4) is not implemented as a broadcast 
interface. It is a multicast capable software loopback interface. It has 
no concept of a broadcast domain. Unicast traffic, as well as multicast 
traffic, is looped back on this interface.

You can see that in the output of 'ifconfig lo0', the BROADCAST flag is 
not set.

RFC 3330 says:
"A datagram sent by a higher level protocol to an address anywhere 
within this block should loop back inside the host."

A few quick tests suggests this does not happen by default on FreeBSD. I 
suspect that this is because although lo0 is configured with 127.0.0.1/8 
by default, a cloning interface route is not added as ARP does not run 
on such an interface. Therefore only a host route for 127.0.0.1 appears 
in the table.

To tell the stack to transmit datagrams destined for 127/8 via lo0 you'd 
do the following:
     route -n add 127.0.0.0/8 -net -iface lo0

Nothing will reply as nothing is listening on that address 
(127.255.255.255).

You can configure multiple lo interfaces, they just don't participate in 
a broadcast domain, as they are not broadcast interfaces. However, how 
lo(4) is implemented has the peculiar side-effect that all loopback 
interfaces are in the same 'transmission domain'... tcpdumping on lo0 
will show you traffic on lo1. All loopback ifnet instances see each 
other's traffic, it's just up to the stack to reject it if it's not 
destined for a configured address on that instance.

To try that, you'd 'ifconfig lo1 create' and 'ifconfig lo1 127.0.0.2/32' 
as FreeBSD's network stack does not really allow you to have more than 
one interface configured on the same subnet.

Regards,
BMS



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4635EA8C.1090404>