Broadcast packets process

I’m working on processing data from three network devices using my own software. These devices send and receive UDP broadcast packets on the address 255.255.255.255:5102. It’s crucial that the devices don’t receive each other’s packets, but I need to capture all of them using a single Ethernet cable. Additionally, I need to send information back to each device separately, and I plan to use different UDP ports for that purpose.

Is there a solution to achieve this configuration? Any guidance would be greatly appreciated

I recently purchased a Mikrotik router with RouterOS, but I’m facing challenges with the configuration. I attempted to use ‘dst-nat’ for incoming packets, trying to convert them to unicast with a different port. Unfortunately, it didn’t work as expected for broadcast packets. I also experimented with the reverse approach for outgoing packets, attempting to ‘dst-nat’ my packets to the device address 255.255.255.255.

How can you connect three devices to a single ethernet cable? I would expect each device to be connected to a switch port, in which case you can use port isolation or bridge horizon to prevent packets from one of these devices being sent on the links to the others.

Some vendors have ‘ip helpers’ which forward certain specific broadcast messages, e.g. for DHCP relay. However, in general routers do not forward broadcast packets, they stay within a layer 2 / ethernet brodcast domain, so your target device has to be part of the same ethernet network.

You should be able to use the /interface/bridge/filter to block the dst-address/port to the other ports except your app/server’s port*.

See https://help.mikrotik.com/docs/display/ROS/Bridging+and+Switching#BridgingandSwitching-BridgePacketFilter


* the bridge filters will not work with VLAN bridging (vlan-filtering=yes) since they are VLAN L2 packets & the filters cannot inspect the inner IP headers if traffic is tagged

I do not want to connect three devices with one cable. I want them to be connected to the router and then process their packets and combine them to send via one (fourth) router interface

looks promising, thanks. I’ll try it out

I used bridge filter and now able to send the data to specific port, thank you very much. I have an additional question: can I somehow mark forwarded broadcast packets to get the information from which port the packet came in my program? I tried dst-nat to change destination port in ip firewall with no luck. Also I tried to dst-nat destination address (MAC) in the bridge NAT section but the packets remain untouched

Not the expert on the bridge NAT rules, so cannot say what expected/allowed.

One option is the “Use IP Firewall” in the bridge settings. The causes packets to go through /ip/firewall (even though they are “bridged”). The packet flow gets more confusing when you do this & you may need to disable fasttrack rule in firewall (or accept these packets before fasttrack rule), but you should be able dst-nat the IP ports there.

Mikrotik documents the packet flow pretty completely so you can trace your rules+packets against the diagrams in:
https://help.mikrotik.com/docs/display/ROS/Packet+Flow+in+RouterOS#PacketFlowinRouterOS-FlowofBridgedPacket

Note: The Prerouting, Forward, and Postrouting boxes happen in /ip/firewall.