中国电信SMGP 3.0全网割接

SMGP 3.0协议有哪些变化
SMGP 3.0增加了对TLV字段的支持。其中有很多字段关系到业务部分。
哪些TLV字段必须支持?
Submit和Deliver包中TLV字段必须支持,其中SubmitMsgType,SPDealResult和LinkID三个TLV字段必须支持。否则无法通过业务测试。
什么是TLV字段?
TLV字段是Token/Length/Value的缩写。详细解释可以参考SMPP协议。
意识是头2个字节是Token标记。再接2个字节是该参数的长度。Value部分为Length * 8octet。
如何测试正向点播业务?
点播业务是电信测试人员发送"db"到UMS2系统。UMS2系统接收到SMGPDeliver后,将解析后的deliver数据插入到数据库中。回复点播测试的SQL(MS SQL Server)如下:
--Check message content.
IF @msg_content = 'db' OR @msg_content = 'DB'
BEGIN
--Reply automatically.
INSERT INTO CMPP_SUBMIT
(service_id,fee_type,fee_code,registered_delivery,dest_terminal_id,fee_terminal_type,fee_terminal_id,msg_content,link_id)
VALUES
('1009','00','000000',0x01,@src_terminal_id,3,@src_terminal_id,convert(varbinary(255),'点播' + @src_terminal_id),@link_id);
RETURN
END
注意:
1.其中registered_delivery的高四位代表SubmitMsgType = 0(普通信息)。低四位为1表示需要收条。
2.下发的时候需要携带linkID。linkID = @linkID
3. 计费模式采用第三方计费模式。fee_terminal_type = 3,fee_terminal_id = @src_terminal_id
4. service_id是点播业务代码,fee_type,fee_code已经意义不大。
如何测试正向定制业务?
电信测试人员会发送定制代码到系统。例如:定制指令是DZ,业务代码是STP100009,手机号码是02022222222。那么UMS2系统会收到SMGPDeliver消息,其总消息内容将是:
DG[空格]STP100009[空格][空格]02022222222[冒号]DZ
注意:
1.DG指令和业务代码之间是一个空格;业务代码和手机号码之间是两个空格。
2.手机号码和指令之间是一个冒号。

回复该消息的SQL(MS SQL Server)如下:

IF RIGHT(@msg_content,2) = 'DZ'
BEGIN
--Reply automatically.
INSERT INTO CMPP_SUBMIT
(service_id,fee_type,fee_code,registered_delivery,dest_terminal_id,fee_terminal_type,fee_terminal_id,msg_content,link_id)
VALUES
('SPT100009','03','000100',0xf0,@src_terminal_id,3,@src_terminal_id,convert(varbinary(255),'DG SPT100009 ' + @src_terminal_id),@link_id);

INSERT INTO CMPP_SUBMIT
(service_id,fee_type,fee_code,registered_delivery,dest_terminal_id,fee_terminal_type,fee_terminal_id,msg_content,link_id)
VALUES
('SPT100009','03','000100',0x01,@src_terminal_id,3,@src_terminal_id,convert(varbinary(255),'普通消息' + @src_terminal_id),@link_id);

RETURN
END

注意:
1. 回复的时候,service_id必须是定制的业务代码。
2. SubmitMsgType = 15所以,registered_delivery的高四位是f,而且这种回复不会有收条。所以registered_delivery = 0xf0。
3.采用第三方计费模式。
4.linkID必须携带上。
5.回复的内容必须是:
DG[空格]STP100009[空格][空格]02022222222
6.下发业务信息的时候,原来的linkID必须要携带,否则将会被拦截。
7.下发业务信息的时候,registered_delivery的高四位必须是0,而且要收条。所以registered_delivery = 0x01。
如何测试正向退定业务?
正向退定的时候,电信测试人员会发送“qx”上行。这个时候UMS2系统会接收到SMGPDeliver,其中内容是“00000”。
下行应答信息如下:
IF @msg_content = '00000'
BEGIN
--Reply automatically.
INSERT INTO CMPP_SUBMIT
(service_id,fee_type,fee_code,registered_delivery,dest_terminal_id,fee_terminal_type,fee_terminal_id,msg_content,link_id)
VALUES
('SPT100009','03','000100',0xf0,@src_terminal_id,3,@src_terminal_id,convert(varbinary(255),'QX SPT100009 ' + @src_terminal_id),@link_id);

