From 8e6576f00ea077f0e388ae449523a0243a63f0b4 Mon Sep 17 00:00:00 2001 From: david Date: Thu, 14 Aug 2008 07:00:24 +0000 Subject: [PATCH] Use only the number of completed ports when computing completion time estimates, and don't consider the number of outstanding probes or number of retries. The old code would overestimate completion, causing a period of 99.99% completion at the end of a scan (which caused earlier estimates to be too soon). For a long UDP scan this puts the completion estimate right on after a little time to allow for convergence. See http://www.bamsoftware.com/wiki/Nmap/CompletionTimeEstimates. --- scan_engine.cc | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/scan_engine.cc b/scan_engine.cc index dbd95ebc1..56b89f4c2 100644 --- a/scan_engine.cc +++ b/scan_engine.cc @@ -3271,10 +3271,7 @@ static void printAnyStats(UltraScanInfo *USI) { hostI != USI->incompleteHosts.end(); hostI++) { host = *hostI; maxtries = host->allowedTryno(NULL, NULL) + 1; - // This is inexact (maxtries - 1) because of numprobes_sent includes - // at least one try of ports_finished. - thishostpercdone = host->ports_finished * (maxtries -1) + host->numprobes_sent; - thishostpercdone /= maxtries * USI->gstats->numprobes; + thishostpercdone = (double) host->ports_finished / USI->gstats->numprobes; if (thishostpercdone >= .9999) thishostpercdone = .9999; avgdone += thishostpercdone; } @@ -4827,10 +4824,7 @@ void ultra_scan(vector &Targets, struct scan_lists *ports, hostI != USI->incompleteHosts.end(); hostI++) { host = *hostI; maxtries = host->allowedTryno(NULL, NULL) + 1; - // This is inexact (maxtries - 1) because of numprobes_sent includes - // at least one try of ports_finished. - thishostpercdone = host->ports_finished * (maxtries -1) + host->numprobes_sent; - thishostpercdone /= maxtries * USI->gstats->numprobes; + thishostpercdone = (double) host->ports_finished / USI->gstats->numprobes; if (thishostpercdone >= .9999) thishostpercdone = .9999; avgdone += thishostpercdone; }