Changeset 1268

Show
Ignore:
Timestamp:
11/15/08 20:30:56 (5 years ago)
Author:
ahu
Message:

make dnsreplay deal with 'the final few packets' so very small pcap files can be analysed too

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/pdns/pdns/dnsreplay.cc

    r1175 r1268  
    7070 
    7171po::variables_map g_vm; 
    72  
    7372 
    7473const struct timeval operator*(float fact, const struct timeval& rhs) 
     
    415414 
    416415 
    417 void houseKeeping() 
    418 { 
    419   static timeval last; 
    420  
    421   struct timeval now; 
    422   gettimeofday(&now, 0); 
    423  
    424   if(DiffTime(last, now) < 0.3) 
    425     return; 
    426  
    427   int weWaitingFor, origWaitingFor, weSlow, origSlow; 
    428   WeOrigSlowQueriesDelta(weWaitingFor, origWaitingFor, weSlow, origSlow); 
    429      
    430   if(!g_throttled) { 
    431     if( weWaitingFor > 1000) { 
    432       cerr<<"Too many questions ("<<weWaitingFor<<") outstanding, throttling"<<endl; 
    433       g_throttled=true; 
    434     } 
    435   } 
    436   else if(weWaitingFor < 750) { 
    437     cerr<<"Unthrottling ("<<weWaitingFor<<")"<<endl; 
    438     g_throttled=false; 
    439   } 
    440  
    441   if(DiffTime(last, now) < 2) 
    442     return; 
    443  
    444   last=now; 
    445  
    446   /* 
    447         Questions - Pend. - Drop = Answers = (On time + Late) = (Err + Ok) 
    448 Orig    9           21      29     36         47        57       66    72 
    449  
    450  
    451    */ 
     416void printStats(uint64_t origWaitingFor=0, uint64_t weWaitingFor=0) 
     417{ 
    452418 
    453419  format headerfmt   ("%|9t|Questions - Pend. - Drop = Answers = (On time + Late) = (Err + Ok)\n"); 
     
    467433  cerr<<"Unmatched from us: "<<s_weunmatched<<", unmatched from original: "<<s_origunmatched << " ( - decoding err: "<<s_origunmatched-s_origdnserrors<<")"<<endl; 
    468434  cerr<<"DNS decoding errors from us: "<<s_wednserrors<<", from original: "<<s_origdnserrors<<", exact duplicates from client: "<<s_duplicates<<endl<<endl; 
     435 
     436} 
     437 
     438void houseKeeping() 
     439{ 
     440  static timeval last; 
     441 
     442  struct timeval now; 
     443  gettimeofday(&now, 0); 
     444 
     445  if(DiffTime(last, now) < 0.3) 
     446    return; 
     447 
     448  int weWaitingFor, origWaitingFor, weSlow, origSlow; 
     449  WeOrigSlowQueriesDelta(weWaitingFor, origWaitingFor, weSlow, origSlow); 
     450     
     451  if(!g_throttled) { 
     452    if( weWaitingFor > 1000) { 
     453      cerr<<"Too many questions ("<<weWaitingFor<<") outstanding, throttling"<<endl; 
     454      g_throttled=true; 
     455    } 
     456  } 
     457  else if(weWaitingFor < 750) { 
     458    cerr<<"Unthrottling ("<<weWaitingFor<<")"<<endl; 
     459    g_throttled=false; 
     460  } 
     461 
     462  if(DiffTime(last, now) < 2) 
     463    return; 
     464 
     465  last=now; 
     466 
     467  /* 
     468        Questions - Pend. - Drop = Answers = (On time + Late) = (Err + Ok) 
     469Orig    9           21      29     36         47        57       66    72 
     470 
     471 
     472   */ 
     473 
     474  printStats(origWaitingFor, weWaitingFor); 
    469475 
    470476  pruneQids(); 
     
    601607 
    602608  g_rdSelector = g_vm["recursive"].as<bool>(); 
     609 
    603610  g_quiet = g_vm["quiet"].as<bool>(); 
    604611 
     
    654661  } 
    655662 out:; 
     663  sleep(1); 
     664  receiveFromReference(); 
     665  printStats(); 
    656666} 
    657667catch(exception& e)