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.

161 lines
7.4 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=8; // 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. //-------------------------------------------------------------
  24. // CONCRETE HOST
  25. module host0
  26. x : [0..TIME_MAX_X]; // first clock of the host
  27. y : [0..TIME_MAX_Y]; // second clock of the host
  28. coll : [0..MAXCOLL]; // number of address collisions
  29. probes : [0..K]; // counter (number of probes sent)
  30. mess : [0..1]; // need to send a message or not
  31. defend : [0..1]; // defend (if =1, try to defend IP address)
  32. ip : [1..2]; // ip address (1 - in use & 2 - fresh)
  33. l : [0..4] init 1; // location
  34. // 0 : RECONFIGURE
  35. // 1 : RANDOM
  36. // 2 : WAITSP
  37. // 3 : WAITSG
  38. // 4 : USE
  39. // RECONFIGURE
  40. [reset] l=0 -> (l'=1);
  41. // RANDOM (choose IP address)
  42. [rec0] (l=1) -> true; // get message (ignore since have no ip address)
  43. [rec1] (l=1) -> true; // get message (ignore since have no ip address)
  44. // small number of collisions (choose straight away)
  45. [] l=1 & coll<MAXCOLL -> 1/3*old : (l'=2) & (ip'=1) & (x'=0)
  46. + 1/3*old : (l'=2) & (ip'=1) & (x'=1)
  47. + 1/3*old : (l'=2) & (ip'=1) & (x'=2)
  48. + 1/3*new : (l'=2) & (ip'=2) & (x'=0)
  49. + 1/3*new : (l'=2) & (ip'=2) & (x'=1)
  50. + 1/3*new : (l'=2) & (ip'=2) & (x'=2);
  51. // large number of collisions: (wait for LONGWAIT)
  52. [time] l=1 & coll=MAXCOLL & x<LONGWAIT -> (x'=min(x+1,TIME_MAX_X));
  53. [] l=1 & coll=MAXCOLL & x=LONGWAIT -> 1/3*old : (l'=2) & (ip'=1) & (x'=0)
  54. + 1/3*old : (l'=2) & (ip'=1) & (x'=1)
  55. + 1/3*old : (l'=2) & (ip'=1) & (x'=2)
  56. + 1/3*new : (l'=2) & (ip'=2) & (x'=0)
  57. + 1/3*new : (l'=2) & (ip'=2) & (x'=1)
  58. + 1/3*new : (l'=2) & (ip'=2) & (x'=2);
  59. // WAITSP
  60. // let time pass
  61. [time] l=2 & x<2 -> (x'=min(x+1,2));
  62. // send probe
  63. [send1] l=2 & ip=1 & x=2 & probes<K -> (x'=0) & (probes'=probes+1);
  64. [send2] l=2 & ip=2 & x=2 & probes<K -> (x'=0) & (probes'=probes+1);
  65. // sent K probes and waited 2 seconds
  66. [] l=2 & x=2 & probes=K -> (l'=3) & (probes'=0) & (coll'=0) & (x'=0);
  67. // get message and ip does not match: ignore
  68. [rec0] l=2 & ip!=0 -> (l'=l);
  69. [rec1] l=2 & ip!=1 -> (l'=l);
  70. // get a message with matching ip: reconfigure
  71. [rec1] l=2 & ip=1 -> (l'=0) & (coll'=min(coll+1,MAXCOLL)) & (x'=0) & (probes'=0);
  72. // WAITSG (sends two gratuitious arp probes)
  73. // time passage
  74. [time] l=3 & mess=0 & defend=0 & x<CONSEC -> (x'=min(x+1,TIME_MAX_X));
  75. [time] l=3 & mess=0 & defend=1 & x<CONSEC -> (x'=min(x+1,TIME_MAX_X)) & (y'=min(y+1,DEFEND));
  76. // receive message and same ip: defend
  77. [rec1] l=3 & mess=0 & ip=1 & (defend=0 | y>=DEFEND) -> (defend'=1) & (mess'=1) & (y'=0);
  78. // receive message and same ip: defer
  79. [rec1] l=3 & mess=0 & ip=1 & (defend=0 | y<DEFEND) -> (l'=0) & (probes'=0) & (defend'=0) & (x'=0) & (y'=0);
  80. // receive message and different ip
  81. [rec0] l=3 & mess=0 & ip!=0 -> (l'=l);
  82. [rec1] l=3 & mess=0 & ip!=1 -> (l'=l);
  83. // send probe reply or message for defence
  84. [send1] l=3 & ip=1 & mess=1 -> (mess'=0);
  85. [send2] l=3 & ip=2 & mess=1 -> (mess'=0);
  86. // send first gratuitous arp message
  87. [send1] l=3 & ip=1 & mess=0 & x=CONSEC & probes<1 -> (x'=0) & (probes'=probes+1);
  88. [send2] l=3 & ip=2 & mess=0 & x=CONSEC & probes<1 -> (x'=0) & (probes'=probes+1);
  89. // send second gratuitous arp message (move to use)
  90. [send1] l=3 & ip=1 & mess=0 & x=CONSEC & probes=1 -> (l'=4) & (x'=0) & (y'=0) & (probes'=0);
  91. [send2] l=3 & ip=2 & mess=0 & x=CONSEC & probes=1 -> (l'=4) & (x'=0) & (y'=0) & (probes'=0);
  92. // USE (only interested in reaching this state so do not need to add anything here)
  93. [] l=4 -> true;
  94. endmodule
  95. //-------------------------------------------------------------
  96. // error automaton for the environment assumption
  97. // do not get a reply when K probes are sent
  98. const int M=1; // time between sending and receiving a message
  99. module env_error8
  100. env : [0..1]; // 0 active and 1 done
  101. k : [0..8]; // counts the number of messages sent
  102. c1 : [0..M+1]; // time since first message
  103. c2 : [0..M+1]; // time since second message
  104. c3 : [0..M+1]; // time since third message
  105. c4 : [0..M+1]; // time since fourth message
  106. c5 : [0..M+1]; // time since fifth message
  107. c6 : [0..M+1]; // time since sixth message
  108. c7 : [0..M+1]; // time since seventh message
  109. c8 : [0..M+1]; // time since eighth message
  110. error : [0..1];
  111. // message with new ip address arrives so done
  112. [send2] error=0 & env=0 -> (env'=1);
  113. // message with old ip address arrives so count
  114. [send1] error=0 & env=0 -> (k'=min(k+1,K));
  115. // time passgae so update relevant clocks
  116. [time] error=0 & env=0 & k=0 -> true;
  117. [time] error=0 & env=0 & k=1 & min(c1,c2,c3,c4,c5,c6,c7,c8)<M -> (c1'=min(c1+1,M+1));
  118. [time] error=0 & env=0 & k=2 & min(c1,c2,c3,c4,c5,c6,c7,c8)<M -> (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1));
  119. [time] error=0 & env=0 & k=3 & min(c1,c2,c3,c4,c5,c6,c7,c8)<M -> (c1'=min(c1+1,M+1)) & (c2'=min(c2+1,M+1)) & (c3'=min(c3+1,M+1));
  120. [time] error=0 & env=0 & k=4 & min(c1,c2,c3,c4,c5,c6,c7,c8)<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));
  121. [time] error=0 & env=0 & k=5 & min(c1,c2,c3,c4,c5,c6,c7,c8)<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)) & (c5'=min(c5+1,M+1));
  122. [time] error=0 & env=0 & k=6 & min(c1,c2,c3,c4,c5,c6,c7,c8)<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)) & (c5'=min(c5+1,M+1)) & (c6'=min(c6+1,M+1));
  123. [time] error=0 & env=0 & k=7 & min(c1,c2,c3,c4,c5,c6,c7,c8)<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)) & (c5'=min(c5+1,M+1)) & (c6'=min(c6+1,M+1)) & (c7'=min(c7+1,M+1));
  124. [time] error=0 & env=0 & k=8 & min(c1,c2,c3,c4,c5,c6,c7,c8)<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)) & (c5'=min(c5+1,M+1)) & (c6'=min(c6+1,M+1)) & (c7'=min(c7+1,M+1)) & (c8'=min(c8+1,M+1));
  125. // all clocks reached their bound so an error
  126. [time] error=0 & env=0 & min(c1,c2,c3,c4,c5,c6,c7,c8)=M -> (error'=1);
  127. // send a reply (then done)
  128. [rec1] error=0 & env=0 & k>0 & min(c1,c2,c3,c4,c5,c6,c7,c8)<=M -> (env'=1);
  129. // finished so any action can be performed
  130. [time] error=1 | env=1 -> true;
  131. [send1] error=1 | env=1 -> true;
  132. [send2] error=1 | env=1 -> true;
  133. [rec1] error=1 | env=1 -> true;
  134. endmodule