[关闭]
@yiltoncent 2015-07-14T07:10:59.000000Z 字数 10103 阅读 5238

ZigBee 协议学习笔记

ZigBee


总览摘要

ZigBee协议体系架构图

pic 1

这是一张很重要的图,将ZigBee体系架构中各层之间的关系阐述出来。
在学习理解ZigBee协议中,本人认为熟悉层级之间关系、了解服务原语以及对于层级之间的接口的掌握是学习的重点。

接口描述

1. MAC层与PHY层的接口:(一般来说,应用层开发是不会关心到这一层的)

  • PD-SAP 物理层数据服务访问点
  • PLME-SAP 物理层管理试题服务访问点

2. NWK层与MAC层接口

  • MLDE-SAP MAC层数据实体SAP
  • MLME-SAP MAC层管理实体SAP

3. NWK层提供的接口

  • NLDE-SAP 网络层数据实体SAP,向APS层提供的服务接口
  • NLME-SAP 网络层管理实体SAP,向ZDO管理面板提供的服务接口

4. APS层提供的接口

  • APSDE-SAP 应用支持子层(APS)数据实体SAP,向应用层和ZDO提供的服务接口
  • APSME-SAP 应用支持子层(APS)管理实体SAP,向ZDO管理面板提供的服务接口

pic 2

ZigBee Wireless Networks and Transceivers [book]

Chapter 1 : ZigBee Basic

Beacon is a message with specific format that is used to synchronize the clocks of the nodes in the network.This is called a beacon-enabled PAN . The disadvantage of using beacons is that all the devices in the network must wake up on a regular basis, listen for the beacon, synchronize their clocks, and go back to sleep. This means that many of the devices in the network may wake up only for synchronization and not perform any other task while they are active.


A network in which the PAN coordinator does not transmit beacons is known as a nonbeacon network . A nonbeacon network cannot have GTSs and therefore contention-free periods because the devices cannot be synchronized with one another. The battery life in a nonbeacon network can be noticeably better than in a beacon-enabled network because in a nonbeacon network, the devices wake up less often.


The Network (NWK) layer of the ZigBee protocol assigns a 16-bit NWK address in addition to the IEEE address. A simple lookup table is used to map each 64-bit IEEE address to a unique NWK address. The NWK layer transactions require the use of the NWK address.


Binding is the task of creating logical links between the applications that are related. For example, a ZigBee device connected to a lamp is logically related to another ZigBee device connected to the switch that controls the lamp. The information regarding these logical links is stored in a binding table . The ZigBee standard, at the application layer, provides support for creating and maintaining binding tables. Devices logically related in a binding table are called bound devices .

ZigBee Packet Structure

pic 3

MAC Frame Structure

The IEEE 802.15.4 defines four MAC frame structures:

The Beacon Frame

pic 4

The Data and Knowledgment Frame

pic 5

The MAC acknowledgment frame is the simplest frame format and does not carry any MAC payload. The acknowledgment frame is sent by one device to another to confirm successful reception of a packet.

The Command Frame

pic 6

The MAC commands such as requesting association or disassociation with a network are transmitted using the MAC command frame

The NWK layer

The NWK layer interfaces between the MAC and the APL and is responsible for managing the network formation and routing.

The APL layer

The application (APL) layer is the highest protocol layer in the ZigBee wireless network and hosts the application objects. Manufacturers develop the application objects to customize a device for various applications. Application objects control and manage the protocol layers in a ZigBee device. There can be up to 240 application objects in a single device.

Security

In a wireless network, the transmitted messages can be received by any nearby device, including an intruder. There are two main security concerns in a wireless network. The first one is data confidentiality . The intruder device can gain sensitive information by simply listening to the transmitted messages. Encrypting the messages before transmission will solve the confidentiality problem. An encryption algorithm modifies a message using a string of bits known as the security key, and only the intended recipient will be able to recover the original message. The IEEE 802.15.4 standard supports the use of Advanced Encryption Standard (AES) [14] to encrypt their outgoing messages.

The second concern is that the intruder device may modify and resend one of the previous messages even if the messages are encrypted. Including a message integrity code (MIC) with each outgoing frame will allow the recipient to know whether the message has been changed in transit. This process is known as data authentication .

Chapter 3 : ZigBee and IEEE 802.15.4 Protocol Layers

3.1 ZigBee Networking Protocol Layers

pic

3.2 The IEEE 802.15.4 PHY Specifications

Energy Detection (ED)

