Well, --sticky-hosts is -c, which is different than -2 :-)  Typically in ntop the -1 
-2, etc. options were cruder debugging and test
options...

Let's look:

    case 'c': /* Sticky hosts = hosts that are not purged when idle */
      myGlobals.stickyHosts = 1;
      break;

    case '2': /* disable purging of idle hosts */
      myGlobals.enableIdleHosts = 0;
      break;

Seriously, have to grep in the code - I'm not sure offhand of the differences...

  if (myGlobals.enableIdleHosts && (myGlobals.rFileName == NULL)) {
    createThread(&myGlobals.scanIdleThreadId, scanIdleLoop, NULL);
    traceEvent(TRACE_INFO, "Started thread (%ld) for idle hosts detection.",
               myGlobals.scanIdleThreadId);
  }

which leads to

void* scanIdleLoop(void* notUsed _UNUSED_) {
  for(;;) {
    int i;

    sleep(60 /* do not change */);

    if(!myGlobals.capturePackets) break;
    myGlobals.actTime = time(NULL);

    for(i=0; i<myGlobals.numDevices; i++)
      if(!myGlobals.device[i].virtualDevice) {
        purgeIdleHosts(i);
#ifdef HAVE_SCHED_H
        sched_yield(); /* Allow other threads to run */
#endif
      }
  }

  return(NULL);
}

So, using -2 prevents running purgeIdleHosts on a timed interval...

-c is internal to purgeIdleHosts... see hash.c around 378:

        if((!myGlobals.stickyHosts)
           || (myGlobals.borderSnifferMode)
           || (!subnetPseudoLocalHost(el))) {
#ifdef MULTITHREADED
          accessMutex(&myGlobals.hostsHashMutex, "scanIdleLoop");
#endif
            theFlaggedHosts[maxBucket++] = el;
            myGlobals.device[actDevice].hash_hostTraffic[theIdx] = NULL; /* (*) */
#ifdef MULTITHREADED
            releaseMutex(&myGlobals.hostsHashMutex);
#endif
            if(maxBucket == (MAX_NUM_PURGED_HOSTS-1)) {
              hashFull = 1;
              continue;
            }
        }

So that flag prevents adding a host to the list to be purged...

So, they're ALMOST the same... except for this:

      /* If (*) the entry might be NULL */
      if(myGlobals.device[actDevice].hash_hostTraffic[theIdx] != NULL)
        myGlobals.device[actDevice].hash_hostTraffic[theIdx]->numUses = 0;

(If numUses is zero, then it's not included in the busiest host calculations in 
traffic.c)

and this at the bottom of the timed loop:

  scanTimedoutTCPSessions(actDevice); /* let's check timedout sessions too */

So -2 prevents running that also (since the entire thread never gets created)...

I suppose that we should clarify the docs...

Why two very similar functions... not a clue.   Could be that there used to be even 
more in the loop?  It could also be that the
numUses/traffic.c interaction is important, and -2 was testing if the whole loop could 
be done away with, which would benefit CPU
challenged users.

I'd prefer -c vs -2 if I were you.

-----Burton


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Bert
Van de Voorde
Sent: Monday, April 29, 2002 8:36 AM
To: [EMAIL PROTECTED]
Subject: [Ntop] Ntop -2 question


Hiya'll

I'm using the -2 switch for ntop so it doesn't purge idle hosts. That works.
But it seems it doesn't purge current sessions either. That's bad. Cause I DO
want it to keep current sessions up 2 date and keep idle hosts in received and
sent data.

Furthermore I can't figure out the difference between --sticky-hosts and -2.

Can someone please clarify these two issues.
Thanks a million.

BTW. Ntop is great...

Bert Van de Voorde


-------------------------------------------------
This mail sent through Tiscali Webmail (http://webmail.tiscali.be)
_______________________________________________
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