RETURN
END
注意:
1. service_id是需要退定的业务。
2. 由于是应答正向退定,所以registered_delivery的高4位是f。这个应答不需要收条,所以registered_delivery = 0xf0。
3. 内容必须填写:
QX[空格]SPT100009[空格][空格][手机号码]
4. SPDealResult系统缺省自动设置成0。
5. 如果退定成功,那么如果再下发普通消息,网关会返回错误。
如何测试反向点播业务?
测试反向点播业务是SP主动发送请求给网关。格式必须如下:
1. service_id是点播业务代码。
2. registered_delivery的高4位必须为d,不需要收条。所以registered_delivery = 0xd0
3. 目标地址和计费地址为接收手机号码。
4. msg_content必须使用如下格式:
DG[空格]1009[空格][空格][手机号码]
5. SPDealResult缺省为0。

INSERT INTO CMPP_SUBMIT
(service_id,fee_type,fee_code,registered_delivery,dest_terminal_id,fee_terminal_type,fee_terminal_id,msg_content)
VALUES
('SPT100009','03','000100',0xd0,@src_terminal_id,3,@src_terminal_id,convert(varbinary(255),'DG 1009 ' + @src_terminal_id));

如果反向点播成功后,UMS2会接收到网关发送的SMGPDeliver数据包,其中会带有link_id。然后利用这个link_id给用户下发相关普通信息。注意:普通消息的registered_delivery的高4位必须是0。下发的SQL语句如下:

INSERT INTO CMPP_SUBMIT
(service_id,fee_type,fee_code,registered_delivery,dest_terminal_id,fee_terminal_type,fee_terminal_id,msg_content,link_id)
VALUES
('1009','01','000100',0x01,@src_terminal_id,3,@src_terminal_id,convert(varbinary(255),'普通消息' + @src_terminal_id),@link_id);
如何测试反向定制业务?
测试反向定制业务的流程和测试反向点播的流程基本一致,仅仅是使用的指令有所差别。

这里给出发送反向定制的例子。

INSERT INTO CMPP_SUBMIT
(service_id,fee_type,fee_code,registered_delivery,dest_terminal_id,fee_terminal_type,fee_terminal_id,msg_content)
VALUES
('SPT100009','03','000100',0xd0,@src_terminal_id,3,@src_terminal_id,convert(varbinary(255),'DG SPT100009 ' + @src_terminal_id));

再得到了网关反馈的link_id(在SMGPDeliver数据包内)以后,下发普通信息。
如何测试反向退定业务?
测试反向退定业务是SP主动发送反向推定指令。发送的SQL如下:

INSERT INTO CMPP_SUBMIT
(service_id,fee_type,fee_code,registered_delivery,dest_terminal_id,fee_terminal_type,fee_terminal_id,msg_content,link_id)
VALUES
('SPT100009','03','000100',0xd0,@src_terminal_id,3,@src_terminal_id,convert(varbinary(255),'00000'),@link_id);

注意:
1.service_id是需要退定的服务代码。
2.registered_delivery 必须为0xd0。
3.msg_content必须是“00000”。
4.link_id是订购的时候返回的link_id。

