Changeset 24 for trunk/src/renetcol.c

Show
Ignore:
Timestamp:
02/06/07 18:31:00 (16 years ago)
Author:
andreu
Message:

aggregation feature first E2E step : collect to rrdfiles

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/renetcol.c

    r23 r24  
    2727 
    2828struct MyPtrs myPtrs; /* defined in dataflowset.h */ 
     29 
     30struct SHMForAgg *shmForAgg; 
    2931 
    3032struct IPFLowCache tabIP[MAX_IP_FLOW]; 
     
    6769unsigned long indexedRouterList[ROUTER_INDEX_MAX]; 
    6870int routerNb = 0;                                  /* routers number */ 
    69 unsigned short v4PrefixNb = 0;                     /* IPv4 prefix number */ 
    70 struct PrefixV4 prefixV4Tab[2][MAX_IPV4_PREFIX];      /* IPv4 prefix structure */ 
    71 unsigned short indexForShmTable = 0; 
     71/* unsigned short v4PrefixNb = 0;                      IPv4 prefix number */  
     72/* struct PrefixV4 prefixV4Tab[2][MAX_IPV4_PREFIX];      IPv4 prefix structure */ 
     73 
    7274 
    7375key_t myKey = 0; /* FIXME to delete in futur */ 
     
    105107{ 
    106108  RulesPtr tmp = NULL; 
    107  
     109  int shmid; 
     110  key_t key; 
     111   
    108112  if ( argc != 4) { 
    109113    fprintf (stderr, 
     
    134138                                  &indexedRouterList[0]); 
    135139  fprintf(stderr, "renetcol: OK\n"); 
     140 
     141  key = 8765; 
     142  if ((shmid = shmget(key, SHMSIZE, IPC_CREAT | 0666)) < 0) { 
     143    perror("shmget"); 
     144    exit(1); 
     145  } 
     146  if ((shmForAgg = (struct SHMForAgg *)shmat(shmid, (void *)0, 0)) == (void *) -1) { 
     147    perror("shmat"); 
     148    exit(1); 
     149  } 
     150 
    136151  fprintf(stderr, "renetcol: reading the IPv4 prefix...\n"); 
    137   if ( (v4PrefixNb = getPrefixV4(prefixV4FileName, &prefixV4Tab[0])) < 1){ 
     152  if ( (shmForAgg->v4PrefixNb = getPrefixV4(prefixV4FileName, &(shmForAgg->prefixV4Tab[0][0]))) < 1){ 
     153    fprintf(stderr, "renetcol:  Error \n"); 
     154    exit(1); 
     155  } else { 
     156    fprintf(stderr, "renetcol:  OK \n"); 
     157  } 
     158  if ( (shmForAgg->v4PrefixNb = getPrefixV4(prefixV4FileName, &(shmForAgg->prefixV4Tab[1][0]))) < 1){ 
    138159    fprintf(stderr, "renetcol:  Error \n"); 
    139160    exit(1); 
     
    372393  lastIPOutput = now; 
    373394  do { 
    374     if ( ((tmPtr->tm_min)%2 == 0) && (currentIntervalle != tmPtr->tm_min)){ 
    375       printf("We change the table, min : %d\n", tmPtr->tm_min); 
     395    if ( ((tmPtr->tm_min)%STEP == 0) && (currentIntervalle != tmPtr->tm_min)){ 
    376396      currentIntervalle = tmPtr->tm_min; 
     397      if (shmForAgg->currentTable == 0) { 
     398        shmForAgg->currentTable = 1; 
     399      }else{ 
     400        shmForAgg->currentTable = 0; 
     401      } 
     402      shmForAgg->readed = 1; 
     403      printf("We change the table, min : %d, ct: %hu\n", tmPtr->tm_min, 
     404             shmForAgg->currentTable); 
    377405    } 
    378406    if (sigusr1Up == 1){ 
     
    420448                                   &myPtrs, 
    421449                                   myQueue,  
    422                                    prefixV4Tab, 
    423                                    (size_t) v4PrefixNb 
     450                                   shmForAgg->prefixV4Tab[shmForAgg->currentTable], 
     451                                   (size_t) shmForAgg->v4PrefixNb 
    424452                                   ); 
    425453        } 
     
    439467      /* FIXME perhaps call this function via the compilation options */ 
    440468      writeAllTplFlSet(); 
    441       for (i=0; i<v4PrefixNb; i++){ 
    442         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", 
    443                 prefixV4Tab[i].beginning, 
    444                 prefixV4Tab[i].flowNbIN, 
    445                 prefixV4Tab[i].bytesNbIN, 
    446                 prefixV4Tab[i].pktsNbIN, 
    447                 prefixV4Tab[i].udpPktsNbIN, 
    448                 prefixV4Tab[i].tcpPktsNbIN, 
    449                 prefixV4Tab[i].icmpPktsNbIN, 
    450                 prefixV4Tab[i].othersPktsNbIN, 
    451                 prefixV4Tab[i].udpBytesNbIN, 
    452                 prefixV4Tab[i].tcpBytesNbIN, 
    453                 prefixV4Tab[i].icmpBytesNbIN, 
    454                 prefixV4Tab[i].othersBytesNbIN, 
    455                 prefixV4Tab[i].udpFlowNbIN, 
    456                 prefixV4Tab[i].tcpFlowNbIN, 
    457                 prefixV4Tab[i].icmpFlowNbIN, 
    458                 prefixV4Tab[i].othersFlowNbIN, 
    459                 prefixV4Tab[i].flowNbOUT, 
    460                 prefixV4Tab[i].bytesNbOUT, 
    461                 prefixV4Tab[i].pktsNbOUT, 
    462                 prefixV4Tab[i].udpPktsNbOUT, 
    463                 prefixV4Tab[i].tcpPktsNbOUT, 
    464                 prefixV4Tab[i].icmpPktsNbOUT, 
    465                 prefixV4Tab[i].othersPktsNbOUT, 
    466                 prefixV4Tab[i].udpBytesNbOUT, 
    467                 prefixV4Tab[i].tcpBytesNbOUT, 
    468                 prefixV4Tab[i].icmpBytesNbOUT, 
    469                 prefixV4Tab[i].othersBytesNbOUT, 
    470                 prefixV4Tab[i].udpFlowNbOUT, 
    471                 prefixV4Tab[i].tcpFlowNbOUT, 
    472                 prefixV4Tab[i].icmpFlowNbOUT, 
    473                 prefixV4Tab[i].othersFlowNbOUT 
    474                 ); 
    475       } 
     469/*       for (i=0; i<shmForAgg->v4PrefixNb; i++){ */ 
     470/*      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", */ 
     471/*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].beginning, */ 
     472/*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].flowNbIN, */ 
     473/*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].bytesNbIN, */ 
     474/*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].pktsNbIN, */ 
     475/*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].udpPktsNbIN, */ 
     476/*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].tcpPktsNbIN, */ 
     477/*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].icmpPktsNbIN, */ 
     478/*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].othersPktsNbIN, */ 
     479/*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].udpBytesNbIN, */ 
     480/*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].tcpBytesNbIN, */ 
     481/*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].icmpBytesNbIN, */ 
     482/*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].othersBytesNbIN, */ 
     483/*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].udpFlowNbIN, */ 
     484/*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].tcpFlowNbIN, */ 
     485/*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].icmpFlowNbIN, */ 
     486/*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].othersFlowNbIN, */ 
     487/*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].flowNbOUT, */ 
     488/*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].bytesNbOUT, */ 
     489/*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].pktsNbOUT, */ 
     490/*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].udpPktsNbOUT, */ 
     491/*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].tcpPktsNbOUT, */ 
     492/*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].icmpPktsNbOUT, */ 
     493/*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].othersPktsNbOUT, */ 
     494/*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].udpBytesNbOUT, */ 
     495/*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].tcpBytesNbOUT, */ 
     496/*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].icmpBytesNbOUT, */ 
     497/*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].othersBytesNbOUT, */ 
     498/*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].udpFlowNbOUT, */ 
     499/*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].tcpFlowNbOUT, */ 
     500/*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].icmpFlowNbOUT, */ 
     501/*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].othersFlowNbOUT */ 
     502/*              ); */ 
     503/*       } */ 
    476504      loopNb = 0; 
    477505    }