Binding
Introduction
- control message flow from one app to another
- implemented in all devices, called Source Binding
- allow sending packet without dest addr. APS layer find addr from binding table.
Build Binding Table
- 3 ways
- ZigBee Device Object Bind Request : a commissioning tool 建立binding record
- ZigBee Device Object End Device Bind Request: 2个device告知coordinator建立binding table record。
- Device Application: device上的application建立binding table
ZigBee Device Object Bind Request
- Assisted Binding: 发送ZDO message to another device;为send device建立binding entry
- commissioning application
- application调用ZDP_BindReq() in ZDProfile.h 建立binding record
- 参数dstAddr is short addr of source
- 参数endpoint,cluster ID
- 调用ZDP_UnbindReq()解除bind
- target device返回ZibBee Device Objiect Bind or Unbind Response with ZDO code on coordinator。通过调用ZDP_ProcessMsgCBs() in ZDApp.c
- Binding Response为:ZDP_SUCCESS, ZDP_TABLE_FULL, ZDP_INVALID_EP, or ZDP_NOT_SUPPORTED
- Unbind Response为: ZDP_SUCCESS, ZDP_NO_ENTRY, ZDP_INVALID_EP, or ZDP_NOT_SUPPORTED
- application调用ZDP_BindReq() in ZDProfile.h 建立binding record
ZigBee Device Object End Device Bind Request
- selected devices使用按键或者类似动作,在timeout之内进行bind
- default end device binding timeout=16s: APS_DEFAULT_MAXBINDING_TIME in nwk_globals.h,可以在f8wConfig.cfg进行修改
- 该信息由coordinator收集,创建binding table entry(profile ID和cluster ID)
- coordinator通过ZD_RegisterForZDOMsg()接收bind request/response/unbind response, 在ZDApp_RegisterCBs() in ZDApp.c。收到信息后调用ZDApp_ProcessMsgCBs()处理
- 该过程称为toggle process:即执行第一次创建binding entry in request devices。如果再执行一次就会被清除。
- 如果coordinator收到2个matching End Device Bind Requests,执行以下步骤
- 发送ZDO unbind req to first device
- wait unbind response。如果为ZDP_NO_ENTRY,发送ZDO bind req创建binding entry in the source device;如果为ZDP_SUCCESS,move on to the cluster ID for the first device(?)
- wait ZDO bind response。When received, move on to the next cluster ID for the first device(?)
- When the first device done, do same with second
- When the second device is done, send the ZDO End Device Bind Response messages to both the first and second device
Device Application Binding Manager
使用一系列函数调用 see Z-Stack Developer’s Guide sec 4.1.2 P14
Configuring Source Binding
- enable souce binding: include the REFLECTOR compile flag in f8wConfig.cfg.
- set defines
- NWK_MAX_BINDING_ENTRIES f8wConfig.cfg。binding table max entry numer
- MAX_BINDING_CLUSTER_IDS: maximum number of cluster IDs in each binding entry
- each binding table entry length: 6 bytesX (MAX_BINDING_CLUSTER_IDS * 2 bytes).
- binding table储存在一个SRAM中,
Routing
Introduction
- decentralized,cooperative process involving many peers
- completely transparent to the application layer
- self healing
- many-to-one routing in ZigBee PRO
Routing Protocol
basic
- based on the AODV (Ad-hoc On-demand Distance Vector) routing protocol
- Neighbor routers: within radio range:
- track in “neighbor table”, updated when router recieves nay message from neighbor router
- NWK layer routing procedure: recieve a unicast packet
- 若routing table中有dest,直接发送
- 如果没有,发给an entry corresponding to the routing destination。如果成功,packet会发个这个中继router;如果失败有一个重试的define:MAX_DATA_RETRIES in f8wconfig.cfg.
- 如果重试次数达到上限,会发起一个route discovery,buffer the packet
- End device不进行routing,由其parent负责
- Z-stack采用an automatic fallback方式执行route
- 通过把router的所有end device打包成为一个node,可以减少table的存储
Route Discovery and Selection
- route discovery: 是device通过协作建立从source到dest的route通路的过程;route selection是选取最小cost的过程
- 每一个node都会保存所有邻居的link costs:通常是接受信号强度的一个函数。
- route discovery过程:
- souce广播一个Route Request(RREQ)给它所有的邻居,
- 邻居收到后,将自己的link cost加在RREQ packet中,更新自己的Route Discovery Table,然后转发;直到到达dest
- dest选择最小cost的RREQ,并且原路返回Route Reply(RREQ)。返回过程的所有node更新其route table
- 当一个route建立后,如果有node无法连接,则发出RERR给所有可能收到RREP的node。
Route maintenance and self healing
Route expiry
- 设置ROUTE_EXPIRY_TIME in f8wconfig.cfg(0表示该功能关闭)
Table storage
Routing Table
- 每个router和coordinator都有一个routing table
- 每个entry记录了contains the destination address, the next hop node, and the link status
- 设置MAX_RTG_ENTRIES in f8wconfig.cfg可配置table size(默认为40)
Routing discorery Table
- 用来暂存discovery过程的临时变量
- 设置MAX_RREQ_ENTRIES in f8wconfig.cfg
Many to one Routing Protocol
basic
- ZigBee Pro可选
- 通过使用中心节点(concentrator)发起discovery操作,建立周边所有节点的many to one的关系,避免每个节点发起各自的discovery
process
- see Z-Stack Developer’s Guide sec 5.4.2 P18
maintenance
- 使用ZDO callback重建: see Z-Stack Developer’s Guide sec 5.4.4 P19