Subject: Re: Broadcast Packet
To: NetBSD Tech-Net <tech-net@netbsd.org>
From: I. Souvatzis <ignatios@cs.uni-bonn.de>
List: tech-net
Date: 03/18/1999 11:04:14
On Wed, Mar 17, 1999 at 06:43:58PM -0500, Mike Pelley wrote:
> I've written a little C program (see below) that sends a broadcast packet.
> I set the destination address to INADDR_BROADCAST (or 255.255.255.255) so I
> would hit all machines.  However, when my machine (NetBSD 1.3.2/i386) sends
> the packet, it doesn't flag the packet as broadcast on the ethernet level,
> so nobody hears me (i.e. tcpdump on another machine shows the packet, but
> tcpdump -p doesn't).  The same program on a Windows machine does flag the
> packet as broadcast on the ethernet level.
> 
> Have I left something out to make the packet properly broadcast?  If I set
> the destination address to the broadcast address of my network, the packet
> is set with the ethernet broadcast on.  This is not good for my application
> as sometimes the destination machine is not on my subnet.

uhm, 255.255.255.255 is not "all Internet". It is "all stations on the 
local subnet". Fortunately, I want to add.

But it looks like you found a bug in 1.3. It works for me with a
NetBSD/arm32-1.3K machine, but doesn't for NetBSD-1.3.2/i386. 

The packet is sent to

09:28:46.304413 0:60:97:bd:7:4b 0:10:2f:e:0:0 ip 60: tangens.cs.uni-bonn.de.2775 > 255.255.255.255.11111: udp 18

instead. 0:10:2f:e:0:0 is the Ethernet address of the default router.

Btw, 1.3K doesn't seem to do really the right thing, either.

I get:

09:59:58.920055 8:0:2b:81:60:1a Broadcast ip 60: drum.cs.uni-bonn.de.49164 > 131.220.4.255.11111: udp 18

for the INADDR_ANY case and

10:00:03.376592 8:0:2b:81:60:1a Broadcast ip 60: drum.cs.uni-bonn.de.49162 > 131.220.4.255.11111: udp 18

for the local broadcast address case. So 1.3K happens to work by changing the
destination address. Maybe the check for wether M_BCAST should be set in
ip_output() needs to be moved up?

Regards,
	-is