Summary of basic theoretical knowledge of Zigbee

foreword

This article is written briefly and focused, and some of my own understanding will be added in the middle. For related basic development and applications, see other articles in the column below, and articles related to protocol stack development will be updated in the future. This article summarizes the basic principles.

chapter

  • Zigbee Overview
  • Principle of zigbee technology
  • zigbee hardware design
  • CC2530 Basic Development
  • Radio frequency and MAC layer
  • Zstack protocol stack
  • Zstack application development

Zigbee Overview

Chapter Focus: Concepts,Features, common chips, protocol stacks, development environment

concept

A short-range, low-complexity, low-power, low-cost two-way wireless communication technology.

Applicable scenarios: short distance, low power consumption and low transmission rate, periodic data, intermittent data, low response data

Features

  1. Low power consumption
  2. low cost
  3. Large capacity (both 64-bit IEEE addresses and short addresses can be used, and 65536 devices can be accommodated in a single Zigbee network)
  4. Reliable (CMSA/CA, RCC, Safe Mode)
  5. short delay
  6. Flexible network topology (star, tree, mesh; single-hop, multi-hop)

chip

CC2530

  • CPU and memory
  • Clock and Power Management
  • Peripherals
  • wireless device

Protocol stack

Zstack (version open source TI company embedded OSAL operating system)

development environment

  • AND
  • Zigbee Sniffer (Zigbee sniffer), a program used to analyze the frame structure of each layer of Zigbee, requires a sniffer device.

Zigbee technology principle

Chapter focus: network structure, network system , protocol architecture, IEEE802.15.4 communication layer, MAC layer and network layer frame structure, network layer service specification, application layer specification

network structure

  • The network coordinator, the center of the entire network, establishes, maintains and manages the network, assigns network addresses, etc., and is equivalent to the "brain" of the network.
  • A network router, responsible for route discovery, message transmission, and allowing other nodes to access the network through it.
  • terminal node. Entering the network through one of the above, responsible for data acquisition or control functions

network system

Divided into 4 layers, from top to bottom:

[Network layer (NWK) and application layer]Zibee Alliance Definition
[Physical Layer, Media Access Control Layer (MAC)]Collectively called IEEE802.15.4 communication layer

Topology

  • Star, END only communicates with the coordinator.
  • In tree type, the device can only communicate with its own parent node or byte node.
  • Mesh type, on the basis of tree type, allows all nodes with routing function in the network to communicate with each other.

Protocol Architecture

Please add image description

physical layer

Main functions: allocation of working frequency bands, allocation of channels, providing data services and management services for MAC layer services

Working frequency band allocation

Three working frequency bands

  • 2.4GHz, capable of reaching a transmission rate of 250kb/s, with a total of 16 channels.
  • 915MHz, the transmission rate is 40kb/s, 10 channels.
  • 868MHz, transmission rate 20kb/s, 1 channel.

channel assignment

There are 27 channels, and the number k is 0~26. The center frequency of the 27 channels and the corresponding channel number are defined as follows:

Please add image description

Physical Layer Service Specification

Realize the transparent transmission of various data bit streams between data link entities. The main services provided are: establishment, maintenance and release of physical layer connections, transmission of physical service data units, physical layer management, and data encoding.


Physical Layer Management Entity (PLME-SAP), PLME-SAP is responsible for maintaining the physical layer PAN information base (PHY PIB) in addition to transferring management services between the physical layer and the MAC layer.
Physical data service access interface (Physical Data SAP, PD-SAP for short), PD-SAP is responsible for providing data services between the physical layer and the MAC layer.

Please add image description

Data sending and receiving

It is accomplished through the PD-DATA primitive provided by PD-SAP (Data Service), which can realize the transmission of two MAC sublayer protocol data units.

Detection of physical energy channels

Before constructing a new network, it is necessary to scan all channels and select an idle channel for the network, which is realized by physical channel energy detection.
When a channel is occupied by another network, the value of the channel energy is different.

  • The energy detection should be generated by the MAC sublayer.
  • Energy detection confirmation is generated by the physical layer.

RF Transceiver Activation and Deactivation

Low power consumption, no need to turn off the underlying RF transceiver.

Clear Channel Assessment (CCA)

The MAC sublayer of the 802.1.4 standard uses the CSMA/CA mechanism to access the channel, on the premise of detecting whether the current physical channel is idle. The physical layer provides the CCA detection function.

link quality indicator

Sometimes it is necessary to select a route according to the link quality (signal quality), and the physical layer can return the current LQI value (signal quality) incidentally. The LQI value can be represented by the Signal Received Strength Indicator (RSSI).

Get and set attribute parameters

Each layer of the protocol has a corresponding PAN (information base), which stores attribute parameters.

MAC layer

Features

  • Use CSMA/CA mechanism to access the channel
  • PAN (Personal Area Network) establishment and maintenance.
  • Supports association (i.e. joining the network) and disassociating (exiting the network) of PAN networks
  • The coordinator generates a network beacon frame, and ordinary devices synchronize with the coordinator according to the beacon
  • Handling and Maintenance Guarantee GTS
  • Provides a reliable link between two peer MAC entities

Service Specification

Please add image description

The MAC management service calls the management service interface and maintains the PAN information base

The MAC data service provides a data service interface and adds a protocol header to the network layer data, thereby realizing the MAC layer frame data.


