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.

64 lines
1.4 KiB

  1. // Modest MDP model of the bounded exponential backoff procedure (BEB)
  2. // [BFHH11]
  3. action tick, tack, tock;
  4. const int K = 4; // maximum value for backoff
  5. const int N = 3; // number of tries before giving up
  6. const int H = 3; // number of hosts (must correspond to the number of Host() instantiations in the global composition)
  7. int(0..2) cr; // count how many hosts attempt to seize the line in a slot (zero, one, many)
  8. bool line_seized;
  9. bool gave_up;
  10. property LineSeized = Pmax(<> line_seized); // some host managed to seize the line before any other gave up
  11. property GaveUp = Pmax(<> gave_up); // some host gave up before any other managed to seize the line (does not work with POR)
  12. process Clock()
  13. {
  14. tick; tack; tau {= cr = 0 =}; tock; Clock()
  15. }
  16. process Host()
  17. {
  18. int(0..N) na; // nr_attempts 0..N
  19. int(0..K) ev = 2; // exp_val 0..K
  20. int(0..K) wt; // slots_to_wait 0..K
  21. do
  22. {
  23. if(wt > 0)
  24. {
  25. // wait this slot
  26. tick {= wt-- =}
  27. }
  28. else
  29. {
  30. tau {= cr = min(2, cr + 1) =}; // attempt to seize the line
  31. tick;
  32. if(cr == 1)
  33. {
  34. // someone managed to seize the line
  35. tau {= line_seized = true =}; stop
  36. }
  37. else if(na >= N)
  38. {
  39. // maximum number of attempts exceeded
  40. tau {= gave_up = true =}; stop
  41. }
  42. else
  43. {
  44. // backoff
  45. tau {= na++, wt = DiscreteUniform(0, max(0, ev - 1)), ev = min(2 * ev, K) =}
  46. }
  47. };
  48. tack; tock
  49. }
  50. }
  51. par
  52. {
  53. :: Clock()
  54. :: Host()
  55. :: Host()
  56. :: Host()
  57. }