SMGP协议错误代码表
0 成功
1 系统忙
2 超过最大连接数
3-9 保留
10 消息结构错
11 命令字错
12 序列号重复
13-19 保留
20 IP地址错
21 认证错
22 版本太高
23-29 保留
30 非法消息类型(MsgType)
31 非法优先级(Priority)
32 非法资费类型(FeeType)
33 非法资费代码(FeeCode)
34 非法短消息格式(MsgFormat)
35 非法时间格式
36 非法短消息长度(MsgLength)
37 有效期已过
38 非法查询类别(QueryType)
39 路由错误
40 非法包月费/封顶费(FixedFee)
41 非法更新类型(UpdateType)
42 非法路由编号(RouteId)
43 非法服务代码(ServiceId)
44 非法有效期(ValidTime)
45 非法定时发送时间(AtTime)
46 非法发送用户号码(SrcTermId)
47 非法接收用户号码(DestTermId)
48 非法计费用户号码(ChargeTermId)
49 非法CP 代码
50 非预付费用户
51 余额不足
52 非注册用户
53 非注册CP
54 账号不可用
55 扣费失败
56-127 保留
128-254 厂家自定义
255 未知错误
SMPP协议错误代码表
1、由ESME提交到短消息中心时,短消息中心回复的错误代码表:
#define smppEsmeROK_M 0 /* no error code given */
#define smppEsmeRInvMsgLen_M 1 /* Invalid Message Length */
#define smppEsmeRInvCmdLen_M 2 /* Invalid Command Length */
#define smppEsmeRInvCmdId_M 3 /* Invalid Command ID */
#define smppEsmeRInvBndSts_M 4 /* Invalid bind status */
#define smppEsmeRAlyBnd_M 5 /* Bind attempted when already bound */
#define smppEsmeRInvPrtFlg_M 6 /* Invalid priority flag */
#define smppEsmeRInvRegDlvFlg_M 7 /* Invalid registered-delivery flag */
#define smppEsmeRSysErr_M 8 /* SMSC system error */
#define smppEsmeRInvPar_M 9 /* Invalid parameter */
#define smppEsmeRInvSrcAdr_M 10 /* Invalid source address */
#define smppEsmeRInvDstAdr_M 11 /* Invalid destination address */
#define smppEsmeRInvMsgId_M 12 /* Invalid message-id */
#define smppEsmeRInvPaswd_M 13 /* Invalid password */
#define smppEsmeRInvPaswdLen_M 14 /* Invalid password length */
#define smppEsmeRInvSysIDSrv_M 15 /* Invalid System-ID */
#define smppEsmeRCntCanMsg_M 16 /* Cannot cancel a message */
#define smppEsmeRInvDatFmt_M 17 /* Invalid date format */
#define smppEsmeRCntRepMsg_M 18 /* Cannot replace a message */
#define smppEsmeRMsgQFul_M 19 /* Too many message in queue, at present */
#define smppEsmeRSerNotSup_M 20 /* Service not supported */
#define smppEsmeRInvRepAddr_M 22 /* Address Mismatch in Replacement attempt */
/* the following is added by shenm. at 99/11/16 */
#define smppEsmeRInvAreaCode_M 50 /* Invalid area code of ESME */
/*为固定电话增加*/
#define smppEsmeAuthFail_M 60 /*Authentication fail*/
#define smppEsmeDestUseBusy_M 61 /*destinantion user busy*/
#define smppEsmeMemCap_M 62 /*话机内存满*/
#define smppEsmeRInvGwMsgId_M 63 /*无效的网关msgid*/
#define smppEsmeInstMsgIdFail_M 64 /*插入网关msgid失败*/


#define smppEsmeRUnknownErr_M 0xFF /* Unknown Error */
短消息中心下发给CTSI时,CTSI回复给短消息中心的错误代码表
// new error code lide add 2002.05.08
#define smppCtsiUserAbsent 0x0400
#define smppCtsiUserBusy 0x0401
#define smppCtsiNoPart 0x0402
#define smppCtsiUserInvalid 0x0403
#define smppCtsiBlackList 0x0404
#define smppCtsiSysError 0x0405
#define smppCtsiMemCap 0x0406
#define smppCtsiProtocolError 0x0407
#define smppCtsiDataError 0x0408
#define smppCtsiDataMissing 0x0409
#define smppGateWayUserBusy 0x0410
短消息中心收条处理
(1) 短消息中心在给ESME代理机deliver回执短消息时把esm_class置为xx0001xx,表示为回执短消息。ESME代理机向短消息中心submit回执短消息时,把submit的esm_class字段置为xx0010xx,表示为回执短消息。
(2) 回执短消息的信息包含在短消息消息包的字段short_message中,其格式如下:

字段 长度 数据类型 说明
id 10 C-Octet String 状态报告对应原短消息的MsgID
sub 3 C-Octet String 取缺省值001
dlvrd 3 C-Octet String 取缺省值001
Submit_date 10 C-Octet String 短消息提交时间(格式:yymmddhhmm,例如010331200000)
done_date 10 C-Octet String 短消息下发时间(格式:yymmddhhmm,例如010331200000)
Stat 7 C-Octet String 短消息状态(参见短信状态表)
Err 3 C-Octet String 参见错误代码表
Txt 20 Octet String 前3个字节,表示短消息长度(用ASCII码表示)

