最近需要通過網(wǎng)絡(luò)管理公司產(chǎn)品,使用的協(xié)議正是TR069,于是看了下協(xié)議過程,還有很有意義的。
通信過程圖

tr069.png
圖中主要步驟包括:
- 建立連接時必須用Inform請求
- 沒有后續(xù)請求則發(fā)送空請求
- ACS要求上報設(shè)備信息并驗證
- ACS下發(fā)設(shè)備的操作命令
解析步驟說明
- 設(shè)備啟動,根據(jù)配置的ACS(自動配置服務(wù)器)地址,建立安全的HTTP連接以后,每次連接CPE都必須首先對ACS發(fā)出一個Inform的RPC調(diào)用請求來向ACS匯報本次連接的信息。ACS會返回給一個Inform response作為確認連接。
標(biāo)準(zhǔn)的Inform方法的參數(shù)如表所示
| 參數(shù)名稱 | 參數(shù)說明 |
|---|---|
| DeviceID | 數(shù)據(jù)結(jié)構(gòu)標(biāo)識CPE |
| Event | 標(biāo)識此次Inform發(fā)起的原因 |
| MaxEnvelopes | HTTP Response可攜帶SOAP信封數(shù) |
| CurrentTime | CPE當(dāng)前的時間 |
| RetryCount | 這次Session最大的重復(fù)連接次數(shù) |
| ParameterList | 這次Inform所需攜帶的參數(shù) |
以下是報文:
POST /service.tr069 HTTP/1.1
Host: 183.62.12.23:8012
User-Agent: cwmp
Content-Type: text/xml; charset=utf-8
Connection: keep-alive
Content-Length: 1730
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:cwmp="urn:dslforum-org:cwmp-1-0">
<SOAP-ENV:Header>
<cwmp:ID SOAP-ENV:mustUnderstand="1">946684824</cwmp:ID>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<!-- inform方法任何時刻要建立與ACS的連接,都必須調(diào)用Inform方法-->
<!-- 來初始化一個傳輸序列,向ACS服務(wù)器上報一些事件,具體事件就攜帶在EventCode -->
<cwmp:Inform>
<!-- 設(shè)備描述信息 -->
<DeviceId>
<!-- 設(shè)備廠商 -->
<Manufacturer>star-net</Manufacturer>
<!-- 設(shè)備制造商的唯一標(biāo)示 -->
<OUI>00D0F8</OUI>
<!-- 設(shè)備類型 -->
<ProductClass>SVP3000_V5_SIP_CN</ProductClass>
<!-- 設(shè)備序列號 -->
<SerialNumber>00100400RJ0100100000001AA9800003</SerialNumber>
</DeviceId>
<!-- 引起此次會話建立的具體事件 -->
<Event SOAP-ENC:arrayType="cwmp:EventStruct[1]">
<EventStruct>
<!-- 上報BOOT事件,也就是告訴ACS要發(fā)起CWMP連接了 -->
<!-- 1 boot表明發(fā)起會話的原因是設(shè)備上電(首次啟動或者其他原因引起的設(shè)備重啟) -->
<EventCode>1 BOOT</EventCode>
<CommandKey></CommandKey>
</EventStruct>
</Event>
<!-- 接收響應(yīng)的允許SOAP信包數(shù)目,0表示無限制 -->
<MaxEnvelopes>1</MaxEnvelopes>
<!-- cpe當(dāng)前的時間 -->
<CurrentTime>2000-01-01T08:00:23</CurrentTime>
<!-- 完成inform調(diào)用前嘗試的次數(shù)每次加1 -->
<RetryCount>0</RetryCount>
<!-- CPE設(shè)備參數(shù)列表-->
<ParameterList SOAP-ENC:arrayType="cwmp:ParameterValueStruct[6]">
<ParameterValueStruct>
<!-- 設(shè)備描述信息 -->
<Name>Device.DeviceSummary</Name>
<Value>Device:1.0[](Baseline:1), VoiceService:1.0[1](Baseline:1)</Value>
</ParameterValueStruct>
<ParameterValueStruct>
<!-- 設(shè)備的硬件版本信息 -->
<Name>Device.DeviceInfo.HardwareVersion</Name>
<Value>5.0</Value>
</ParameterValueStruct>
<ParameterValueStruct>
<!-- 設(shè)備的軟件版本信息 -->
<Name>Device.DeviceInfo.SoftwareVersion</Name>
<Value>AIM1.3.10.8</Value>
</ParameterValueStruct>
<ParameterValueStruct>
<!-- 請求URL(設(shè)備聯(lián)系地址) -->
<Name>Device.ManagementServer.ConnectionRequestURL</Name>
<Value>http://192.168.99.17:7547/</Value>
</ParameterValueStruct>
<ParameterValueStruct>
<!-- 對某些方法的調(diào)用會導(dǎo)致該值的該改變?nèi)?Scheduled Inform、reboot、download、upload方法 -->
<!-- 除此以外的調(diào)用該值均為空,此消息中設(shè)備只調(diào)用了 inform方法,故該值應(yīng)該置為空 -->
<Name>Device.ManagementServer.ParameterKey</Name>
<Value></Value>
</ParameterValueStruct>
<ParameterValueStruct>
<!-- 設(shè)備ip地址 -->
<Name>Device.LAN.IPAddress</Name>
<Value>192.168.99.17</Value>
</ParameterValueStruct>
</ParameterList>
</cwmp:Inform>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
- ACS服務(wù)器接受到設(shè)備端(CPE端)發(fā)出的inform消息之后,會給予一個 informresponse響應(yīng)機cwmp連接創(chuàng)建成功
HTTP/1.1 200 OK
Date: Tue, 02 Aug 2011 03:20:53 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Set-Cookie: SerialNumber=00100400RJ0100100000001AA9800003; path=/
Cache-Control: private
Content-Type: text/xml;charset=UTF-8
Content-Length: 522
<!-- 對設(shè)備端inform消息的響應(yīng)即接受連接請求 -->
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:cwmp="urn:dslforum-org:cwmp-1-0"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<soap:Header>
<cwmp:ID soap:mustUnderstand="1">946684824</cwmp:ID>
<cwmp:HoldRequests soap:mustUnderstand="1">0</cwmp:HoldRequests>
</soap:Header>
<soap:Body>
<!-- ACS接受設(shè)備端(cpe)端的inform請求(即創(chuàng)建cwmp連接的請求) -->
<cwmp:InformResponse>
<MaxEnvelopes>1</MaxEnvelopes>
</cwmp:InformResponse>
</soap:Body>
</soap:Envelope>
- 設(shè)備端發(fā)送空消息,表示沒有后續(xù)的請求
POST /service.tr069 HTTP/1.1
Host: 183.62.12.23:8012
User-Agent: cwmp
Content-Type: text/xml; charset=utf-8
Connection: keep-alive
Cookie: SerialNumber=00100400RJ0100100000001AA9800003;path=/
Content-Length: 0
<!-- Host: ACS(自動配置服務(wù)器)地址 -->
<!-- Cookie: 設(shè)置在設(shè)備的序列號-->
<!-- Content-Length: 消息內(nèi)容長度為0代表空消息-->
- ACS服務(wù)器收到空消息后,根據(jù)空消息中攜帶的序列號對設(shè)備進行合法性驗證,若驗證通過則進行后續(xù)操作,若不通過則下發(fā)消息提示設(shè)備非法。序列號的判斷在ACS內(nèi)部判斷,未體現(xiàn)在報文中
- ACS驗證設(shè)備序列號合法,發(fā)送消息要求設(shè)備端上報網(wǎng)管的賬號信息
HTTP/1.1 200 OK
Date: Tue, 02 Aug 2011 03:20:53 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Set-Cookie: SerialNumber=00100400RJ0100100000001AA9800003; path=/
Cache-Control: private
Content-Type: text/xml;charset=UTF-8
Content-Length: 658
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:cwmp="urn:dslforum-org:cwmp-1-0"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<soap:Header>
<cwmp:ID soap:mustUnderstand="1">1</cwmp:ID>
<cwmp:HoldRequests soap:mustUnderstand="1">0</cwmp:HoldRequests>
</soap:Header>
<soap:Body>
<!-- 請求的方法為GetParameterValues,獲取設(shè)備端的參數(shù)信息 -->
<cwmp:GetParameterValues>
<ParameterNamesSOAP-ENC:arrayType="xsd:string[2]">
<!-- 獲取設(shè)備TR069網(wǎng)管用戶名 -->
<string>Device.ManagementServer.Username</string>
<!-- 獲取設(shè)備TR069網(wǎng)管密碼 -->
<string>Device.ManagementServer.Password</string>
</ParameterNames>
</cwmp:GetParameterValues>
</soap:Body>
</soap:Envelope>
- 設(shè)備端接收該ACS服務(wù)器請求上報賬號的消息后,將發(fā)送設(shè)備上配置的賬號信息作為請求的響應(yīng)
HTTP/1.1
Host: 183.62.12.23:8012
User-Agent: cwmp
Content-Type: text/xml; charset=utf-8
Connection: keep-alive
Cookie: SerialNumber=00100400RJ0100100000001AA9800003;path=/
Content-Length: 828
SOAPAction: ""
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cwmp="urn:dslforum-org:cwmp-1-0">
<SOAP-ENV:Header>
<cwmp:ID SOAP-ENV:mustUnderstand="1">1</cwmp:ID>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<!-- 將賬號信息作為ACS請求的響應(yīng)消息 -->
<cwmp:GetParameterValuesResponse>
<ParameterList xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="cwmp:ParameterValueStruct[2]">
<ParameterValueStruct>
<!-- 設(shè)置在設(shè)備上的網(wǎng)管用戶名 -->
<Name>Device.ManagementServer.Username</Name>
<!-- 用戶名的具體值 -->
<Value>66661160</Value>
</ParameterValueStruct>
<ParameterValueStruct>
<!-- 設(shè)置在設(shè)備上的網(wǎng)管密碼 -->
<Name>Device.ManagementServer.Password</Name>
<!-- 密碼的具體值 -->
<Value>66661160</Value>
</ParameterValueStruct>
</ParameterList>
</cwmp:GetParameterValuesResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
- ACS服務(wù)器收到消息后,根據(jù)消息中攜帶的賬號信息進行合法性驗證,若驗證通過則進行后續(xù)操作,若不通過則下發(fā)消息提示賬號非法。序列號的判斷在ACS內(nèi)部判斷,未體現(xiàn)在報文中
- ACS驗證賬號合法,發(fā)送消息要求設(shè)備從特定URL上下載配置文件
HTTP/1.1 200 OK
Date: Tue, 02 Aug 2011 03:21:04 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Set-Cookie: SerialNumber=00100400RJ0100100000001AA9800003; path=/
Cache-Control: private
Content-Type: text/xml;charset=UTF-8
Content-Length: 856
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:cwmp="urn:dslforum-org:cwmp-1-0"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<soap:Header>
<cwmp:ID soap:mustUnderstand="1">1</cwmp:ID>
<cwmp:HoldRequests soap:mustUnderstand="1">0</cwmp:HoldRequests>
</soap:Header>
<soap:Body>
<cwmp:Download>
<CommandKey>M Download</CommandKey>
<!-- 文件類型 配置文件-->
<FileType>3 Vendor Configuration File</FileType>
<!-- 配置文件的URL地址,設(shè)備端從該地址獲取配置文件并自動載入設(shè)備 -->
<URL>http://183.62.12.23:8012/Config.aspx?ID=00100400RJ0100100000001AA9800003</URL>
<Description></Description>
<Username></Username>
<Password></Password>
<FileSize>0</FileSize>
<TargetFileName>ConfigFile.xml</TargetFileName>
<DelaySeconds>0</DelaySeconds>
<SuccessURL></SuccessURL>
<FailureURL></FailureURL>
</cwmp:Download>
</soap:Body>
</soap:Envelope>
- 設(shè)備接收到該消息之后,并根據(jù)消息中的URL地址下載配置文件并自動配置,同時給ACS服務(wù)器一個下載成功的響應(yīng)消息
Host: 183.62.12.23:8012
User-Agent: cwmp
Content-Type: text/xml; charset=utf-8
Connection: keep-alive
Cookie: SerialNumber=00100400RJ0100100000001AA9800003;path=/
Content-Length: 484
SOAPAction: ""
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cwmp="urn:dslforum-org:cwmp-1-0">
<SOAP-ENV:Header>
<cwmp:ID SOAP-ENV:mustUnderstand="1">1</cwmp:ID>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<!-- 通過該消息告知ACS服務(wù)器設(shè)備成功獲取配置文件 -->
<cwmp:DownloadResponse>
<!-- 成功下載的狀態(tài)碼 -->
<Status>1</Status>
</cwmp:DownloadResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
- ACS服務(wù)器發(fā)送消息,要求設(shè)備從特定的URL下載升級文件(是否升級可由用戶自行決定)
HTTP/1.1 200 OK
Date: Tue, 02 Aug 2011 03:21:04 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Set-Cookie: SerialNumber=00100400RJ0100100000001AA9800003; path=/
Cache-Control: private
Content-Type: text/xml;charset=UTF-8
Content-Length: 889
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:cwmp="urn:dslforum-org:cwmp-1-0"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<soap:Header>
<cwmp:ID soap:mustUnderstand="1">1</cwmp:ID>
<cwmp:HoldRequests soap:mustUnderstand="1">0</cwmp:HoldRequests>
</soap:Header>
<soap:Body>
<cwmp:Download>
<CommandKey>M Download</CommandKey>
<!-- 文件類型升級文件 -->
<FileType>1 Firmware Upgrade Image</FileType>
<!-- 升級文件的URL地址,設(shè)備端從該地址獲取配置文件并自動載入設(shè)備 -->
<URL>http://183.62.12.23:8010/DeviceSoftWareVersion/20110714/svp3000.update</URL>
<Description></Description>
<Username></Username>
<Password></Password>
<FileSize>3493888</FileSize>
<TargetFileName>/DeviceSoftWareVersion/20110714/svp3000.update</TargetFileName>
<DelaySeconds>0</DelaySeconds>
<SuccessURL></SuccessURL>
<FailureURL></FailureURL>
</cwmp:Download>
</soap:Body>
</soap:Envelope>
- 設(shè)備接收到該消息之后,并根據(jù)消息中的URL地址獲取升級文件,同時給予ACS服務(wù)器一個響應(yīng)
POST /service.tr069 HTTP/1.1
Host: 183.62.12.23:8012
User-Agent: cwmp
Content-Type: text/xml; charset=utf-8
Connection: keep-alive
Cookie: SerialNumber=00100400RJ0100100000001AA9800003;path=/
Content-Length: 484
SOAPAction: ""
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cwmp="urn:dslforum-org:cwmp-1-0">
<SOAP-ENV:Header>
<cwmp:ID SOAP-ENV:mustUnderstand="1">1</cwmp:ID>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<!-- 通過該消息告知ACS服務(wù)器設(shè)備成功獲取配置文件 -->
<cwmp:DownloadResponse>
<!-- 成功下載的狀態(tài)碼 -->
<Status>1</Status>
</cwmp:DownloadResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
- ACS服務(wù)器發(fā)送空消息結(jié)束流程
HTTP/1.1 200 OK
Date: Tue, 02 Aug 2011 03:21:05 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Set-Cookie: SerialNumber=00100400RJ0100100000001AA9800003; path=/
Cache-Control: private
Content-Length: 0
<!-- Content-Length: 消息內(nèi)容長度為0代表空消息 -->
TR069協(xié)議簇的其他規(guī)范
TR069協(xié)議不僅僅包括TR-069子協(xié)議,還包括其他一些的協(xié)議,構(gòu)成了一個完整的網(wǎng)管協(xié)議簇。與之配套的TR-098協(xié)議和TR-104協(xié)議分別定義了CPE的數(shù)據(jù)業(yè)務(wù)的管理參數(shù)和VoIP業(yè)務(wù)的管理參數(shù),WT-135協(xié)議用于定義數(shù)字機頂盒的管理參數(shù),TR-111協(xié)議定義了在家庭內(nèi)部數(shù)字設(shè)備上實施TR069網(wǎng)管的機制,WT-121協(xié)議則是各個廠家在實現(xiàn)和部署TR069過程中對協(xié)議的修訂。