views:

574

answers:

9

Given two computers attached to the Internet that know nothing about each other before hand, is it possible for one computer to be able to broadcast a message so that the second computer could receive it and respond?

I know UDP broadcast exsits, but I believe that those are generally filtered by the ISP before it reaches the true Internet. Is this true?

+2  A: 

No, you can't broadcast like that over the internet. You need to know which address you want your packets to go to.

Harley
I don't know about this and I'm really curious, can't you send the packets to all the computers? You can broadcast over LAN; in theory, what would stop you to send a packet to ALL the computers in the world?
Tom
@Tom: Hint: How many people can broadcast to the world without the whole system melting down?
Bjarke Ebert
IP broadcasts only work on the local network segment, because the network stack converts the IP broadcast into an ethernet broadcast
Alnitak
@Alnitak: That's the kind of answer I expect to see more often on stackoverflow. Thank you.
Tom
+1 - The other higher answers seem to have ignored the "know nothing about each other before hand" part of the question.
benc
+6  A: 

You need an intermediate third party that they both know, that could distribute messages directed towards it in a broadcast-like fashion.

Jay Kominek
The best example of this is DNS, but there are others.
Tom
Yes, DHT, as mentioned by Vinko Vrsalovic
bortzmeyer
But if they did know they had a common third-party system, then wouldn't that be DNS? Then wouldn't they be able to use a non-broadcast mechanism to find each other?
benc
+8  A: 

The current best way to achieve a multinode network without centralized coordination is through the use of Distributed Hash Tables. That link explains a bit and links to various implementations you can leverage.

That said, you still need each machine to coordinate with at least some peers. It's just that you don't need it to coordinate with a central server. A solution using a central server that know both (all) participating machines will also work, but imposes further restrictions on anonymity and scalability, just remember what happened to Napster.

Vinko Vrsalovic
How does this qualify under the "know nothing about each other before hand" part" of the question?
benc
They do not have to know anything a priori about each other. Of course somebody will have to know something about any other machine as to actually do something. When I download something over BitTorrent I know nothing about any other machine before hand, I just discover about them while downloading.
Vinko Vrsalovic
+4  A: 

A solution for this problem (where none of your peers know the final address of the other) could be relying on IM protocols.

In particular, the XMPP protocol is extensible, open and used by many providers such as Google Talk. Libraries exist for most languages and it has the plus of being able to work (slowly and going through a 3rd party server) even if both hosts are behind a NAT-box.

If communication must use another channel, you can use XMPP to exchange IP address and then proceed with the standard socket route (but if you encrypt your messages, there should be no problem even going through a 3rd party server - to be true all packets go through untrusted 3rd party routers so you should encrypt anyway if you have sensitive data..).

Hope this helps.

Marco M.
+1  A: 

UDP is a dead end - its just a protocol where the order the packets are received is less important and there are issues routing over WANS. You said that you want to connect two computer on the "internet" presumably with the end points moving around etc. The only way is to use a central server as a register/directory. If each end point allso a web service or something and registeres its current IP address and name periodically then the other end point can look up the IP address of the other using this service. (could host your own DNS server and code your end point to register on this DNS?)

One of the problems is that even if you have the IP address what is one or more nodes are behind a firewall or NAT router ? You will need to host a server to proxy traffic. The best example is SKYPE - look into how it works it is documented, very interesting.

The simplist answer might be to jump on the back on an existing service such as messanger, skype, bit torrent, etc.

Simon

+2  A: 

A possible solution for you is to use a dynamic DNS service.

Your application would need to know in advance which hostname the other host will be using, but this service would at least get around the fact that you don't know exactly which IP address the other computer is on.

Note that this won't solve the potential issue of firewalls between the two hosts blocking your packets. The only practical way around that is for both hosts to open an outbound connection to a central host which can then relay data between them.

Alnitak
A: 

Multicasting is also a possible solution. It's certainly feasible in a corporate network

Jeff
and currently barely feasible at all across the whole internet.
Alnitak
@Alnitak - agree, sure wish it was implemented correctly. But there would probably be a whole rash of Multicasting attacks if it did.
Jeff
Plus, they would have to know which multi-cast address to use. That means they wouldn't "know nothing about each other before hand".
benc
+1  A: 

If the computers are running Windows, I'd look at using PNRP.

Jon Galloway
+1  A: 

Look at the chord or pastry algorithm. It is an overlay network (DHT based) which has a discovery mechanism involved. It's a P2P (Peer 2 Peer) routing algorithm.

steve