/**************************************************************************** * Pathneck: locating network path bottlenecks * Copyright (C) 2004 * Ningning Hu and the Carnegie Mellon University * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License (in the COPYING file) for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ****************************************************************************/ /* Copied from get-choke.c, used by pathneck.c for on-line processing * to get the choke points */ #include #include #ifdef SUN #include #else #include #endif #include "choke.h" #include "pathneck.h" #include "util.h" struct node_t in_node[MAX_PATH]; /* the original reading */ struct node_t node[MAX_PATH]; /* used for processing, by discarding the unuseless elements from in_node */ int in_path_len = 0; int path_len = 0; char * selected[MAX_PATH]; double conf[MAX_SEG_NUM]; double conf_gap[MAX_SEG_NUM]; int choke_gap[MAX_SEG_NUM]; int num_choke = 0; /* out is a sorted index for the values in "in" */ void sort(double *in, int *out, int len) { int i, j; int tmp[MAX_PATH]; double max; int maxi; for (i=0; i= 0 && tmp[j] > max) { maxi = j; max = tmp[j]; } } out[i] = maxi; tmp[maxi] = -1; } } int sanity_check() { int sg[MAX_PATH]; double gap[MAX_PATH]; int i, j, k; int mean_gap; if (in_path_len < 4) return 0; path_len = in_path_len; for (i=0; i= path_len) return 0; for (j=0; j node[k-1].gap1 && node[k].gap > node[k+1].gap) { node[k].gap1 = (node[k-1].gap1 > node[k+1].gap) ? node[k-1].gap1 : node[k+1].gap; } else if (node[k].gap < node[k-1].gap1 && node[k].gap < node[k+1].gap) { node[k].gap1 = (node[k-1].gap1 < node[k+1].gap) ? node[k-1].gap1 : node[k+1].gap; } else { node[k].gap1 = node[k].gap; } } k = path_len - 1; if (node[k].gap < mean_gap / 5) { node[k].gap1 = node[k-1].gap1; } else { node[k].gap1 = node[k].gap; } #if DEBUG for (k=0; kopt = sum; rec->ls = cur_avg; rec->fs = cur_avg; } void bit_merge(char * in1, int k, char * in2, char * dst) { int i; for (i=0; i= 0 && k < 8) dst[i] |= (0x1 << k); k -= 8; } } void segment_all() { struct rec_t rec[MAX_PATH][MAX_PATH][MAX_PATH]; int i, j, l, k, m, i1, i2; char * map, mask; double diff[MAX_PATH]; int sd[MAX_PATH]; int diff_len, index, pos[MAX_PATH]; /* initialization */ bzero((void *)&rec, sizeof(struct rec_t) * MAX_PATH * MAX_PATH * MAX_PATH); for (i=0; i GAP_THRESHOLD && rec[i][k][m].opt + rec[k+1][j][l-m-1].opt < rec[i][j][l].opt) { /* add in one more split point for "k" */ rec[i][j][l].opt = rec[i][k][m].opt + rec[k+1][j][l-m-1].opt; bit_merge(rec[i][k][m].sp, k, rec[k+1][j][l-m-1].sp, rec[i][j][l].sp); rec[i][j][l].ls = rec[k+1][j][l-m-1].ls; rec[i][j][l].fs = rec[i][k][m].fs; } } } } // sleep(1); } } /* now all the splitting points are in SP[0][path_len-1][path_len-1] */ /* calculate the gap differences at the splitting points */ diff_len = 0; index = 0; map = rec[0][path_len-1][path_len-1].sp; for (i=0; i