MMS协议解析
MMS协议解析
MMS(Multimedia Messaging Service)就是我们俗称的彩信,它能提供比SMS(短信)更加丰富的信息,能提供包括图片、视频、声音、各种格式的文字等内容。
目前的应用主要有以下几个方面: ▪ ▪
便利性实用性娱乐性互动性个人化 端到端通信
自拍照片自编贺卡/图片
带有图片照片和语音片断等表达感情内容的增强型聊天 电子邮件附件在移动终端上的增强型应用 ▪
娱乐
手机铃声/屏保下载 节日贺卡明星贺卡
多媒体交友利用手机察看自己心仪的对象并通过信息向她表达心意 原创基地:利用多媒体短信传播自己的原创动漫和音乐 ▪
新闻/金融服务
体育比赛集锦和得分镜头视频剪辑
通过移动终端获取多媒体新闻和金融信息分析等 ▪
其他
定位业务 移动广告
一、 数据流程
MMS系统大致网络拓扑图如下:
.
.
先介绍一下网络中的节点设备:
MMS Client:MMS客户端,就是平常用的手机等移动设备; MMS Proxy Relay:MMS代理中继,用于转发MMS;
MMS Server:MMS服务器,用于存储MMS,一般与MMS代理集成在一台设备上; Legacy Wireless Messaging Systems:传统的无线消息系统,比如SMS系统; Email Server:邮件服务器,Ineternet上的邮件服务器,比如139邮件服务器; Other MMS Systems:其他地方或其他运营商的MMS系统;
MMS承载于WAP之上,在WAP1.x系统里采用WSP协议,在WAP2.0系统里采用HTTP协议,如下图所示:
.
.
详细网络图如下:
MMSInterne SE-mail Server IP网 MMS WAP GW GGSN ISM 核心 SMSSGS MS B MMS终端1 BS MMS终端2 MMS的发送接收实体包括如下几种方式:
.
.
1、 终端<——>同一系统内终端 2、 终端<——>不同系统内终端 3、 终端<——>Email server 4、 终端<——>SP
我们以第一种情况进行MMS收发流程说明,大致有以下几步: 1、 发送终端发送MMS到MMS代理; 2、 MMS代理发送通知到接收终端;
3、 接收终端发送提取MMS命令到MMS代理; 4、 MMS代理返回MMS到接收终端;
5、 MMS代理发送回执给发送终端,表示对方已收到MMS;
其中第2步的通知是通过WAP PUSH实现的,目前中国移动实现的方式是通过SMS(短信)通知对方。
二、 消息解析
前面提到MMS可以通过wsp和http两种方式传输,无论哪种方式,其Content-Type都必须为application/vnd.wap.mms-message(0x3E)。
MMS可以分为4类:发送、通知、提取、回执。每一类消息都包含消息头,有的还包含正文。如下:
.
.
2.1 发送
发送是指发送者发送MMS到MMS中心,包括两条消息:MMS发送请求、MMS发送确认。
2.1.1 MMS发送请求
MMS发送请求消息由发送者到MMS中心,包含消息头和正文,正文紧跟消息头。消息头包含内容如下:
Name X-Mms -Message-Type Content Comments Message-type-value = Mandatory. m-send-req Specifies the transaction type. .
.
X-Mms -Transactio n-ID Transaction-id-value Mandatory. A unique identifier for the message. This transaction ID identifies the M -Send.req and the corresponding reply only. X-Mms -MMS-Version MMS-version-value Mandatory. The MMS version number. According to this specificatio n, the version is 1.0 Date Date-value Optional. Arrival time of the message at MMSProxy -Relay. MMS Proxy -Relaywill generate this field when not supplied by terminal. From From-value Mandatory. Address of the message sender. This field MUST be present in a message delivered to a recipient. The sending client MUST send either its address or To To-value insert -an- address token. In case of token, the Optional1. Address of the recipient. Cc Bcc Subject Cc-value Bcc-value Subject-value Optional1. Optional1. Optional. X-Mms -Message-Class Message-class -value Optional. X-Mms -Expiry Expiry -value Optional, default: maximum. X-Mms -Delivery -Time Delivery -time -value Optional: default: immedia te. X-Mms -Priority X-Mms Priority-value Optional. Default: Normal. -Sender- Sender-visibility-vaOptional. Default: show address/phone number of the sender to the recipient unless the sender has Visibility lue a secret number/address. Hide = don't show any address. Show = show even secret address. X-Mms Report -Delivery- Delivery -value -report Optional. Default determined when service is ordered. Specifies whether the user wants a delivery report from each recipient. When Message-Class is Auto, the field SHALL always be present and the value SHALL be No. .
.
X-Mms -Read-Reply Read-reply -value Optional. Specifies whether the user wants a read report from each recipient as a new message. When Message-Class is Auto, the field SHALL always be present and the value SHALL be No. Content-Type Content-type-value Mandatory. The content type of the message. 以上字段除了开头的Message-Type、Transaction-ID、MMS-Version和末尾的Content-Type之外,其他字段没有顺序要求,以下消息也是一样。
2.1.2 MMS发送确认
MMS发送确认由MMS中心到发送者,只包含消息头,没有正文。消息头格式如下:
Name X-Mms -Message-Type Content Comments Message-type-value = Mandatory. m- send -conf Identifies the message type. Mandatory. X-Mms -Transaction-ID Transaction-id-value This transaction ID identifies the M -Send.conf and the corresponding request only. X-Mms -MMS-Version MMS-version-value Mandatory. The MMS version number. According to this specification, the version is 1.0 X-Mms -Response-Status Response-status -value Mandatory. MMS specific status. X-Mms -Response-Text Response-text -value Optional. Description which qualifies the response status value. Message-ID Message-ID-value Optional. This is a unique reference assigned to message. This ID SHALL always be present when the MMS Proxy - Relayaccepted the message. The ID enables a client to match delivery .
.
2.2 通知
通知是指MMS中心发送通知到接收者,包括两条消息:请求和响应。目前是通过SMS进行通知,Gb接口上不存在该类数据包,所以在这里不做分析。
2.3 提取
提取是指MMS接收者从MMS中心提取MMS的过程,包括三个步骤:提取请求、提取响应、响应确认。
2.3.1 MMS提取请求
MMS提取请求消息是由接收者到MMS中心,没有真正的消息头和正文,完全由WSP或HTTP的请求头实现,也就是WSP或HTTP一个普通的GET请求,其uri是通知消息里指定的地址。
2.3.2 MMS提取响应
MMS提取响应消息是由MMS中心到接收者,包括消息头和正文,消息头包含内容如下:
Name X-Mms -Message-Type Content Comments Message-type-value = Mandatory. m-retrieve-conf Specifies the message type. X-Mms -Transaction-ID Transaction-id-value Optional. Identifies either the transaction that has been started by M-Notification without M -NotifResp or new transaction when deferred delivery was requested. The new transaction ID is optional. X-Mms -MMS-Version MMS-version-value Mandatory. The MMS version number. According to this specification, the version is 1.0. Message-ID Message-ID-value Optional. This is an unique reference assigned to message. This ID SHALL always be present when the originator client requested a read reply. The ID enables a client to match read reports with previously sent messages. .
.
Date Date-value Mandatory. Sending date and time. From From-value Optional. Address of the sender. If hiding the address of the sender from the recipient is supported, the MMS Proxy -Relay will not add this field to a message header. Optional. Address of the recipient. Any number of address fields allowed. To To-value Cc Cc-value Optional. Address of the recipient. Any number of address fields allowed. Subject Subject-value Optional. Message subject X-Mms -Message-Class Message-class -value Optional. Message class. If field is not present, the receiver inteprets the message as personal. X-Mms -Priority Priority-value Optional. Default: Normal Priority of the message. X-Mms -Delivery - Delivery Report -value -report Optional. Default: No. Specifies whether the user wants a delivery report from each recipient. .
.
X-Mms -Read-Reply Read-reply -value Optional. Default: No. Specifies whether the user wants a read report from each recipient as a new message. Content-Type Content-type-value Mandatory. The content type of the message.
2.3.3 MMS提取响应确认
MMS提取响应确认消息由接收者到MMS中心,包括消息头,不包含正文,消息头包含内容如下:
Name X-Mms -Message-Type Content Comments Message-type-value = Mandatory. m- acknowledge-ind Identifies the transaction type. Mandatory. X-Mms -Transaction-ID Transaction-id-value This is the transaction number that originates from immediately previous M X-Mms -MMS-Version MMS-version-value Mandatory. The MMS version number. According to this specification, the version is 1.0 X-Mms -Report -Allowed Report -allowed-value Optional. Default: Yes. Sending of delivery report allowed to the user. 2.4 回执
包括两种回执:提取回执和阅读回执,是可选的。
2.4.1 MMS提取回执
当接收者从MMS中心取得MMS后,MMS中心会向发送者发送提取回执。MMS提取回执消息只有消息头,没有正文。消息头格式如下:
.
.
Name X-Mms -Message-Type Content Comments Message-type-value = Mandatory. m- delivery -ind Identifies the PDU type. Mandatory. X-Mms -MMS-Version MMS-version-value The MMS version number. According to this specification, the version is 1.0 Message-ID Message-ID-value Mandatory. Identifier of the message. From Send request, connects delivery report to sent message in MS. To To-value Mandatory. Needed for reporting in case of point-to-multipoint message. Date Date-value Mandatory. Date and time the message was handled (fetched, expired, etc.) by the recipient or X-Mms -Status Status-value Mandatory. The status of the message.
2.4.2 MMS阅读回执
当接收者阅读完MMS后,MMS中心会向发送者发送提取回执。该回执是在发送者发送MMS时要求有阅读回执时才会产生,该消息格式不清楚,我们暂不做分析。
2.5 字段说明
以上消息头每一个字段都是KV结构,前面是字段名称,后面是字段值。字段名称是一个字节,对应编码如下:
Name Assigned Number Bcc Cc Content-Location Content-Type 0x01 0x02 0x0 3 0x04 Value 用户地址,是以\\0结尾的字符串 用户地址,是以\\0结尾的字符串 Uri地址,是以\\0结尾的字符串 与WSP的Content-Type一样 .
.
Date 0x05 4字节的长整形值,自1970 -01-01, 00:00:00 GMT到现在的秒数 Yes:0x80,No:0x81 5字节,第一个字节代表时间类型,后4个字节是时间值,时间类型:绝对时间——0x80,相对时间——0x81 5字节,第一个字节代表时间类型,后4个字节是时间值,时间类型:绝对时间——0x80,相对时间——0x81 第一个字节代表地址类型,后面字符串代表地址,地址以\\0结尾,地址类型:Address -present-token——0x80,Insert -address –token——0x81 Personal——0x80 Advertisement——0x81 Informational——0x82 Auto——0x83 以\\0结尾的字符串 m-send-req——0x80 m-send-conf——0x81 m-notification-ind——0x82 m-notifyresp-ind——0x83 m-retrieve-conf——0x84 m-acknowledge-ind——0x85 m-delivery –ind——0x86 2字节的短整形 4字节的长整形 Low——0x80 Normal——0x81 High——0x82 Yes:0x80,No:0x81 Yes:0x80,No:0x81 Delivery -Report Delivery -Time 0x06 0x07 Expiry 0x08 From 0x09 Message-Class 0x0A Message-ID Message-Type 0x0B 0x0C MMS-Version Message-Size Priority 0x0D 0x0E 0x0F Read-Reply Report -Allowed 0x10 0x1 1 .
.
Response-Status 0x12 Response-Text Sender-Visibility Status 0x13 0x14 0x15 Ok——0x80 Error-unspecified——0x81 Error- service-denied——0x82 Error-message-format-corrupt——0x83 Error-sending-address-unresolved——0x84 Error-message-not -found——0x85 Error-network -problem——0x86 Error- content-not-accepted——0x87 Error-unsupported-message——0x88 以\\0结尾的字符串 Hide:0x80,Show:0x81 Expired——0x80 Retrieved ——0x81 Rejected ——0x82 Deferred ——0x83 Unrecognised ——0x84 以\\0结尾的字符串 用户地址,是以\\0结尾的字符串 以\\0结尾的字符串 Subject To Transaction-Id 0x16 0x17 0x18 实际数据包中字段名的最高位都被置1了。
.
因篇幅问题不能全部显示,请点此查看更多更全内容