Changeset 60 for trunk/src/dataFlowSet.c

Show
Ignore:
Timestamp:
10/25/07 07:23:46 (15 years ago)
Author:
andreu
Message:

new aggregation mode based on SNMP index and AS aggregation

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/dataFlowSet.c

    r59 r60  
    6666  unsigned short tplMsgType = 11; 
    6767  struct PrefixV4 prefixKey, *res, *res2; /* for bsearch */ 
     68#if defined(IPV4AGGIDSNMP) 
     69  struct PrefixV4 *res3; 
     70#endif 
     71#ifdef ASACC 
     72  struct AS asKey, *asres; /* for bsearch */ 
     73#endif 
    6874  struct AggCache agCache; 
    6975  int bool = 0; /* in IPV4 Agg mode enabled, we need to now if it's an IPv4 */ 
     
    229235              } 
    230236#endif 
     237#ifdef ASACC 
     238              if (pftmp->fieldType==16){ 
     239                agCache.asS = *((unsigned short*)&buffer2); 
     240              }    
     241              if (pftmp->fieldType==17){ 
     242                agCache.asD = *((unsigned short*)&buffer2); 
     243              } 
     244#endif 
    231245              break; 
    232246            case 3: 
     
    482496          }        
    483497#endif 
     498#ifdef ASACC 
     499          if (pftmp->fieldType==16){ 
     500            agCache.asS = *((unsigned short*)&buffer2); 
     501          }        
     502          if (pftmp->fieldType==17){ 
     503            agCache.asD = *((unsigned short*)&buffer2); 
     504          } 
     505#endif 
    484506          break; 
    485507        case 3: 
     
    548570        /* Aggregation mode must be enable in ./configure options   */ 
    549571        /* first we must know if the address belong to our prefix   */ 
     572        /* 
     573         * AS ACCOUNTING 
     574         */ 
     575#if defined(ASACC) && defined(IPV4AGGIDSNMP) 
     576        if ( (bool == 1) && (isMplsFlow == 0) ){ 
     577          asKey.as = agCache.asS; 
     578          asres = bsearch(&asKey, myPtrs->currentASTab, myPtrs->asNb, sizeof(struct AS), asGlobalCmp); 
     579          if (asres != NULL) { 
     580            if ( myPtrs->currentRouterPtr->snmpIndexList[agCache.inputSnmp] == 1  ) {          
     581              if (myPtrs->currentRouterPtr->sampled != 0 ){ 
     582                /* OUT ("traffic from the AS")  */ 
     583                asres->bytesNbOUT += agCache.bytes; 
     584                asres->pktsNbOUT += agCache.pkts; 
     585                (asres->flowNbOUT)++; 
     586              } 
     587              if (asres->sampling == 0  
     588                  && myPtrs->currentRouterPtr->sampled != 0){ 
     589                asres->sampling = myPtrs->currentRouterPtr->sampled; 
     590              } 
     591              asres = NULL; 
     592              asKey.as = agCache.asD; 
     593              asres = bsearch(&asKey, myPtrs->currentASTab, myPtrs->asNb, sizeof(struct AS), asGlobalCmp); 
     594              if (asres!=NULL){ 
     595                if (myPtrs->currentRouterPtr->sampled != 0 ){ 
     596                  /* IN ("traffic to the AS")  */ 
     597                  asres->bytesNbIN += agCache.bytes; 
     598                  asres->pktsNbIN += agCache.pkts; 
     599                  (asres->flowNbIN)++; 
     600                } 
     601                if (asres->sampling == 0  
     602                    && myPtrs->currentRouterPtr->sampled != 0){ 
     603                  asres->sampling = myPtrs->currentRouterPtr->sampled; 
     604                } 
     605                asres = NULL; 
     606              } 
     607            } 
     608          } else { 
     609            asres = NULL; 
     610            asKey.as = agCache.asD; 
     611            asres = bsearch(&asKey, myPtrs->currentASTab, myPtrs->asNb, sizeof(struct AS), asGlobalCmp); 
     612            if (asres!=NULL){ 
     613              if ( myPtrs->currentRouterPtr->snmpIndexList[agCache.inputSnmp] == 1  ) { 
     614                if (myPtrs->currentRouterPtr->sampled != 0 ){ 
     615                  /* IN ("traffic to the AS")  */ 
     616                  asres->bytesNbIN += agCache.bytes; 
     617                  asres->pktsNbIN += agCache.pkts; 
     618                  (asres->flowNbIN)++; 
     619                } 
     620                if (asres->sampling == 0  
     621                    && myPtrs->currentRouterPtr->sampled != 0){ 
     622                  asres->sampling = myPtrs->currentRouterPtr->sampled; 
     623                } 
     624              } 
     625            } 
     626          } 
     627        } 
     628#endif 
     629        /* 
     630         * PREFIX &/or MATRIX ACCOUNTING 
     631         */ 
    550632#if defined(IPV4AGGIDR) || defined(IPV4AGGIDSNMP) 
    551633        if ( (bool == 1) && (isMplsFlow == 0) ){ 
     
    569651                res->sampling = myPtrs->currentRouterPtr->sampled; 
    570652              } 
     653#if defined(IPV4AGGIDSNMP) 
     654              prefixKey.beginning = agCache.v4AdD>>(32-agCache.maskD)<<(32-agCache.maskD); 
     655              res3 = bsearch(&prefixKey, V4PTab, nbPV4,  
     656                             sizeof(struct PrefixV4), prefGlobalCmp); 
     657              if (res3!=NULL){ 
     658                if (myPtrs->currentRouterPtr->sampled != 0 ){ 
     659                  /* IN ("traffic to the prefix/subnet")  */ 
     660                  res3->bytesNbIN += agCache.bytes; 
     661                  res3->pktsNbIN += agCache.pkts; 
     662                  (res3->flowNbIN)++; 
     663                } 
     664                if (res3->sampling == 0  
     665                    && myPtrs->currentRouterPtr->sampled != 0){ 
     666                  res3->sampling = myPtrs->currentRouterPtr->sampled; 
     667                } 
     668              } 
     669#endif 
    571670#if defined(MATRIX) && defined(IPV4AGGIDR) 
    572671              /* inter-pop matrix Accounting */ 
     
    603702              /* doublon or bad reference in prefix list */ 
    604703            } 
    605           } else { 
     704          } else { /* the prefix in source don't exist in your prefix list */ 
    606705            prefixKey.beginning = agCache.v4AdD>>(32-agCache.maskD)<<(32-agCache.maskD); 
    607706            res = bsearch(&prefixKey, V4PTab, nbPV4,  
    608707                          sizeof(struct PrefixV4), prefGlobalCmp); 
    609708            if (res!=NULL){ 
    610               if ( myPtrs->currentRouterPtr->snmpIndexList[agCache.inputSnmp] == 1  ) {        
     709              if ( myPtrs->currentRouterPtr->snmpIndexList[agCache.inputSnmp] == 1  ) { 
    611710                if (myPtrs->currentRouterPtr->sampled != 0 ){ 
    612711                  /* IN ("traffic to the prefix/subnet")  */ 
     
    628727                  res->sampling = myPtrs->currentRouterPtr->sampled; 
    629728                } 
    630 /*            } else { */ 
     729              } else { 
    631730                /* doublon or bad reference in prefix list */ 
    632731              } 
    633732            } else { 
     733              /* UNKNOW SUBNET CASE                                        */ 
     734              /*                                                           */ 
    634735              /* HERE : we are in the cases of the address/mask don't      */ 
    635736              /*        belong to a prefix listed in the IPv4 prefix file  */ 
     
    663764#endif /* (IPV4AGGIDR) || (IPV4AGGIDSNMP) */ 
    664765        /*  
    665          * Redirection if needed  
     766         * 
     767         * SOCKET OUTPUT TO A REMOTE CLIENT 
     768         * 
    666769         * switch the rules definition (check & fieldToRecord),  
    667770         * we send the flow or a part of the flow to a remote host or a file. 
     
    772875     * 
    773876     * 
    774      *       Optional template 
     877     *  OPTIONAL TEMPLATE 
    775878     * 
    776879     *