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.

174 lines
7.1 KiB

  1. // IPv4: PTA model with digitial clocks
  2. // multi-objective model of the host
  3. // gxn/dxp 28/09/09
  4. mdp
  5. //-------------------------------------------------------------
  6. // VARIABLES
  7. const int N=20; // number of abstract hosts
  8. const int K=4; // number of probes to send
  9. // PROBABILITIES
  10. const double old = N/65024; // probability pick an ip address being used
  11. //const double old = 0.5; // probability pick an ip address being used
  12. const double new = (1-old); // probability pick a new ip address
  13. // TIMING CONSTANTS
  14. const int CONSEC = 2; // time interval between sending consecutive probles
  15. const int TRANSTIME = 1; // upper bound on transmission time delay
  16. const int LONGWAIT = 60; // minimum time delay after a high number of address collisions
  17. const int DEFEND = 10;
  18. const int TIME_MAX_X = 60; // max value of clock x
  19. const int TIME_MAX_Y = 10; // max value of clock y
  20. const int TIME_MAX_Z = 1; // max value of clock z
  21. // OTHER CONSTANTS
  22. const int MAXCOLL = 10; // maximum number of collisions before long wait
  23. const int M=1; // time between sending and receiving a message
  24. const int T=10;
  25. //-------------------------------------------------------------
  26. // CONCRETE HOST
  27. module host0
  28. x : [0..TIME_MAX_X]; // first clock of the host
  29. y : [0..TIME_MAX_Y]; // second clock of the host
  30. coll : [0..MAXCOLL]; // number of address collisions
  31. probes : [0..K]; // counter (number of probes sent)
  32. mess : [0..1]; // need to send a message or not
  33. defend : [0..1]; // defend (if =1, try to defend IP address)
  34. ip : [1..2]; // ip address (1 - in use & 2 - fresh)
  35. l : [0..4] init 1; // location
  36. // 0 : RECONFIGURE
  37. // 1 : RANDOM
  38. // 2 : WAITSP
  39. // 3 : WAITSG
  40. // 4 : USE
  41. // RECONFIGURE
  42. [reset] l=0 -> (l'=1);
  43. // RANDOM (choose IP address)
  44. [rec0] (l=1) -> true; // get message (ignore since have no ip address)
  45. [rec1] (l=1) -> true; // get message (ignore since have no ip address)
  46. // small number of collisions (choose straight away)
  47. [] l=1 & coll<MAXCOLL -> 1/3*old : (l'=2) & (ip'=1) & (x'=0)
  48. + 1/3*old : (l'=2) & (ip'=1) & (x'=1)
  49. + 1/3*old : (l'=2) & (ip'=1) & (x'=2)
  50. + 1/3*new : (l'=2) & (ip'=2) & (x'=0)
  51. + 1/3*new : (l'=2) & (ip'=2) & (x'=1)
  52. + 1/3*new : (l'=2) & (ip'=2) & (x'=2);
  53. // large number of collisions: (wait for LONGWAIT)
  54. [time] l=1 & coll=MAXCOLL & x<LONGWAIT -> (x'=min(x+1,TIME_MAX_X));
  55. [] l=1 & coll=MAXCOLL & x=LONGWAIT -> 1/3*old : (l'=2) & (ip'=1) & (x'=0)
  56. + 1/3*old : (l'=2) & (ip'=1) & (x'=1)
  57. + 1/3*old : (l'=2) & (ip'=1) & (x'=2)
  58. + 1/3*new : (l'=2) & (ip'=2) & (x'=0)
  59. + 1/3*new : (l'=2) & (ip'=2) & (x'=1)
  60. + 1/3*new : (l'=2) & (ip'=2) & (x'=2);
  61. // WAITSP
  62. // let time pass
  63. [time] l=2 & x<2 -> (x'=min(x+1,2));
  64. // send probe
  65. [send1] l=2 & ip=1 & x=2 & probes<K -> (x'=0) & (probes'=probes+1);
  66. [send2] l=2 & ip=2 & x=2 & probes<K -> (x'=0) & (probes'=probes+1);
  67. // sent K probes and waited 2 seconds
  68. [configured] l=2 & x=2 & probes=K -> (l'=3) & (probes'=0) & (coll'=0) & (x'=0);
  69. // get message and ip does not match: ignore
  70. [rec0] l=2 & ip!=0 -> (l'=l);
  71. [rec1] l=2 & ip!=1 -> (l'=l);
  72. // get a message with matching ip: reconfigure
  73. [rec1] l=2 & ip=1 -> (l'=0) & (coll'=min(coll+1,MAXCOLL)) & (x'=0) & (probes'=0);
  74. // WAITSG (sends two gratuitious arp probes)
  75. // time passage
  76. [time] l=3 & mess=0 & defend=0 & x<CONSEC -> (x'=min(x+1,TIME_MAX_X));
  77. [time] l=3 & mess=0 & defend=1 & x<CONSEC -> (x'=min(x+1,TIME_MAX_X)) & (y'=min(y+1,DEFEND));
  78. // receive message and same ip: defend
  79. [rec1] l=3 & mess=0 & ip=1 & (defend=0 | y>=DEFEND) -> (defend'=1) & (mess'=1) & (y'=0);
  80. // receive message and same ip: defer
  81. [rec1] l=3 & mess=0 & ip=1 & (defend=0 | y<DEFEND) -> (l'=0) & (probes'=0) & (defend'=0) & (x'=0) & (y'=0);
  82. // receive message and different ip
  83. [rec0] l=3 & mess=0 & ip!=0 -> (l'=l);
  84. [rec1] l=3 & mess=0 & ip!=1 -> (l'=l);
  85. // send probe reply or message for defence
  86. [send1] l=3 & ip=1 & mess=1 -> (mess'=0);
  87. [send2] l=3 & ip=2 & mess=1 -> (mess'=0);
  88. // send first gratuitous arp message
  89. [send1] l=3 & ip=1 & mess=0 & x=CONSEC & probes<1 -> (x'=0) & (probes'=probes+1);
  90. [send2] l=3 & ip=2 & mess=0 & x=CONSEC & probes<1 -> (x'=0) & (probes'=probes+1);
  91. // send second gratuitous arp message (move to use)
  92. [send1] l=3 & ip=1 & mess=0 & x=CONSEC & probes=1 -> (l'=4) & (x'=0) & (y'=0) & (probes'=0);
  93. [send2] l=3 & ip=2 & mess=0 & x=CONSEC & probes=1 -> (l'=4) & (x'=0) & (y'=0) & (probes'=0);
  94. // USE (only interested in reaching this state so do not need to add anything here)
  95. [] l=4 -> true;
  96. endmodule
  97. //-------------------------------------------------------------
  98. // error automaton for the environment assumption
  99. // do not get a reply when K probes are sent
  100. module env_error4
  101. env : [0..1]; // 0 active and 1 done
  102. k : [0..4]; // counts the number of messages sent
  103. c1 : [0..M+1]; // time since first message
  104. c2 : [0..M+1]; // time since second message
  105. c3 : [0..M+1]; // time since third message
  106. c4 : [0..M+1]; // time since fourth message
  107. error : [0..1];
  108. // message with new ip address arrives so done
  109. [send2] error=0 & env=0 -> (env'=1);
  110. // message with old ip address arrives so count
  111. [send1] error=0 & env=0 -> (k'=min(k+1,K));
  112. // time passgae so update relevant clocks
  113. [time] error=0 & env=0 & k=0 -> true;
  114. [time] error=0 & env=0 & k=1 & min(c1,c2,c3,c4)<M -> (c1'=min(c1+1,M+1));
  115. [time] error=0 & env=0 & k=2 & min(c1,c2,c3,c4)<M -> (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1));
  116. [time] error=0 & env=0 & k=3 & min(c1,c2,c3,c4)<M -> (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1)) & (c3'=min(c3+1,M+1));
  117. [time] error=0 & env=0 & k=4 & min(c1,c2,c3,c4)<M -> (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1)) & (c3'=min(c3+1,M+1)) & (c4'=min(c4+1,M+1));
  118. // all clocks reached their bound so an error
  119. [time] error=0 & env=0 & min(c1,c2,c3,c4)=M -> (error'=1);
  120. // send a reply (then done)
  121. [rec1] error=0 & env=0 & k>0 & min(c1,c2,c3,c4)<=M -> (env'=1);
  122. // finished so any action can be performed
  123. [time] error=1 | env=1 -> true;
  124. [send1] error=1 | env=1 -> true;
  125. [send2] error=1 | env=1 -> true;
  126. [send2] error=1 | env=1 -> true;
  127. [rec1] error=1 | env=1 -> true;
  128. endmodule
  129. //-------------------------------------------------------------
  130. // error automaton for the time bounded assumption
  131. // host does not send configured signal within T seconds
  132. module time_error
  133. time_error : [0..1];
  134. done : [0..1];
  135. t : [0..T];
  136. [time] t<T-1 & done=0 & time_error=0 -> (t'=t+1); // time passes and bound not reached
  137. [time] t=T-1 & done=0 & time_error=0 -> (time_error'=1); // bound reached so error
  138. [configured] time_error=0 -> (done'=1); // configured within the time bound
  139. // when in error or done state can loop with either action
  140. [configured] time_error=1 | done=1 -> true;
  141. [time] time_error=1 | done=1 -> true;
  142. endmodule