The comparison function for host name sorting is in reportUtils.c around
line 822.
The sort is a basic quicksort (c library function)
If you look at it (snipping out the ifdefs):
if(myGlobals.columnSort == HOST_DUMMY_IDX_VALUE) {
int rc;
/* Host name */
if((*a)->hostSymIpAddress[0] != '\0') {
char *name1, *name2;
name1 = (*a)->hostSymIpAddress;
name2 = (*b)->hostSymIpAddress;
rc = strcasecmp(name1, name2);
} else
rc = strcasecmp((*a)->ethAddressString, (*b)->ethAddressString);
return(rc);
}
The sort comparison is sensitive to the various types of host "names"
(hostSymIpAddress), IF they have been resolved...
hash.c:966: strcpy(el->hostSymIpAddress, sniffedName);
pbuf.c:478: strcpy(el->hostSymIpAddress, el->nbHostName);
pbuf.c:480: strcpy(el->hostSymIpAddress, el->ipxHostName);
pbuf.c:482: strcpy(el->hostSymIpAddress, el->atNodeName);
Suboptimally, the test only checks if the "a" value is set, not both "a" and
"b"... thus in the case of unresolved names violating transitivity (that is
A == B is not the same as B == A). However fixing that that won't "fix" the
problem...
If the name hasn't been resolved it uses the MAC address (ethAddressString).
This can occasionally yield odd results where values aren't populated... as
some of the comparisons go one way, others differently, (i.e. A < B and B <
C but A might be > C)
Sort it yourself and see:
1. 00:60:97:04:30:33 a.b.com
2. 02:00:00:00:02:01 **unresolved**
3. 02:00:00:00:01:02 d.e.com
The comparison between #1 and #2 is a.b.com vs. null, so "2" < "1"
The comparison between #2 and #3 is 02:00:00:00:02:01 vs. 02:00:00:00:01:02,
so "3" < "2"
One would expect "3" < "2" < "1"
But, the comparison between #1 and #3 is a.b.com vs. d.e.com, so "1" < "3"
Even odder, since the displayed value will use the numeric IP address, it
will look like what you're seeing.
I can add an FAQ entry, but the code is what it is... there really isn't
any consistent way to sort with unresolved information.
-----Burton
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Kai
Schaetzl
Sent: Sunday, October 13, 2002 10:07 AM
To: [EMAIL PROTECTED]
Subject: [Ntop] alphabetic ordering of host names not correct
2.1.51 on Windows .NET
The ordering of host names isn't correct most of the time, there are
always hosts which are not put in the correct
order. Seen f.i. on the "Network Traffic: Data Sent" page (Host
Activity) F.i. when I order ascending I get this order (just the
first letter/digit):
2
6
6
6
6
b
2
66
62
62
62
b
. lots of correctly ordered hosts until the end of the alphabet ...
ASCEND (the router)
1 (ntop machine)
And on next refresh it's totally different:
2
6
6
6
6
b
b
62
2
62
2
62
66
f
. lots of correctly ordered hosts until almost the end of the
alphabet ...
ASCEND (the router)
1 (ntop machine)
t
u
. and so on to the end of the alphabet
Also, several of the IP only hosts get a US flag although there
shouldn't be one.
Well, this is what I wrote yesterday. It's better today after most of
the IPs are resolved to names now, but still not perfect.
F.i. I get 205.171.9.242 listed between hosts starting with "n" and
with a US flag. The host name of that IP is
dca-ans-01.inet.qwest.net, so displaying the flag would be correct.
However, if ntop knows that name it could also display it (and in the
correct order) ...
And the router (Ascend) is sometimes displayed at the end of the list
and sometimes near the end.
Kai
--
Kai Sch�tzl, Berlin, Germany
Get your web at Conactive Internet Services: http://www.conactive.com
IE-Center: http://ie5.de & http://msie.winware.org
_______________________________________________
Ntop mailing list
[EMAIL PROTECTED]
http://listgateway.unipi.it/mailman/listinfo/ntop
_______________________________________________
Ntop mailing list
[EMAIL PROTECTED]
http://listgateway.unipi.it/mailman/listinfo/ntop