## 4 DASH7 Alliance Mode
### Implementation Details
Second, as only a certain group of nodes will engage in replying to a certain query and queries can be done incrementally, the congestion probability in the channel access mechanism is minimized. Thus, using the query system not only improves the significance of the received data, but also enhances the network performance and reduces the energy consumption of the nodes. To implement the query system, a query template is defined at the transport layer. The query template is a variable length payload that is transported on top of the D7A network protocol (D7 ANP) using foreground frames. Queries can be global or local depending on the nodes being addressed at the network layer, e.g., if the destination address at the data-link layer is broadcast or multicast, respectively. The variable length payload of a query template is composed of four fields: the compare length (one byte), the compare code (one byte), the compare mask (n bytes) and the compare value (n bytes). First, the compare length determines the length of the mask and the compare values fields in the query. Second,  
Figure 7: Forward error correction (FEC) coding schemes with the convolutional encoder and matrix interleaver. the compare code enables to select the compare type and operation. The supported compare types are non-null check (if the data exists), arithmetic comparison, string comparison and custom. In turn, the supported operations for arithmetic comparison are inequality, equality, less than, less or equal than, greater than and greater or equal than. Regarding the string comparison, the process is done bit by bit and a threshold can be defined to trigger a match. Third, the compare mask is the bitmask that will be applied to the compare value to trigger a match with the local data. Finally, the compare value is the data with which the local value will be compared after applying the compare mask. Finally, another key aspect to implement D7 AM consists in maintaining synchronization among the nodes that form the network to ensure proper protocol operation, e.g., the receiver is in receive mode before the transmitter starts transmitting. The protocol operation is based on a common knowledge of time, the tick or ti, which is defined as 32 ticks at 32.768 Hz (0.9765 ms) and needs to be shared by all nodes in the network. However, every node derives the tick reference from its own clock source, and thus, divergences may exist, due to static effects and the dynamic effects of crystals. Regarding static effects, differences in crystal construction can make each individual clock tick at different rates. For example, two clocks rated at 10 ppm can drift up to 20 ppm with respect to each other. Regarding dynamic effects, aging and temperature also effect the rate at which two clocks drift with respect to each other. Regarding aging, as the crystal vibrates, the friction affects its stability and accuracy, thus leading to relative drift. Regarding temperature, a crystal placed in an area 20 \({}^{\circ}\)C colder than another crystal will lead to a relative drift of around \(-\)15 \(\mu\)s per second. However, it is important to take into account that D7 AM operation does not have the same stringent requirements as TSCH because time synchronization is _ad hoc_. That is, synchronization happens every time a network event is triggered and only needs to be maintained for the duration of such an event, which typically lasts for a time shorter than clock drifts relative to each other.