Burton,

I hope I understood what you told me, thanks for taking the time... I have
limited programming knowledge in C++ (I'm OK with Visual Basic, ...), but I
know how to do networking... At least I have a reasonable understanding
about this...

I have two ideas how to handle the problem. But this only will work if you
find a way to do a "correct" sorting, this is nothing, I can handle...

1.) Do a sorting by "best known information"
I'm not sure if there's already a field for sorting, I think you mentioned
something like that. Fill this with be "best known information". This should
be i.e. MAC-Address (bad luck if you only have that), IP-Address (well,
that's better) to host name (which is best). Sort then by this name, not
more or less. Do a "clean" formatting of MAC- and IP-Adresses (i.e.
192.168.005.001), this is not nice but gives you a good chance to do a
correct sorting... I have no idea how fibre channel and iSCSI work, but I
guess there will be good and better "names", too.

2.) Introduce more columns for sorting
Perhaps it's the best way to introduce more colums so that you can choose
what you want as sorting criteria. Add MAC-Address, IP-Address, Hostname,
... to the lists and everybody will have the chance to sort by whatever. The
IP-Addresses should be formatted like 192.168.005.001 again or there must be
a special sorting routine for them...

Perhaps the combination of both will be the right solution. Perhaps using
DHTML with "intelligent" tables is an idea, too.

I just saw Mark's actual comments, I agree 100%. I tried to explain
everything from a user's point of view. I want to see a sorting which is
obviously logical. I understand (at least I try to) the technical problems
behind that. I just can't live with it. Try to tell someone why a sorting by
a column, whatever is in there, is not working (forget about the problem of
getting data just when the sort is done - I can live with that, but that
seams to be a rare case). Nobody will understand you! They see a text (or
even a number), try to sort just what they see (not what's behind that
information), and everything they get simply makes no sense. 

There must be a solution for that and I hope I gave you some ideas...


Regards,
 
 

Thomas Pagel
-----Urspr�ngliche Nachricht-----
Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im Auftrag von Burton
M. Strauss III
Gesendet: Donnerstag, 19. Februar 2004 05:42
An: [EMAIL PROTECTED]
Betreff: RE: [Ntop] Sorting

IT IS NOT JUST SORTING NUMBERS - PLEASE READ WHAT I WROTE THAT EXPLAINS WHAT
IS REALLY HAPPENING.

I CAN'T SAY IT ANY SIMPLER - it is a complex problem.  You are trying to
apply simple logic to a non-simple task.


The sort field is one that start unvalued.  As ntop learns more about the
host, it can set or change the value in that field.  It represents the best
information we have about the 'name' of that host - at that instant in time.

But the name of the host is not an absolute thing.  At a minimum, you have
THREE names, valid in different ways.

Your network card has an address burned into it called a MAC address.  It's
a 48 bit quantity, used for the local delivery of packets - at the lowest
(data link or frame level).

Your Host has an address, it's a TCP/IP address - at 32 bit number that
uniquely identifies a single host on the global internet.  This is used for
non-local routing. (You might also have 128 bit IPv6 address - either, both
or neither, but ignore this).

Your host MAY have a name.  This is used for easy of access -- www.ntop.org
is easier than some 32 bit number.  That name is mapped to the 32 bit number
via DNS.  But you don't HAVE to have a name, or you may have multiple names
mapped to that 32 bit number, or a single name may map to multiple 32 bit
numbers...

All THREE of these are valid names for the host, used in different ways.


Follow this message from me to you.

I send it to [EMAIL PROTECTED]

My mail program goes out to the DNS and asks for the MX (mail exchange)
record for software4you.com - and is told

software4you.com MX (Mail Exchanger) Priority: 20 mail.de.uu.net

So my mail program looks up mail.de.uu.net and creates a packet to send from
MY address (67.166.222.162) to 192.76.144.89

That tcp/ip packet is wrapped in an Ethernet frame with the lower level MAC
address 02:00:00:00:00:01 or whatever.

THAT PACKET IS WHAT NTOP SEES

(macsrc)(macdst)((ipsrc)(ipdst)...)

The local router looks at the tcp/ip destination, decides it's not local and
routes it as a TCP/IP packet.  Each router in turn does this until finally
it gets to your local router, 149.227.16.166.

That router looks at the addresses of it's interface and realizes it's now a
local delivery.  So it issues an ARP (Address Resolution Protocol) request
"WHO-HAS 192.76.144.89".  Your mail host responds "I do, and I'm at
02:00:00:11:11:11" - with the 48 bit address.  The router rewrites the
packet to be

