Apologies for all the spelling mistakes in that last post - fingers glued together :-)
-----Original Message----- From: Mark Gibbons Sent: 19 February 2004 08:24 To: [EMAIL PROTECTED] Subject: RE: [Ntop] Sorting Burton I certainly do not wish to stoke you up any more than you are now, HOWEVER please *LISTEN* to us. All we want is that the DISPLAYED data is sorted - we understand all the complex decisions that have to be made in naming the host. The problem is that the DISPLAYED data is not sorted correctly. My argumant is that if you can display it then you can sort it WHATEVER you have to sort. If you have decided to display the IP in the hosts column (for a certain host) then you should be Alpha sorting on that - THATS IT - no more complex argument than that. I actually greatly appreciate the time you have spent explaining the naming decision. However it is IRRELAVENT to the problem of correctly sorting the data diaplyed - or certainly should be. I dont really mind if you show the mac, Ip or resolved host - I do expect that the displayed data is correctly sorted. If I gave you random words from the disctionary - random numbers from the uk and US telephone directories some with and some without area codes and asked you to alpha sort then you would. And I doubt you would show the illogicality that the current sort process in ntop does. If you are displaying the data then you should sort by the data you are displaying - end of story. i.e. the ip's I gave you are in a random order - that just should not happen. THAT IS WHAT IS APPEARING ON THE WEB PAGE AND IT SHOULD NOT. If ntop is putting those ip's on the web page THEN they should be sorted. This may seem unimportant to you BUT from a users point of view I think it is The same is true on the data values - If you have numeric data of some type and you are DISPLAYING that data then you should be able to display it in a sorted order. That is Thomas's beef and I can see on the win32 version exactly where he is coming from - the columns are just jibberish. If you ask a column to be sorted, by clicking on it, then you expect the column to be sorted. So i'm afraid sorting the data values - IS just sorting numbers. If you are trying to make it more complex than that then that is where the problem is. As I said - not trying to stoke you up - but inconsistencies like this just hit the plain old simple user straight between the eyes so they are important. If people see the inconsistency in a simple sort then they wonder how innacurate the rest of the packet capture and analysis routines are. Regards Mark -----Original Message----- From: Burton M. Strauss III [mailto:[EMAIL PROTECTED] Sent: 19 February 2004 04:42 To: [EMAIL PROTECTED] Subject: 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 _______________________________________________ Ntop mailing list [EMAIL PROTECTED] http://listgateway.unipi.it/mailman/listinfo/ntop _______________________________________________ Ntop mailing list [EMAIL PROTECTED] http://listgateway.unipi.it/mailman/listinfo/ntop
