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.

111 lines
5.4 KiB

  1. dtmc
  2. // probability of forwarding
  3. const double PF = 0.8;
  4. const double notPF = 0.2; // must be 1-PF
  5. // probability that a crowd member is bad
  6. const double badC = 0.167;
  7. // probability that a crowd member is good
  8. const double goodC = 0.833;
  9. // Total number of protocol runs to analyze
  10. const int TotalRuns = 5;
  11. // size of the crowd
  12. const int CrowdSize = 20;
  13. module crowds
  14. // protocol phase
  15. phase: [0..4] init 0;
  16. // crowd member good (or bad)
  17. good: bool init false;
  18. // number of protocol runs
  19. runCount: [0..TotalRuns] init 0;
  20. // observe_i is the number of times the attacker observed crowd member i
  21. observe0: [0..TotalRuns] init 0;
  22. observe1: [0..TotalRuns] init 0;
  23. observe2: [0..TotalRuns] init 0;
  24. observe3: [0..TotalRuns] init 0;
  25. observe4: [0..TotalRuns] init 0;
  26. observe5: [0..TotalRuns] init 0;
  27. observe6: [0..TotalRuns] init 0;
  28. observe7: [0..TotalRuns] init 0;
  29. observe8: [0..TotalRuns] init 0;
  30. observe9: [0..TotalRuns] init 0;
  31. observe10: [0..TotalRuns] init 0;
  32. observe11: [0..TotalRuns] init 0;
  33. observe12: [0..TotalRuns] init 0;
  34. observe13: [0..TotalRuns] init 0;
  35. observe14: [0..TotalRuns] init 0;
  36. observe15: [0..TotalRuns] init 0;
  37. observe16: [0..TotalRuns] init 0;
  38. observe17: [0..TotalRuns] init 0;
  39. observe18: [0..TotalRuns] init 0;
  40. observe19: [0..TotalRuns] init 0;
  41. // the last seen crowd member
  42. lastSeen: [0..CrowdSize - 1] init 0;
  43. // get the protocol started
  44. [] phase=0 & runCount<TotalRuns -> 1:(phase'=1) & (runCount'=runCount+1) & (lastSeen'=0);
  45. // decide whether crowd member is good or bad according to given probabilities
  46. [] phase=1 -> goodC : (phase'=2) & (good'=true) + badC : (phase'=2) & (good'=false);
  47. // if the current member is a good member, update the last seen index (chosen uniformly)
  48. [] phase=2 & good -> 1/20 : (lastSeen'=0) & (phase'=3) + 1/20 : (lastSeen'=1) & (phase'=3) + 1/20 : (lastSeen'=2) & (phase'=3) + 1/20 : (lastSeen'=3) & (phase'=3) + 1/20 : (lastSeen'=4) & (phase'=3) + 1/20 : (lastSeen'=5) & (phase'=3) + 1/20 : (lastSeen'=6) & (phase'=3) + 1/20 : (lastSeen'=7) & (phase'=3) + 1/20 : (lastSeen'=8) & (phase'=3) + 1/20 : (lastSeen'=9) & (phase'=3) + 1/20 : (lastSeen'=10) & (phase'=3) + 1/20 : (lastSeen'=11) & (phase'=3) + 1/20 : (lastSeen'=12) & (phase'=3) + 1/20 : (lastSeen'=13) & (phase'=3) + 1/20 : (lastSeen'=14) & (phase'=3) + 1/20 : (lastSeen'=15) & (phase'=3) + 1/20 : (lastSeen'=16) & (phase'=3) + 1/20 : (lastSeen'=17) & (phase'=3) + 1/20 : (lastSeen'=18) & (phase'=3) + 1/20 : (lastSeen'=19) & (phase'=3);
  49. // if the current member is a bad member, record the most recently seen index
  50. [] phase=2 & !good & lastSeen=0 & observe0 < TotalRuns -> 1:(observe0'=observe0+1) & (phase'=4);
  51. [] phase=2 & !good & lastSeen=1 & observe1 < TotalRuns -> 1:(observe1'=observe1+1) & (phase'=4);
  52. [] phase=2 & !good & lastSeen=2 & observe2 < TotalRuns -> 1:(observe2'=observe2+1) & (phase'=4);
  53. [] phase=2 & !good & lastSeen=3 & observe3 < TotalRuns -> 1:(observe3'=observe3+1) & (phase'=4);
  54. [] phase=2 & !good & lastSeen=4 & observe4 < TotalRuns -> 1:(observe4'=observe4+1) & (phase'=4);
  55. [] phase=2 & !good & lastSeen=5 & observe5 < TotalRuns -> 1:(observe5'=observe5+1) & (phase'=4);
  56. [] phase=2 & !good & lastSeen=6 & observe6 < TotalRuns -> 1:(observe6'=observe6+1) & (phase'=4);
  57. [] phase=2 & !good & lastSeen=7 & observe7 < TotalRuns -> 1:(observe7'=observe7+1) & (phase'=4);
  58. [] phase=2 & !good & lastSeen=8 & observe8 < TotalRuns -> 1:(observe8'=observe8+1) & (phase'=4);
  59. [] phase=2 & !good & lastSeen=9 & observe9 < TotalRuns -> 1:(observe9'=observe9+1) & (phase'=4);
  60. [] phase=2 & !good & lastSeen=10 & observe10 < TotalRuns -> 1:(observe10'=observe10+1) & (phase'=4);
  61. [] phase=2 & !good & lastSeen=11 & observe11 < TotalRuns -> 1:(observe11'=observe11+1) & (phase'=4);
  62. [] phase=2 & !good & lastSeen=12 & observe12 < TotalRuns -> 1:(observe12'=observe12+1) & (phase'=4);
  63. [] phase=2 & !good & lastSeen=13 & observe13 < TotalRuns -> 1:(observe13'=observe13+1) & (phase'=4);
  64. [] phase=2 & !good & lastSeen=14 & observe14 < TotalRuns -> 1:(observe14'=observe14+1) & (phase'=4);
  65. [] phase=2 & !good & lastSeen=15 & observe15 < TotalRuns -> 1:(observe15'=observe15+1) & (phase'=4);
  66. [] phase=2 & !good & lastSeen=16 & observe16 < TotalRuns -> 1:(observe16'=observe16+1) & (phase'=4);
  67. [] phase=2 & !good & lastSeen=17 & observe17 < TotalRuns -> 1:(observe17'=observe17+1) & (phase'=4);
  68. [] phase=2 & !good & lastSeen=18 & observe18 < TotalRuns -> 1:(observe18'=observe18+1) & (phase'=4);
  69. [] phase=2 & !good & lastSeen=19 & observe19 < TotalRuns -> 1:(observe19'=observe19+1) & (phase'=4);
  70. // good crowd members forward with probability PF and deliver otherwise
  71. [] phase=3 -> PF : (phase'=1) + notPF : (phase'=4);
  72. // deliver the message and start over
  73. [] phase=4 -> 1:(phase'=0);
  74. endmodule
  75. label "observe0Greater1" = observe0 > 1;
  76. label "observeIGreater1" = observe1 > 1 | observe2 > 1 | observe3 > 1 | observe4 > 1 | observe5 > 1 | observe6 > 1 | observe7 > 1 | observe8 > 1 | observe9 > 1 | observe10 > 1 | observe11 > 1 | observe12 > 1 | observe13 > 1 | observe14 > 1 | observe15 > 1 | observe16 > 1 | observe17 > 1 | observe18 > 1 | observe19 > 1;
  77. label "observeOnlyTrueSender" = observe0 > 1 & observe1 <= 1 & observe2 <= 1 & observe3 <= 1 & observe4 <= 1 & observe5 <= 1 & observe6 <= 1 & observe7 <= 1 & observe8 <= 1 & observe9 <= 1 & observe10 <= 1 & observe11 <= 1 & observe12 <= 1 & observe13 <= 1 & observe14 <= 1 & observe15 <= 1 & observe16 <= 1 & observe17 <= 1 & observe18 <= 1 & observe19 <= 1;