mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 04:31:29 +00:00
Go back to the old method of calculating the completion percentage. My clever
formula algebraically reduced to 1.0 - gstats->numprobes / host->freshPortsLeft(), which doesn't regard the number of sent probes, leading to long stalls in the completion when, for example, maxtries is increased.
This commit is contained in:
@@ -1366,21 +1366,16 @@ double UltraScanInfo::getCompletionFraction() {
|
|||||||
/* Get the completion fraction for each incomplete host. */
|
/* Get the completion fraction for each incomplete host. */
|
||||||
for(hostI = incompleteHosts.begin(); hostI != incompleteHosts.end(); hostI++) {
|
for(hostI = incompleteHosts.begin(); hostI != incompleteHosts.end(); hostI++) {
|
||||||
HostScanStats *host = *hostI;
|
HostScanStats *host = *hostI;
|
||||||
int ports_left;
|
int maxtries = host->allowedTryno(NULL, NULL) + 1;
|
||||||
double rate;
|
double thishostpercdone;
|
||||||
double probes_left;
|
|
||||||
|
|
||||||
ports_left = host->freshPortsLeft();
|
// This is inexact (maxtries - 1) because numprobes_sent includes
|
||||||
if (ports_left == gstats->numprobes)
|
// at least one try of ports_finished.
|
||||||
continue;
|
thishostpercdone = host->ports_finished * (maxtries - 1) + host->numprobes_sent;
|
||||||
/* Get the overall rate of probes sent to ports completed. */
|
thishostpercdone /= maxtries * gstats->numprobes;
|
||||||
rate = (double) host->numprobes_sent / (gstats->numprobes - ports_left);
|
if (thishostpercdone >= 0.9999)
|
||||||
/* Find out how many probes it will take to scan the remainder of the ports
|
thishostpercdone = 0.9999;
|
||||||
at that rate. */
|
total += thishostpercdone;
|
||||||
probes_left = rate * ports_left;
|
|
||||||
/* Get the completion fraction: number of probes sent divided by estimated
|
|
||||||
total number of probes. */
|
|
||||||
total += (double) host->numprobes_sent / (host->numprobes_sent + probes_left);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return total / gstats->numtargets;
|
return total / gstats->numtargets;
|
||||||
|
|||||||
Reference in New Issue
Block a user