NAT and UDP replies
Solution 1:
Only if the source port of the original outgoing datagram was also port N, and if the NAT didn't choose to float the source port.
That is, the first UDP datagram from Machine A looks like this on your LAN:
Source IP: MachineAPrivate
Source Port: PortA <-- note this is typically different than the destination port
Destination IP: MachineBPublic
Destination Port: PortN
Then, after it is translated by the NAT in the outbound direction, it looks like this:
Source IP: NATPublic
Source Port: PortC <-- note this may or may not be the same as "PortA" above
Destination IP: MachineBPublic
Destination Port: PortN
Now, when Machine B replies, the reply typically looks like this:
Source IP: MachineBPublic
Source Port: PortN
Destination IP: NATPublic
Destination Port: PortC
Then, after it goes through the inbound NAT translation process:
Source IP: MachineBPublic
Source Port: PortN
Destination IP: MachineAPrivate
Destination Port: PortA
So, IF Machine A sends the frame from the same source port as the destination port ("Port N"), and IF the NAT is able to preserve that source port (i.e. it's configured to preserve source ports when possible, and that source port is not in use), THEN you can expect a reply to "Port N" to get back to Machine A.
Here's the authoritative reference on proper NAT UDP behavior:
RFC 4787 / BCP 127: Network Address Translation (NAT) Behavioral Requirements for Unicast UDP
Solution 2:
Close, but Machine B needs to look at the source address and port number that it actually receives, which might be different than N.
The NAT at Machine A might not use the same port N that Machine A sent on. (Imagine machine C behind that same NAT also sending on port N: they can't both use it.) So Machine B might see a different source port, M. But if the NAT does that, then it should accept traffic sent back to port M and automatically map it back to N at Machine B.
In other words, as long as Machine B sends back to the source address and source port given in the packet it received, that you can reasonably expect the return packet to find its way back to the original source. This assumes that the return packet is sent within a short amount of time, as automatic NAT rules tend to timeout after some number of minutes.