|
Home > Archive > Unix Programming > August 2006 > receive broadcasts on INADDR_ANY on the same machine does not work sometimes
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
receive broadcasts on INADDR_ANY on the same machine does not work sometimes
|
|
| linux62i@yahoo.com 2006-08-22, 7:32 am |
| Hello,
I have got a problem with receiving broadcasted (to 255.255.255.255)
packets.
I receive such packets on INADDR_ANY on the same host and on remote one
via normal UDP sockets (all things like setting flags for broadcast are
ok).
If I use UDP datagramm sockets for _sending_ everything is caught on
both
machines. If I use PF_PACKET and assemble packet myself one-to-one
matching the datagramm and send it I only receive the broadcast on
remote host.
I can see packets with tcpdump - they are identical. Everything happens
on eth0.
Linux 2.6.9.
What could be the problem and how can I workaround it? I would like
to leave receiver using simpel UDP sockets not going into PF_PACKET...
Many thanks in advance.
Vlad.
PS. No firewall is on.
| |
| Barry Margolin 2006-08-22, 7:35 pm |
| In article <1156248087.196065.173000@p79g2000cwp.googlegroups.com>,
linux62i@yahoo.com wrote:
> Hello,
>
> I have got a problem with receiving broadcasted (to 255.255.255.255)
> packets.
> I receive such packets on INADDR_ANY on the same host and on remote one
>
> via normal UDP sockets (all things like setting flags for broadcast are
>
> ok).
> If I use UDP datagramm sockets for _sending_ everything is caught on
> both
> machines. If I use PF_PACKET and assemble packet myself one-to-one
> matching the datagramm and send it I only receive the broadcast on
> remote host.
> I can see packets with tcpdump - they are identical. Everything happens
>
> on eth0.
When a packet is sent on the wire, it is not received by the same NIC
that sent it. The IP stack notices that the destination
address/protocol/port is one that it's listening on, so it loops the
packet around to that listening socket, in addition to broadcasting it.
But when you use a raw socket, it doesn't examine the packet to see what
protocol and port you're sending to. It just sends the packet out on
the network.
> What could be the problem and how can I workaround it? I would like
> to leave receiver using simpel UDP sockets not going into PF_PACKET...
Why would you need to do that? The UDP socket is doing the right thing.
If you want to ignore packets sent from yourself, put that check in the
receiver application.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
| |
| linux62i@yahoo.com 2006-08-23, 7:36 am |
| Thanks a lot for the explanations and hits!
|
|
|
|
|