(macsrc)(02:00:00:11:11:11)((ipsrc)(ipdst)...) and squirts it onto the wire.

The network card on the mail host recognizes it's MAC address and grabs the
packet to process.  Everyone else ignores it.


If you think about this, then, the 1st thing ntop usually sees is a MAC
level (48 bit) address.  After a while, it sees a packet with both that MAC
and an 32bit TCP/IP address, so it can associate the two.

But it could be the other way around - or ntop may NEVER see the MAC
address, for example a remote host.

After a while, ntop either sniffs a DNS packet or makes it's own query and
can then associate the TCP/IP number with the address mail.de.uu.net.

(The reality is worse, because ntop actually deals with other kinds of
addresses - IPv6, FibreChanel host adapters, etc. - but lets leave things
where we are).

So it comes down to a tough question - how do you sort hosts in a way that
is valid when you don't have all the information??  And what you do know is
changing on you...

If you sort by 48 bit mac address, 1) most people would think it's a
nonsense sort - as there is no rhyme nor reason to the 'order'. and 2) you
only know these for LOCAL addresses.

If you sort by 32 bit IP address - regardless of whether you fix the trivial
problem of sorting by nibbles or not - again most people would think it's a
nonsense sort - why should www.ibm.com sort before www.compaq.com, but after
www.abc.com???

If you sort by DNS resolved name, what do you do before you KNOW this value.
It can be seconds or minutes from when you first see the host until you know
the name.


The last part of the problem is that the sort key value can change in the
middle of the sort, if we happen to learn additional information.  We
basically punt here - use the mutex to protect the integrity of the data and
accept the rare, pathological case where you get a messed up sort that will
automatically fix itself when you resort.


But you're still back at the crux of the problem.

If you drop all records that don't have DNS entries, you lose data.
If you sort by any of the numeric fields, people interpret it as nonsense.
If you sort by a combination of fields, you are going to have seemingly
inexplicable results.


What can be done?

Not much

Testing BOTH the a and b parts of the hostSymIpAddress and falling back to
the backup sort if EITHER of them is \0 will slightly improve things, but
you're still going to have results that look inexplicable because of the
fall back.  But at least the sort would then be stable (except in the
pathological case where the DNS resolution happens in the middle of the
sort).

If you want to try this, change the line in reportUtils.c (around 1099) from
this:

    if((*a)->hostSymIpAddress[0] != '\0') {

to

    if(((*a)->hostSymIpAddress[0] != '\0') && ((*b)->hostSymIpAddress[0] !=
'\0')) {

But that's not going to fix the whole "problem" and nothing will.  We can
eliminate more and more corner cases, but we can't completely 'fix' it.

Basically the answer is that, because ntop is a hybrid layer 2/layer 3
analyzer, there will ALWAYS be some case you can construct where the sort
isn't going to be 'pretty'.  What we have looks good in MOST cases.
Something like Rocco's change will make things a little better, but won't
fix every case.  It can't.

Live with it...


-----Burton



> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of
> Pagel, Thomas
> Sent: Wednesday, February 18, 2004 5:38 PM
> To: [EMAIL PROTECTED]
> Subject: AW: [Ntop] Sorting
>
>
> Burton,
>
> sorry, it's past midnight here, maybe that's why I don't understand the
> logic you try to explain... But don't mind...
>
> My point is just, well, there must be a way to sort numbers correctly... I
> will not believe that Microsoft has the only knowledge in the world how to
> do a sorting correctly, because I never saw an incorrect sorting
> in Excel. I
> don't care about bubble or quick sort. I simply would like to see a sort
> working... Sorry, this is a simple request from a user, I can't help you
> finding out the right solution.
>
> In my former posts the answer was: tell us how to sort and we'll
> do it. It's
> not much what I would like to see. I'm not searching the perfect sort (I'd
> like to see it but I understand that it's not easy to define), I just want
> to have an understanding how data is sorted. This doesn't mean that I want
> to see the code, discuss the algorithms, I'd like to have simply
> a result me
> (or better my boss) will understand without long discussions. Is it really
> to much to ask for a numerically correct solution?
>
> I really appreciate the effort you spend to make us understand what's
> happening behind the scene. But I simply have a problem to understand the
> point "Sorry, we simply can't sort correctly"....
>
>
> Regards,
>
>
>
> Thomas Pagel

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

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to