From owner-freebsd-net@FreeBSD.ORG Wed Apr 8 12:44:07 2015 Return-Path: Delivered-To: net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D2E5E8B0 for ; Wed, 8 Apr 2015 12:44:07 +0000 (UTC) Received: from a0i241.smtpcorp.com (a0i241.smtpcorp.com [216.22.15.73]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AAE31F3 for ; Wed, 8 Apr 2015 12:44:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=smtpcorp.com; s=a0_1; h=Feedback-ID:X-Smtpcorp-Track:Message-ID:Date:Subject:To:From; bh=Dfy7jNQpMZzDXPr1p10UjG+GnLBqrmicSwqFmYMsY2o=; b=ZwWlz3gJzPWG6lHobWEY5dYFmcLMebXf4J+AV0WzxDln+p6cd7JPBgGS+BzoKgHD/NKZo7YF09yXTd0O2JHwir2kgI2HddO7vK5v3VNCxYzGmZHB2hxH4iZ3iN6sCSJy7hhyKECiAkeirE6CD8Tka1LXR6cd6ZUNUhX5LYEWhpU=; From: Daniel Corbe To: Yuri Subject: Re: Socket bound to 0.0.0.0 never receives broadcasts with non-zero IP source address References: <55248957.60109@rawbw.com> Date: Wed, 08 Apr 2015 08:32:13 -0400 In-Reply-To: <55248957.60109@rawbw.com> (yuri@rawbw.com's message of "Tue, 07 Apr 2015 18:50:15 -0700") Message-ID: <878ue2n6lu.fsf@corbe.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Smtpcorp-Track: 1Yfp9Vmkf4HKRN.JRBQSgpEI Feedback-ID: 10661m:10661aegzayD:10661sApYUW4ktf:SMTPCORP Cc: net@freebsd.org X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Apr 2015 12:44:07 -0000 If nobody answers this question by the time I get home I'll try and help; however, in the mean time I do have a couple of suggestions. Have you tried writing the equivalent program in C using the sockets API? IE is this a python specific problem or a sockets problem in general? The second thing is you may just want to try using raw sockets instead. -Daniel Yuri writes: > I noticed that the socket bound to '0.0.0.0' only receives UDP > broadcasts when they are sent from zero IP: > 0.0.0.0->255.255.255.255. When the source IP is not zeros, but some > valid IP on that network, socket never receives such broadcast. > > I compared two packets in wireshark as they arrive, and the only > difference on Ether/IP/UDP level is source IP. > > Is there any reason why source IP address would influence the > reception of the broadcast packets? > > I use this python3 program to create bound socket and listen: > #!/usr/bin/env python3.4 > import socket > sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP) > sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) > sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) > sock.bind(('0.0.0.0', 67)) > print("Waiting for broadcast") > (data, flags, ancillary, addr) = sock.recvmsg(4096, 256) > print("Received broadcast packet") > > I use dhclient to send broadcast packets. It sends with src=0.0.0.0 > when no /var/db/dhclient.leases.* exists, and it always sends with > src= when the previous lease exists. > > 10.1 STABLE > > Yuri > _______________________________________________ > freebsd-net@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-net > To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org"