> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of
> Pagel, Thomas
> Sent: Wednesday, February 18, 2004 11:37 AM
> To: [EMAIL PROTECTED]
> Subject: [Ntop] Sorting
>
> Hi,
>
> I just had a look at the version 3 for Windows... Looks very nice...
>
> But there's still that issue I reported months ago... The sorting of the
> columns IP Address and Host Name simply make no sense... At least I don't
> understand it...
>
> Thomas Pagel

Same answer as the last two times you asked,
http://article.gmane.org/gmane.linux.ntop.general/3651 - it's based on which
fields do and don't exist (are valued).  As I recall (and memory is a fuzzy
thing), you left that discussion mumbling about creating some kind of rule
to follow instead of leaving ntop to sort on nulled fields.

Finding what ntop does is easy.  Figuring out what it SHOULD do is hard.

To figure out how ntop IS sorting, figure out which html page it is (status
bar will usually show it to you). For each page, find the piece in http.c
for that specific _HTML constant and find the function it calls.  In that
function - usually in report.c, find the qsort and see what the column # is
and the specific function.

You'll usually find them in reportUtils.c, and usually in cmpFctn():

The case statement shows you what field ntop is sorting on.  For example,
here is the 'host' sort, used in printHostsTraffic() (used in
CONST_SORT_DATA_HOST_TRAFFIC_HTML, e.g. dataHostTraffic.html):

  if(myGlobals.columnSort == FLAG_HOST_DUMMY_IDX) {
    int rc;

    /* Host name */
    accessAddrResMutex("cmpFctn");

    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);

    releaseAddrResMutex();
    return(rc);
  } ...


Reading that, it does a case insensitive compare of the address previously
stored as a string (e.g. "1.2.3.4").  That's pretty clealy sub-optimal,
since what if b doesn't have a value (what does strcasecmp("1.2.3.4", NULL)
give?)?  It works fine if all hosts are resolved, but where it breaks down
is if one host is resolved and the other isn't, or if they're different
types of hosts, such as a non-IP address.

The function that sets this is in pbuf.c:

void updateHostName(HostTraffic *el) {

  if((el->hostNumIpAddress[0] == '\0')
     || (el->hostSymIpAddress == NULL)
     || strcmp(el->hostSymIpAddress, el->hostNumIpAddress) == 0) {
    int i;

    if(el->nonIPTraffic == NULL) el->nonIPTraffic = (NonIPTraffic*)calloc(1,
sizeof(NonIPTraffic));

    if(el->nonIPTraffic->nbHostName != NULL) {
      /*
        Use NetBIOS name (when available) if the
        IP address has not been resolved.
      */
      memset(el->hostSymIpAddress, 0, sizeof(el->hostSymIpAddress));
      strcpy(el->hostSymIpAddress, el->nonIPTraffic->nbHostName);
    } else if(el->nonIPTraffic->ipxHostName != NULL)
      strcpy(el->hostSymIpAddress, el->nonIPTraffic->ipxHostName);
    else if(el->nonIPTraffic->atNodeName != NULL)
      strcpy(el->hostSymIpAddress, el->nonIPTraffic->atNodeName);

    if(el->hostSymIpAddress[0] != '\0')
      for(i=0; el->hostSymIpAddress[i] != '\0'; i++)
        el->hostSymIpAddress[i] = (char)tolower(el->hostSymIpAddress[i]);
  }
}

What it's attempting to do is to set some kind of reasonable value in that
field for every type of host.

So it's still the same problem as when you 1st asked in Oct 2002 (and April
2003 and Sept 2003) - and I still don't have a clue what the "RIGHT" answer
is.

If you can propose a reasonable set of rules, we can look at it, but it's
got to pass both the reality and sniff tests.

Remember, you have NetBIOS names, AppleTalk names, FibreChannel, iSCSI and
normal IPs. Is just a simple alpha sort enough, if the function in pbuf.c
gets smarter???  You talked at one point about relative placement - do
NetBIOS names get sorted in with tcp/ip dns, or are they at the end.  What
about cross-compares??

Say you have this set:

192.168.1.1  -- no dns lookup
192.168.1.2  -- ftp.imahostingcompany.tld
92.99.9.888 - www.imahostingcompany.tld
92.99.9.999 -- no dns
02:00:00:00:00:01 -- MAC level only
WINSTATION -- Win98 NetBIOS

How do you sort 'em?????

Is it

02:00:00:00:00:01
192.168.1.1
92.99.9.999
ftp.imahostingcompany.tld
WINSTATION
www.imahostingcompany.tld

or is it

02:00:00:00:00:01
92.99.9.999
192.168.1.1
ftp.imahostingcompany.tld
WINSTATION
www.imahostingcompany.tld

etc...


(NB: The reality test is that I'm unlikely to make major changes having just
pushed 3.0pre1 up for widespread testing).




-----Burton





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

Reply via email to