Mehdi Saffar
Mehdi Saffar

Reputation: 780

Test UDP Broadcast locally

This is for a school project so I need to use UDP Broadcast.

I am building a P2P app that uses only port 5000 over UDP. I need to send a discovery broadcast packet to all clients in my network.

Normally the app will be used over Hamachi but for the purpose of developing I would like to use the simplest fastest network environment so I would like to test multiple instances locally.

I discovered that it is possible to use 127.0.0.1 127.0.0.2 etc as IPs for my local instance. (Actually tested with ips from 1 to 6 and sending messages at random to each other)

I now need to use the SAME port 5000 but do a broadcast UDP

When I invoke ifconfig on the loopback interface I do not see the BROADCAST option.

Since apparently it is impossible to add the BROADCAST option to the loopback interface, what is the easiest way to have:

Should I consider using Docker or VM or some network simulator for this purpose?

Upvotes: 1

Views: 2042

Answers (1)

tyChen
tyChen

Reputation: 1494

If you only want to broadcast to all clients, maybe multicast is enough for you. And this can fullfill all the three need you mention. Here is the definition, and here is a little example may help you.

Upvotes: 0

Related Questions