You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

350 lines
21 KiB

  1. // WLAN PROTOCOL (two stations)
  2. // discrete time model
  3. // gxn/jzs 20/02/02
  4. mdp
  5. // COLLISIONS
  6. const int COL; // maximum number of collisions
  7. // TIMING CONSTRAINTS
  8. // we have used the FHSS parameters
  9. // then scaled by the value of ASLOTTIME
  10. const int ASLOTTIME = 1;
  11. const int DIFS = 3; // due to scaling can be either 2 or 3 which is modelled by a non-deterministic choice
  12. const int VULN = 1; // due to scaling can be either 0 or 1 which is modelled by a non-deterministic choice
  13. const int TRANS_TIME_MAX; // scaling up
  14. const int TRANS_TIME_MIN = 4; // scaling down
  15. const int ACK_TO = 6;
  16. const int ACK = 4; // due to scaling can be either 3 or 4 which is modelled by a non-deterministic choice
  17. const int SIFS = 1; // due to scaling can be either 0 or 1 which is modelled by a non-deterministic choice
  18. // maximum constant used in timing constraints + 1
  19. const int TIME_MAX = max(ACK_TO,TRANS_TIME_MAX)+1;
  20. // CONTENTION WINDOW
  21. // CWMIN =15 & CWMAX =1023
  22. // this means that MAX_BACKOFF IS 6
  23. const int MAX_BACKOFF = 6;
  24. //-----------------------------------------------------------------//
  25. // THE MEDIUM/CHANNEL
  26. // FORMULAE FOR THE CHANNEL
  27. // channel is busy
  28. formula busy = c1>0 | c2>0;
  29. // channel is free
  30. formula free = c1=0 & c2=0;
  31. module medium
  32. // number of collisions
  33. col : [0..COL];
  34. // medium status
  35. c1 : [0..2];
  36. c2 : [0..2];
  37. // ci corresponds to messages associated with station i
  38. // 0 nothing being sent
  39. // 1 being sent correctly
  40. // 2 being sent garbled
  41. // begin sending message and nothing else currently being sent
  42. [send1] c1=0 & c2=0 -> (c1'=1);
  43. [send2] c2=0 & c1=0 -> (c2'=1);
  44. // begin sending message and something is already being sent
  45. // in this case both messages become garbled
  46. [send1] c1=0 & c2>0 -> (c1'=2) & (c2'=2) & (col'=min(col+1,COL));
  47. [send2] c2=0 & c1>0 -> (c1'=2) & (c2'=2) & (col'=min(col+1,COL));
  48. // finish sending message
  49. [finish1] c1>0 -> (c1'=0);
  50. [finish2] c2>0 -> (c2'=0);
  51. endmodule
  52. //-----------------------------------------------------------------//
  53. // STATION 1
  54. module station1
  55. // clock for station 1
  56. x1 : [0..TIME_MAX];
  57. // local state
  58. s1 : [1..12];
  59. // 1 sense
  60. // 2 wait until free before setting backoff
  61. // 3 wait for DIFS then set slot
  62. // 4 set backoff
  63. // 5 backoff
  64. // 6 wait until free in backoff
  65. // 7 wait for DIFS then resume backoff
  66. // 8 vulnerable
  67. // 9 transmit
  68. // 11 wait for SIFS and then ACK
  69. // 10 wait for ACT_TO
  70. // 12 done
  71. // BACKOFF
  72. // separate into slots
  73. slot1 : [0..63];
  74. backoff1 : [0..15];
  75. // BACKOFF COUNTER
  76. bc1 : [0..MAX_BACKOFF];
  77. // SENSE
  78. // let time pass
  79. [time] s1=1 & x1<DIFS & free -> (x1'=min(x1+1,TIME_MAX));
  80. // ready to transmit
  81. [] s1=1 & (x1=DIFS | x1=DIFS-1) -> (s1'=8) & (x1'=0);
  82. // found channel busy so wait until free
  83. [] s1=1 & busy -> (s1'=2) & (x1'=0);
  84. // WAIT UNTIL FREE BEFORE SETTING BACKOFF
  85. // let time pass (no need for the clock x1 to change)
  86. [time] s1=2 & busy -> (s1'=2);
  87. // find that channel is free so check its free for DIFS before setting backoff
  88. [] s1=2 & free -> (s1'=3);
  89. // WAIT FOR DIFS THEN SET BACKOFF
  90. // let time pass
  91. [time] s1=3 & x1<DIFS & free -> (x1'=min(x1+1,TIME_MAX));
  92. // found channel busy so wait until free
  93. [] s1=3 & busy -> (s1'=2) & (x1'=0);
  94. // start backoff first uniformly choose slot
  95. // backoff counter 0
  96. [] s1=3 & (x1=DIFS | x1=DIFS-1) & bc1=0 -> (s1'=4) & (x1'=0) & (slot1'=0) & (bc1'=min(bc1+1,MAX_BACKOFF));
  97. // backoff counter 1
  98. [] s1=3 & (x1=DIFS | x1=DIFS-1) & bc1=1 -> 1/2 : (s1'=4) & (x1'=0) & (slot1'=0) & (bc1'=min(bc1+1,MAX_BACKOFF))
  99. + 1/2 : (s1'=4) & (x1'=0) & (slot1'=1) & (bc1'=min(bc1+1,MAX_BACKOFF));
  100. // backoff counter 2
  101. [] s1=3 & (x1=DIFS | x1=DIFS-1) & bc1=2 -> 1/4 : (s1'=4) & (x1'=0) & (slot1'=0) & (bc1'=min(bc1+1,MAX_BACKOFF))
  102. + 1/4 : (s1'=4) & (x1'=0) & (slot1'=1) & (bc1'=min(bc1+1,MAX_BACKOFF))
  103. + 1/4 : (s1'=4) & (x1'=0) & (slot1'=2) & (bc1'=min(bc1+1,MAX_BACKOFF))
  104. + 1/4 : (s1'=4) & (x1'=0) & (slot1'=3) & (bc1'=min(bc1+1,MAX_BACKOFF));
  105. // backoff counter 3
  106. [] s1=3 & (x1=DIFS | x1=DIFS-1) & bc1=3 -> 1/8 : (s1'=4) & (x1'=0) & (slot1'=0) & (bc1'=min(bc1+1,MAX_BACKOFF))
  107. + 1/8 : (s1'=4) & (x1'=0) & (slot1'=1) & (bc1'=min(bc1+1,MAX_BACKOFF))
  108. + 1/8 : (s1'=4) & (x1'=0) & (slot1'=2) & (bc1'=min(bc1+1,MAX_BACKOFF))
  109. + 1/8 : (s1'=4) & (x1'=0) & (slot1'=3) & (bc1'=min(bc1+1,MAX_BACKOFF))
  110. + 1/8 : (s1'=4) & (x1'=0) & (slot1'=4) & (bc1'=min(bc1+1,MAX_BACKOFF))
  111. + 1/8 : (s1'=4) & (x1'=0) & (slot1'=5) & (bc1'=min(bc1+1,MAX_BACKOFF))
  112. + 1/8 : (s1'=4) & (x1'=0) & (slot1'=6) & (bc1'=min(bc1+1,MAX_BACKOFF))
  113. + 1/8 : (s1'=4) & (x1'=0) & (slot1'=7) & (bc1'=min(bc1+1,MAX_BACKOFF));
  114. // backoff counter 4
  115. [] s1=3 & (x1=DIFS | x1=DIFS-1) & bc1=4 -> 1/16 : (s1'=4) & (x1'=0) & (slot1'=0 ) & (bc1'=min(bc1+1,MAX_BACKOFF))
  116. + 1/16 : (s1'=4) & (x1'=0) & (slot1'=1 ) & (bc1'=min(bc1+1,MAX_BACKOFF))
  117. + 1/16 : (s1'=4) & (x1'=0) & (slot1'=2 ) & (bc1'=min(bc1+1,MAX_BACKOFF))
  118. + 1/16 : (s1'=4) & (x1'=0) & (slot1'=3 ) & (bc1'=min(bc1+1,MAX_BACKOFF))
  119. + 1/16 : (s1'=4) & (x1'=0) & (slot1'=4 ) & (bc1'=min(bc1+1,MAX_BACKOFF))
  120. + 1/16 : (s1'=4) & (x1'=0) & (slot1'=5 ) & (bc1'=min(bc1+1,MAX_BACKOFF))
  121. + 1/16 : (s1'=4) & (x1'=0) & (slot1'=6 ) & (bc1'=min(bc1+1,MAX_BACKOFF))
  122. + 1/16 : (s1'=4) & (x1'=0) & (slot1'=7 ) & (bc1'=min(bc1+1,MAX_BACKOFF))
  123. + 1/16 : (s1'=4) & (x1'=0) & (slot1'=8 ) & (bc1'=min(bc1+1,MAX_BACKOFF))
  124. + 1/16 : (s1'=4) & (x1'=0) & (slot1'=9 ) & (bc1'=min(bc1+1,MAX_BACKOFF))
  125. + 1/16 : (s1'=4) & (x1'=0) & (slot1'=10) & (bc1'=min(bc1+1,MAX_BACKOFF))
  126. + 1/16 : (s1'=4) & (x1'=0) & (slot1'=11) & (bc1'=min(bc1+1,MAX_BACKOFF))
  127. + 1/16 : (s1'=4) & (x1'=0) & (slot1'=12) & (bc1'=min(bc1+1,MAX_BACKOFF))
  128. + 1/16 : (s1'=4) & (x1'=0) & (slot1'=13) & (bc1'=min(bc1+1,MAX_BACKOFF))
  129. + 1/16 : (s1'=4) & (x1'=0) & (slot1'=14) & (bc1'=min(bc1+1,MAX_BACKOFF))
  130. + 1/16 : (s1'=4) & (x1'=0) & (slot1'=15) & (bc1'=min(bc1+1,MAX_BACKOFF));
  131. // backoff counter 5
  132. [] s1=3 & (x1=DIFS | x1=DIFS-1) & bc1=5 -> 1/32 : (s1'=4) & (x1'=0) & (slot1'=0 ) & (bc1'=min(bc1+1,MAX_BACKOFF))
  133. + 1/32 : (s1'=4) & (x1'=0) & (slot1'=1 ) & (bc1'=min(bc1+1,MAX_BACKOFF))
  134. + 1/32 : (s1'=4) & (x1'=0) & (slot1'=2 ) & (bc1'=min(bc1+1,MAX_BACKOFF))
  135. + 1/32 : (s1'=4) & (x1'=0) & (slot1'=3 ) & (bc1'=min(bc1+1,MAX_BACKOFF))
  136. + 1/32 : (s1'=4) & (x1'=0) & (slot1'=4 ) & (bc1'=min(bc1+1,MAX_BACKOFF))
  137. + 1/32 : (s1'=4) & (x1'=0) & (slot1'=5 ) & (bc1'=min(bc1+1,MAX_BACKOFF))
  138. + 1/32 : (s1'=4) & (x1'=0) & (slot1'=6 ) & (bc1'=min(bc1+1,MAX_BACKOFF))
  139. + 1/32 : (s1'=4) & (x1'=0) & (slot1'=7 ) & (bc1'=min(bc1+1,MAX_BACKOFF))
  140. + 1/32 : (s1'=4) & (x1'=0) & (slot1'=8 ) & (bc1'=min(bc1+1,MAX_BACKOFF))
  141. + 1/32 : (s1'=4) & (x1'=0) & (slot1'=9 ) & (bc1'=min(bc1+1,MAX_BACKOFF))
  142. + 1/32 : (s1'=4) & (x1'=0) & (slot1'=10) & (bc1'=min(bc1+1,MAX_BACKOFF))
  143. + 1/32 : (s1'=4) & (x1'=0) & (slot1'=11) & (bc1'=min(bc1+1,MAX_BACKOFF))
  144. + 1/32 : (s1'=4) & (x1'=0) & (slot1'=12) & (bc1'=min(bc1+1,MAX_BACKOFF))
  145. + 1/32 : (s1'=4) & (x1'=0) & (slot1'=13) & (bc1'=min(bc1+1,MAX_BACKOFF))
  146. + 1/32 : (s1'=4) & (x1'=0) & (slot1'=14) & (bc1'=min(bc1+1,MAX_BACKOFF))
  147. + 1/32 : (s1'=4) & (x1'=0) & (slot1'=15) & (bc1'=min(bc1+1,MAX_BACKOFF))
  148. + 1/32 : (s1'=4) & (x1'=0) & (slot1'=16) & (bc1'=min(bc1+1,MAX_BACKOFF))
  149. + 1/32 : (s1'=4) & (x1'=0) & (slot1'=17) & (bc1'=min(bc1+1,MAX_BACKOFF))
  150. + 1/32 : (s1'=4) & (x1'=0) & (slot1'=18) & (bc1'=min(bc1+1,MAX_BACKOFF))
  151. + 1/32 : (s1'=4) & (x1'=0) & (slot1'=19) & (bc1'=min(bc1+1,MAX_BACKOFF))
  152. + 1/32 : (s1'=4) & (x1'=0) & (slot1'=20) & (bc1'=min(bc1+1,MAX_BACKOFF))
  153. + 1/32 : (s1'=4) & (x1'=0) & (slot1'=21) & (bc1'=min(bc1+1,MAX_BACKOFF))
  154. + 1/32 : (s1'=4) & (x1'=0) & (slot1'=22) & (bc1'=min(bc1+1,MAX_BACKOFF))
  155. + 1/32 : (s1'=4) & (x1'=0) & (slot1'=23) & (bc1'=min(bc1+1,MAX_BACKOFF))
  156. + 1/32 : (s1'=4) & (x1'=0) & (slot1'=24) & (bc1'=min(bc1+1,MAX_BACKOFF))
  157. + 1/32 : (s1'=4) & (x1'=0) & (slot1'=25) & (bc1'=min(bc1+1,MAX_BACKOFF))
  158. + 1/32 : (s1'=4) & (x1'=0) & (slot1'=26) & (bc1'=min(bc1+1,MAX_BACKOFF))
  159. + 1/32 : (s1'=4) & (x1'=0) & (slot1'=27) & (bc1'=min(bc1+1,MAX_BACKOFF))
  160. + 1/32 : (s1'=4) & (x1'=0) & (slot1'=28) & (bc1'=min(bc1+1,MAX_BACKOFF))
  161. + 1/32 : (s1'=4) & (x1'=0) & (slot1'=29) & (bc1'=min(bc1+1,MAX_BACKOFF))
  162. + 1/32 : (s1'=4) & (x1'=0) & (slot1'=30) & (bc1'=min(bc1+1,MAX_BACKOFF))
  163. + 1/32 : (s1'=4) & (x1'=0) & (slot1'=31) & (bc1'=min(bc1+1,MAX_BACKOFF));
  164. // backoff counter 6
  165. [] s1=3 & (x1=DIFS | x1=DIFS-1) & bc1=6 -> 1/64 : (s1'=4) & (x1'=0) & (slot1'=0 ) & (bc1'=min(bc1+1,MAX_BACKOFF))
  166. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=1 ) & (bc1'=min(bc1+1,MAX_BACKOFF))
  167. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=2 ) & (bc1'=min(bc1+1,MAX_BACKOFF))
  168. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=3 ) & (bc1'=min(bc1+1,MAX_BACKOFF))
  169. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=4 ) & (bc1'=min(bc1+1,MAX_BACKOFF))
  170. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=5 ) & (bc1'=min(bc1+1,MAX_BACKOFF))
  171. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=6 ) & (bc1'=min(bc1+1,MAX_BACKOFF))
  172. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=7 ) & (bc1'=min(bc1+1,MAX_BACKOFF))
  173. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=8 ) & (bc1'=min(bc1+1,MAX_BACKOFF))
  174. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=9 ) & (bc1'=min(bc1+1,MAX_BACKOFF))
  175. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=10) & (bc1'=min(bc1+1,MAX_BACKOFF))
  176. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=11) & (bc1'=min(bc1+1,MAX_BACKOFF))
  177. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=12) & (bc1'=min(bc1+1,MAX_BACKOFF))
  178. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=13) & (bc1'=min(bc1+1,MAX_BACKOFF))
  179. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=14) & (bc1'=min(bc1+1,MAX_BACKOFF))
  180. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=15) & (bc1'=min(bc1+1,MAX_BACKOFF))
  181. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=16) & (bc1'=min(bc1+1,MAX_BACKOFF))
  182. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=17) & (bc1'=min(bc1+1,MAX_BACKOFF))
  183. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=18) & (bc1'=min(bc1+1,MAX_BACKOFF))
  184. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=19) & (bc1'=min(bc1+1,MAX_BACKOFF))
  185. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=20) & (bc1'=min(bc1+1,MAX_BACKOFF))
  186. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=21) & (bc1'=min(bc1+1,MAX_BACKOFF))
  187. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=22) & (bc1'=min(bc1+1,MAX_BACKOFF))
  188. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=23) & (bc1'=min(bc1+1,MAX_BACKOFF))
  189. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=24) & (bc1'=min(bc1+1,MAX_BACKOFF))
  190. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=25) & (bc1'=min(bc1+1,MAX_BACKOFF))
  191. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=26) & (bc1'=min(bc1+1,MAX_BACKOFF))
  192. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=27) & (bc1'=min(bc1+1,MAX_BACKOFF))
  193. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=28) & (bc1'=min(bc1+1,MAX_BACKOFF))
  194. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=29) & (bc1'=min(bc1+1,MAX_BACKOFF))
  195. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=30) & (bc1'=min(bc1+1,MAX_BACKOFF))
  196. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=31) & (bc1'=min(bc1+1,MAX_BACKOFF))
  197. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=32) & (bc1'=min(bc1+1,MAX_BACKOFF))
  198. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=33) & (bc1'=min(bc1+1,MAX_BACKOFF))
  199. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=34) & (bc1'=min(bc1+1,MAX_BACKOFF))
  200. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=35) & (bc1'=min(bc1+1,MAX_BACKOFF))
  201. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=36) & (bc1'=min(bc1+1,MAX_BACKOFF))
  202. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=37) & (bc1'=min(bc1+1,MAX_BACKOFF))
  203. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=38) & (bc1'=min(bc1+1,MAX_BACKOFF))
  204. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=39) & (bc1'=min(bc1+1,MAX_BACKOFF))
  205. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=40) & (bc1'=min(bc1+1,MAX_BACKOFF))
  206. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=41) & (bc1'=min(bc1+1,MAX_BACKOFF))
  207. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=42) & (bc1'=min(bc1+1,MAX_BACKOFF))
  208. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=43) & (bc1'=min(bc1+1,MAX_BACKOFF))
  209. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=44) & (bc1'=min(bc1+1,MAX_BACKOFF))
  210. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=45) & (bc1'=min(bc1+1,MAX_BACKOFF))
  211. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=46) & (bc1'=min(bc1+1,MAX_BACKOFF))
  212. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=47) & (bc1'=min(bc1+1,MAX_BACKOFF))
  213. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=48) & (bc1'=min(bc1+1,MAX_BACKOFF))
  214. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=49) & (bc1'=min(bc1+1,MAX_BACKOFF))
  215. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=50) & (bc1'=min(bc1+1,MAX_BACKOFF))
  216. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=51) & (bc1'=min(bc1+1,MAX_BACKOFF))
  217. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=52) & (bc1'=min(bc1+1,MAX_BACKOFF))
  218. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=53) & (bc1'=min(bc1+1,MAX_BACKOFF))
  219. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=54) & (bc1'=min(bc1+1,MAX_BACKOFF))
  220. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=55) & (bc1'=min(bc1+1,MAX_BACKOFF))
  221. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=56) & (bc1'=min(bc1+1,MAX_BACKOFF))
  222. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=57) & (bc1'=min(bc1+1,MAX_BACKOFF))
  223. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=58) & (bc1'=min(bc1+1,MAX_BACKOFF))
  224. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=59) & (bc1'=min(bc1+1,MAX_BACKOFF))
  225. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=60) & (bc1'=min(bc1+1,MAX_BACKOFF))
  226. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=61) & (bc1'=min(bc1+1,MAX_BACKOFF))
  227. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=62) & (bc1'=min(bc1+1,MAX_BACKOFF))
  228. + 1/64 : (s1'=4) & (x1'=0) & (slot1'=63) & (bc1'=min(bc1+1,MAX_BACKOFF));
  229. // SET BACKOFF (no time can pass)
  230. // chosen slot now set backoff
  231. [] s1=4 -> 1/16 : (s1'=5) & (backoff1'=0 )
  232. + 1/16 : (s1'=5) & (backoff1'=1 )
  233. + 1/16 : (s1'=5) & (backoff1'=2 )
  234. + 1/16 : (s1'=5) & (backoff1'=3 )
  235. + 1/16 : (s1'=5) & (backoff1'=4 )
  236. + 1/16 : (s1'=5) & (backoff1'=5 )
  237. + 1/16 : (s1'=5) & (backoff1'=6 )
  238. + 1/16 : (s1'=5) & (backoff1'=7 )
  239. + 1/16 : (s1'=5) & (backoff1'=8 )
  240. + 1/16 : (s1'=5) & (backoff1'=9 )
  241. + 1/16 : (s1'=5) & (backoff1'=10)
  242. + 1/16 : (s1'=5) & (backoff1'=11)
  243. + 1/16 : (s1'=5) & (backoff1'=12)
  244. + 1/16 : (s1'=5) & (backoff1'=13)
  245. + 1/16 : (s1'=5) & (backoff1'=14)
  246. + 1/16 : (s1'=5) & (backoff1'=15);
  247. // BACKOFF
  248. // let time pass
  249. [time] s1=5 & x1<ASLOTTIME & free -> (x1'=min(x1+1,TIME_MAX));
  250. // decrement backoff
  251. [] s1=5 & x1=ASLOTTIME & backoff1>0 -> (s1'=5) & (x1'=0) & (backoff1'=backoff1-1);
  252. [] s1=5 & x1=ASLOTTIME & backoff1=0 & slot1>0 -> (s1'=5) & (x1'=0) & (backoff1'=15) & (slot1'=slot1-1);
  253. // finish backoff
  254. [] s1=5 & x1=ASLOTTIME & backoff1=0 & slot1=0 -> (s1'=8) & (x1'=0);
  255. // found channel busy
  256. [] s1=5 & busy -> (s1'=6) & (x1'=0);
  257. // WAIT UNTIL FREE IN BACKOFF
  258. // let time pass (no need for the clock x1 to change)
  259. [time] s1=6 & busy -> (s1'=6);
  260. // find that channel is free
  261. [] s1=6 & free -> (s1'=7);
  262. // WAIT FOR DIFS THEN RESUME BACKOFF
  263. // let time pass
  264. [time] s1=7 & x1<DIFS & free -> (x1'=min(x1+1,TIME_MAX));
  265. // resume backoff (start again from previous backoff)
  266. [] s1=7 & (x1=DIFS | x1=DIFS-1) -> (s1'=5) & (x1'=0);
  267. // found channel busy
  268. [] s1=7 & busy -> (s1'=6) & (x1'=0);
  269. // VULNERABLE
  270. // let time pass
  271. [time] s1=8 & x1<VULN -> (x1'=min(x1+1,TIME_MAX));
  272. // move to transmit
  273. [send1] s1=8 & (x1=VULN | x1=VULN-1) -> (s1'=9) & (x1'=0);
  274. // TRANSMIT
  275. // let time pass
  276. [time] s1=9 & x1<TRANS_TIME_MAX -> (x1'=min(x1+1,TIME_MAX));
  277. // finish transmission successful
  278. [finish1] s1=9 & x1>=TRANS_TIME_MIN & c1=1 -> (s1'=10) & (x1'=0);
  279. // finish transmission garbled
  280. [finish1] s1=9 & x1>=TRANS_TIME_MIN & c1=2 -> (s1'=11) & (x1'=0);
  281. // WAIT FOR SIFS THEN WAIT FOR ACK
  282. // WAIT FOR SIFS i.e. c1=0
  283. // check channel and busy: go into backoff
  284. [] s1=10 & c1=0 & x1=0 & busy -> (s1'=2);
  285. // check channel and free: let time pass
  286. [time] s1=10 & c1=0 & x1=0 & free -> (x1'=min(x1+1,TIME_MAX));
  287. // let time pass
  288. // following guard is always false as SIFS=1
  289. // [time] s1=10 & c1=0 & x1>0 & x1<SIFS -> (x1'=min(x1+1,TIME_MAX));
  290. // ack is sent after SIFS (since SIFS-1=0 add condition that channel is free)
  291. [send1] s1=10 & c1=0 & (x1=SIFS | (x1=SIFS-1 & free)) -> (s1'=10) & (x1'=0);
  292. // WAIT FOR ACK i.e. c1=1
  293. // let time pass
  294. [time] s1=10 & c1=1 & x1<ACK -> (x1'=min(x1+1,TIME_MAX));
  295. // get acknowledgement so packet sent correctly and move to done
  296. [finish1] s1=10 & c1=1 & (x1=ACK | x1=ACK-1) -> (s1'=12) & (x1'=0) & (bc1'=0);
  297. // WAIT FOR ACK_TO
  298. // check channel and busy: go into backoff
  299. [] s1=11 & x1=0 & busy -> (s1'=2);
  300. // check channel and free: let time pass
  301. [time] s1=11 & x1=0 & free -> (x1'=min(x1+1,TIME_MAX));
  302. // let time pass
  303. [time] s1=11 & x1>0 & x1<ACK_TO -> (x1'=min(x1+1,TIME_MAX));
  304. // no acknowledgement (go to backoff waiting DIFS first)
  305. [] s1=11 & x1=ACK_TO -> (s1'=3) & (x1'=0);
  306. // DONE
  307. [time] s1=12 -> (s1'=12);
  308. endmodule
  309. // ---------------------------------------------------------------------------- //
  310. // STATION 2 (rename STATION 1)
  311. module
  312. station2=station1[x1=x2,
  313. s1=s2,
  314. s2=s1,
  315. c1=c2,
  316. c2=c1,
  317. slot1=slot2,
  318. backoff1=backoff2,
  319. bc1=bc2,
  320. send1=send2,
  321. finish1=finish2]
  322. endmodule
  323. // ---------------------------------------------------------------------------- //
  324. label "twoCollisions" = col=2;
  325. label "fourCollisions" = col=4;
  326. label "sixCollisions" = col=6;