通信流程 - 王茜翻译
Messaging Flow
SGIP有两种具体实现方式,一种是采用专用SGIP方式,另一种是采用通用HTTP方式。SMG和GNS、以及SMG和SMG之间采用专用SGIP方式作为承载协议;而SP和SMG的通信同时支持专用SGIP方式和通用HTTP方式两种承载协议。
There are two realization modes for SGIP, one being exclusive SGIP mode
and the other being general HTTP mode. The exclusive SGIP mode is the
load protocol between SMG and GNS as well as between SMG and SMG; whereas
communications between SP and SMG support both the exclusive SGIP mode
and the general HTTP mode.
1 The Exclusive SGIP Mode
采用专用SGIP方式承载时,通信双方互为客户端和服务器端。当客户端要发送命令时,主动向服务器端建立连接,然后向服务器端发送命令,并接收应答;服务器端从客户端接收命令,返回应答。
When loaded via the exclusive SGIP mode, one party of the communication
is the client while the other party is the server. When the client needs
to send out a command, it initiates a connection to the server, sends
the command to the server, and receives the response; the server receives
the command from the client and returns the response.
连接建立以后,客户端可以连续发送多条命令。命令发送完并接收到所有应答后,客户端应该主动断开连接。但是,命令及其应答之间的时间间隔最大不能超过30秒(默认,可配置)(如果命令应答时间超过最大等待时间,则要求客户端重发该条命令,重发机制参见业务联网规范有关内容),且待应答的命令不得超过32条(可以根据线路的质量和服务器的处理能力配置)。
After the connection is established, the client can send multiple commands
successively. After it has sent out all the commands and received all
the responses, the client shall initiate to terminate the connection.
However, the time interval between a command and the response to it shall
not exceed 30 seconds (default, configurable) (if the responding time
for a command exceeds the maximum time, the client will be required to
resend the command. See the Service Networking Regulations part for the
resending system), and the number of commands waiting for responses shall
not exceed 32 (configuerable according to the line quality and the server’s
processing capacity ).
而且,如果服务器端检测出一条连接长时间空闲(默认60秒,可配置),可以主动断开该连接。如果需要,客户端可以同时向一个服务器端建立多个连接(SMG与单个其他SMG最多不能建立超过15个连接,对与之相连的单个SP的最大连接数视具体情况而定)。采用专用SGIP承载方式时,SMG和SMG、SP和SMG之间使用的端口号是8801,GNS监听SMG的端口号为8802,SMG监听GNS的端口号为8803,主GNS和备用GNS之间的端口号为8804,SMG之间的测试用端口号为8810。
In addition, if a long connection idle time (60 seconds for default, configurable)
is detected at the server, it can initiate to terminate the connection.
If necessary, the client can establish multiple connections to a server
synchronously (a SMG can establish at most 15 connections to another single
SMG, and the maximum number of single SPs connected to it depends on the
specific circumstances). When loaded via the exclusive SGIP mode, the
terminal port used between SMG and SMG, between SP and SMG is 8801, the
terminal port for GNS monitoring SMG is 8802, the terminal port for SMG
monitoring GNS is 8803, the terminal port between the main GNS and the
standby GNs is 8804, and the terminal ports between SMG for test is 8810.
2 The General HTTP Mode
HTTP承载方式只适用于SP和SMG的通信中。与SP与SMG之间的专用SGIP承载方式不同的是,该种方式一次连接仅仅传送一条命令,而且连接的认证采用HTTP的URL的授权认证的方式,不需要专门的连接认证的命令,使用的端口号是80。
The HTTP load mode applies only to SP and SMG communications. Different
from the exclusive SGIP load mode between SP and SMG, the HTTP mode only
sends one command in one connection, and the certification of the connection
is a certification mode authorized by the URL of HTTP. No specific connection
certification command is required, and the terminal port used is 80.
3 Communication Node Numbering Rules
在整个网关系统中,所有的通信节点(SMG、GNS、SP和SMSC)都有一个唯一的数字编号,不同的SP或SMSC或SMG或GNS编号不能相同,编号由系统管理人员负责分配。编号规则如下:
In the whole gateway system, all communication nodes (SMG, GNS, SP and
SMSC) have a sole numerical number. Different SPs or SMSCs or SMGs or
GNSs have different numbers, which are designated by the system manager.
The numbering rules are as follow:
Numbering rule of SMG: 1AAAAX
Numbering rule of SMSC: 2AAAAX
Numbering rule of SP: 3AAAAQQQQQ
Numbering rule of GNS: 4AAAAX
其中, AAAA表示四位长途区号(不足四位的长途区号,左对齐,右补零),X表示1位序号,QQQQQ表示5位企业代码。
AAAA stands for a four-digit long-distance area code (long-distance area
codes that have less than four digits shall be left-align, the voids on
the right to be filled with the number Zero). X stands for one-digit sequence
number, and QQQQQ stands for five-digit corporate ID.
4 序列号的定义Defining the Sequence number
短消息网关系统之中传输的每一条命令都有一个序列号,序列号由命令源节点产生并唯一标记一条命令;也就是说,网关系统中任何两个命令的序列号都不相同。需要注意的是,一条命令在发送过程中转发的不同副本视为一条命令,使用相同的序列号。
Every command transmitted in the Short Message Gateway system has a sequence
number, which is generated by the command source node and marks a command
exclusively; i.e., the sequence numbers of any two commands in the gateway
systems are different. It is worth noticing that during the course of
transmission, different duplicates forwarded by a command are recognized
as one command and share the same sequence number.
比如,SP1X向SMSC2A发送一条命令,该命令需经过多次转发才能到达SMSC2A,而转发该命令的每一次通信过程中使用的命令的序号均相同,为SP1X与SMG1通信所使用的序列号。对于MO短消息,例如SMSC1B向SP3X发送一条命令,短消息首先采用SMPP协议发送到SMG1,经过SMG1转发时序列号必须由SMG1重新生成(此时命令源节点为SMG1)。
For example, when SP1X sends a command to SMSC2A, the command can only
reach SMSC2A after many times of forwarding, and the sequence numbers
of commands used in each course of communication forwarding this command
are the same, being the sequence number used for communications between
SP1X and SMG1. For a MO short message, such as SMSC1B sending a command
to SP3X, the short message is first sent to SMG1 via SMPP protocol, and
the sequence number at SMG1 forwarding must be regenerated by the SMG1
(at which time the command source node is SMG1).
序列号分成三部分,每部分为一个32位整数,第一部分表示命令源节点的编号,第二部分表示命令产生的日期和时间(网关系统中的任何命令的保存时间都不应该超过一年),格式为十进制的mmddhhmmss,比如11月20日20时32分25秒产生的命令,其第二部分为十进制1120203225;第三部分由0开始,循环进位,直到进位满了之后再清零,重新开始计数。接收方在返回应答时,应答的序列号必须和相对应的命令的序列号相同。There
are three parts in a sequence number, each part being an integer with
32 digits. The first part is the number of the command source node. The
second party is the date and time when the command is generated (the storage
time of any command in the gateway system shall not exceed one year),
the format being decimal mmddhhmmss. For example, the second part of a
command generated at 32 minutes and 25 seconds past 20 o’clock on 20th
November is decimal 1120203225. The third part begins with 0, does end-round
carry, clears when the carry is full and restarts counting. When the receiver
returns a response, the sequence number of the response and the sequence
number of the corresponding command must be the same.
5 Communication Safety
SP与SMG、SMG与SMG以及SMG与GNS之间采用专用SGIP方式通信时可采用对称加密方式。SP与SMG之间采用通用HTTP方式时,可采用HTTPS方式加密。
The Symmetrical cipher mode can be used for the exclusive SGIP mode communications
between SP and SMG, between SMG and SMG, as well as between SMG and GNS.
The HTTPS cipher mode can be used for the general HTTP mode communications
between SP and SMG.
6 用户鉴权 User Authentication
当一条MT短消息需要处理时,终点SMG必须保证该短消息的付费方有资格享用该服务(比如付费用户不欠费)。根据短消息服务类型的不同,可以将付费方式分成三类:被叫方付费、SP付费和第三方付费。
When a MT message needs processing, the destination SMG must ensure that
the paying party of the message is entitled to the service (for example,
the paying party does not have any overdue bills). The payment methods
can be classified into three categories according to different types of
short message services: the called party paying, the SP paying and the
third party paying.
6.1 被叫方付费Called Party Paying
目前的短消息中心都具有对被叫用户鉴权的功能,所以对由被叫方付费的MT短消息,SMG不作鉴权检查,直接转发至SMSC;如果被叫方鉴权失败,SMSC会通过反馈通知SMG。
All existing SMSCs have the function to authenticate called users, therefore
SMG will not carry out an authentication test to a MT short message to
be paid by the called party, but will forward it directly to SMSC; in
the event the authentication of the called party fails, SMSC will notify
SMG by feedback.
6.2 SP Paying
当MT短消息是由SP付费时(如SP发送广告),SMG不作鉴权检查。
When a MT short message is to be paid by SP (an example is SP sends out
ads) SMG will not carry out authentication tests.
6.3第三方付费Third Party Paying
当MT短消息是由第三方付费 (如手机用户A通过SP给手机用户B点歌,并由手机用户A付费)时,应该对付费方进行鉴权。这种情况下,该MT短消息应该从付费方归属地的短消息中心发送,并且由付费方归属地的计费中心完成鉴权操作。如果计费中心鉴权成功,SMG即将该MT短消息发送至SMSC,否则SMG不再发送该短消息,并根据SP的要求决定是否返回Report命令通知SP发送失败的原因。
If a MT short message is to be paid by a third party (an example is that
mobile user A orders a song for mobile user B via SP and mobile user A
will cover the bill), an authentication shall be carried out to the paying
party. Under this condition, the MT short message shall be sent from the
SMSC local to the paying party, and the billing center local to the paying
party shall complete the authentication operations. If the authentication
at the billing center succeeds, SMG will send the MT short message to
SMSC, otherwise SMG will not send the message, and will decide if a Report
command will be returned to notify SP of the failure causes according
to requirements from SP.
SMG和计费中心通过TCP/IP通信实现鉴权功能。计费中心为服务器端,SMG为客户端。一次鉴权过程完成对一个手机号码的鉴权。鉴权步骤如下:
SMG and the billing center realize the authentication function via TCP/IP
communications, the billing center being the server and the SMG being
the client. One course of authentication completes the authentication
for one mobile number, the specific steps being as follow:
1. SMG和计费中心建立TCP/IP连接;
A TCP/IP connection is established between SMG and the billing center;
2. SMG向计费中心发送鉴权命令;
SMG sends authentication command to the billing center;
3. SMG从计费中心接收鉴权应答;
SMG receives authentication response from the billing center;
4. SMG和计费中心断开连接;
The connection between SMG and the billing center is terminated.
7 Communications between SP and SMG
SP和SMG支持两种类型的通信承载方式:通用HTTP承载方式和通用SGIP承载方式。
SP and SMG support two types of communication load modes: the general
HTTP load mode and the general SGIP load mode.
7.1 General HTTP Mode
SP和SMG之间采用通用HTTP方式通信时,SP和SMG互为HTTP的客户端和服务器端。HTTP服务器端对相关的URL进行保护,HTTP客户端必须采用授权方式访问这些URL。HTTP的特点决定客户端和服务器端的每一次通信都必须一次完成授权连接、发送请求、接收应答、关闭连接等过程(HTTP承载方式不再需要专门的连接命令)。
When the general HTTP mode is used for communications between SP and SMG,
SP is the client of HTTP and SMG is the server of HTTP. HTTP server-side
protects concerned URLs, while HTTP client-side must access these URLs
via an authorized method. The features of HTTP determine that each communication
between the client and the server must complete a number of missions including
connection authorizing, request submitting, response receiving and connection
terminating at one time (the HTTP load mode does not require any specific
connection commands).
对于MO方向的命令(即命令接收方为SP),由SMG通过POST方式提交给SP进行处理,SP将处理结果以及MT方向信息在HTTP应答中返回给SMG;
For MO-direction commands (viz. SP being the command receiver), SMG submits
them via the POST mode to SP for processing, and SP returns the processing
results and the MT-direction message to SMG in the HTTP response.
对于SP主动向用户发送信息的PUSH业务,由SP作为客户端将信息通过POST方式提交给SMG进行处理,SMG在应答中确认信息发送成功与否。
For PUSH services (SP pushes to send messages to users), SP, as the client,
submits the message to SMG for processing via the POST method, and SMG
confirms if the message is sent successfully or not in the response.
因为HTTP服务器对URL进行了授权保护,所以HTTP客户端必须在每次请求中都带上授权信息。HTTP客户端的一个请求只能携带一条命令。SP与SMG之间发送的任何一条命令都带有一个序列号,序列号由命令源产生,任何两条命令的序列号不能重复。
As the HTTP server carries authorization protection to the URLs, the HTTP
client must include authorization information in each request. One request
from the HTTP client can carry only one command. Any command transmited
between SP and SMG has a sequence number that is generated by the command
source, and no any sequence number is repetitive of another.
如果HTTP服务器接收到的HTTP请求内容的格式不完整或不正确, HTTP服务器应该返回错误码。
If the format of the content of a HTTP request received by the HTTP server
is incomplete or incorrect, the HTTP server shall return an error code.
HTTP承载方式支持的HTTP协议为1.0版。
The HTTP load mode supports the 1.0 Version of HTTP Protocol.
HTTP承载方式使用如下命令:
The HTTP load mode uses the following commands:
7.2 Exclusive SGIP Mode
SP和SMG之间的通信由客户端向服务器端发起连接。连接建立以后,由客户端向服务器端发送命令,服务器端必须对接收到的每一条命令返回一条应答消息。SP和SMG互为客户端和服务器端。
The client initiates the connection to the server for the communications
between SP and SMG. After the connection is established, the client sends
commands to the server, which must return a responding message to each
command it receives. SP and SMG act as the client or server for each other.
7.2.1 Communication Initializing 通信初始化
客户端有命令要向服务器端发送时,由客户端首先通过Bind命令向服务器端发起连接。服务器端根据Bind命令之中的登录名和密码,对客户端的合法性进行验证,然后返回一条Bind_Resp应答给客户端。如果验证通过,则客户端和服务器端的通信开始,否则中断连接。
When the client has a command to transmit to the server, the client initiates
the connection to the server via Bind command. The server verifies the
validity of the client according to the login name and passwords in the
Bind command, then returns a Bind_Resp to the client. If the verification
passes, communications between the client and the server will begin, otherwise
the connection will be disrupted.
7.2.2通信过程Communication Process
SP与SMG之间发送的任何一条命令都带有一个序列号,序列号由命令源产生。
Any command transmitted between SP and SMG has a sequence number that
is generated by the command source.
客户端与服务器端通信开始以后,客户端可以向服务器端发送相应的命令,服务器端对收到的命令返回应答。
After the communications between the client and the server begin, the
client can send corresponding commands to the server, which returns responses
to commands it has received.
命令在SP和SMSC之间的传输是采用类似接力的方式,每条命令和对应的应答仅仅表示该次命令发送的结果是否正确。比如,SP向某一个手机发送一条短消息,是通过向本地SMG发送一条Submit命令实现的,随后,SP会从SMG接收到一条Submit_Resp应答。
The transmission of commands between SP and SMSC is like in a relay race.
Each command and its corresponding response only mean if the result of
this command transmission is correct or not. For example, SP sends a short
message to a handset, which is realized by sending a Submit command to
the local SMG. Then, SP will receive a Submit_Resp response from the SMG.
但是,即使应答表示Submit命令已正确接收,也不表示Submit命令内的短消息已经发送到手机上了,而仅仅表示该短消息已经传送到SMG,SMG将会作下一步处理,或者发送给SMSC,或者路由到另外的SMG,最终由目的SMSC发送到手机上。这中间任何一个环节出现错误,系统会终止信息的继续发送,并且通过向原SP发送Report命令告诉发送出错的原因(如果SP指定要求反馈的话)。
However, even the response means that the Submit command has been received
correctly, it does not mean that the short message in the Submit command
has been sent to the handset. It only means that the short message has
been delivered to the SMG, and the SMG will further process the message,
either sending it to SMSC or routing it to another SMG. At the end the
destination SMSC will send it to a handset. In case any error occurs during
any of the steps, the system will terminate the further transmission of
the message, and sends a Report command to the original SP informing the
causes of the error (if SP requires feedback).
7.2.3通信结束Communication Completion
如果客户端认为和服务器端的通信已结束,则客户端应该向服务器端发送Unbind命令,服务器端随后返回Unbind_Resp应答,然后双方断开连接。
If the client thinks the communications with the server have ended, the
client shall send an Unbind command to the server, which will then return
an Unbind_Resp before the connection between the parties is terminated.
7.2.4故障处理Malfunction Tackling
发生故障时,SP、SMG以及GNS节点应通过Report命令和其它相关命令的应答相结合返回故障原因;如果MO不成功,该用户所属的SMG还应向用户终端返回友好的应答信息说明不成功原因。
When there is any malfunction, SP, SMG and GNS node shall combine the
Report command and other concerned commands to return the malfunction
causes; if MO fails, the SMG of the user shall still return friendly responding
message to the user terminal, informing causes of the failure.
7.2.4.1网络故障Network Malfunction
客户端与服务器端的通信过程中如果检测到双方连接中断(如网络断线),客户端应该断开连接,然后尝试重新向服务器端建立新的连接;服务器端应该按照接收到Unbind的情况进行处理,断开和客户端的连接。During
the communications between the client and the server, if the connection
between the parties is detected as broken (such as network disconnection),
the client shall terminate the connection, and try to establish a new
connection with the server. The server shall handle the problem according
to Unbind conditions it has received, and terminate the connection with
the client.
7.2.4.2接收到非法命令或应答Receiving Invalid Commands or Responses
如果服务器端接收到的命令语法错误,比如命令不完整、命令无法识别等,则断开和客户端的连接;客户端应该向服务器端建立新连接继续发送命令。
In case the server receives any commands that contain grammar mistakes,
such as incomplete commands or unidentifiable commands, it shall terminate
the connection with the client. The client shall establish a new connection
with the server and continue to send commands.
如果客户端接收到的应答语法错误,比如命令不完整、命令无法识别等,则主动断开和服务器端的连接;服务器端也应该断开和客户端的连接。In case
the client receives any responses that contain grammar mistakes, such
as incomplete commands or unidentifiable commands, it shall terminate
the connection with the server, and the server shall also terminate the
connection with the client.
如果命令语法正确,但服务器端不处理该命令,比如SP为服务器端时收到Submit命令,则返回相应应答,并在应答中指定错误原因。
If the server does not process a grammatically correct command (for example
SP being the server receives a Submit command), a corresponding response
shall be returned, in which the causes of the mistake shall be stated.
如果应答语法正确,但客户端不处理该应答,比如SP为客户端时收到Deliver_Resp应答,则丢弃。
If the client does not process a grammatically correct response (for example
SP being the client receives a Deliver_Resp response), it shall be discarded.
7.2.4.3序列号重复 Repetitive Sequence numbers
如果命令的序列号和以前接收到的命令的序列号相同,且命令内容也相同,则接收方丢弃该命令;如果序列号相同,但是命令内容并不相同,则命令接收方在应答中返回错误码。
If the sequence number of a command is identical with the sequence number
of a command that has been received before, and the contents of the two
commands are identical too, then the receiver shall discard the command;
if the sequence numbers of two commands are identical while their contents
are different, then the command receiver shall return an error code in
the response.
8 SMG与SMG之间的通信Communications between SMG and SMG
在网关系统之中,任何两个SMG之间都要建立一对基于TCP/IP的连接,以实现命令的路由。两个SMG互为客户端和服务器端,客户端向服务器端发送命令,接收应答;服务器端从客户端接收命令,返回应答。
In the gateway system, a pair of TCP/IP-based connections must be established
between any two SMGs so as to realize command routing. For a pair of SMGs,
one SMG acts either as the client or as the server of the other SMG. The
client transmits commands to the server and receives responses, while
the server receives commands from the client and returns responses.
8.1通信初始化Communication Initializing
SMG与SMG通信时,由客户端首先通过Bind命令向服务器端发起连接。服务器端根据Bind命令之中的登录名和密码,对客户端的合法性进行验证,然后返回一条Bind_Resp应答给客户端。如果验证通过,则客户端和服务器端的通信开始,否则中断连接。
During the communications between two SMGs, the client first initiates
a connection to the server via a Bind command. The server will verify
the validity of the client according to the login name and password in
the Bind command, and return a Bind_Resp response to the client. If the
verification passes, the communications between the client and the server
will begin, otherwise the connection will be disrupted.
8.2通信过程Communication Process
两个SMG之间的通信和SP和SMG之间的基于TCP/IP的承载方式的通信方式相同。
The communications between two SMGs are identical with the communications
between a SP and a SMG based on TCP/IP load mode.
8.3通信结束Communication Ending
如果客户端认为和服务器端的通信已结束,则客户端应该向服务器端发送Unbind命令,服务器端随后返回Unbind_Resp应答,然后双方断开连接。
If the client thinks the communications with the server have completed,
it shall transmit an Unbind command to the server, which shall then return
an Unbind_Resp response before the connection between both parties is
terminated.
8.4故障处理Malfunction Tackling
SMG之间的故障处理和SP与SMG之间的故障处理相同。
Malfunction tackling between SMGs are the same with that between a SP
and a SMG.
9 SMG与GNS之间的通信 Communications between SMG and GNS
在网关系统之中,任何一个SMG都要和GNS以互为客户端/服务器的方式建立连接来完成路由表的更新和维护。当SMG对本地的路由表作修改后,需要主动以客户端的身份向GNS建立连接,通知GNS更新路由表;当GNS修改了路由表后,需要主动以客户端的身份向所有的SMG建立连接,通知SMG更新路由表。
In the gateway system, any SMG must establish a connection with GNS, either
of them being the client/server of the other, to carry out the upgrading
and maintenance of routing lists. After SMG has modified the local routing
list, it needs to initiate to establish a connection to GNS as the client
and notify GNS to upgrate the routing list. After GNS has modified the
routing list, it needs to initiate to establish connections to all SMGs
as the client and notify these SMGs to upgrade their routing lists.
9.1通信初始化Communication Initializing
SMG与GNS通信时,由客户端首先通过Bind命令向服务器端发起连接。服务器端根据Bind命令之中的登录名和密码,对客户端的合法性进行验证,然后返回一条Bind_Resp应答给客户端。如果验证通过,则客户端和服务器端的通信开始,否则中断连接。
During communications between SMG and GNS, the client first initiates
a connection to the server via a Bind command. The server will then verify
the validity of the client according to the login name and password in
the Bind command, and returns a Bind_Resp response to the client. If the
verification passes, the communications between the client and the server
will start, otherwise the connection will be disrupted.
9.2通信过程Communication Process
客户端和服务器端建立连接以后,客户端向服务器端发送命令,服务器端则返回应答。
After the connection between the client and the server is established,
the client transmits a command to the server, which will return a response.
9.3通信结束Communication Ending
如果客户端认为和服务器端的通信已结束,则客户端应该向服务器端发送Unbind命令,服务器端随后返回Unbind_Resp应答,然后双方断开连接。
If the client thinks the communications with the server have ended, it
shall send an Unbind command to the server, which shall then returns an
Unbind_Resp response before the connection between both parties is terminated.
9.4故障处理Malfunction Tackling
SMG和GNS的故障处理和SP与SMG之间的故障处理相同。
The malfunction tackling between SMG and GNS is the same with that between
SP and SMG.
9.5从SMG到GNS的消息Messages from SMG to GNS
|