Mastering FreeSWITCH
上QQ阅读APP看书,第一时间看更新

Network requirements

Quality of audio perceived by the user will first and foremost be affected by the network performance. Delays, jitter, and loss of packets can severely degrade end user experience, to an unacceptable level. There are several key components that can enable FreeSWITCH to operate more securely and efficiently: MPLS or dedicated peering connections can greatly enhance the network reliability, while Quality of Service (QoS) packet tagging and differentiating settings between your local LAN and the public WAN infrastructures will let you find the sweet point between infrastructure costs and audio quality.

Understanding QoS

QoS is a mechanism for guaranteeing that certain types of communication can be ranked for importance of delivery to ensure quality. There are multiple types of QoS that can be achieved in most network environments. Generally, QoS can be done on the physical layer (for example, guaranteeing that all phones are connected on a network that has its own cables, separate from any web browsing or data networks), the virtual network layer (by creating a VLAN which splits all voice traffic from data), and on the packet layer (by tagging individual VoIP packets for importance and priority over others).

Properly planned out physically separated networks or networks where voice operates on a VLAN and a dedicated network uplink on the WAN side have the highest chance of success and improved quality. Simply put, if data and voice aren't mixing, and you have sufficient bandwidth for times when everyone is on the phone at the same time, you should have a reliable experience without much extra work because every device has all the capacity it needs. Unfortunately, in today's world, customers aren't often willing to invest in such scenarios.

While VLANs and separated networks are great concepts and should be implemented where possible, they're not practical in many network setups. This leaves packet-based QoS, often nicknamed as packet tagging or QoS tagging. In this method, every IP packet that leaves FreeSWITCH can be tagged as to its priority level. This priority level is supposed to be used by all associated network equipment to guarantee timely or priority delivery. As an example, if a router is receiving requests to service two different websites at the same time, but packets for one site are marked as higher priority, and the Internet link is saturated, the high priority packets will be sent before the low priority packets. The assumption is the lower priority application can handle loss of packets while the higher priority application cannot, or is more sensitive to such losses and will have a degraded experience for the user.

Enabling QoS is a weakest link network design. Simply tagging packets as important won't do anything unless all the equipment on the path looks at the tags and processes them properly. This means your network gear at all sections of your network must be of sufficient quality to support QoS properly. Assuming that's the case, enabling QoS on the FreeSWITCH server is relatively easy if you're using Linux and have the ability to setup IPTables.

Tip

It's important to note that, very often, people who know SIP typically run it on port 5060, mistakenly believing that setting up QoS tagging on port 5060 will somehow result in improved call audio. This is not the case because 5060 is used for signaling, not media. Instead, media is done over a range of ports (on FreeSWITCH this defaults to 16384-32768). This port range is defined in the switch.conf.xml file in the autoload_configs/ directory. These are the ports which you should be tagging with QoS if you're seeking improved audio quality.

In the following example, we provide the IPTables command which will tag audio packets as high priority. # Mark RTP packets with EF:

iptables -t mangle -A OUTPUT -p udp -m udp --sport 16384:32768 -j DSCP --set-dscp-class ef

This command will change the DSCP tag in the IP header to indicate a class of ef or Expedited Forwarding.

Once this command is executed, all audio packets sent out from the network will be tagged as high priority. If the network infrastructure supports this, those packets are more likely to be sent (even on a saturated link) than other packets, leading to better quality audio.

LANs, WANs, and peering

FreeSWITCH has some powerful configuration capabilities when being utilized in an environment where multiple LAN, WAN, or other peering engagements exist. Specifically, FreeSWITCH allows for multiple interfaces to be defined, in the form of bindings. This allows you to send and receive data on a specific IP and port combination, and treat all packets on that port and IP with specific settings and handling.

A sample scenario of how to utilize FreeSWITCH's multi-interface capabilities to take advantage of LAN, WAN, and peering arrangements is as follows.

Note

In this scenario, we simulate a high-traffic office environment with demanding call quality requirements.

The specific objectives are as follows:

  • Route all LAN traffic over a specific network card which is physically connected to the corporate LAN and has physical guarantees of sufficient bandwidth
  • Route all WAN signaling traffic over a medium-quality network link to the public Internet
  • Route all WAN audio traffic over a high-quality network link to the public Internet
  • Route all traffic destined for our upstream VoIP provider's gateway over a specific network card which links to an MPLS and connects directly to that VoIP provider

The preceding scenario would have the following benefits:

  • Calls from LAN phones to the PSTN would traverse only the MPLS link and the corporate LAN, making the call more secure while guaranteeing call quality over dedicated links
  • Calls from LAN phones to non-PSTN numbers or that route via Internet gateways or peers would traverse high quality network paths for audio and standard quality links for signaling
  • Calls from roaming WAN users which utilize the system remotely would also have audio routed via high-quality links and signaling routed via standard quality links
  • As a side benefit, a security benefit would be that an attacker attempting to DoS the WAN network might only know the signaling IP addresses, so any DoS attack would have no impact on call quality for already established calls

To achieve this, you would set up:

  • A network interface with a local IP address for your corporate LAN
  • A network interface with a public IP address for signaling, which maps to your medium quality network
  • A network interface with a public IP address for audio, which maps to your high quality network
  • A network interface with an IP address for your MPLS and VoIP carrier gateway

In the end, you will end up with four IP addresses. You would attach those four IP addresses to three SIP interfaces within FreeSWITCH. We'll call them corp, Internet and voip_gateway for simplicity. Corp and voip_gateway would carry signaling and audio on the same IP address, while Internet would actually consist of two IP addresses, one for audio and one for signaling.

The preceding scenario would be set up in your FreeSWITCH SIP Profiles. This would result in the highest quality possible for any type of common call traversing this environment.