Support IP handover in rtpproxy for VoIP applications
If you do VoIP applications, especially with open sources like pjsip, you may encounter kamalio and rtpproxy to serve SIP requests. Due to limitation of NAT traversals, rtpproxy is needed to work around NAT. All SIP handshake requests go through a proxy server, but rtpproxy can also relay voice, video or any RTP stream of data. When I played with rtpproxy, it was before version 2.0 and I need to handle IP handover. This refers to the scenario when user switches between different network, for example from Wifi to 4G and they get new IP. Normally this means ending in the SIP call, but the expectation is that we can retry and continue the call if possible for users.
That’s why I forked rtpproxy and add IP handover support. You can check the GitHub repo at rtpproxy.
Use src_cnt
to track the number of consecutive packets from different address. When this number exceeds THRESHOLD
(10 for RTP and 2 for RTCP), I switch to this new address
This way
- Client can ALWAYS change IP when he switches from 3G to Wifi, or from this Wifi hotspot to another
- There’s no chance for attack, unless attacker sends > 10 (RTP THRESHOLD) packets in 20ms (supposed my client sends packets every 20ms)