I am writing a VoIP server using UDP sockets which I want to run on a VPS with public IP. Apparently, sending UDP packets from server to client behind NAT (which is basically behind any ISP/Cellular network) is problematic, since most NATs assign random ports to the device for each outgoing connection. TURN server should supposedly solve the issue, but I don’t understand how and can’t find a lot of relevant information on that. I’ve looked through some implementations (WebRTC, Coturn) but they are too huge and incomprehensible. My questions are:
- Can I implement it as a part of VoIP server?
- How does having relay server help in delivering UDP packets between 2 clients if their addresses(ports) always change? Reading through RFC8656 didn’t really help with understanding how client’s port numbers are updated.
- are there other ways around NATs that are easier to implement?