UDP discovery Simulator

I’ve noticed Qt UDP discovery example is different from boost UDP discovery.
I’m investigating this because I have troubles connecting to simulator on other PC in local network if a PC has multiple networks connected (say local intranet + tethering from phone).

This is my Qt code:

One message for each broadcast address instead of a single broadcast message.

Also I have problem in Master/Replica discovery.

Master has to be launched first. If I launch replica before master discovery does not work.

Also replica on other PC in local network does not discover reliably, sometimes it does not work…

Hi,

Here is the UDP broadcast logic of Traintastic client: traintastic/client/src/dialog/connectdialog.cpp at master · traintastic/traintastic · GitHub

It is indeed required to sent a broadcast on each broadcast address separately, when using the IPv4 255.255.255.255 broadcast address, it will only be send the UDP packet on the default gateway interface.

Did you use WireShark to investigate the UDP traffic? I would set it up on both systems, then you can check if and how messages are sent/received. That will make it much easier to determine if it is a network/firewall problem or something in the C++ logic. It really helped me finding network related bugs in the early days of Traintastic.

Greetings,
Reinder

Ok I’ve tried Wireshark.

Replica’s UDP socket sends 2 broadcast messages: 127.255.255.255 and 192.168.1.255

But only the second one seems to be shown.

Anyway Master sends back 2 messages with local TCP port to 127.0.0.1 and 196.168.1.my_ip

After trying to move network code to separate thread capture stays the same but now it does not work even if I start Master first :slight_smile: