function eliminate_repeating_points($path1) { global $MERGER_debug; $most_eliminated = 0; $maxlen = $path1['lk'] / 2; if ($maxlen > get_config_var("max_wp_count")) { $maxlen = get_config_var("max_wp_count"); } for ($len = 1; $len <= $maxlen; $len++) { for ($slide = 0; $slide < $len; $slide++) { $t = get_eliminated_pointcount($slide, $len, $path1); if ($t > $most_eliminated) { $most_eliminated = $t; $best_slide = $slide; $best_len = $len; } } } if ($most_eliminated != 0) { if ($MERGER_debug) { parse_debug_report("managed to find repetative paterns in path, eliminating wp count {$most_eliminated} from " . ($path1['lk'] - 1) . " (" . ($path1['biglk'] - 1) . ")for spawn " . $path1['spid']); } $WP_EXACT_MATCH_ERROR = get_config_var("min_wp_dist"); // $WP_EXACT_MATCH_ERROR=3; $iend = (int) (($path1['lk'] - $best_slide) / $best_len); for ($i = 0; $i <= $iend; $i++) { $matchcount = 0; $start = $best_slide + $best_len * $i; $end = $start + $len; for ($j = $start; $j < $end; $j++) { $dist_x = ABS($path1[$j + $best_len]['x'] - $path1[$j]['x']); $dist_y = ABS($path1[$j + $best_len]['y'] - $path1[$j]['y']); $dist = sqrt($dist_x * $dist_x + $dist_y * $dist_y); //parse_debug_report("len=$best_len, slide=$best_slide,iend=$iend, start=$start, end=$end,j=$j,j2=".($j+$best_len)." total nodes =".$path1['lk']." dist=$dist x1=".$path1[$j+$best_len]['x']." y1 =".$path1[$j+$best_len]['y']." x2=".$path1[$j]['x']." y2=".$path1[$j]['y'].""); if ($dist < $WP_EXACT_MATCH_ERROR) { $matchcount++; } } if ($matchcount == $len) { for ($j = $start; $j <= $end; $j++) { if ($j < $path1['lk']) { $path1[$j]['del'] = 1; if ($MERGER_debug) { $dist_x = ABS($path1[$j + $best_len]['x'] - $path1[$j]['x']); $dist_y = ABS($path1[$j + $best_len]['y'] - $path1[$j]['y']); $dist = sqrt($dist_x * $dist_x + $dist_y * $dist_y); parse_debug_report("node {$j} matches node " . ($j + $best_len) . " and distance is {$dist}"); } } } } } } return $path1; }
$to1 = strpos($line, " Pac", $from1); $str_opcode = substr($line, $from1, $to1 - $from1); $timestamp = substr($line, strpos($line, "p = ") + 5); if (strlen($str_opcode) > 3 && $str_opcode != "UNKNOWN") { $packet_name = $str_opcode; } else { $packet_name = $hex_opcode; } if ($packet_name == "") { continue; } $file_name = "step2/" . $packet_name . ".txt"; if (!($f_handlers[$file_name] > 0)) { $outf = fopen($file_name, "a+"); if (!$outf) { parse_debug_report("could not open outputfile({$file_name})!<br>\n"); } else { $f_handlers[$file_name] = $outf; } } else { $outf = $f_handlers[$file_name]; } if ($outf > 0) { $line = rtrim(fgets($inp_h)); //data line if (strlen($line) > 2) { if ($hex_opcode == 0x1f6 && $outf_comp) { fputs($outf_comp, "{$timestamp} \r\n"); fputs($outf, str_replace(array("\n", "\r"), "", rtrim($line)) . " \r\n"); } else { fputs($outf, str_replace(array("\n", "\r"), "", rtrim($line)) . " " . $timestamp . "\r\n");