Networking and Communications

Network Bring up and Discovery

When a network is powered up, there is the notion of discovery. How the network is formed, and how new nodes are added without causing interruption to existing nodes.

For this weeks project, I decided to use Neil’s existing hello.bus bridge and  node board as my platform. My challenge was to try and allow new nodes to join the network, with a dynamically allocated id, as opposed to the existing solution were id was allocated statically  at compile time.

Challenge #1 - Building a true random number generator

I could not use the AVR LiBC random function nor could I use a barrel shift register.

Both of these methods produce a pseudo random sequence, which would be identical on each of the nodes.

In order to solve this, I rely on the internal oscillator as a source of entropy for my random generator.

This oscillator exhibits significant jitter. During a fix period, multiple timer counts will differ. The problem is, how can you stop the timer after a fixed period which does not relay on the same oscillator?

Answer: use an additional internal oscillator. But, does one exist you should ask?

Indeed, it does. The ATTiny45 has a watchdog which feeds from a 2nd oscillator. I use this to time a fixed period and then read my counter. The result times some constant will be my random number

Proposed Solution - Dynamically Allocated IDs

My solution to this problem was to create a protocol that would enable each node to randomly generate its ID, and get approval from a network access management entity.

The node would also have to transmit its request at a random time, so that it would not conflict with other node requests. Finally, the response should be unique so that the requesting node would know that it received approval to use this ID in order to multiple nodes with the same ID.

Challenge #2 - Develop the protocol

I needed a way for the nodes to notify the hub of their chosen ID, and receive approval that the specific ID was available.

Transmit ID approval request

Conclusion - It Works !!!!

I tested this quit extensively, and the network always stabilized within a reasonable amount of time (usually a few seconds). Further improvement can include additional steps during the registration sequence to assure that no 2 nodes receive the same ID.

Check if ID is in DB and assigned to other node

Transmit NACK

Randomly generate ID and transmission time

Check if ID is in DB. ID is not assigned already

Transmit ID approval request

Transmit ACK

Randomly generate ID and transmission time

Node start using the ID

char is transmitted for specific node ID

node handles request


The hub was implemented as a simple python scripts. All it does is receive the node id authorization requests and responds with an ACK or NACK. In order for each node to receive its ACK and not an ACK intended for another node, the 4 upper bits of each ACK contain the node request ID.