If you are creating an app that opens a UDP socket and sends traffic to a particular target the only thing you need to concern yourself with is the ip-addresses. If your listener works on layer 2. i.e. when both systems are on the same subnet, then it should work exactly the same way when you move to layer 3 provided your network is correctly set up. If that fails then try using something to test it that you know works. There are plenty of diagnostic apps out there but the easiest is probably netcat, install that and try this:
On your target system:
nc -l -u -p 1234
On your source system
nc -u -p 1234
Change the port number to the one you're using for your app and if you should be able to see anything you type on the source appear on the destination console provided your layer-3 network is set up properly and isn't blocking UDP over that port.
If you are embedding the MAC address in the payload then that's one thing but the source (and destination) MAC addresses embedded in the Ethernet frame will be changed by the router, that's how it works. If your app expects them to remain the same at both ends of the conversation then it will fail but in general you should not be digging that deep into the network stack. What are you using to build this?