From: Philippe Troin <phil@fifi.org>
To: Rob Landley <telomerase@yahoo.com>
Cc: Jeff Garzik <jgarzik@mandrakesoft.com>, linux-kernel@vger.kernel.org
Subject: Re: 255.255.255.255 won't broadcast to multiple NICs
Date: 03 Nov 2000 12:19:53 -0800 [thread overview]
Message-ID: <87zojgvmdy.fsf@tantale.fifi.org> (raw)
In-Reply-To: <20001103173316.17356.qmail@web5201.mail.yahoo.com>
In-Reply-To: <20001103173316.17356.qmail@web5201.mail.yahoo.com> (Rob Landley's message of "Fri, 3 Nov 2000 09:33:16 -0800 (PST)")
Rob Landley <telomerase@yahoo.com> writes:
> --- Philippe Troin <phil@fifi.org> wrote:
> > All the code I've encountered which actually needed
> > to perform
> > broadcast on all interfaces was sending
> > subnet-directed broadcasts by
> > hand on all interfaces.
>
> Bind to a socket to a local port and query that
> address you say? Nope, too easy. The address
> returned when I query a socket (rather than a
> connection) is 0.0.0.0 on any machine with multiple
> interfaces (even loopback), since the socket is bound
> to that port on ALL the interfaces. Each incoming or
> outgoing connection does have a valid "from" IP
> address, but I have to wait for a connection to come
> in to get that. (Unless I explicitly specify which IP
> to bind to when I create the socket, but if I knew
> that I'd already be there.)
>
> Nope, making my own connection to a port on the same
> machine just means 127.0.0.1 is talking to 127.0.0.1.
> Tried it. Didn't work.
>
> Nope, feeding the loopback address to getAllByName()
> doesn't help either. I tried that too, it just
> returns a length 1 array containing just the loopback
> address.
The source IP address (as returned by getsockname()) is only set when
the socket is connected... It follows the same logic: for a multihomed
machine, we know which interface will be used only when we know who
we'll be talking to...
> Now you know why I'm resorting to 255.255.255.255.
> I'm sort of faking things: when the server broadcasts
> to clients they know who it is, and when they
> broadcast to it, it knows who THEY are (it says in the
> UDP datagram header info). And the way I've written
> it, that's all they really need to know (although when
> we reply to each other we can each find out the info
> we don't know: who WE are. But by that point, we no
> longer need it. :)
>
> I may just document "if you run this on a machine with
> more than one network card, you have to specify the
> broadcast addresses on the command line". It's
> configuration, but the only machine likely to HAVE
> multiple interfaces is the server (which could be
> serving multiple subnets in a really BIG render farm),
> so I suppose it's tolerable...
You could use SIOGIFCONF (from C) to get the address list. I'm not
sure is java has the equivalent... Or maybe a very small native
method...
> > Broadcast is ugly anyways, why don't you use
> > multicast ?
>
> I'm only passingly familiar with it, does it map well
> to this problem?
>
> The only data I'm trying to transmit is "where is
> everybody", or "wake up". The broadcast packets are
> only needed for clients to find the server on bootup
> (and vice versa if the server is rebooted). They're
> also used to wake up clients if they go to sleep
> because the server has nothing for them to do at the
> moment, but that second part's a convenience, really.
> The server could loop through and address them
> individually instead since it knows where they are by
> that point.
>
> The actual heavy lifting of data is done by TCP/IP
> streams. UDP broadcast is just for figuring out where
> to open the TCP/IP connections to.
Sounds like a good job for multicast... It's fairly simple to use,
but:
1) I'm not sure if java gives you access to the required ioctls
(there's only five of them).
2) You may need to run mrouted on all your gateways.
Phil.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/
next prev parent reply other threads:[~2000-11-03 20:20 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-11-03 17:33 255.255.255.255 won't broadcast to multiple NICs Rob Landley
2000-11-03 18:11 ` Paul Flinders
2000-11-03 20:19 ` Philippe Troin [this message]
-- strict thread matches above, loose matches on Subject: below --
2000-11-04 3:15 Rob Landley
2000-11-03 19:46 Rob Landley
2000-11-03 4:17 Rob Landley
2000-11-03 1:22 Rob Landley
2000-11-03 2:14 ` Philippe Troin
2000-11-02 23:55 Rob Landley
2000-11-03 0:29 ` Jeff Garzik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87zojgvmdy.fsf@tantale.fifi.org \
--to=phil@fifi.org \
--cc=jgarzik@mandrakesoft.com \
--cc=linux-kernel@vger.kernel.org \
--cc=telomerase@yahoo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox