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.

136 lines
2.7 KiB

  1. // bounded retransmission protocol [D'AJJL01]
  2. // gxn/dxp 23/05/2001
  3. dtmc
  4. // number of chunks
  5. const int N;
  6. // maximum number of retransmissions
  7. const int MAX;
  8. module sender
  9. s : [0..6];
  10. // 0 idle
  11. // 1 next_frame
  12. // 2 wait_ack
  13. // 3 retransmit
  14. // 4 success
  15. // 5 error
  16. // 6 wait sync
  17. srep : [0..3];
  18. // 0 bottom
  19. // 1 not ok (nok)
  20. // 2 do not know (dk)
  21. // 3 ok (ok)
  22. nrtr : [0..MAX];
  23. i : [0..N];
  24. bs : bool;
  25. s_ab : bool;
  26. fs : bool;
  27. ls : bool;
  28. // idle
  29. [NewFile] (s=0) -> (s'=1) & (i'=1) & (srep'=0);
  30. // next_frame
  31. [aF] (s=1) -> (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=0);
  32. // wait_ack
  33. [aB] (s=2) -> (s'=4) & (s_ab'=!s_ab);
  34. [TO_Msg] (s=2) -> (s'=3);
  35. [TO_Ack] (s=2) -> (s'=3);
  36. // retransmit
  37. [aF] (s=3) & (nrtr<MAX) -> (s'=2) & (fs'=(i=1)) & (ls'=(i=N)) & (bs'=s_ab) & (nrtr'=nrtr+1);
  38. [] (s=3) & (nrtr=MAX) & (i<N) -> (s'=5) & (srep'=1);
  39. [] (s=3) & (nrtr=MAX) & (i=N) -> (s'=5) & (srep'=2);
  40. // success
  41. [] (s=4) & (i<N) -> (s'=1) & (i'=i+1);
  42. [] (s=4) & (i=N) -> (s'=0) & (srep'=3);
  43. // error
  44. [SyncWait] (s=5) -> (s'=6);
  45. // wait sync
  46. [SyncWait] (s=6) -> (s'=0) & (s_ab'=false);
  47. endmodule
  48. module receiver
  49. r : [0..5];
  50. // 0 new_file
  51. // 1 fst_safe
  52. // 2 frame_received
  53. // 3 frame_reported
  54. // 4 idle
  55. // 5 resync
  56. rrep : [0..4];
  57. // 0 bottom
  58. // 1 fst
  59. // 2 inc
  60. // 3 ok
  61. // 4 nok
  62. fr : bool;
  63. lr : bool;
  64. br : bool;
  65. r_ab : bool;
  66. recv : bool;
  67. // new_file
  68. [SyncWait] (r=0) -> (r'=0);
  69. [aG] (r=0) -> (r'=1) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T);
  70. // fst_safe_frame
  71. [] (r=1) -> (r'=2) & (r_ab'=br);
  72. // frame_received
  73. [] (r=2) & (r_ab=br) & (fr=true) & (lr=false) -> (r'=3) & (rrep'=1);
  74. [] (r=2) & (r_ab=br) & (fr=false) & (lr=false) -> (r'=3) & (rrep'=2);
  75. [] (r=2) & (r_ab=br) & (fr=false) & (lr=true) -> (r'=3) & (rrep'=3);
  76. [aA] (r=2) & !(r_ab=br) -> (r'=4);
  77. // frame_reported
  78. [aA] (r=3) -> (r'=4) & (r_ab'=!r_ab);
  79. // idle
  80. [aG] (r=4) -> (r'=2) & (fr'=fs) & (lr'=ls) & (br'=bs) & (recv'=T);
  81. [SyncWait] (r=4) & (ls=true) -> (r'=5);
  82. [SyncWait] (r=4) & (ls=false) -> (r'=5) & (rrep'=4);
  83. // resync
  84. [SyncWait] (r=5) -> (r'=0) & (rrep'=0);
  85. endmodule
  86. module checker // prevents more than one frame being set
  87. T : bool;
  88. [NewFile] (T=false) -> (T'=true);
  89. endmodule
  90. module channelK
  91. k : [0..2];
  92. // idle
  93. [aF] (k=0) -> 0.98 : (k'=1) + 0.02 : (k'=2);
  94. // sending
  95. [aG] (k=1) -> (k'=0);
  96. // lost
  97. [TO_Msg] (k=2) -> (k'=0);
  98. endmodule
  99. module channelL
  100. l : [0..2];
  101. // idle
  102. [aA] (l=0) -> 0.99 : (l'=1) + 0.01 : (l'=2);
  103. // sending
  104. [aB] (l=1) -> (l'=0);
  105. // lost
  106. [TO_Ack] (l=2) -> (l'=0);
  107. endmodule
  108. rewards
  109. [aF] i=1 : 1;
  110. endrewards
  111. label "target" = s=5;