

read_ping_list
send_pings
receive_pings
exit; 

sub send_pings {
  disable ALRM
  if ( $next_node_on_list == 0 )
    do start of ping list stuff
  for $i ($next_node_on_list .. nodes)
    if $node[i]->$next_ping < $now then
      if state =~ PINGING 
        mark node as DOWN
        mark state as NONE
      set icmp sequence num to $i
      send ping via sendto()
      mark state as PINGING
      set next_ping as $polling_interval
      $next_node_on_list = $i
      set ALRM interrupt to interpacket_delay
      return
  $next_node_on_list = 0;
  do end of list stuff
  write details 
  set ALRM interrupt to polling_interval
  return
}

sub receive_pings {
  while (1) {
    get ping packet via recvfrom()
    set $idx to index into ping list via icmp sequence num
    if ( $idx > -1 && $idx < ping_list_size )) { 
      mark node as UP
      mark state as NONE
      set next_ping as $polling_interval
      calc rtt and exp ave
      last; 
}

