This project has moved and is read-only. For the latest updates, please go here.

16bit Network Address Lookup

Feb 23, 2012 at 1:29 PM

There should be an automatic network address lookup system - You only send messages with the 64bit destination address and the system will automatically store any 16bit network addresses it gets from the responses. (It should also automatically invalidate them if required.)

Feb 28, 2012 at 1:13 AM

Please take a look at changeset 0cb0502d88a3. I have added a listener that can be enabled or disabled and is responsible for collecting packets that contain address data. Right now it's only storing serial address mapping to network address using hashtable. Next thing would be to use those values to provide network address in request when only serial number was provided, right? Also in wpan mode the requests are sent with either serial or network address. Does it mean the XBee is doing serial to network address translation in between and always sends packets with network address? 

Feb 28, 2012 at 8:20 PM

Keep in mind that when an XBee leaves the network, the address is no longer valid and must be removed. This is shown in the "DiscoveryResult".


Here's a section from an XBee book which explains the purpose of the 16bit network address:

These two bytes can be set to the 16-bit address of the destination radio, if you know what that is. Assigning this address manually is optional, but it will greatly speed upyour transmission. This can be essential on larger networks. If you don’t know the 16-bit address that the coordinator has assigned for the destination, simply set thesetwo bits to 0xFF and 0xFE respectively. This will cause an address lookup to occur so that the transmission can be properly delivered. 0xFFFE is also the proper 16-bit addresssetting for broadcast transmissions to be delivered to all the devices on the network.

Using 64-bit addressing to route messages requires broadcast transmissions to discoverthe 16-bit address. This is almost never a good idea when using the Series 2 on networksthat are larger than around 10 nodes. Here’s what happens during a transmission cyclewhen the 16-bit address is set to 0xFFFE for broadcast:

1. A broadcast is sent three times (a value controlled by the ZigBee stack profile) on the network asking to resolve the 64-bit address to the 16-bit network address.These broadcasts are very, very expensive in terms of routing and network overheadbecause they create three additional messages to every node on the networkfor every single message sent by any radio.

2. One or more nodes respond to the requester with a point-to-point frame containingthe 16-bit address.

3. The transmission proceeds with the newly discovered 16-bit address being used.

If you have started with 64-bit addressing for your messages and your network grows,you will want to migrate your application toward either discovering and using the 16-bit addresses in advance via the API or saving them offboard on your computer ordevice when it receives incoming data from the remote node. (If you do this, also considertracking the TX status of any transmissions using the short address to see if thetransmission fails so that you can invalidate the known 16-bit address to 0xFFFE andstart the process again.) Remember that you don’t need to worry about any of this ifyour network is relatively small, if messages are not sent too frequently, or if you areusing a ConnectPort X gateway—as this is handled for you automatically. Phew!

(Building Wireless Sensor Networks: With ZigBee, XBee, Arduino, and Processing)

Feb 29, 2012 at 11:58 AM

Thanks, now i understand why is that needed. Since this is not applicable to wpan (no hoping) i think we should either turn lookup table mode on when we know this is a series 2 module or always let the user decide.

Feb 29, 2012 at 1:02 PM

Also as a little bit of an aside - I can't view the source code right now but if the addresses are structures, they should probably be passed in-to and out-of the methods as a reference so that the value isn't copied every time.

Feb 29, 2012 at 1:52 PM

There is an XBeeAddress class that has equality members and operators overloaded, so no memory copying.