Changeset 58 for trunk/src/dataFlowSet.c

Show
Ignore:
Timestamp:
10/09/07 12:01:26 (15 years ago)
Author:
andreu
Message:

new aggregation method, new configuration files, corrections on the php script for graph generation.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/dataFlowSet.c

    r57 r58  
    153153      field_size = (int) pftmp->fieldLength; 
    154154       
    155       /* special case: check yes on all flows from one router (phantom field nb 0) */ 
     155      /* special case: check yes on all flows from one router */ 
     156      /* (phantom field nb 0) */ 
    156157      /* FIXME : this code is repeated, perhaps past before */ 
    157158      while ( ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+j))) != NULL ) { 
     
    222223#ifdef IPV4AGG 
    223224              if (pftmp->fieldType==10){ 
    224                 agCache.idSnmp = *((unsigned short*)&buffer2); 
     225                agCache.inputSnmp = *((unsigned short*)&buffer2); 
     226              } 
     227              if (pftmp->fieldType==14){ 
     228                agCache.outputSnmp = *((unsigned short*)&buffer2); 
    225229              } 
    226230#endif 
     
    472476#ifdef IPV4AGG 
    473477          if (pftmp->fieldType==10){ 
    474             agCache.idSnmp = *((unsigned short*)&buffer2); 
     478            agCache.inputSnmp = *((unsigned short*)&buffer2); 
     479          }        
     480          if (pftmp->fieldType==14){ 
     481            agCache.outputSnmp = *((unsigned short*)&buffer2); 
    475482          }        
    476483#endif 
     
    547554                        sizeof(struct PrefixV4), prefGlobalCmp); 
    548555          if (res!=NULL){ 
    549             if ( myPtrs->routersID[res->routerNb] == agCache.routerAd  ) { 
     556/*          if ( myPtrs->routersID[res->routerNb] == agCache.routerAd  ) { */ 
     557            if ( myPtrs->currentRouterPtr->snmpIndexList[agCache.inputSnmp] == 1  ) {          
    550558              /* OUT ("traffic from the prefix/subnet")  */ 
    551559              res->bytesNbOUT += agCache.bytes; 
    552560              res->pktsNbOUT += agCache.pkts; 
    553561              (res->flowNbOUT)++; 
     562              if (res->sampling == 0) { 
     563                res->sampling = myPtrs->currentRouterPtr->sampled; 
     564              } else if (res->sampling != myPtrs->currentRouterPtr->sampled) { 
     565                syslog(LOG_INFO, 
     566                       "2 sampling values for 1 subnet: %lu.%lu.%lu.%lu % from router %lu.%lu.%lu.%lu", 
     567                       agCache.v4AdS>>24, 
     568                       agCache.v4AdS<<8>>24, 
     569                       agCache.v4AdS<<16>>24, 
     570                       agCache.v4AdS<<24>>24, 
     571                       (myPtrs->pcktPtr->ipH->srcAdd>>24), 
     572                       (myPtrs->pcktPtr->ipH->srcAdd<<8>>24), 
     573                       (myPtrs->pcktPtr->ipH->srcAdd<<16>>24), 
     574                       (myPtrs->pcktPtr->ipH->srcAdd<<24>>24)); 
     575              } 
    554576              /* inter-pop matrix Accounting */ 
    555577              prefixKey.beginning = agCache.v4AdD>>(32-agCache.maskD)<<(32-agCache.maskD); 
    556578              res2 = bsearch(&prefixKey, V4PTab, nbPV4,  
    557579                            sizeof(struct PrefixV4), prefGlobalCmp); 
    558               if (res2!=NULL){ 
     580              if (res2!=NULL){           
    559581                ((struct POP *)((myPtrs->matrixPOP) 
    560582                                +((res->routerNb)*ROUTER_INDEX_MAX) 
     
    588610            res = bsearch(&prefixKey, V4PTab, nbPV4,  
    589611                          sizeof(struct PrefixV4), prefGlobalCmp); 
    590             if (res!=NULL){  
    591               if ( myPtrs->routersID[res->routerNb] == agCache.routerAd  ) { 
    592                 /* IN ("traffic to the prefix")  */ 
     612            if (res!=NULL){ 
     613              if ( myPtrs->currentRouterPtr->snmpIndexList[agCache.inputSnmp] == 1  ) {        
     614                /* IN ("traffic to the prefix/subnet")  */ 
    593615                res->bytesNbIN += agCache.bytes; 
    594616                res->pktsNbIN += agCache.pkts; 
    595                 (res->flowNbIN)++; 
    596               } else { 
     617                (res->flowNbIN)++;       
     618/*            if ( myPtrs->routersID[res->routerNb] == agCache.routerAd  ) { */ 
     619/*               IN ("traffic to the prefix")  */  
     620/*              res->bytesNbIN += agCache.bytes; */ 
     621/*              res->pktsNbIN += agCache.pkts; */ 
     622/*              (res->flowNbIN)++; */ 
     623/*              if (res->sampling == 0) { */ 
     624/*                res->sampling = myPtrs->currentRouterPtr->sampled; */ 
     625/*              } else if (res->sampling !=  myPtrs->currentRouterPtr->sampled) { */ 
     626/*                syslog(LOG_INFO, */ 
     627/*                       "2 sampling values for 1 /: %lu.%lu.%lu.%lu % from router %lu.%lu.%lu.%lu", */ 
     628/*                       agCache.v4AdS>>24, */ 
     629/*                       agCache.v4AdS<<8>>24, */ 
     630/*                       agCache.v4AdS<<16>>24, */ 
     631/*                       agCache.v4AdS<<24>>24, */ 
     632/*                       (myPtrs->pcktPtr->ipH->srcAdd>>24), */ 
     633/*                       (myPtrs->pcktPtr->ipH->srcAdd<<8>>24), */ 
     634/*                       (myPtrs->pcktPtr->ipH->srcAdd<<16>>24), */ 
     635/*                       (myPtrs->pcktPtr->ipH->srcAdd<<24>>24)); */ 
     636/*              } */ 
     637/*            } else { */ 
    597638                /* doublon or bad reference in prefix list */ 
    598                  
    599 /*              fprintf(stderr, "IN NC: %lu.%lu.%lu.%lu/%hu -> %lu.%lu.%lu.%lu/%hu R:%lu.%lu.%lu.%lu \n", */ 
    600 /*                      (agCache.v4AdS>>24), */ 
    601 /*                      (agCache.v4AdS<<8>>24),  */ 
    602 /*                      (agCache.v4AdS<<16>>24),  */ 
    603 /*                      (agCache.v4AdS<<24>>24),  */ 
    604 /*                      (agCache.maskS),  */ 
    605 /*                      (agCache.v4AdD>>24),  */ 
    606 /*                      (agCache.v4AdD<<8>>24),  */ 
    607 /*                      (agCache.v4AdD<<16>>24),  */ 
    608 /*                      (agCache.v4AdD<<24>>24),  */ 
    609 /*                      (agCache.maskD),  */ 
    610 /*                      (myPtrs->pcktPtr->ipH->srcAdd>>24),  */ 
    611 /*                      (myPtrs->pcktPtr->ipH->srcAdd<<8>>24), */ 
    612 /*                      (myPtrs->pcktPtr->ipH->srcAdd<<16>>24), */ 
    613 /*                      (myPtrs->pcktPtr->ipH->srcAdd<<24>>24) */ 
    614 /*                      ); */ 
    615639              } 
    616640            } else { 
     
    788812          if (pftmp->fieldType==34){ 
    789813            if ((*((unsigned long*)&buffer4)==1)  
    790                 || (*((unsigned long*)&buffer4)==10)  
     814                || (*((unsigned long*)&buffer4)==10) 
     815                || (*((unsigned long*)&buffer4)==100) 
    791816                || (*((unsigned long*)&buffer4)==1000)) { 
    792817              if (myPtrs->currentRouterPtr->sampled != *((unsigned long*)&buffer4) ) { 
     
    795820                        myPtrs->currentRouterPtr->sampled); 
    796821#endif                      
     822                syslog(LOG_INFO,"Sampling value change for router : %lu.%lu.%lu.%lu, old: %lu, new: %lu", 
     823                       (myPtrs->pcktPtr->ipH->srcAdd>>24), 
     824                       (myPtrs->pcktPtr->ipH->srcAdd<<8>>24), 
     825                       (myPtrs->pcktPtr->ipH->srcAdd<<16>>24), 
     826                       (myPtrs->pcktPtr->ipH->srcAdd<<24>>24), 
     827                       myPtrs->currentRouterPtr->sampled, 
     828                       *((unsigned long*)&buffer4) 
     829                       ); 
    797830                myPtrs->currentRouterPtr->sampled = *((unsigned long*)&buffer4); 
    798                 for (i=0; i<nbPV4; i++) { 
    799                   /* we update the PrefixV4 structure with the sampled information */ 
    800                   if ( myPtrs->currentRouterPtr->IpAddress == myPtrs->routersID[V4PTab[i].routerNb]) { 
    801                     V4PTab[i].sampling = *((unsigned long*)&buffer4); 
    802                     myPtrs->secondV4Tab[i].sampling = *((unsigned long*)&buffer4); 
    803                   } 
    804                 } 
    805               } 
     831              } 
     832            }else{ 
     833              syslog(LOG_INFO,"Sampling value not standard for router : %lu.%lu.%lu.%lu", 
     834                     (myPtrs->pcktPtr->ipH->srcAdd>>24), 
     835                     (myPtrs->pcktPtr->ipH->srcAdd<<8>>24), 
     836                     (myPtrs->pcktPtr->ipH->srcAdd<<16>>24), 
     837                     (myPtrs->pcktPtr->ipH->srcAdd<<24>>24) 
     838                     ); 
    806839            } 
    807840          }