Code Search for Developers
 
 
  

quantify_faults.pl from EmStar at Krugle


Show quantify_faults.pl syntax highlighted

#!/usr/bin/perl
# NR NOTE: right now, it considers ANY Sympathy notification
#   not just Root notifications. Thats probably not the right
#   thing to do.
# We only start counting faults once the fault has been injected - 
#   is that fair? yes because fault injection time happens at different
#   times so simulations naturally last longer. Only way to normalize
#   is to start from when fault is injected.

# Include all faults recorded in a time-slice, don't just stop 
#   once the correct fault is detected.

if ($#ARGV != 0) {
  die "Usage: perl quantify_faults.pl <input_file>\n";
}

$input = $ARGV[0];
open (IN, $input) || die ("Could not open file: $input\n");

my $inject_time = -1;
my $SYMPATHY = 0;
my $CONFIDENCE = 1;

for ($i = 0; $i <= $CONFIDENCE; $i++) {
  $detect_time[$i] = -1;
  $detect_faults[$i] = 0;
  $last_fault_time[$i] = -1;
  $last_fault_node[$i] = -1;
  $suppressed_faults[$i] = 0;
}

sub calculate_time {
  my $index = $SYMPATHY;

  if ($type =~ /C/) {
    $index = $CONFIDENCE;
  }
     
  if (($success >= 3) && ($detect_time[$index] == -1)) {
    $detect_time[$index] = $time - $inject_time;
    $time_detected[$index] = $time;
  }

  # If the fault has not been detected, or it has
  #   been detected but we are still in the same time
  #   slot as when it was detected, then count faults.
  if (($detect_time[$index] == -1) || ($time_detected[$index] >= $time)) {

    if (($last_fault_time[$index] != $time) 
      || ($last_fault_node[$index] != $node)) {

      if ($index == $SYMPATHY) {
        if ($failure_type =~ /Root/) { $detect_faults[$index]++; }
	else { 
	  $suppressed_faults[$index]++; 
	}
      }
      else { 
        print "failure: $failure_type\n";
        if ($failure_type =~ /LOCALI/ || $failure_type =~ /NEEDED/) {
	  $suppressed_faults[$index]++; 
        }
        else { $detect_faults[$index]++; }
      }
    }
    $last_fault_time[$index] = $time;
    $last_fault_node[$index] = $node;
  }
}


while ($line = <IN>) {
  if ($line =~ /^\d+\W+(\d+).*Inject.*halt/) {
    $inject_time = $1;
  }

#1       1643    9       18      ** Root         Failure SRC_NO_ROUTE    1 S

  elsif (($line =~ /^\d+\W+(\d+)\W+\d+\W+(\d+)(.*)(\d) ([C,S])$/) 
      && ($inject_time > -1)) {
    $time = $1;
    $node = $2;
    $failure_type = $3;
    $success = $4;
    $type = $5;
  
    &calculate_time();
  }
}

print "C $detect_time[$CONFIDENCE] $detect_faults[$CONFIDENCE] $suppressed_faults[$CONFIDENCE] $inject_time\n";
print "S $detect_time[$SYMPATHY] $detect_faults[$SYMPATHY] $suppressed_faults[$SYMPATHY] $inject_time\n";




See more files for this project here

EmStar

EmStar is a software system for developing and deploying wireless sensor networks involving Linux-based platforms. As the wireless sensor network community has attempted to deploy more complex designs---large-scale, long-lived systems that need self-organization and adaptivity---a number of difficult software design issues have arisen. Advances in software design have not kept pace with the capabilities of hardware. This is because designing for an adaptive, efficient, and useful sensor network has turned out to be surprisingly complex and difficult. EmStar is a Linux-based software framework, whose goal is to dramatically reduce this complexity, enabling work to be shared and reused, and simplifying and speeding the design of new sensor network applications.

Project homepage: http://cvs.cens.ucla.edu/emstar/
Programming language(s): C,Shell Script
License: other

  cars.pl
  change_node_status
  quantify_faults.pl
  run_quantify_faults.sh
  take_actions