Skip to main content
. 2018 Nov 8;18(11):3829. doi: 10.3390/s18113829
Algorithm 1. Processing of SUBMSG Message
/*Upon a cluster node vx receiving a SUBMSG message from the CH node vIDi*/
flg = false; // flg records whether the accusation in the SUBMSG message is true.
if (rcd = 0)
 if (the z nodes to be substituted did not send their kjP to vIDi) flg = true;
else if (rcd = 1)
 if (the z nodes to be substituted did not provide their σj or provided incorrect σj) flg = true;
if (flg = false)
 Perform Algorithm 3 to substitute vIDi;
else {
 for (each node vIDm to be substituted) {
  TVIDm = TVIDm − 0.2;
  if (TVIDm < TTv && NAIDm < Nc/2) {
   Broadcast an ALARM message for vIDm;
   vx, and each cluster node that hears the ALARM message, executes Algorithm 2;
  }
 }//end for
 if (the number of trusted non-participating cluster nodes < z) {
  Fail_flag = true; // Report generation fails.
  Cancel the timer TRG;
 }
 else {
  Select the z trusted non-participating cluster nodes, whose IDs are closer to hv than the others, to participate in report generation;
  if (vx is a new participating node) {
   Pick kx in [1, q − 1] and send kxP to vIDi;
   Compute σx after receiving X(R);
   Send σx to vIDi;
  }
  else if (vx is a participating node that has not been substituted) {
   Recompute σx after receiving X(R);
   Send σx to vIDi;
  }
 }
}