Understanding SIP and RTP in Asterisk
In a standard VoIP setup, SIP is used for signaling—establishing, managing, and terminating the call. Once the call is established, RTP (Real-Time Transport Protocol) carries the actual voice media.
By default, Asterisk can either relay the media (RTP flows through Asterisk) or allow direct media, where RTP flows peer-to-peer between the two endpoints.
This behavior is controlled by a setting often called directmedia=yes in sip.conf (or “Allow Direct Media” in FreePBX for each extension).
When Does RTP Bypass Asterisk?
RTP typically flows directly between endpoints when:
- Both phones are on the same network or PBX.
- NAT is not an issue (i.e., both phones are on the same subnet).
- directmedia or similar options are enabled in your configuration.
This is by design, and it’s more efficient. Offloading media reduces CPU and bandwidth load on the PBX.
So… When Would You Want RTP to Go Through Asterisk?
There are valid cases where you’d want RTP to flow through Asterisk, such as:
- When using Music on Hold or playing IVR prompts, Asterisk must generate the audio.
- For call recording.
- When bridging two different codecs or networks (e.g., NAT traversal).
- To enforce QoS monitoring, which some admins prefer for troubleshooting.
Common Misconceptions Cleared
- Asterisk can handle RTP. It’s required for playing audio, handling voicemail, conferencing, etc.
- Direct RTP or Media is not a misconfiguration. It’s used when your phones are optimized for performance. However, it may cause audio issues like one-way audio if NAT traversal isn’t properly configured.