Support Services - How does asterisk and Switchvox choose RTP ports?
How Asterisk (and by extension Switchvox) chooses RTP ports:
By default any Asterisk/Switchvox is setup with RTP port range between 10000 and 20000. This can be changed on Asterisk by editing rtp.conf and Switchvox exposes this setting under the VoIP provider tab (Setup > VoiP Providers).
When the RTP module receives a request for a port (or ports - more on this later), the module starts in the middle of the range and starts going up until it finds an available port(s), if it reaches the top of the range, it goes to the bottom and continues looking until it reaches the point in which it started the search.
In the event that the RTP module circles through the ports and gets back to the port in which it started the search, it will conclude that there are no available ports and the request will be rejected thus rejecting the call that initialized the request in the first place.
The specification recommends that RTP port numbers are chosen to be even and that each associated RTCP port be the next higher odd number. This is the reason that in each call you will see at least two RTP ports being used.
NOTE: You don't have a port for inbound and another for outbound media. the media is carried on one port, the second port (next odd) is used out of band statistics and control information for an RTP session (AKA RTCP)
Regarding the number of ports:
Depending on what codecs you have an enable, a single call could need more than two ports. For instance, let say that you enabled video support on the extension, when the request for a call is placed - even if not a video call - the RTP module will assign for 4 ports (2 RTP, 2 RTCP) to the call, this is going to guarantee that there will be an available port in the event that video is enabled in the middle of the call.
What would happen if the customer's network has only a portion of the ports opened:
Switchvox or asterisk has no obligation or requirement to ask the network which ports are open. The PBX is always going to look at the range that is setup on its configuration and choose a port(s) within that range, If the port happens to be blocked at the firewall level, the customer will experience a call without any audio (or video).
An important note about Switchvox RTP range:
While in asterisk you can set any range that you want, Switchvox limits you to have a range between 10000 and 20000. Anything outside of that range will be automatically blocked by the access control, since the access control is hardcoded to only allow media within the default range.