Randomize Period for Sending Packet

Channel Distribution in TSCH Network


TSCH network uses channel hopping technique to spread packets on different channels to against multiple pass fading and external interference. To make sure the channels used by the slots, with same slotoffset at each slotframe, are different, a primary number of slotframe length is required to be used. In the case 16 channels, those channels are distributed in 16 slotframes in sequence. For example in the figure below, a channel hopping sequence of [5,6,12,7,15,4,14,11,8,0,1,2,13,3,9,10] are used, the slotframe length is 17. Slot with offset 0 are used for sending packets. All 16 channels are used in 16 serial slotframes and it's repeated at next 16 slotframes.

Randomize Packet Sending Period


Periodically sending packet is like sampling a time point among the timezone that 16 slotframes repeat over and over. To make sure the packets periodically generated are sent on all 16 channels evenly, we need to randomize the period to cover the 16 slotframes long duration.

In case the sending period is shorter than 16 slotframes. The period can be randomized as:

RandomizedPeriod = originalPeriod/2 + originalPeriod%openrandom_get16b();

In case it's longer than 16 lsotframes, it can be randomized as:

RandomizedPeriod = originalPeriod-16slotframelength/2+openrandom_get16b()%16slotframelength;

The related function doing this job is called: openrandom_getRandomizePeriod  which can be found at: https://github.com/openwsn-berkeley/openwsn-fw/blob/develop/openstack/cross-layers/openrandom.c#L34