<?xml version="1.0" encoding="utf-8"?><!DOCTYPE nta PUBLIC '-//Uppaal Team//DTD Flat System 1.1//EN' 'http://www.it.uu.se/research/group/darts/uppaal/flat-1_1.dtd'><nta><declaration>
//Simple model of Chess Mac protocol for wireless sensor networks


//Model by Faranak Heidarian, Julian Schmaltz, Frits Vaandrager, 
//Version March 30, 2009

//CONSTANTS AND TYPES
//number of nodes; we assume N&gt;=2
const int N = 4;
//set of node identifiers
typedef int[0,N-1] Nodes;

//number of slots within one frame
const int C = 6;

//number of active slots within one frame; we assume N &lt;= n &lt;= C
const int n = 4;
//transmission slot number; we assume each node has unique active slot tsn[i] in which it transmits
const int[0,n-1] tsn[Nodes] = {0,1,2,3};

//number of clock cycles per slot
const int k0 = 21;

//guard time; we assume 0 &lt; g and 2g &lt; k0
const int g = 10;

//tail time; we assume t&gt;0 and g+t+2 &lt;= k0
const int t = 2;

//minimal time  between two clock ticks; we assume 0&lt; min
const int min = 30;

//maximal time  between two clock ticks; we assume min&lt;= max
const int max = 31;
//NB We grossly exagerate the clock drift theta; in reality it is approximately 20ppm

//CHANNELS
broadcast chan start_message[Nodes], tick[Nodes];

//STATE VARIABLES
//hardware clock of a node; to keep state space tractable
//we assume clocks are reset at the end of each slot
int[0,k0-1] clk[Nodes];

//current slot number of a node
int[0,C-1] csn[Nodes]; 

//HISTORY VARIABLES

clock y;

int[-1,C-1] last = -1;

</declaration><template><name x="5" y="5">WSN</name><parameter>const Nodes i</parameter><location id="id0" x="512" y="352"><name x="448" y="320">GO_SEND</name><urgent/></location><location id="id1" x="608" y="448"><name x="624" y="440">WAIT</name></location><location id="id2" x="704" y="352"><name x="704" y="320">SENDING</name></location><init ref="id1"/><transition><source ref="id0"/><target ref="id2"/><label kind="synchronisation" x="544" y="328">start_message[i]!</label><label kind="assignment" x="548" y="352">y :=0,
last := csn[i]</label></transition><transition><source ref="id1"/><target ref="id1"/><label kind="guard" x="544" y="544">clk[i]==k0-1</label><label kind="synchronisation" x="544" y="560">tick[i]?</label><label kind="assignment" x="544" y="576">csn[i] := (csn[i]+1) % C</label><nail x="512" y="544"/><nail x="704" y="544"/></transition><transition><source ref="id2"/><target ref="id1"/><label kind="guard" x="680" y="384">clk[i]==k0 - t -1</label><label kind="synchronisation" x="680" y="400">tick[i]?</label><label kind="comments">Transmission of the message ends Guard Time before
the end of the TX Time Slot.</label></transition><transition><source ref="id1"/><target ref="id0"/><label kind="guard" x="456" y="384">csn[i]==tsn[i]
&amp;&amp; clk[i]==g -1</label><label kind="synchronisation" x="456" y="416">tick[i]?</label><label kind="comments">Transmission of the message starts
Guard Time after the TX Time Slot
has started.</label></transition></template><template><name x="5" y="5">CLOCK</name><parameter>const Nodes i</parameter><declaration>clock x;</declaration><location id="id3" x="160" y="-24"><name x="122" y="-30">X0</name><label kind="invariant" x="88" y="-8">x &lt;= max</label></location><init ref="id3"/><transition><source ref="id3"/><target ref="id3"/><label kind="guard" x="272" y="-32">x &gt;= min</label><label kind="synchronisation" x="272" y="-16">tick[i]!</label><label kind="assignment" x="272" y="0">x := 0,
clk[i] := (clk[i] + 1) % k0</label><nail x="256" y="8"/><nail x="256" y="-24"/></transition></template><template><name>SYNCHRONIZER</name><parameter>const Nodes i</parameter><location id="id4" x="-152" y="-192"><name x="-152" y="-224">S1</name></location><location id="id5" x="-288" y="-192"><name x="-298" y="-222">S0</name></location><init ref="id5"/><transition><source ref="id4"/><target ref="id5"/><label kind="synchronisation" x="-272" y="-128">tick[i]?</label><label kind="assignment" x="-272" y="-112">clk[i]:= g+1</label><nail x="-152" y="-128"/><nail x="-288" y="-128"/></transition><transition><source ref="id5"/><target ref="id4"/><label kind="select" x="-272" y="-248">j:Nodes</label><label kind="guard" x="-272" y="-232">csn[i] &lt; n</label><label kind="synchronisation" x="-272" y="-216">start_message[j]?</label></transition></template><system>system CLOCK, WSN, SYNCHRONIZER;</system></nta>