From: xchaos Date: Tue, 29 Oct 2013 12:10:50 +0000 (+0000) Subject: analysing network topology - more work done X-Git-Url: http://git.harvie.cz/?a=commitdiff_plain;h=2b460b72764116f1846fbb5f51299e4cc8074b9a;hp=cdfd88eb2cfba828e5bfc3f77eba37b3cba286ce;p=svn%2FPrometheus-QoS%2F.git analysing network topology - more work done git-svn-id: https://dev.arachne.cz/repos/prometheus/trunk@229 251d49ef-1d17-4917-a970-b30cf55b089b --- diff --git a/networks.c b/networks.c index 965b2de..c9e54f8 100644 --- a/networks.c +++ b/networks.c @@ -7,13 +7,13 @@ extern struct IP *ips, *networks; -struct IP* find_network_for_ip(char *ipaddr_orig) +void update_network(char *look_for, struct IP* ip) { struct IP *network; char *netaddr, *lastnum, *ipaddr; int ipnum, netnum; - duplicate(ipaddr_orig, ipaddr); + duplicate(look_for, ipaddr); lastnum = strrchr(ipaddr, '.'); if(lastnum) { @@ -34,11 +34,27 @@ struct IP* find_network_for_ip(char *ipaddr_orig) and netnum + (1<<(32-network->mask)) > ipnum and netnum <= ipnum) { - return network; + network->group += 1; + network->min += ip->min; + network->direct += ip->max<<10; /* sum of Mbps, not kbps*/ + + if(ip->max > network->max) + { + network->max = ip->max; + } + + if(network->max > network->min) + { + network->desired = network->max; + } + else + { + network->desired = network->min; + } + return; } } } - return NULL; } void analyse_topology(char *traceroute) @@ -47,11 +63,6 @@ void analyse_topology(char *traceroute) int col, gateway, netnum, tracert; struct IP *network=NULL, *ip; - for_each(ip, networks) - { - printf("%s/%d %s min=%d max=%d sum=%d\n",ip->addr, ip->mask, ip->name, ip->min, ip->max, ip->desired); - } - /*-----------------------------------------------------------------*/ puts("Analysing network topology ..."); /*-----------------------------------------------------------------*/ @@ -81,27 +92,26 @@ void analyse_topology(char *traceroute) } else if(col==2) { +//#ifdef DEBUG printf("via [%s]\n", ptr); - network = find_network_for_ip(ptr); - if(network) - { - network->min += ip->min; - network->desired += ip->max; - if(ip->max > network->max) - { - network->max = ip->max; - } - } +//#endif + update_network(ptr, ip); } } } } } sort(network, networks, desc_order_by, min); - sort(network, networks, desc_order_by, max); - for_each(ip, networks) + sort(network, networks, desc_order_by, desired); + + /*-----------------------------------------------------------------*/ + puts("Requested network parameters are:"); + /*-----------------------------------------------------------------*/ + for_each(ip, networks) if(ip->desired>>10 > 0) { - printf("%s/%d %s min=%d max=%d sum=%d\n",ip->addr, ip->mask, ip->name, ip->min, ip->max, ip->desired); + printf("%s/%d %s REQUESTED=%dM (classes=%d, sum_min=%dk, max_1=%dk, sum_max=%LuM, agreg.=1:%d)\n", + ip->addr, ip->mask, ip->name, ip->desired>>10, ip->group, ip->min, ip->max, ip->direct, + (int)((float)(ip->direct)/(ip->desired>>10))); } exit(-1); } diff --git a/parsehosts.c b/parsehosts.c index b21af78..bcf222e 100644 --- a/parsehosts.c +++ b/parsehosts.c @@ -17,7 +17,7 @@ extern int free_min; extern const int highest_priority; extern char *ip6prefix; -struct IP* find_network_for_ip(char *ipaddr_orig); +void update_network(char *look_for, struct IP* ip); /* implemented in networks.c */ /* This must be object oriented! This looks almost like constructor ;-) */ @@ -257,16 +257,7 @@ void parse_hosts(char *hosts) } ip->mark = FIRSTIPCLASS+1+class_count++; - network = find_network_for_ip(ip->addr); - if(network) - { - network->min += ip->min; - network->desired += ip->max; - if(ip->max > network->max) - { - network->max = ip->max; - } - } + update_network(ip->addr, ip); if_exists(group,groups,(group->min == ip->min)) {