Interesting... and thanks for the find!

long long IS part of the C standard and has been part of gcc...  The
standard isn't available on the web (that I know of), but a (supposedly)
nearly final draft is at
http://anubis.dkuug.dk/JTC1/SC22/WG14/www/docs/n869/  (note that I found the
.pdf.gz was already uncompressed)

There is code in ntop.h ~56 to define u_int64_t as a 64bit unsigned type,
yet the definition of TrafficCounter at 710 doesn't use that.  I think this
is an oversight.

I also think that there should be a macro defined for this and then used in
the 100+ places where %llu is used:

emitter.c:1
mysql.c:77
sql.c:39

I'm going to bounce this to Luca for decision/action (our agreement is that
while I have access to the cvs for minor fixes, I let him make the
architectural ones - and frankly he's much more experienced with
cross-platform C than I am - he may have a better decision)...

Luca?

-----Burton



-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of
Vaclav Chaloupka
Sent: Thursday, May 16, 2002 7:02 AM
To: [EMAIL PROTECTED]
Subject: Re: [Ntop] RE: fetching data from perl


Found it!

TrafficCounter is defined in ntop.h like this:
#ifdef WIN32
typedef float TrafficCounter;
#else
typedef unsigned long long TrafficCounter;
#endif

emitter.c is calling wrtLlongItm to concert it to string and then print it.
It uses...
sprintf(buf,"%llu",value);
Which apparantely failed to print float variable, When I changed it to
sprintf(buf,"%.0f",value);
It works like a charm.

Now how how would you like to solve it so it works accross platforms?
Something like
#ifdef WIN32
sprintf(buf,"%.0f",value);
#else
sprintf(buf,"%llu",value);
#endif
....or would you rather define the argument as macro?

Burton?

