In recent years, with the increasing development of broadband networks and IP technology, VoIP (Volee over Internet Protoc01) technology has become more and more widely used. A gateway is an important device in a VoIP network, and can be divided into a carrier-grade gateway and a user-side gateway according to the application field. User-side gateway equipment is mainly used in communities and enterprises, and is a bridge connecting terminal phones and IP networks. Its main function is to perform voice encoding and decoding, signaling processing, VoIP protocol processing, and routing protocol processing. The position of the user-side gateway device in the VoIP network is shown in Figure 1.It can be seen that the gateway is at the end of the user’s telephone line part and the beginning of the IP network part

Author: Xia Hailun; Ding Wei

In recent years, with the increasing development of broadband networks and IP technology, VoIP (Volee over Internet Protoc01) technology has become more and more widely used. A gateway is an important device in a VoIP network, and can be divided into a carrier-grade gateway and a user-side gateway according to the application field. User-side gateway equipment is mainly used in communities and enterprises, and is a bridge connecting terminal phones and IP networks. Its main function is to perform voice encoding and decoding, signaling processing, VoIP protocol processing, and routing protocol processing. The position of the user-side gateway device in the VoIP network is shown in Figure 1. It can be seen that the gateway is at the end of the user’s telephone line part and the beginning of the IP network part.

Based on H. 323 protocol stack to realize the application design of dual-mode gateway

“Dual mode” refers to both VoIP and PSTN modes. The dual-mode gateway is a user-side gateway device that connects the PSTN network and the VoIP network at the same time and can automatically switch between the two. Dual-mode gateways can use VoIP network to save a lot of call costs. It can also use PSTN network to ensure that the telephone line is always unblocked when the VoIP network is unavailable (power failure or route unreachable), and the use of dual-mode gateways does not require any changes to the PBX switch , Users can also choose freely or automatically choose whether to use VoIP network or PSTN network by the gateway, which has good practicability and flexibility.

1 Working principle of VoIP dual-mode gateway

The gateway mainly plays the role of protocol conversion, control and gatekeeper in the VoIP network, such as call control and call management. The dual-mode gateway adds a switch between VoIP and PSTN on the basis of ordinary VoIP gateways. The dual-mode gateway system can be divided into dual-mode switching modules, FXS interface circuit modules, voice processing modules, and software control modules from the functional perspective. The system block diagram is shown in Figure 2.

Based on H. 323 protocol stack to realize the application design of dual-mode gateway

The FXS (Fbreign eXchange Subscdber) interface and the FXO (Foreign eXchange Office) interface are two very important interfaces in the VoIP gateway. In the traditional PSTN telephone connection, the central office switch of the call center provides power feed and ring current, and the telephone itself completes the Tip/Ring circuit to request services or answer calls on the PSTN. In the VoIP telephone connection, the FXS circuit simulates the function of the central office switch of the telephone center, provides power feed and ring current, and detects loop current. The FXO circuit is equivalent to simulating the function of a telephone, providing loop closure and detecting ring current.

The FXS interface circuit is directly connected to an analog phone, provides dial tone, power feed, and ring current voltage, and can detect the pick-up and hang-up and loop closure of the phone, and complete the conversion between analog and digital signals. The FXS interface circuit includes a codec CODEC and a subscriber line interface circuit SLIC (Subscriber Line Interface Circuit). The CODEC includes an analog-to-digital converter (ADC) and a digital-to-analog converter (DAC). The SLIC circuit simulates the PSTN voltage. It must be able to detect the pick-up and hang-up of the phone and generate a ring current voltage of up to 120V.

The dual-mode switching module mainly includes FXO interface circuit, which is composed of CODEC and data processing array DAA (Data Access Arrangement). The CODEC is the same as that in the FXS circuit; DAA simulates a phone and removes the high-voltage DC component by providing a loop closure of the PSTN, and only allows the analog AC signal on the PSTN line to pass. The FXO interface circuit used in the gateway can realize the following functions:

(1) The line remains unblocked when the power is off: when the gateway cannot connect to the VoIP network when the power is off, switch the line to the PSTN line.

(2) Call redirection: When the VoIP network is unavailable due to congestion or other reasons, the line can be switched to the PSTN, and the dialed number can be remembered and automatically redialed.

(3) Remote VoIP call: VoIP users can make VoIP calls through PSTN dial-in in other places. The FXO interface first receives the telephone dial tone (analog signal) on the PSTN, and then converts it into a digital signal and sends it out, which is equivalent to Extend the dial tone from one FXO to multiple local FXS.

The voice processing module of the gateway is responsible for compressing and decompressing the PCM digital voice signal. Standards for compression algorithms include G. 711, G. 723.1 and G. 729 and so on. Different algorithms have different compression ratios and take up different bandwidths. The compression algorithm can be implemented with hardware DSP or pure software.

The software control module implements the gateway’s protocol stack processing and routing processing functions. The protocol stack is responsible for encapsulating the compressed data stream and adding the IP protocol header to form an IP data packet that can be transmitted in the VoIP network. The current VoIP protocol stack is mainly based on H. 323 and SIP two standards. After the protocol stack classifies the data stream into IP data packets, it selects an appropriate route and sends it to the VoIF network via the Ethernet interface. After receiving the IP data packet, the receiving gateway decompresses the data packet and decodes the decompressed PCM digital signal to restore the original voice signal.

2 VoIP dual-mode gateway system design

This section proposes a method based on H. 323 dual-mode gateway system design scheme, this scheme supports 4 channels of voice, using an economical and practical “fake FXO interface” way to achieve dual-mode switching, can detect calls coming in on the PSTN line during VoIP calls and pass Press the phone’s clap or flash button to switch the answer.

