Changeset 25 for trunk

Show
Ignore:
Timestamp:
02/08/07 22:44:36 (16 years ago)
Author:
andreu
Message:

aggregation feature : prefix selection even if no routed subnet

Location:
trunk/src
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/dataFlowSet.c

    r23 r25  
    624624          res = bsearch(&prefixKey, V4PTab, nbPV4,  
    625625                        sizeof(struct PrefixV4), prefCmp); 
    626           if (res!=NULL){ /* OUT ("traffic from the prefix")  */ 
     626          if (res!=NULL){  
     627            /* OUT ("traffic from the prefix/subnet")  */ 
    627628            res->bytesNbOUT += agCache.bytes; 
    628629            res->pktsNbOUT += agCache.pkts; 
  • trunk/src/prefix_mgmt.c

    r17 r25  
    2323 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA 
    2424 */ 
    25 #include <stdio.h> 
    2625 
    2726#include "prefix_mgmt.h" 
     
    3837          ); 
    3938} 
     39 
     40 
     41/* 
     42 * prefGlobalCmp() 
     43 */ 
     44int 
     45prefGlobalCmp(const void *elem1, const void *elem2){ 
     46  struct PrefixV4 *el1 = (struct PrefixV4 *) elem1; 
     47  struct PrefixV4 *el2 = (struct PrefixV4 *) elem2; 
     48  if ( el1->beginning >= el2->beginning && el1->beginning <= el2->end ) { 
     49    return 0; 
     50  } else if (el1->beginning < el2->beginning) { 
     51    return -1; 
     52  } else if (el1->beginning > el2->end) { 
     53    return 1; 
     54  } else { 
     55    syslog(LOG_ERR,"You have won !!! This case doesn't exist !!!!"); 
     56    exit(1); 
     57    return 0; 
     58  } 
     59} 
     60 
  • trunk/src/prefix_mgmt.h

    r16 r25  
    2626#define PREFIX_MGMT_H 
    2727 
     28#include <unistd.h> 
     29#include <stdio.h> 
     30#include <string.h> 
     31#include <stdlib.h> 
     32#include <syslog.h> 
     33#include <errno.h> 
     34 
    2835#include "get_conf.h" 
    2936 
    30 int prefCmp(const void *, const void *); 
     37int prefCmp(const void *, const void *); /* quickly cmp, used in headers_mgmt.c */ 
     38int prefGlobalCmp(const void *, const void *); /* bigger cmp, used in dataflowset.c */  
    3139 
    3240#endif /* PREFIX_MGMT_H */ 
  • trunk/src/renetcol.c

    r24 r25  
    151151  fprintf(stderr, "renetcol: reading the IPv4 prefix...\n"); 
    152152  if ( (shmForAgg->v4PrefixNb = getPrefixV4(prefixV4FileName, &(shmForAgg->prefixV4Tab[0][0]))) < 1){ 
    153     fprintf(stderr, "renetcol:  Error \n"); 
     153    fprintf(stderr, "renetcol: Error \n"); 
    154154    exit(1); 
    155155  } else { 
    156     fprintf(stderr, "renetcol:  OK \n"); 
     156    fprintf(stderr, "renetcol: OK \n"); 
    157157  } 
    158158  if ( (shmForAgg->v4PrefixNb = getPrefixV4(prefixV4FileName, &(shmForAgg->prefixV4Tab[1][0]))) < 1){ 
     
    160160    exit(1); 
    161161  } else { 
    162     fprintf(stderr, "renetcol:  OK \n"); 
     162    fprintf(stderr, "renetcol: OK \n"); 
    163163  } 
    164164  myPtrs.rulesListPtr = NULL; 
    165165  fprintf(stderr, "renetcol: reading the rules...\n"); 
    166166  myPtrs.rulesListPtr = getLightRules(myPtrs.rulesListPtr, rulesFileName); 
    167   fprintf(stderr, "renetcol : OK \n"); 
     167  fprintf(stderr, "renetcol: OK \n"); 
    168168  tmp = myPtrs.rulesListPtr; 
    169169  for ( ; tmp->next; tmp=tmp->next) { 
  • trunk/src/renetcolAgg.c

    r24 r25  
    6969      now = time((time_t *)NULL); 
    7070      for (i=0; i<shmForAgg->v4PrefixNb; i++){ 
    71          
    7271        /* HERE Put in RRD FILE */ 
    73          
    74         name[0] = '\0'; 
     72        name[0] = '\0'; 
    7573        createstr[0] = '\0'; 
    7674        ipStr[0] = '\0'; 
    7775        buf[0] = '\0'; 
    78 /*      strcat(name, RRD_LOCATION); */ 
     76        strcat(name, RRD_LOCATION); 
    7977        sprintf(ipStr, "%lu", shmForAgg->prefixV4Tab[index][i].beginning);  
    8078        strcat(name, ipStr); 
    81 /*      strcat(name, SAMPLING_HERE); */ 
     79        /*      strcat(name, SAMPLING_HERE); */ 
    8280        strcat(name, RRD_EXTENSION); 
    8381        fprintf(stderr, "%s\n", name); 
     
    8785          fprintf(stderr, "%s\n", createstr); 
    8886          res_rrd = wrap_rrd_create(createstr); 
    89 /*        printf("%d\n", res_rrd); */ 
    9087        }else{ 
    9188          fclose(fp); 
    9289        } 
    9390     
    94         snprintf(buf, 1024, "%s%s %lu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu",  
    95 /*               RRD_LOCATION, */ 
     91        snprintf(buf, 2048, "%s%s%s %lu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu",  
     92                 RRD_LOCATION,  
    9693                 ipStr, 
    9794                 RRD_EXTENSION,  
    98                  now,  /* or ctime(&now) with %s */ 
     95                 now,  /* or ctime(&now) with %s FIXME -300 */ 
    9996                 shmForAgg->prefixV4Tab[index][i].flowNbIN,  /* 1  */ 
    10097                 shmForAgg->prefixV4Tab[index][i].flowNbOUT, 
     
    129126                 ); 
    130127        printf("\n%s\n", buf);  
    131         res_rrd = wrap_rrd_update(buf); 
    132         printf("resultat wrap_rrd_update : %d\n", res_rrd); 
    133          
    134 /*      fprintf(stderr, "%lu \n %llu flows,\t %llu bytes,\t %llu pkts\n Pkts (udp tcp icmp others): %llu \t %llu \t %llu \t %llu\n Bytes (udp tcp icmp others): %llu \t %llu \t %llu \t %llu\n Flows (udp tcp icmp others): %llu \t %llu \t %llu \t %llu\n \n %llu flows,\t %llu bytes,\t %llu pkts\n Pkts (udp tcp icmp others): %llu \t %llu \t %llu \t %llu\n Bytes (udp tcp icmp others): %llu \t %llu \t %llu \t %llu\n Flows (udp tcp icmp others): %llu \t %llu \t %llu \t %llu\n \n", */ 
    135 /*              shmForAgg->prefixV4Tab[index][i].beginning, */ 
    136 /*              shmForAgg->prefixV4Tab[index][i].flowNbIN, */ 
    137 /*              shmForAgg->prefixV4Tab[index][i].bytesNbIN, */ 
    138 /*              shmForAgg->prefixV4Tab[index][i].pktsNbIN, */ 
    139 /*              shmForAgg->prefixV4Tab[index][i].udpPktsNbIN, */ 
    140 /*              shmForAgg->prefixV4Tab[index][i].tcpPktsNbIN, */ 
    141 /*              shmForAgg->prefixV4Tab[index][i].icmpPktsNbIN, */ 
    142 /*              shmForAgg->prefixV4Tab[index][i].othersPktsNbIN, */ 
    143 /*              shmForAgg->prefixV4Tab[index][i].udpBytesNbIN, */ 
    144 /*              shmForAgg->prefixV4Tab[index][i].tcpBytesNbIN, */ 
    145 /*              shmForAgg->prefixV4Tab[index][i].icmpBytesNbIN, */ 
    146 /*              shmForAgg->prefixV4Tab[index][i].othersBytesNbIN, */ 
    147 /*              shmForAgg->prefixV4Tab[index][i].udpFlowNbIN, */ 
    148 /*              shmForAgg->prefixV4Tab[index][i].tcpFlowNbIN, */ 
    149 /*              shmForAgg->prefixV4Tab[index][i].icmpFlowNbIN, */ 
    150 /*              shmForAgg->prefixV4Tab[index][i].othersFlowNbIN, */ 
    151 /*              shmForAgg->prefixV4Tab[index][i].flowNbOUT, */ 
    152 /*              shmForAgg->prefixV4Tab[index][i].bytesNbOUT, */ 
    153 /*              shmForAgg->prefixV4Tab[index][i].pktsNbOUT, */ 
    154 /*              shmForAgg->prefixV4Tab[index][i].udpPktsNbOUT, */ 
    155 /*              shmForAgg->prefixV4Tab[index][i].tcpPktsNbOUT, */ 
    156 /*              shmForAgg->prefixV4Tab[index][i].icmpPktsNbOUT, */ 
    157 /*              shmForAgg->prefixV4Tab[index][i].othersPktsNbOUT, */ 
    158 /*              shmForAgg->prefixV4Tab[index][i].udpBytesNbOUT, */ 
    159 /*              shmForAgg->prefixV4Tab[index][i].tcpBytesNbOUT, */ 
    160 /*              shmForAgg->prefixV4Tab[index][i].icmpBytesNbOUT, */ 
    161 /*              shmForAgg->prefixV4Tab[index][i].othersBytesNbOUT, */ 
    162 /*              shmForAgg->prefixV4Tab[index][i].udpFlowNbOUT, */ 
    163 /*              shmForAgg->prefixV4Tab[index][i].tcpFlowNbOUT, */ 
    164 /*              shmForAgg->prefixV4Tab[index][i].icmpFlowNbOUT, */ 
    165 /*              shmForAgg->prefixV4Tab[index][i].othersFlowNbOUT */ 
    166 /*              ); */ 
     128        if ( 0 == (res_rrd = wrap_rrd_update(buf) )) {  
     129          syslog(LOG_ERR, "wrap_rrd_update return : %d, param were : %s", res_rrd, buf); 
     130        } 
     131        /* Reinit the shared table */ 
    167132        shmForAgg->prefixV4Tab[index][i].flowNbIN = 0; 
    168133        shmForAgg->prefixV4Tab[index][i].bytesNbIN = 0; 
  • trunk/src/renetcolAgg.h

    r24 r25  
    3939 
    4040#include "rrdwrap.h" 
     41#include "dataFlowSet.h" 
    4142 
    42 #define RRD_LOCATION "/tmp/" 
     43#define RRD_LOCATION "" 
    4344#define RRD_EXTENSION ".rrd" 
    4445#define END_RRD_CREATE " --start 1106560200 DS:inFlows:GAUGE:600:U:U DS:outFlows:GAUGE:600:U:U DS:inBytes:GAUGE:600:U:U DS:outBytes:GAUGE:600:U:U DS:inPkts:GAUGE:600:U:U DS:outPkts:GAUGE:600:U:U DS:inUdpPkts:GAUGE:600:U:U DS:outUdpPkts:GAUGE:600:U:U DS:inTcpPkts:GAUGE:600:U:U DS:outTcpPkts:GAUGE:600:U:U DS:inIcmpPkts:GAUGE:600:U:U DS:outIcmpPkts:GAUGE:600:U:U DS:inOthersPkts:GAUGE:600:U:U DS:outOthersPkts:GAUGE:600:U:U DS:inUdpBytes:GAUGE:600:U:U DS:outUdpBytes:GAUGE:600:U:U DS:inTcpBytes:GAUGE:600:U:U DS:outTcpBytes:GAUGE:600:U:U DS:inIcmpBytes:GAUGE:600:U:U DS:outIcmpBytes:GAUGE:600:U:U DS:inOthersBytes:GAUGE:600:U:U DS:outOthersBytes:GAUGE:600:U:U DS:inUdpFlows:GAUGE:600:U:U DS:outUdpFlows:GAUGE:600:U:U DS:inTcpFlows:GAUGE:600:U:U DS:outTcpFlows:GAUGE:600:U:U DS:inIcmpFlows:GAUGE:600:U:U DS:outIcmpFlows:GAUGE:600:U:U DS:inOthersFlows:GAUGE:600:U:U DS:outOthersFlows:GAUGE:600:U:U RRA:AVERAGE:0.5:1:2100 RRA:AVERAGE:0.5:24:1550 RRA:AVERAGE:0.5:288:1594 RRA:AVERAGE:0.5:2016:1040 RRA:MAX:0.5:1:2100 RRA:MAX:0.5:24:1550 RRA:MAX:0.5:288:1594 RRA:MAX:0.5:2016:1040" 
    45  
    46 #include "dataFlowSet.h" 
    47  
    4846#define SHMSIZE 3000000 
    4947