Regards
> -----Original Message-----
> From: Vaclav Chaloupka [mailto:[EMAIL PROTECTED]]
> Sent: Monday, May 13, 2002 11:17 AM
> To: Burton M. Strauss III
> Subject: Re: [Ntop] RE: fetching data from perl
>
>
> Burton,
>
> Thanks for the navigation. I do not see anythink wrong with the code. It
> looks perfectly ok to me.
> But when I go to http://127.0.0.1:3000/dumpData.html, serch IP address of
my
> PC and look for bytesSent, there is '0'. So I do ftp of a quite large file
> and there is still 0.
> The same think with the bytesRcvd.
> Sometimes, there is 0....0...0..suddenly 2147483648 and next time I do
> refresh 0 again.
> Does it work for you, you? Any tips what could it be? From what I
understood
> from the code I think this is set in the pbuf.c, but I do not see anything
> wrong with the code (but it is quite complex so it will take me years :(.
>
> '54.101.69.190' => {
>  'index' => '6',
>  'hostNumIpAddress' => '54.101.69.190',
>  'hostSymIpAddress' => 'bebr4469',
>  'firstSeen' => '1021305805',
>  'lastSeen' => '1021306442',
>  'minTTL' => '128',
>  'maxTTL' => '128',
>  'nodeType' => '0',
>  'atNetwork' => '0',
>  'atNode' => '0',
>  'pktSent' => '0',
>  'pktRcvd' => '0',
>  'pktDuplicatedAckSent' => '0',
>  'pktDuplicatedAckRcvd' => '0',
>  'pktBroadcastSent' => '0',
>  'bytesMulticastSent' => '0',
>  'pktMulticastSent' => '0',
>  'bytesMulticastSent' => '0',
>  'pktMulticastRcvd' => '0',
>  'bytesSent' => '0',
>  'bytesSentLoc' => '0',
>  'bytesSentRem' => '0',
>  'bytesRcvd' => '0',
>
> Thanks
> V.
> ----- Original Message -----
> From: "Burton M. Strauss III" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Cc: <[EMAIL PROTECTED]>
> Sent: Wednesday, 08 May, 2002 16:51
> Subject: RE: [Ntop] RE: fetching data from perl
>
>
> > You might not know, but checkFilter just says that based on this
request,
> do I
> > output this data.
> >
> > Then you grep for the variable...
> >
> > grep --line-number '\->bytesSent' *.c | grep -v report
> >
> > give you about 15... windowing that for the += gives you
> > pbuf.c:502:  srcHost->bytesSent += length;
> > sessions.c:1305:      theSession->bytesSent      += length;
> > sessions.c:1451:        scanner->element->bytesSent += length;
> > traffic.c:533:
> > myGlobals.device[actualDeviceId].ipTrafficMatrix[id]->bytesSent +=
length;
> >
> > Four places to look...
> >
> > -----Burton
> >
> > -----Original Message-----
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of
> > Vaclav Chaloupka
> > Sent: Wednesday, May 08, 2002 9:30 AM
> > To: [EMAIL PROTECTED]
> > Subject: Re: [Ntop] RE: fetching data from perl
> >
> >
> > Burton,
> >
> > Ok, 15 questions was a bit too much, I admit. Forget it then.
> >
> > But I still have one single question. I've been looking in the source
code
> > since yesterday night. I think that the dumpData.html is done from the
> > emitter.c file.
> > For sent bytes:
> > if(checkFilter(filter, &filterPattern, "bytesSent")) wrtLlongItm(fDescr,
> > lang, "\t", "bytesSent",         el->bytesSent, ',', numEntries);
> > where
> > el =
> myGlobals.device[myGlobals.actualReportDeviceId].hash_hostTraffic[idx]
> >
> > But I have no idea how it gets to the bytesSent variable. Is the value
> > incremented by number of bytes every time there is a packet sent by the
> > host? I do not have the feeling.
> > That's why I just attached the pdf in my last message and I was hoping
> > someone who was involved in development of that would just briefly
explain
> > me what this means.
> >
> > V.
> > -----Original Message-----
> > From: Burton M. Strauss III [mailto:[EMAIL PROTECTED]]
> > Sent: Wednesday, 08 May, 2002 14:53
> > To: [EMAIL PROTECTED]
> > Cc: [EMAIL PROTECTED]
> > Subject: RE: [Ntop] RE: fetching data from perl
> >
> >
> > ntop is open source, and this list is a community resource.  If nobody
> > answered
> > your 15 questions, then nobody knew the answers off-hand and nobody
wanted
> > to
> > spend THEIR time solving your problem.
> >
> > I would suggest you examine the source to determine how the numbers are
> > being
> > calculated and displayed.
> >
> > The easiest way is to find the lines in the source that output the item
> > you're
> > concerned about and then grep for the particular counter.  Very few
> counters
> > are
> > referenced more than once or twice...
> >
> > Start in http.c and find the text or constant for the page you're
> interested
> > in,
> > e.g. dataSentHostTraffic.html is:
> >
> > #define STR_SORT_DATA_SENT_HOST_TRAFFIC "dataSentHostTraffic.html"
> >
> > That's in http.c:
> >
> >   } else if(strncmp(pageName, STR_SORT_DATA_SENT_HOST_TRAFFIC, strlen
> > (STR_SORT_DATA_SENT_HOST_TRAFFIC)) == 0) {
> > ...
> >        printHostsTraffic(4, sortedColumn, revertOrder, pageNum,
> > STR_SORT_DATA_SENT_HOST_TRAFFIC);
> >
> > Now look for printHostsTraffic and find the code that creates the cell
you
> > are
> > interested in.
> >
> > etc.
> >
> > If you want to discuss commercial support, please email me off-list.
> >
> >
> > -----Burton
> > _______________________________________________
> > Ntop mailing list
> > [EMAIL PROTECTED]
> > http://listgateway.unipi.it/mailman/listinfo/ntop
> >
> >
>
> _______________________________________________
> Ntop mailing list
> [EMAIL PROTECTED]
> http://listgateway.unipi.it/mailman/listinfo/ntop
>
_______________________________________________
Ntop mailing list
[EMAIL PROTECTED]
http://listgateway.unipi.it/mailman/listinfo/ntop

_______________________________________________
Ntop mailing list
[EMAIL PROTECTED]
http://listgateway.unipi.it/mailman/listinfo/ntop

Reply via email to