So you can have a remote peer and try to contact it via UDP/TCP/TLS. You can even attempt via multiple interfaces (Wifi and 5G).
You can then measure the packet loss/latency across these different paths and figure out which one is best.
Dependent on the firewall, but most I have seen allow NAT mapping with different behaviors.