How CSMA/CA works
Purpose: To avoid the channel collision problem.
Methods (two):

  • (1) Before sending data, monitor the channel usage for a period of time, and wait for a random period of time after the channel is still idle, then send data. (Since the random time of each device is different, the occurrence of conflicts can be reduced, but cannot be completely avoided)
  • (2) "Handshake judgment", before sending, send a request RTS message to the target end, and start sending after the target end can respond to the CTS message. (to ensure no collision)

PAN establishment and maintenance

The coordinator is powered on, scans the existing network, selects the free channel and PANID, and constructs the network.

beacon frame

  • Know if there is data sent to yourself in the coordinator
  • When to turn off and on RF

frame structure=

Full name: MAC Protocol Data Unit (MPDU), which consists of a series of fields arranged in a specific order.

general structure

MAC Frame Header (MHR), MAC Payload, MAC Frame Footer (MFR)

Please add image description

  • Destination PAN identifier. The length of the destination PAN field is 16 bits, and it specifies the PAN identifier where the receiving device is located.
  • Destination address field. The frame expects to receive the address of the device.
  • Source PAN identifier. The length of the source PAN is 16 bits, and the PAN identification code of the sending device is sent. The PAN identifier of a set is obtained when the PAN is initially associated, and may change in the event of a conflict.
  • Source address field. The address of the sending device.
  • FCS field, CRC check code.

specific structure

  • Beacon frame. Realize the synchronous work and sleep of the equipment in the network, and establish the PAN master coordinator.
  • data frame . The data sent by the upper layer to the MAC sublayer is transmitted. When the data payload is sent to the MAC sublayer, it is called the MAC service data unit, and the first bit is encapsulated.
  • determine frame
  • command frame

Network layer

Features

  • Build a new network
  • Allows devices to join or leave, assigns internal logical addresses to devices, establishes and maintains neighbor tables

frame structure

Network Layer Protocol Data Unit (NPUD)

Please add image description

  • Destination address. According to the subfield value of the broadcast flag, the 16-bit device network address, broadcast address or destination multicast group ID is obtained.
  • source address. The source device gets the network address.
  • radius field. The length is 8 bits. Each time frame data is received, the broadcast radius is reduced by 1, and the broadcast radius determines the propagation radius.
  • IEEE destination address. If it exists, it is included in the 64-bit IEEE E address corresponding to the 16-bit network address of the destination address in the address header.
  • IEEE source address. Ditto
  • Multicast control. Exists during multicast.

application layer


constitute

Application Support Sublayer (APS), Zigbee Device Objects, Zigbee Application Framework (AF), Zigbee Device Profile Templates and Manufacturer Definitions

Node address and endpoint number
  • Node address: divided into two types, 64bit IEEE address (MAC address), 16bit network address (short address, assigned by the coordinator)
  • Endpoint number: The entry of the application layer of the protocol stack, which describes the cluster defined by a device. Each zigbee device can support up to 240 endpoints, and 240 application objects can be defined on each device, of which endpoint 0 is used to reserve the device object interface, endpoint 255 is reserved for broadcasting, and 241~245 are used for future expansion.
Indirect and direct communication
  • In indirect communication, two nodes establish a logical link on the application layer.
  • Direct communication, using the node address communication (partial bottom layer)
cluster

type of message


Application Support Sublayer

Function: Responsible for application support sublayer data unit APDU processing, data transmission management and maintenance binding list

APS provides an interface between the network layer and the application layer through a common set of service bits.

application framework

Functions: Combined transactions ( several transactions are combined into one frame, large transactions are divided into multiple frames ), receive and reject

device object

The application communicates with other layers of the Zigbee stack through the endpoint 0, so as to realize the initialization and configuration of each layer. The object attached to the endpoint 0 is called the Zigbee device object.
ZDO function: Initialize application support sublayer, network layer and other Zigbee device layers; aggregate information from endpoint applications to implement device and service discovery, network management, binding management, security management, node management and other functions.

Zigbee Coordinator

Features:

  • Accept a device to join the network, or disconnect a device from the network.
  • Device services and service discovery in response to requests from other devices, including requests to own and requests to own sleeping child devices.
  • Support the binding function between Zigbee devices, etc. It is guaranteed that the number of binding items cannot exceed the value specified by the attribute.
  • Maintains a list of currently connected devices, receives orphaned scans, and reconnects orphaned devices to the network.
  • Receive and process notification requests from terminal devices.
Zigbee router

Features:

  • Allow other devices to connect to the network.
  • Accept and execute commands to remove a device from the network.
  • Responds to device discovery and service discovery.
  • A list of devices connected to it should be maintained, allowing devices to rejoin the network.
Zigbee terminal equipment

When Zigbee terminal equipment is initialized, it first sets the initial value for the parameters required in the work; secondly, it starts to discover the operation of the network, and selects a suitable network to connect to it; after connecting, it uses its own IEEE address and network address to send terminal equipment notification information . Under normal operation, the terminal device should respond to device discovery and service discovery requests, receive notification information from the coordinator, check whether there is an entry that matches it in the binding table, and so on. In a secure network, the acquisition, establishment and management of various keys should also be completed.


You can follow this column, and Zstack development will be updated in the future.

Guess you like

Origin blog.csdn.net/qq_45628620/article/details/121482051
Recommended