Design and implementation of short message gateway communication module
Deng Lihua, Huang Hua, Zhang Jingyu 2
(1. School of Electrical Information, Sichuan University 2. Time Li Yonglian Technology Co., Ltd.)
Abstract: On the basis of explaining the short message gateway structure, the design idea of the short message gateway communication module is proposed, and the specific implementation of the communication module is given.
Key words: short message; short message gateway; communication
1 Introduction
With the development of communication technology, the wireless Internet short message service is providing users with more and more services. People can not only broadcast news, stock information, weather forecasts through mobile phone, but also download tones, pictures, etc. No matter what kind of information you need, we can access the Internet from the mobile phone anytime, anywhere, and enjoy a variety of services. Telecom operators must implement these value-added services, they must support interconnection interconnection between the Internet.
There are four ways to realize interconnection interconnection between networks, including: interconnection interconnecting through mobile gateway; through signaling forwarding point interconnection; interconnection through short message gateways; interconnection through third party operator systems. The first two ways are not easy to set the billing point and the argument bill, so it is not conducive to the network settlement; the last way, although it is possible to ensure the unity of the billing point and the settlement point, it is susceptible to geographical conditions. Through the short message gateway, Internet messaging is achieved, there is no need to make large-area data changes and upgrade modifications to the equipment running in the current network, and can set the billing point, ensure the accuracy of the billing, and realize the function of business authentication and service filtering. To ensure the safety of the network, it is also possible to prevent the occurrence of network storms by monitoring and control of business flow, such interconnection, which has other three ways unparalleled advantages. At present, most of the interconnection of most short message services is implemented using short message gateways.
2 short message gateway structure
The short message gateway (ISMG) is a device in the Short Message Center (SMSC) and Service Provider (SP), which provides secure and fast channels for the data exchange of these two entities. The gateway and the short message center use the SMPP protocol (Short Message Peer to Peer, Short Message Peer Total Point Protocol), using the CMPP protocol between SP (China Mobile Peer to Peer, China Mobile Point-to-Point Agreement), so short message gateway needs to complete the protocol Effects of conversion, billing, routing, security and network management. Its structural diagram is shown in Figure 1.
SMPP
CMPP
Short message gateway (ISMG)
SMSC
SMPP Communication Agent System
Short message gateway processing system
SP
CMPP Communication Agent System
SMS gateway billing system
Business management system
Firewall system
Specifically, the figure
1
in
SMPP
Communication agent system mainly implements gateways and
GSM
Short message center in the net (
SMSC
The connection ensures accurate reception and transmitting data, achieving efficient, reliable data transmission. In order to meet the requirements of the specification
0.001%
Data packet loss rate,
SMPP
Communication agent needs to support traffic control.
CMPP
Communication agent systems are mainly implemented
SP
Service provider connection, with
SMPP
Different communication agent systems are due to the impact of the protocol,
CMPP
Communication agent is server side, waiting for
SP
Connection
SMPP
Communication agent is a client, you need active connection
SMSC
. The short message gateway processing system is the most complex processing process in the gateway, and its completion tasks include:
GNS
Gather gateway
)
Query routing, maintenance routing tables, and perform protocol conversion and data distribution. The firewall system provides security for the gateway system, including
IP
Packing filter and authentication. The SMS gateway billing system mainly forms a variety of billing orders, providing a basis for billing. The business management system mainly completes statistical reports to the business, generating reports, providing interfaces and interfaces for operators to add, modify, delete, and providing interfaces and interfaces for user data. 3 short message gateway communication module design and implementation
The short message gateway communication module is the basis of the entire short message gateway. Whether it is billing, statistics, or overtime retransmission, high quality communication framework is essential. This communication architecture not only has the function of the basic transmission and reception message, but also has a good structure to support various business needs and ensure good scalability.
3.1. Design of short message gateway communication module
When designing a short message gateway communication module, we consider the following points:
First, because there is a wide variety of short message gateways, if communication and specific services are developed together, it is easy to take care of this. May be due to the beginning of the considering, causing the communication underlying and the original business code to increase the new business, resulting in repeated development. Therefore, we use communication agents to separate communications and specific services. When adding new services, we need to modify the settings of the communication agent, and do not have to change the original business code.
Second, the communication agent needs to listen at multiple ports at the same time, and we choose multiple multiplex I / O methods. Although multi-threading can improve code efficiency and resource utilization through parallel computing and shared memory, in short message gateways, the processing amount of data is large, and the multi-threaded parallel processing will cause some messaging logic confusion, resource sharing will also increase The complexity of the code. The multiplexing is simple, the logic is clear, and it is not easy to have errors, and there will be no synchronization and mutual exclusive problems due to resource sharing. Therefore, it is reasonable to use multiplex I / O.
Third, the business processing module and the communication agent can use the queue to communicate, and the management and parameters of the queue (such as the mutual exclusion of the same queue operation, and the number of queues, etc.) use specialized queue kernel programs. Uniform scheduling and encapsulates into a function interface to facilitate the use of the business processing module to the queue. In addition, through queue communication, good scalability can be provided for future increased services.
Fourth, in order to reach a 99.999% non-packet loss rate, the communication agent needs to use the traffic control mechanism to ensure that the gateway is not packetified. This is because no matter how big the queue is set, if there is a message that only does not accept it, it will cause queue overflow and packet loss. Therefore, record the message cached in each queue, when a queue is required, the queue is no longer assembled to ensure that the message arriving at the gateway will not be lost.
3.2. Implementation of the short message gateway communication module
Based on the above design idea, our short message communication module includes four parent processes: CMPP Communication Agent (CMPP_SERVER), SMPP Communication Agent (SMPP_SERVER), message distribution processing server (package_server), and forward message processing Server (route_server). They communicate with each other between six messages. The specific software structure is shown in Figure 2.
CMPP_SERVER
Mainly
SP
A high quality transmission channel is established between the gateway. It also listens many more than it
Socket
, Through the queue interface function
MQM_SEND ()
Put it
CMPP
Format message sent to the queue
2
in. At the same time, it also passes the function
MQM_RECV ()
Keep from the queue
1
Get messages and forward it to the corresponding purpose
SP
.
CMPP_SERVER
Do not need to judge the type of message received, only responsible for communication, so communication agent.
SMPP_SERVER is basically consistent with CMPP_SERVER: the only difference: SMPP protocol specifies that SMPP_server is a client, requiring active initiative to establish a connection request; and the CMPP protocol specifies that CMPP_Server is the server side, waiting for the other party. Package_server is the core of the short message gateway, and all messages need to pass it, including protocol conversion, timeout retransmission, billing, routing, need to be completed in package_server. Package_server simultaneously listens 2, 4, 6 three queues, and determines the next destination of this message according to different messages. The routing table also needs to be maintained in Package_Server so that package_server can get routing information and forward messages. If the relevant information is not found in the routing table, the package_server will forward the message to the route_server, and then send the message from the Route_Server from the inclusion gateway.
Route_server mainly handles messages that need to be forwarded to other gateways. When the Destination of the package_server discovers the message is not the SP or SMSC connected to the local gateway, then it will forward the message to the Route_Server process. Route_server then communicates with the message gateway, request the gateway address of the destination, and then establishes a Socket connection with the destination gateway, delivers the message and records the previous conversation.
In the entire communication module, all Server uses the queue interface function MQM_INIT () to initialize the message queue and copy it on the queue. Transceiver data is complete using the MQM_send () and MQM_RECV () functions. The storage message uses a fixed data structure, and its structure is as follows:
Struct MQM_CONNECTION {
Unsigned int package_server_seqnum; // is generated by the gateway. If the message comes from the queue 4, the element will be a message serial number in the transformed CMPP protocol format; if the message comes from the queue 2, the element will be the message serial number of the transformed SMPP protocol format.
Short mqm_sockfd; // Receive the Socket of the message;
Short MQM_SEQNUM; // Received Message Serial Number;
Time_t mqm_timeout; // Time to receive the message;
INT TOTAL_LENGTH; / / The length of the message;
Char MQM_BUF [MAX_PACKET_SIZE]; // The content of the message;
Char control_buf [max_packet_size]; // The message content after the conversion protocol;
}
The workflow of the communication module is now described as an example of the MO request business.
When SMSC issues a SMPP format speech short message, it is received from Queu 4 to Package_Server via SMPP_SERVER. Package_server receives the MO request to the SPP format Deliver_SM_REP response message and store the respective information of this MO message with the MQM_Connection structure. After that, the package_server converts the message to the CMPP_DELIVER message of the CMPP protocol and sent to the CMPP_SERVER through the queue 1, forwarding to the destination SP. After the SP receives this message, the reply message of the CMPP_DELIVER_REP in a CMPP format is generated returns to the gateway. When Package_Server receives a response signal, you also need to store with MQM_Connection structures. At this time, an MO short message forward is successful, and the package_server records the SMO. Hereinafter, under the Linux7.2 version of the operating system, the main code of the package_server implemented with the C language:
Main ()
{
MQM_INIT (); // Initialization queue;
......
PIPE (); // Establish a pipe;
IF ((Child_PID = fork ()) == 0)
{
// Number of queues notified by pipelines;
While (1) {
GET_RESULT_MSG_INFO (Request_2, PIPFD2 [1]);
}
}
......
// Establish an listening descriptor set;
FD_ZERO (& Monit);
FD_SET () _;
......
// Treat data from the queue
While (1)
{
SELECT (); // Monitor 2, 4, 6 queues;
IF (FD_Isset (Queue2, & Read_Monit) // If the 2 queue has a number;
{
Handle_Queue2_in (); // Handling the data from the 2 queue;
}
......
} // end while;
} // end main;
4 Conclusion
The short message gateway is the most critical device in the wireless Internet short message service, which races a bridge for mobile phone users and Internet information resources. The communication module of the short message gateway in this paper is complete, the structure is reasonable, and it provides good scalability for billing, routing, timeout retransmission. After laboratory test, on the 2 processor, 64 mega memory machine, the transceiver package rate is 5,000 per second, and the no packetization rate is 100%, which is a stable system.
references
[1] Short message gateway equipment specification (V1.2). China Mobile Communications Corporation, 2001.
[2] China Mobile Communications Short Wensive Gateway Test Specification (V1.2). China Mobile Communications Company, 2001.
[3] China Mobile Communications Information Resource Station Entity and Internet Short Skeft Gateway Interface Protocol (V1.3). China Mobile Communications Corporation, 2001.
[4] Short Message Peer to Peer Protocol Specification V3.4 .smpp Developers Forum, 1999.
[5] W.Richard Stevens.Unix network programming. Shi Zhenchuan, Zhou Li Min, Sun Honghui and other translations. Tsinghua University Press, 1999.