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.

153 lines
6.2 KiB

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