When a device plans to transmit a message, it first goes into the receive mode to detect and estimate the signal energy level in the desired channel. This task is known as energy detection (ED).

Carrier Sense (CS)

Clear Channel Assessment (CCA)

PHY Services

1. PHY PIB Attribute

2. The IEEE 802.15.4 PHY Reference Model Interfacing the MAC Layer

3. Concept

PPDU: PHY Protocol Data Unit
PLME: Physical Layer Management Entity. PLME also maintains the PHY PAN Information Base (PIB).
PD-SAP: PHY Data SAP
PLME-SAP

4. PHY Data Service

The data that needs to be transmitted is always provided as a MAC Protocol Data Unit (MPDU). The local MAC generates the request for transmission and provides the MPDU.
The PHY attempts the transmission and reports the result of the attempt (successful or unsuccessful) to the MAC.
Unsucess Condition:
* Radio transciever is disabled (first to be checked)
* Radio transciever is in receive mode. [Radio cannot transmit and receive simultaneously] (second)
* Radio transciever is busy (already engaged in transimiting) (third)

5. Data Transfer Service Between Two Devices

The PHY not only provides the MPDU to the MAC layer, it also delivers the LQI information.
On the receiver side, the data is passed upward from one layer to the next higher layer and the header and footers are removed until the DU reaches the intended layer at the destination.

6. PHY Management Service

PLME-SAP is utilized to transport commands between MLME and PLME. The services provided through the PLME-SAP are:

The Service Primitives [Important Concept]

The IEEE 802.15.4 and ZigBee standards use the concept of primitives to describe the services that a layer provides to the service user in the next higher layer.
The communications between the adjacent protocol layers are managed by calling functions or passing messages, called primitives , between the layers.

Although each layer has a different role in the overall system, the way each layer operates has some similarities to other layers. Because of these similarities, service primitives are found to be useful in describing the capabilities of each standard protocol layer. Each primitive specifies the action to be performed or provides the result of a previously requested action. A primitive may also carry the parameters needed to perform its task.

PHY Packet Format


PPDU contains:

Summary of the PHY Layer Responsibilities

The PHY layer is the closest layer to hardware and directly controls and communicates with the radio transceiver.

3.3 IEEE 802.15.4 MAC Layer

The IEEE 802.15.4 is not developed specifically for ZigBee applications, and the next higher layer can be any networking protocol layer. In this book, the MAC services are discussed in interfacing with the ZigBee NWK layer.

The MAC also has its own database, referred to as the MAC PAN Information Base (MAC-PIB). All the MAC constants have a general prefix of a . The MAC attributes have a general prefix of mac . The size of the MAC-PIB is larger than the PHY-PIB.

Beacon-Enabled Operation and Superframe Structure

One of the advantages of a beacon-enabled network is the availability of guaranteed time slots (GTSs). The beacon frames are MAC frames that contain beacon information such as the time interval between the beacons and number of GTSs.

In beacon-enabled operation, it is possible to use a superframe structure. A superframe, shown in Figure 3.7 , is bounded by two beacon frames. The use of a superframe structure is optional in the IEEE 802.15.4 standard. There can be up to three types of periods in a superframe: the contention access period (CAP), the contention-free period (CFP), and the inactive period.

The Interframe Spacing (IFS)

In transmitting data from one device to another, the transmitting device must wait briefly between its successive transmitted frames to allow the recipient device process a received frame before the next frame arrives. This is known as interframe spacing (IFS).

CSMA-CA

RTS/CTS handshake mechanism are suggested methods for overcoming the hidden or exposed node problem.

MAC Services

There are two types of service provided by MAC layer:

The MAC data service is accessed by the NWK Layer Data Entity (NLDE) through the MAC Common Part Sublayer SAP (MCPS-SAP). The MAC management service is accessed through MLME-SAP.

1. MAC Data Service

The NWK generates the request for the data transmission through MCPS-SAP and provides the NPDU.

To keep track of different MSDUs in a device, each MSDU is associated with a unique MSDU handle ( msduhandle ). The msduhandle is an integer number that identifies the MSDU.

The data sequence number (DSN) may be used as msduhandle . The DSN is a MAC attribute stored in the MAC-PIB ( macDSN ). The initial value of the macDSN is a random number. Each time a data frame or a MAC command frame is generated, the MAC sublayer copies the value of macDSN into the outgoing frame and increments the macDSN by one.

The MSDU can be purged from the transaction queue if requested by the NWK layer.

2. MAC Management Service

//to be continued

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注