短信状态表:
状态名 状态值(字符串) 说明
DELIVERED DELIVRD 短消息转发成功
EXPIRED EXPIRED 短消息超过有效期
DELETED DELETED 短消息已经被删除
UNDELIVERABLE UNDELIV 短消息是不可转发的
ACCEPTED ACCEPTD 短消息已经被最终用户接收(为保持与SMPP兼容,保留)
UNKNOWN UNKNOWN 未知短消息状态
REJECTED REJECTD 短消息被拒绝(为保持与SMPP兼容,保留)

错误代码表
状态值(字符串) 说明 对应状态 command_status对应值 Command_status代码
000 成功 DELIVRD ESME_ROK 0x00000000
001 用户不能通信 EXPIRED ESME_RUSRABSENT 0x00000400
002 用户忙 EXPIRED ESME_RUSRUSY 0x00000401
003 终端无此部件号 UNDELIV ESME_RNOPART 0x00000402
004 非法用户 UNDELIV ESME_RUSRINVALID 0x00000403
005 用户在黑名单内 UNDELIV ESME_RBLACKLIST 0x00000404
006 系统错误 UNDELIV ESME_RSYSERROR 0x00000405
007 用户内存满 EXPIRED ESME_RMEMCAP 0x00000406
008 非信息终端 UNDELIV ESME_RPROTOCOLERROR 0x00000407
009 数据错误 UNDELIV ESME_RDATAERROR 0x00000408
010 数据丢失 UNDELIV ESME_RDATAMISSING 0x00000409
999 未知错误 UNKNOWN ESME_RUNKNOWNERR 0x000000FF
ISMAP错误代码(返回给SP为 12××××)

类别 结果码 描述
Success 0 Success 成功
Protocol error协议相关错误 General error通用错误 1 Length of PDU is invalid(greater than 30K or less than zero)消息长度非法
2 Failed to decode the PDU(lack of fields or field type invalid)消息解码错误
6 Service enabler has not binded yet业务系统链接未建立
7 Timeout while waiting for the response message等待应答超时
8 Timeout while waiting for the confirmation message等待确认消息超时
Field error or others字段及其他相关错误 100 Field value is invalid(not expected or error)字段值无效


101 Source device type is out of range源设备类型无效
102 Source device id is incorrect源设备编号错误
103 Destination device type is out of range目的设备类型无效
104 Destination device id is incorrect目的设备编号错误

105 Timestamp field is in a bad format时间戳字段格式错误
106 Subscriber's ID is invalid用户ID非法
107 MSISDN is invalid手机号码非法
108 SP identifier is invalidSP ID非法
109 Service identifier is invalid业务ID非法
110 Service code(Access NO) is invalid.接入号非法
System error系统类错误 System error系统类错误 500 Disk read-write error磁盘读写错误
501 Network connection is abnormal网络链接异常
502 Network error网络故障
503 LICENSE file is illegalLICENSE不合法
504 Number of registered user is beyond the limitation of the LICENSE已超过LICENSE限定数量
505 System internal error 系统内部错误

506 Database error(Database connection broken, SQL syntax invalid)数据库错误

Subscriber related error用户相关错误 Subscriber related error用户相关错误 1001 The subscriber does not exist用户不存在
1002 The subscriber's status is stopped用户状态为停机状态
1003 The subscriber owes payment用户欠费
1004 The subscriber is in blacklist用户已被列入黑名单
1005 用户不属于本平台
1100 The specified service is not open to the subscriber业务对此用户不开放
1103 The subscriber has already registered用户已注册
1104  The subscriber has not registered yet用户未注册
1105 Status of the subscriber is abnormal(not normal)用户状态异常
1106 Failed to authenticate the subscriber by password用户密码认证失败
1107 Failed to generate a pseudo code伪码生成失败
1200 The subscription already exists定购关系已存在
1201 The subscription does not exist定购关系不存在
1202 Status of the subscription is abnormal定购关系状态异常
1203 定购关系通知sp失败
SP and service related errorSP和业务相关错误 SP related errorSP相关错误 2000 The SP does not existSP不存在
2001 Status of the SP is abnormalSP状态异常
Service related error业务相关错误 2100 The service does not exist业务不存在
2101 The service is not open(Its status is abnormal)业务状态异常
2200 The is no such type of service(SMS, MMS, etc.)业务类型不存在
2201 The service cannot be subscribed业务不能定购
2202 剩余使用量不足
Charging error计费相关错误 Charging error计费相关错误 3000 CDR format is wrongCDR格式错误
3001 The price is negative价格为负数
3002 The price format is wrong价格格式错误
3003 The price is out of range价格超界
3100 The subscribe is not a prepaid user用户不是预付费用户
3101 Balance of the subscribe is not enough用户余额不足
3102 Failed to impact balance补款失败
3103 There is no required charging information没有对应的计费信息
3104 Failed to write a CDR写CDR失败
3105 The CDR is duplicatedCDR重复
3106 Failed to insert the CDR to databaseCDR写数据库失败
3107 Price of the CDR is too highCDR中标识的价格太高
3108 Timeout while waiting for the SCP response等待SCP应答超时
3109 Failed to reload the charging matrix into memory计费矩阵更新失败
BOSS Integer errorBOSS接口相关错误 BOSS Interface errorBOSS接口相关错误 4001 There is no subscriber's information in BOSSBOSS中无此用户信息
Default Error 9999 Default Error缺省错误

