59
59
while(pr.getUDPPacket()) {
60
60
if((ntohs(pr.d_udp->uh_dport)==5300 || ntohs(pr.d_udp->uh_sport)==5300 ||
61
ntohs(pr.d_udp->uh_dport)==53 || ntohs(pr.d_udp->uh_sport)==53) &&
61
ntohs(pr.d_udp->uh_dport)==53 || ntohs(pr.d_udp->uh_sport)==53) &&
64
MOADNSParser mdp((const char*)pr.d_payload, pr.d_len);
66
lowestTime=min((time_t)lowestTime, (time_t)pr.d_pheader.ts.tv_sec);
67
highestTime=max((time_t)highestTime, (time_t)pr.d_pheader.ts.tv_sec);
69
string name=mdp.d_qname+"|"+DNSRecordContent::NumberToType(mdp.d_qtype);
71
QuestionIdentifier qi=QuestionIdentifier::create(pr.d_ip, pr.d_udp, mdp);
73
if(!mdp.d_header.qr) {
74
// cout<<"Question for '"<< name <<"'\n";
76
QuestionData& qd=statmap[qi];
78
if(!qd.d_firstquestiontime.tv_sec)
79
qd.d_firstquestiontime=pr.d_pheader.ts;
82
else { // NO ERROR or NXDOMAIN
83
QuestionData& qd=statmap[qi];
89
// cout<<"Answer to '"<< name <<"': RCODE="<<(int)mdp.d_rcode<<", "<<mdp.d_answers.size()<<" answers\n";
91
uint32_t usecs= (pr.d_pheader.ts.tv_sec - qd.d_firstquestiontime.tv_sec) * 1000000 +
92
(pr.d_pheader.ts.tv_usec - qd.d_firstquestiontime.tv_usec) ;
93
// cout<<"Took: "<<usecs<<"usec\n";
100
if(mdp.d_header.rcode != 0 && mdp.d_header.rcode!=3)
104
if(!qd.d_qcount || qd.d_qcount == qd.d_answercount)
105
statmap.erase(statmap.find(qi));
108
rcodes[mdp.d_header.rcode]++;
64
MOADNSParser mdp((const char*)pr.d_payload, pr.d_len);
66
lowestTime=min((time_t)lowestTime, (time_t)pr.d_pheader.ts.tv_sec);
67
highestTime=max((time_t)highestTime, (time_t)pr.d_pheader.ts.tv_sec);
69
string name=mdp.d_qname+"|"+DNSRecordContent::NumberToType(mdp.d_qtype);
71
QuestionIdentifier qi=QuestionIdentifier::create(pr.d_ip, pr.d_udp, mdp);
73
if(!mdp.d_header.qr) {
74
// cout<<"Question for '"<< name <<"'\n";
76
QuestionData& qd=statmap[qi];
78
if(!qd.d_firstquestiontime.tv_sec)
79
qd.d_firstquestiontime=pr.d_pheader.ts;
82
else { // NO ERROR or NXDOMAIN
83
QuestionData& qd=statmap[qi];
89
// cout<<"Answer to '"<< name <<"': RCODE="<<(int)mdp.d_rcode<<", "<<mdp.d_answers.size()<<" answers\n";
91
uint32_t usecs= (pr.d_pheader.ts.tv_sec - qd.d_firstquestiontime.tv_sec) * 1000000 +
92
(pr.d_pheader.ts.tv_usec - qd.d_firstquestiontime.tv_usec) ;
93
// cout<<"Took: "<<usecs<<"usec\n";
100
if(mdp.d_header.rcode != 0 && mdp.d_header.rcode!=3)
104
if(!qd.d_qcount || qd.d_qcount == qd.d_answercount)
105
statmap.erase(statmap.find(qi));
108
rcodes[mdp.d_header.rcode]++;
110
110
catch(MOADNSException& mde) {
111
// cerr<<"error parsing packet: "<<mde.what()<<endl;
111
// cerr<<"error parsing packet: "<<mde.what()<<endl;
117
117
catch(std::exception& e) {
195
195
for(done_t::iterator j=done.begin(); j!=done.end(); ++j)
196
196
if(!j->second && i->first > j->first) {
199
perc=sum*100.0/totpackets;
201
cout<< perc <<"% of questions answered within " << j->first << " usec (";
203
cout<< perc <<"% of questions answered within " << j->first/1000.0 << " msec (";
205
cout<<perc-lastperc<<"%)\n";
206
lastperc=sum*100.0/totpackets;
199
perc=sum*100.0/totpackets;
201
cout<< perc <<"% of questions answered within " << j->first << " usec (";
203
cout<< perc <<"% of questions answered within " << j->first/1000.0 << " msec (";
205
cout<<perc-lastperc<<"%)\n";
206
lastperc=sum*100.0/totpackets;