Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.mixmin.net!news2.arglkargh.de!news.n-ix.net!news.belwue.de!news-zh.switch.ch!kanaga.switch.ch!switch.ch!newsfeed-00.mathworks.com!panix!not-for-mail From: Grant Edwards Newsgroups: comp.lang.python Subject: Re: Problem receiving UDP broadcast packets. Date: Wed, 20 Apr 2011 00:00:56 +0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Lines: 45 Message-ID: References: NNTP-Posting-Host: dsl.comtrol.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: reader1.panix.com 1303257656 10786 64.122.56.22 (20 Apr 2011 00:00:56 GMT) X-Complaints-To: abuse@panix.com NNTP-Posting-Date: Wed, 20 Apr 2011 00:00:56 +0000 (UTC) User-Agent: slrn/pre0.9.9-102 (Linux) Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:3614 On 2011-04-19, Dan Stromberg wrote: > On Tue, Apr 19, 2011 at 3:21 PM, Grant Edwards wrote: >> I'm have problems figuring out how to receive UDP broadcast packets on >> Linux. >> >> Here's the receiving code: >> >> ------------------------------receive.py------------------------------- > >> But, the receiving Python program never sees any packets unless the >> _source_ IP address in the packets is on the same subnet as the >> receiving machine. > > This is just how broadcasts work. > > Normally, you take your subnet mask and "bitwise and" it with the IP > addresses of the sending and receiving machines. If the results match > for two such pairs on two different machines, then the broadcast > should be visible, given appropriate code. That certainly looks like what's hapenning, but it seems very counter-productive to me. If I send a packet to ff:ff:ff:ff:ff:ff--255.255.255.255, it's because I want everybody on the Ethernet segment to receive it. If I wanted only people on a particular subnet (e.g. 10.0.0.0/8) to receive it, I would have sent it to the subnet broadcast address (e.g. 10.255.255.255). > However, some routers have the ability to pass packets from one subnet > to another. I believe this is called a "helper", at least in the > Cisco world, and must be configured specially. There are no routers or firewalls involved -- just a dumb Ethernet switch. It seems I'm going to have to use raw sockets to do what I need to do. That's exactly what I was trying to avoid by using UDP: I'm replacing a proprietary (non IP) MAC-level protocol that was implemented using raw sockets. -- Grant Edwards grant.b.edwards Yow! I'm young ... I'm at HEALTHY ... I can HIKE gmail.com THRU CAPT GROGAN'S LUMBAR REGIONS!