正向业务测试用全部SQL(For Sql Server)
DROP TRIGGER cmpp_dispatcher
GO

CREATE TRIGGER cmpp_dispatcher
ON cmpp_deliver
FOR INSERT AS

DECLARE @registered_delivery INT
DECLARE @src_terminal_id VARCHAR(50)
DECLARE @msg_content VARCHAR(255)
DECLARE @service_id VARCHAR(50)
DECLARE @link_id VARCHAR(50)
DECLARE @gateway_name VARCHAR(50)
DECLARE @prefix VARCHAR(50)

--Select parameter from inserted message.
SELECT
@registered_delivery = INSERTED.registered_delivery,
@src_terminal_id = INSERTED.src_terminal_id,
@service_id = INSERTED.service_id,
@msg_content = CONVERT(VARCHAR(255),INSERTED.msg_content),
@link_id = INSERTED.link_id,
@gateway_name = INSERTED.ih_gateway
FROM INSERTED

--Only process normal message.
IF (@registered_delivery <> 0) RETURN
--Print message.
PRINT '接收来自' + @src_terminal_id + '的消息:' + @msg_content

--Check message content.
IF @msg_content = 'db' OR @msg_content = 'DB'
BEGIN
--Reply automatically.
INSERT INTO CMPP_SUBMIT
(service_id,fee_type,fee_code,registered_delivery,dest_terminal_id,fee_terminal_type,fee_terminal_id,msg_content,link_id)
VALUES
('1009','00','000000',0x01,@src_terminal_id,3,@src_terminal_id,convert(varbinary(255),'点播' + @src_terminal_id),@link_id);
RETURN
END

IF RIGHT(@msg_content,2) = 'DZ'
BEGIN
--Reply automatically.
INSERT INTO CMPP_SUBMIT
(service_id,fee_type,fee_code,registered_delivery,dest_terminal_id,fee_terminal_type,fee_terminal_id,msg_content,link_id)
VALUES
('SPT100009','03','000100',0xf0,@src_terminal_id,3,@src_terminal_id,convert(varbinary(255),'DG SPT100009 ' + @src_terminal_id),@link_id);

INSERT INTO CMPP_SUBMIT
(service_id,fee_type,fee_code,registered_delivery,dest_terminal_id,fee_terminal_type,fee_terminal_id,msg_content,link_id)
VALUES
('SPT100009','03','000100',0x01,@src_terminal_id,3,@src_terminal_id,convert(varbinary(255),'普通消息' + @src_terminal_id),@link_id);

RETURN
END

IF @msg_content = '00000'
BEGIN
--Reply automatically.
INSERT INTO CMPP_SUBMIT
(service_id,fee_type,fee_code,registered_delivery,dest_terminal_id,fee_terminal_type,fee_terminal_id,msg_content,link_id)
VALUES
('SPT100009','03','000100',0xf0,@src_terminal_id,3,@src_terminal_id,convert(varbinary(255),'QX SPT100009 ' + @src_terminal_id),@link_id);

RETURN
END

RETURN
如何从SMGP 3.0平台实施2.0平台客户的反向退定!
一般来说,反向退订需要一个LinkID,而2.0平台中是没有的。在3.0中无LinkID直接退定,会返回错误。
但是SP在导入电信管理平台前,需要提供一份需要导入的定购关系文件。然后用这个文件中自定义的LINKID下发反向取消。就可以解决这个问题。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值