In order to make effective use of resources, the system uses a three-phase adapter to combine the telephone line and PSTN line into one RJ11 interface, and each channel uses a three-phase adapter. The connection mode of the three-phase adapter is shown in Figure 3.

Based on H. 323 protocol stack to realize the application design of dual-mode gateway

The use of three-phase adapters can simplify the realization of dual-mode switching and also reduce the number of physical ports of the device.

The system design adopts the overall architecture of “hardware + embedded operating system + application layer software”.

2.1 Hardware design scheme

The hardware part of the system mainly includes dual-mode switching module, FXS interface circuit, voice processing module circuit, CPU module and Ethernet module. The hardware design principle diagram is shown in Figure 4.

Based on H. 323 protocol stack to realize the application design of dual-mode gateway

The dual-mode switching module uses a “fake FXO interface” method. In the circuit, a relay is used to control the dual-mode switching between the VoIP and PSTN channels of each voice channel. When the relay is not powered on, the gateway will be placed in the state of docking the phone line with the PSTN line by default. After power on, an FPGA programmable logic chip will control the switching of the relay. FPGA chip is the key component of the gateway to realize intelligent switching. The realized control logic includes the ring current detection on the PSTN line, the phone spring motion detection and other logic, and the relay is controlled to switch based on this. The FPGA and CPU interface can realize the logic of switching to the PSTN network when the VoIP network route is unreachable. The dual-mode switching module implements part of the functions of the FXO interface, but it is not a real FXO interface, so it is called a “fake FXO interface”.

The FXS interface circuit module is mainly composed of SUC chip and Codee chip, and Le79R70 chip and Le58Q021 chip of Legerity Company are selected respectively. Le58Q021 is a 4-channel Codec chip, which can control the working status of the SLIC chip (Le79R70), select the coding scheme (linear, a-law, μ-law), and also supports software programmable SLIC input impedance, balanced impedance and frequency response characteristics. The system uses 1 piece of Le58Q021 and 4 pieces of Le79R70 to work together to support 4 channels of voice, provide power to the phone, generate ringing signals, detect phone pick-up, etc., and is responsible for completing the conversion between phone analog signals and PCM digital signals.

The voice processing DSP chip selects AudioCodes AC483, which can support 4-channel voice codec at the same time, and supports G. 729A, G. 723.1, G. 727、G. 726、G. Compression algorithm standards such as 711 can complete real-time voice compression, DTMF signal detection, generation, and echo cancellation.

The system CPU chip selects Samsung’s ARM7TDMI series S3C4510B, its operating frequency is 50NHz, and a wealth of general-purpose modules are integrated on the chip, including a 10M/100M adaptive Ethernet controller, which can directly lead to the Ethernet interface through the PHY chip. The Ethernet PHY chip selects Intel’s LXT972A chip, which has a 1OM/100M adaptive transceiver function and supports full-duplex operation. In addition, the system also uses 2MB Flash, 16MB SDRAM and 512KB SRAM as memory.

2.2 Software design plan

The software part is mainly composed of embedded operating system and application layer software, which completes protocol stack processing, routing processing and other control functions. The software solution hierarchy is shown in Figure 5.

Based on H. 323 protocol stack to realize the application design of dual-mode gateway

The embedded operating system adopts μCLinux. μCLinux is an embedded operating system customized for processors without a memory management unit. It has the characteristics of rich network functions, open source code, tailorable inner edges, and easy portability. According to the characteristics of the hardware platform, it is also necessary to develop drivers suitable for the hardware platform, including Bootloader, serial port driver and Ethernet driver. Among them, the Bootloader is the key to transplanting the uCLinux operating system. When the system is powered on, the Bootloader is responsible for hardware initialization, interrupt processing and hardware clock management, and loads the operating system image to the memory. In order to facilitate the system network upgrade, Bootloader can realize the TFTP network function. The serial port and the Ethernet port driver are relatively simple, and the data can be sent and received correctly.

The software of the application layer is mainly composed of H. 323 protocol stack processing module, routing processing module and DSP control module. H. The 323 protocol stack is responsible for functions such as call control and signaling, audio processing, and real-time media transmission. The system uses the more mature open source OpenH323 protocol stack as a reference, and the functional modules on the application layer are all developed based on this protocol stack. The routing addressing module is mainly responsible for routing addressing and routing management, determining the IP address of the destination gateway, and selecting the best route to transmit the IP data packet to the destination gateway through the IP network. The DSP control module is mainly to control the behavior of the DSP chip AC483 in the application program according to the call flow. The network management module provides Web network management and CLI command line interface, which makes it easy to configure and maintain the dual-mode gateway.

3 Application scheme

As a user-side gateway device, the system can be widely used in communities and enterprises. For a cell with a relatively small number of users, the phone can be directly connected to the gateway, as shown in Figure 6. For enterprises with a relatively large number of users, it can be connected to a PBX switch, as shown in Figure 7.

Based on H. 323 protocol stack to realize the application design of dual-mode gateway

The system is based on H. 323 protocol stack design. At present, the basic functions of the system have been implemented, and it can interoperate with other gateway devices, and can interoperate with the operator’s Gatekeeper. On the basis of this design, more voice channels can be supported by selecting chips with stronger processing capabilities, SIP protocol stacks can be added to support dual protocol stack architecture, and real FXO interface circuits can be implemented to support remote VoIP calls. These are the areas where the system can be improved in the future.

The Links:   PD10M44OH7B06 PM300DVA120