# UDP discovery Simulator

**URL:** <https://discourse.traintastic.org/t/udp-discovery-simulator/173>\
**Category:** Simulator\
**Created:** [September 17, 2026, 7:40am UTC](https://discourse.traintastic.org/t/udp-discovery-simulator/173 "2026-09-17T07:40:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gfgit](https://discourse.traintastic.org/letter_avatar_proxy/v4/letter/g/5f8ce5/32.png) [@gfgit](https://discourse.traintastic.org/u/gfgit)\
**Post date:** [September 17, 2026, 7:40am UTC](https://discourse.traintastic.org/t/udp-discovery-simulator/173/1 "2026-09-17T07:40:43Z")

</div>

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:

> **[423 lines 12 KiB C++ Raw Blame History -...](https://codeberg.org/gfgit/SimulatoreRelaisApparato/src/commit/43977261427293b9257a57ac53c3d570e4d8f5f7/src/network/peermanager.cpp#L280)**
>
> Powered by Forgejo | SimulatoreRelaisApparato - Simulatore di circuiti di relè per imparare il funzionamento degli Apparati Centrali Elettrici FS

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

---

<div class="post-metadata">

**Author:** ![gfgit](https://discourse.traintastic.org/letter_avatar_proxy/v4/letter/g/5f8ce5/32.png) [@gfgit](https://discourse.traintastic.org/u/gfgit)\
**Post date:** [September 17, 2026, 7:52am UTC](https://discourse.traintastic.org/t/udp-discovery-simulator/173/2 "2026-09-17T07:52:54Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![reinder](https://discourse.traintastic.org/user_avatar/discourse.traintastic.org/reinder/32/9_2.png) [@reinder](https://discourse.traintastic.org/u/reinder)\
**Post date:** [September 17, 2026, 8:17pm UTC](https://discourse.traintastic.org/t/udp-discovery-simulator/173/3 "2026-09-17T20:17:55Z")

</div>

Hi,

Here is the UDP broadcast logic of Traintastic client: [traintastic/client/src/dialog/connectdialog.cpp at master · traintastic/traintastic · GitHub](https://github.com/traintastic/traintastic/blob/master/client/src/dialog/connectdialog.cpp#L134)

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](https://www.wireshark.org) 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

---

<div class="post-metadata">

**Author:** ![gfgit](https://discourse.traintastic.org/letter_avatar_proxy/v4/letter/g/5f8ce5/32.png) [@gfgit](https://discourse.traintastic.org/u/gfgit)\
**Post date:** [September 25, 2026, 2:33pm UTC](https://discourse.traintastic.org/t/udp-discovery-simulator/173/4 "2026-09-25T14:33:37Z")

</div>

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 🙂
