Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending UDP packets over the Internet

I'm trying to learn some of the ins and outs of P2P/decentralized networks. My question is the following. Say I have two machines named comp1 and comp2. Now comp1 is setup on my home network behind a router, and comp2 is located in my office at also behind a router. Is it possible for me to send UDP packets back and forth across the Internet like this assuming of course that ports are forwarded properly? To offer more insight on what I'm investigating, I'm trying to figure out how a new node would discover existing nodes without the use of a central server.

Thank you!

like image 684
cskwrd Avatar asked Mar 31 '11 16:03

cskwrd


People also ask

Can you send UDP over the Internet?

Sending UDP multicast over the Internet This protocol offers a number of benefits in comparison with other protocols. It is used to transmit data between two Flussonics. Add a Flussonic Media Server to the network where you plan to distribute video by multicast.

How are UDP packets sent?

UDP works by gathering data in a UDP packet and adding its own header information to the packet. This data consists of the source and destination ports on which to communicate, the packet length and a checksum. After UDP packets are encapsulated in an IP packet, they're sent off to their destinations.

Can you send UDP over TCP?

You can't send or receive UDP packets from a TCP connection. If you need to send UDP packets, use a UDP connection.

Can UDP packets be sent out of order?

UDP Traffic: Out-of-order packets can also be caused by UDP traffic. This issue occurs primarily due to stateless connections and the lack of flow control mechanisms that exist within UDP protocol.


1 Answers

Assuming, as you said the ports are forwarded correctly you can send UDP packets to 2 clients behind router's.

A good way of detecting clients on a local intranet may be using Multicast, however this does not have widespread support on ISP's (At least here in the UK) so cannot be relied upon. Multicast is used by many device discovery platforms, such as mDNS (used inApple's Bonjour)

http://en.wikipedia.org/wiki/Multicast

(It basically works by clients subscribing to groups, and then sending messages to that group)

I think the best way of discovering new clients over the internet is to have one server which new clients contact to let it know they exist, then the centralised server will tell all the other clients about you. This is used for example in P2P games such as Modern Warfare 2 and this is what the "Trackers" do in the BitTorrent protocol.

This isn't entirely decentralised but it's probably the easiest to implement, and the most reliable.

like image 103
Adam Casey Avatar answered Sep 22 '22 05:09

Adam Casey