[Winpcap-users] Traffic Stats Bug
Cirix MAN
cirixman at hotmail.com
Tue May 30 07:48:43 GMT 2006
Hello,
I had write to you there is that a few times for errors during compilation.
Today I need again your assistance. Indeed, when I launch the function based
on the tutorial Gathering Statistics one the network traffic and that flow
networks is already in place, incoherent values are printed on the screen
very quickly, then at the end of 5 to 15 seconds, measurement returns to the
normal.
It is not very well for me because I must take delivery of the values in a
table to make the average of it. This one is thus thereafter completely
distorted. On the other hand if I start flow networks right after the
beginning of the capture, I obtain dice the beginning, good results.
This is my fonction :
void packet_handler(u_char *state, const struct pcap_pkthdr *header, const
u_char *pkt_data)
{
struct timeval *old_ts = (struct timeval *)state;
unsigned long int delay;
LARGE_INTEGER Bps,Pps;
struct tm *ltime;
char timestr[16];
int cpt_graph2;
int cpt_graph3;
delay=(header->ts.tv_sec - old_ts->tv_sec) * 1000000 - old_ts->tv_usec +
header->ts.tv_usec;
Bps.QuadPart=(((*(LONGLONG*)(pkt_data +8)) * 8 * 1000000) / (delay));
Pps.QuadPart=(((*(LONGLONG*)(pkt_data)) * 1000000) / (delay));
if(cpt_graph1==(graph-1))
for (cpt_graph2=1;cpt_graph2<graph;cpt_graph2++)
{
tab_graph[cpt_graph2-1]=tab_graph[cpt_graph2];
}
tab_graph[cpt_graph1]=(Bps.QuadPart/1024);
if(cpt_graph1<(graph-1))
{
cpt_graph1++;
}
ltime=localtime(&header->ts.tv_sec);
strftime(timestr, sizeof timestr, "%H:%M:%S", ltime);
printf("-------------------------------------------------------\n");
printf("Time : %s\t", timestr);
printf("PPS : %I64u\t\t", Pps.QuadPart);
printf("BPS : %I64u\n", Bps.QuadPart);
/* Calcul et affichage de la moyenne */
if((delay<10000000)&&(Bps.QuadPart!=0))
{
cumul_pkt=cumul_pkt+(*(LONGLONG*)(pkt_data));
cumul_bit=cumul_bit+(*(LONGLONG*)(pkt_data +8)) * 8;
cumul_tps=cumul_tps+delay;
moyenne_pkt=(cumul_pkt* 1000000) / (cumul_tps);
moyenne_bit=(cumul_bit* 1000000) / (cumul_tps);
moyenne_kbit=(moyenne_bit/1024);
printf("Total\t\tPaquets : %I64u",cumul_pkt);
printf("\t\tBits : %I64u\n",cumul_bit);
printf("Moyenne\t\tPPS : %I64u",moyenne_pkt);
printf("\t\tKBPS : %I64u\n",moyenne_kbit);
}
else printf("Le calcul de la moyenne est impossible\n");
old_ts->tv_sec=header->ts.tv_sec;
old_ts->tv_usec=header->ts.tv_usec;
for(cpt_graph3=0;cpt_graph3<(graph-1);cpt_graph3++)
{
printf("%i ",tab_graph[cpt_graph3]);
}
}
But if you want look all my source code, you can at this link :
http://s149731613.onlinehome.fr/tdfstage/sources/udpmeter.cpp
If you have the least idea concerning this problem, thx you in advance.
Best Regards ;)
_________________________________________________________________
Windows Live Mail : venez tester la version bêta !
http://www.ideas.live.com/programpage.aspx?versionId=5d21c51a-b161-4314-9b0e-4911fb2b2e6d
More information about the Winpcap-users
mailing list