Changeset 84 for trunk/src

Show
Ignore:
Timestamp:
11/07/08 16:20:00 (14 years ago)
Author:
andreu
Message:

multi-sampling implementation - phase 1

Location:
trunk/src
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/dataFlowSet.c

    r83 r84  
    657657                        sizeof(struct PrefixV4), prefGlobalCmp); 
    658658          if (res!=NULL){ 
    659             /* res is supernet or subnet ? */ 
     659            /* WE HAVE FOUND SOURCE ADDRESS IN OUR LIST */ 
    660660            if (res->hasSubnet == 1) { 
    661661              resSub = NULL; 
     
    667667              }  
    668668            } 
     669#ifdef DEBUG 
     670            fprintf(stderr,"S %lu.%lu.%lu.%lu/%hu %lu.%lu.%lu.%lu/%hu Rs %lu Ps %lu\n", 
     671                    (agCache.v4AdS>>24), 
     672                    (agCache.v4AdS<<8>>24),  
     673                    (agCache.v4AdS<<16>>24),  
     674                    (agCache.v4AdS<<24>>24),  
     675                    (agCache.maskS), 
     676                    (agCache.v4AdD>>24),  
     677                    (agCache.v4AdD<<8>>24),  
     678                    (agCache.v4AdD<<16>>24),  
     679                    (agCache.v4AdD<<24>>24),  
     680                    (agCache.maskD), 
     681                    myPtrs->currentRouterPtr->sampled, 
     682                    res->sampling); 
     683#endif 
    669684#if defined(IPV4AGGIDR) 
    670685            if ( myPtrs->routersID[res->routerNb] == agCache.routerAd  ) {  
     
    672687              if ( myPtrs->currentRouterPtr->snmpIndexList[agCache.inputSnmp] == 1  ) {        
    673688#endif 
    674  
    675689                /* OUT ("traffic from the prefix/subnet")  */ 
    676690#if defined(MULTISAMPLING) 
     
    710724                    } 
    711725                  } 
     726#ifdef DEBUG 
     727            fprintf(stderr,"S&D %lu.%lu.%lu.%lu/%hu %lu.%lu.%lu.%lu/%hu Rs %lu Ps %lu\n", 
     728                    (agCache.v4AdS>>24), 
     729                    (agCache.v4AdS<<8>>24),  
     730                    (agCache.v4AdS<<16>>24),  
     731                    (agCache.v4AdS<<24>>24),  
     732                    (agCache.maskS), 
     733                    (agCache.v4AdD>>24),  
     734                    (agCache.v4AdD<<8>>24),  
     735                    (agCache.v4AdD<<16>>24),  
     736                    (agCache.v4AdD<<24>>24),  
     737                    (agCache.maskD), 
     738                    myPtrs->currentRouterPtr->sampled, 
     739                    res3->sampling); 
     740#endif 
    712741#if defined(MULTISAMPLING) 
    713742                  if (myPtrs->currentRouterPtr->sampled != res3->sampling ){ 
     
    772801            } 
    773802#endif 
    774           } else { /* res==NULL, the prefix in source don't exist in your prefix list */ 
     803          } else { /* SOURCE ADDRESS DOESN'T IN OUR LIST */ 
    775804            prefixKey.beginning = agCache.v4AdD>>(32-agCache.maskD)<<(32-agCache.maskD); 
    776805            res = bsearch(&prefixKey, V4PTab, nbPV4,  
    777806                          sizeof(struct PrefixV4), prefGlobalCmp); 
    778807            if (res!=NULL){ 
    779               /* res is supernet or subnet ? */ 
     808              /* DESTINATION ADDRESS IS IN OUR LIST */ 
    780809              if (res->hasSubnet == 1) { 
    781810                resSub = NULL; 
     
    787816                } 
    788817              } 
     818#ifdef DEBUG 
     819            fprintf(stderr,"D %lu.%lu.%lu.%lu/%hu %lu.%lu.%lu.%lu/%hu Rs %lu Ps %lu R@ %lu.%lu.%lu.%lu\n", 
     820                    (agCache.v4AdS>>24), 
     821                    (agCache.v4AdS<<8>>24),  
     822                    (agCache.v4AdS<<16>>24),  
     823                    (agCache.v4AdS<<24>>24),  
     824                    (agCache.maskS), 
     825                    (agCache.v4AdD>>24),  
     826                    (agCache.v4AdD<<8>>24),  
     827                    (agCache.v4AdD<<16>>24),  
     828                    (agCache.v4AdD<<24>>24),  
     829                    (agCache.maskD), 
     830                    myPtrs->currentRouterPtr->sampled, 
     831                    res->sampling, 
     832                    (myPtrs->pcktPtr->ipH->srcAdd>>24),  
     833                    (myPtrs->pcktPtr->ipH->srcAdd<<8>>24), 
     834                    (myPtrs->pcktPtr->ipH->srcAdd<<16>>24), 
     835                    (myPtrs->pcktPtr->ipH->srcAdd<<24>>24)); 
     836#endif 
    789837#if defined(IPV4AGGIDSNMP) 
    790838              if ( myPtrs->currentRouterPtr->snmpIndexList[agCache.inputSnmp] == 1  ) { 
     839#if defined(MULTISAMPLING) 
     840                if (myPtrs->currentRouterPtr->sampled != res->sampling ){ 
     841                  res->bytesNbIN += agCache.bytes*myPtrs->currentRouterPtr->sampled/res->sampling; 
     842                  res->pktsNbIN += agCache.pkts*myPtrs->currentRouterPtr->sampled/res->sampling; 
     843                }else{ 
     844                  res->bytesNbIN += agCache.bytes; 
     845                  res->pktsNbIN += agCache.pkts; 
     846                  (res->flowNbIN)++; 
     847                } 
     848#else 
    791849                if (myPtrs->currentRouterPtr->sampled != 0 ){ 
    792850                  /* IN ("traffic to the prefix/subnet")  */ 
     
    795853                  (res->flowNbIN)++; 
    796854                } 
     855#endif 
    797856              } 
    798857#endif 
     
    806865                } 
    807866              } 
    808 #endif 
    809867              if (res->sampling == 0  
    810868                  && myPtrs->currentRouterPtr->sampled != 0 ){ 
    811869                res->sampling = myPtrs->currentRouterPtr->sampled; 
    812870              } 
     871#endif 
    813872            } else { 
    814873              /* UNKNOW SUBNET CASE                                        */ 
     
    9641023#ifdef DEBUG 
    9651024      fprintf(stderr,"<d id: %hu, lg %hu", (*myPtrs->currentFlowsetIdPtr), data_length); 
    966 #endif       
     1025#endif 
    9671026      for ( i=0; i<(tmpOpt->optionScopeLg/4); i++){ 
    9681027        /* FIXME : today we skip the scope fields, it's bad :( */  
     
    9871046          buffer4[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 
    9881047          buffer4[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 
    989           if (pftmp->fieldType==34){ 
     1048          if (pftmp->fieldType==34||pftmp->fieldType==50){ 
    9901049            if ((*((unsigned long*)&buffer4)==1)  
    9911050                || (*((unsigned long*)&buffer4)==10) 
     
    9961055                fprintf(stderr,"\n SV (p) %lu != %lu (r)", *((unsigned long*)&buffer4), 
    9971056                        myPtrs->currentRouterPtr->sampled); 
    998 #endif                      
     1057#endif 
    9991058                syslog(LOG_INFO,"Sampling value change for router : %lu.%lu.%lu.%lu, old: %lu, new: %lu", 
    10001059                       (myPtrs->pcktPtr->ipH->srcAdd>>24), 
  • trunk/src/get_conf.c

    r83 r84  
    335335        pV4SubTabPtr[subNetIndex].mask = n4; 
    336336#if defined(MULTISAMPLING) 
    337         pV4TabPtr[subNetIndex].sampling = n6; 
     337        pV4SubTabPtr[subNetIndex].sampling = n6; 
    338338#else 
    339         pV4TabPtr[subNetIndex].sampling = 0; 
     339        pV4SubTabPtr[subNetIndex].sampling = 0; 
    340340#endif 
    341341#ifdef IPV4AGGIDR       
  • trunk/src/routers_mgmt.c

    r80 r84  
    4949    tmp->tplList = NULL; 
    5050    tmp->tplOptList = NULL; 
     51#if defined(MULTISAMPLING) 
     52    tmp->sampled = 1; 
     53#else 
    5154    tmp->sampled = 0; 
     55#endif 
    5256    tmp->next = routersList; 
    5357    if (routersList!=NULL) { routersList->prev = tmp;}