Node Discovery

XBee modules provide some features for discovering and searching nodes. These features added to 802.15.4 allow a node to send a broadcast message to discover other nodes in the network within its coverage.

Structure used in Node Discovery

Discovering nodes is used to discover and report all modules on its current operating channel and PAN ID.

To store the reported information by other nodes, a structure called 'Node' has been created. This structure has the next fields:

struct Node
{
uint8_t MY[2];
uint8_t SH[4];
uint8_t SL[4];
char NI[20];
uint8_t PMY[2];
uint8_t DT;
uint8_t ST;
uint8_t PID[2];
uint8_t MID[2];
uint8_t RSSI;
};
  • MY: 16-bit Network Address of the reported module

  • SH[4] and SL[4]: 64-bit MAC Source Address of the reported module

  • NI: Node Identifier of the reported module

  • PMY: Parent 16-bit network address. It specifies the 16-bit network address of its parent

  • DT: Device Type (Not used in 802.15.4)

  • ST: Status (Reserved)

  • PID: Profile ID. Profile ID used to application layer addressing

  • MID: Manufacturer ID. ID set by the manufacturer to identify the module

  • RSSI: RSSI of last hop

To store the found brothers, an array called scannedBrothers has been created. It is an array of structures Node. To specify the maximum number of found brothers, it is defined a constant called MAX_BROTHERS. It is also a variable called totalScannedBrothers that indicates the number of brothers that have been discovered. Using this variable as index in the scannedBrothers array, it will be possible to read the information about each node discovered.

Example of use:

{
xbee802.scanNetwork();
}

Related variables:

xbee802.totalScannedBrothers // stores the number of discovered brothers
xbee802.scannedBrothers // Node structure array that stores the info

Scan network example: https://development.libelium.com/802-13-scan-network/

Searching specific nodes

Another possibility is searching for a specific node. This search is based on using the Node Identifier. The NI of the node to discover is used as the input in the API function responsible of this purpose. This function provides the 16-bit network address of the searched node.

Example of use:

{
uint8_t naD[2];
xbee802.nodeSearch("node01", naD);
}

Related variables:

naD[0] and naD[1] // Store the 16-bit address of the searched node

Node search example: https://development.libelium.com/802-14a-node-search-tx/ https://development.libelium.com/802-14b-node-search-rx/

Node discovery to a specific node

When executing a Node Discovery all the nodes respond to it. If its Node Identifier is known, a Node Discovery using its NI as an input can be executed.

Example of use:

{
xbee802.scanNetwork("node01");
}

Related variables:

xbee802.totalScannedBrothers // stores the number of discovered brothers. Must be '1'.
xbee802.scannedBrothers // Node structure array that stores the info

Node Discovery Time

It is the amount of time (NT) a node will wait for responses from other nodes when performing a ND. Range: 0x01 - 0xFC [x 100 ms]. Default: 0x19.

Example of use:

{
uint8_t time[2]={0x19,0x00}; // In 802.15.4 is only used first array position
xbee802.setScanningTime(time);
xbee802.getScanningTime();
}

Available Information

xbee802.scanTime[0] // stores the time a node will wait for responses.

Node Discover options

Enables node discover self-response on the module.

Example of use:

{
xbee802.setDiscoveryOptions(); // Set Discovery Options for ND
xbee802.getDiscoveryOptions(); // Get Discovery Options for ND
}

Available Information

xbee802.discoveryOptions // stores the selected options for ND

If Node Discovery Time is a long time, the API function may exit before receiving a response, but the module will wait for it, crashing the code. If this time is too short, it is possible the modules don't answer. After testing several times, the best values are between 1-2 seconds, setting the API function appropriately.

While testing, many questions came up about discovering nodes. Now these questions are going to be exposed an explained to help the developer.

• ¿What are the network parameters needed to perform a ND?

After testing a network, PAN ID and channel are needed to perform a ND. If one of these parameters is unknown, when performing a ND no node will response. If security is enabled in a network, the security key will be needed too.

• ¿Is a node obliged to answer a ND? DoS Attack.

Yes, it is obliged to answer. The only way to prevent a network form DoS attack is using encryption, since the attacker will have to know the key to perform the ND.

• ¿What happens when ND is performed using PANID=0xFFFF?

When performing a ND using this PANID no response is received. Broadcast PANID is not as useful as in a broadcast message, since the nodes does not receive any message.

• Node Discover Time. Tests.

By default, this parameter is 0x19 (2.5 seconds). This is a great value, that can be reduced to make the ND process shorter. Tests have demonstrated this value can be reduced up to 0.5 seconds and the nodes still answer.

However, it is recommended not to reduce this parameter so much. When reducing this time, a node may answer after this time, the code crashing.

During this discovery time, the module is waiting for an answer and will not accept any data via serial port, so the API function scanNetwork() will have to be modified if this parameter is changed. If it is not modified, the API function will exit but the module will be still waiting, making the next functions don't work.

If this discovery time is reduced and a node answers when the module and the API function have exit ND, the next called function will not work because the data sent by the module via serial will correspond with the response of ND.

Last updated