From owner-freebsd-net@FreeBSD.ORG Sat Jan 6 19:05:24 2007 Return-Path: X-Original-To: freebsd-net@freebsd.org Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 1FEB316A403 for ; Sat, 6 Jan 2007 19:05:24 +0000 (UTC) (envelope-from bms@FreeBSD.org) Received: from out5.smtp.messagingengine.com (out5.smtp.messagingengine.com [66.111.4.29]) by mx1.freebsd.org (Postfix) with ESMTP id EBD7A13C459 for ; Sat, 6 Jan 2007 19:05:23 +0000 (UTC) (envelope-from bms@FreeBSD.org) Received: from out1.internal (unknown [10.202.2.149]) by out1.messagingengine.com (Postfix) with ESMTP id 08D375DF5D; Sat, 6 Jan 2007 13:40:09 -0500 (EST) Received: from heartbeat2.messagingengine.com ([10.202.2.161]) by out1.internal (MEProxy); Sat, 06 Jan 2007 13:40:09 -0500 X-Sasl-enc: 52f3AFkGGpejYgV2JmfEtSRzLlfN0t4TndTHuOu5VQaA 1168108808 Received: from [192.168.123.18] (82-35-112-254.cable.ubr07.dals.blueyonder.co.uk [82.35.112.254]) by mail.messagingengine.com (Postfix) with ESMTP id D6754130F2; Sat, 6 Jan 2007 13:40:07 -0500 (EST) Message-ID: <459FEDBC.4070008@FreeBSD.org> Date: Sat, 06 Jan 2007 18:43:08 +0000 From: "Bruce M. Simpson" User-Agent: Thunderbird 1.5.0.5 (X11/20060825) MIME-Version: 1.0 To: LI Xin References: <459D4D88.2030708@delphij.net> In-Reply-To: <459D4D88.2030708@delphij.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-net@freebsd.org Subject: Re: Different behavior of ping'ing INADDR_BROADCAST? X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Jan 2007 19:05:24 -0000 LI Xin wrote: > Dear colleagues, > > I have a strange question about our way of handling INADDR_BROADCAST, > the behavior looks different from all other operating systems I have > tried, except Mac OS X ;-) > > By ping'ing 255.255.255.255 from FreeBSD (mostly RELENG_6 with some > unrelated patches) or Mac OS X, I got response from another subnet (I > guess that there is some configuration problem in the network, though), > but no boxes (running various operating systems) on local network > responds the ping. > > However, with OpenBSD, Linux and Windows, ping'ing 255.255.255.255 would > get response from local network. > > Just curious why there is such difference. Literally, I think > INADDR_BROADCAST is supposed to reach local network nodes, no? > With FreeBSD's stack, sending packets to the undirected broadcast address INADDR_BROADCAST will result in the first ifnet with IPv4 configured and IFF_BROADCAST set being selected as the source ifnet. See ip_output.c for details. In my local network, pinging 255.255.255.255 from my FreeBSD laptop (running 6.2-RC1) results in a single unicast ICMP reply from the edge router, with its source address on the same LAN. The IP_SENDONES socket option may be used to select the source interface for undirected broadcasts, by sending to a directed broadcast address. The stack will munge the directed address to 255.255.255.255 before it goes on the wire. This came from BSD/OS; See ip(4) for details. You might want to take a look at NetBSD's stack, which has recently had IPv4 source address selection logic added to it to support schemes such as link-local addressing (Zeroconf/Rendezvous). It would be great if someone had time to look at this and perhaps port it. Regards, BMS