ZigBee join & rejoin & leave procedure

ZigBee join & rejoin & leave procedure

一、Join 流程

1、 通過協調器加入網絡
Joining direct to Trust Center
在關聯之前需要打開 Permit Join,Joining Device 發送 Beacon Request,附近的 Router/Coordiantor 會響應一個 Beacon,Joining Device 會選擇一個信號最好的設備作爲父設備申請加網。

  1. Joining Device 發送關聯請求;
  2. Trust Center 發送關聯響應;
  3. Trust Center 用 Default Global Centralized Key 或者 Install Code derived key(用Install Code 生成的Link key)加密 Network Key 後傳輸給 Joining Device;
  4. Joining Device 收到 Network Key 後發送 Device Announce;
  5. Joining Device 向 Trust Center 請求節點描述符;
  6. Joining Device 收到節點描述符後解析數據,判斷 Stack Compliance Revision是否大於等於21(R21)和 apsTrustCenterAddress 不等於0xFFFFFFFFFFFFFFFF(等於 0xFFFFFFFFFFFFFFFF 表示網絡處於分佈式網絡安全模式),條件成立就發送 Request Key 命令請求更新 Unique Trust Center link key ;
  7. Trust Center 發送 Unique Trust Center link key;
  8. Joining Device 如果使用了Install Code, 則將從 Defautl 或 Provisional(臨時)狀態更新到 Unverified(未驗證)狀態,然後發送驗證密鑰請求;
  9. Trust Center 收到後將對比密鑰,正確則發送 Confirm Key。

在 Z-Stack 3.0.2 中可以看到 apsTrustCenterAddress 是在傳輸 Network key 時更新的,其實就是 Trust center 的擴展地址(extAddr, 8字節)。

相關函數:
void ZDSecMgrTransportKeyInd( ZDO_TransportKeyInd_t* ind );
void ZDSecMgrUpdateTCAddress( uint8 *extAddr );

2、通過路由加入網絡
Joining when parent is not the Trust Center通過路由加入網絡和通過協調器加入網絡差不多,多了兩個步驟,如下;

  1. Update Device:作用是通知 Trust Center 有設備變動,設備加入網絡或者離開網絡;
  2. Tunnel: Transport Key:傳輸 Network Key。

二、Rejoin 流程

1、Secured Rejoin
Secured Rejoin當設備需要 Rejoin 的時候,它應該先嚐試 Secured Rejoin,Rejoin 失敗後再嘗試 Unsecured Rejoin。
Secured Rejoin 流程如上圖,不再詳述。

2、Trust Center Rejoin(Unsecured Rejoin)

Trust Center RejoinTrust Center Rejoin 需要重新傳輸 Network Key。

三、Leave 流程

Leave 分主動離網和被動離網,流程很簡單,本設備發送Leave命令或者其他設備發送Leave命令。

一般情況的離網 Rejoin 標誌位爲0,即不再發生 Rejoin 動作,如下圖;並且清除相關表和變量:
a. nwkNeighborTable
b. nwkRouteTable
c. nwkManagerAddr
d. nwkUpdateId
e. nwkNetworkAddress
f. nwkGroupIDTable
g. nwkExtendedPANID
h. nwkRouteRecordTable
i. nwkIsConcentrator
j. nwkConcentratorRadius
k. nwkSecurityMaterialSet
l. nwkActiveKeySeqNumber
m. nwkAddressMap
n. nwkPANID
o. nwkTxTotal
p. nwkParentInformation
Leave
1. 主動離網

調用Leave功能函數即可,Router 離網時一般是不會將子設備強制離網的,也就是 Remove Children 標誌位爲0;

2、被動離網

本設備被其他設備要求離網,Router 離網時一般是不會將子設備強制離網的,也就是 Remove Children 標誌位爲0,除非其他設備要求它清除子設備。

參考:
Ti《Z-Stack 3.0 Developer’s Guide.pdf》
Silicon Labs《ug103-05-fundamentals-security.pdf》
ZigBee Alliance《docs-05-3474-21-0csg-zigbee-specification.pdf》

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章