1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-20 22:49:01 +00:00

Merge from /nmap-exp/david/nmap-massping-migration. This is the change that

scales per-host congestion control increments in the same way those for the
group already are. This speeds scanning in some cases (particularly with few
hosts, when the group congestion control is not the limiting factor). I'm going
to experiment with raising the increment cap to allow this to have more of an
effect.

Scale host congestion control variables similarly to the way group congestion
control is scaled. For the rationale see
http://www.bamsoftware.com/wiki/Nmap/PerformanceGraphs#host-scaled.

Host cc_scale should use (numprobes_sent + numpings_sent), not (numprobes_sent + numprobes_sent).
This commit is contained in:
david
2007-10-02 06:58:12 +00:00
parent b64243b05a
commit 0f396a5b3a

View File

@@ -571,6 +571,13 @@ public:
int numpings_sent; int numpings_sent;
/* Boost the scan delay for this host, usually because too many packet /* Boost the scan delay for this host, usually because too many packet
drops were detected. */ drops were detected. */
int numprobes_replied_to; /* The number of probes for which we've received
responses. Used for scaling congestion control increments. */
/* Returns the scaling factor to use when incrementing the congestion window.
This is the minimum of
(numprobes_sent + numpings_sent) / numprobes_replied_to and
cc_scale_max. */
double cc_scale();
void boostScanDelay(); void boostScanDelay();
struct send_delay_nfo sdn; struct send_delay_nfo sdn;
struct rate_limit_detection_nfo rld; struct rate_limit_detection_nfo rld;
@@ -976,6 +983,7 @@ HostScanStats::HostScanStats(Target *t, UltraScanInfo *UltraSI) {
ports_finished = 0; ports_finished = 0;
numprobes_sent = 0; numprobes_sent = 0;
numpings_sent = 0; numpings_sent = 0;
numprobes_replied_to = 0;
init_ultra_timing_vals(&timing, TIMING_HOST, 1, &(USI->perf), &USI->now); init_ultra_timing_vals(&timing, TIMING_HOST, 1, &(USI->perf), &USI->now);
bench_tryno = 0; bench_tryno = 0;
memset(&sdn, 0, sizeof(sdn)); memset(&sdn, 0, sizeof(sdn));
@@ -1837,6 +1845,7 @@ static void ultrascan_adjust_timing(UltraScanInfo *USI, HostScanStats *hss,
USI->gstats->timing.num_updates++; USI->gstats->timing.num_updates++;
USI->gstats->probes_replied_to++; USI->gstats->probes_replied_to++;
hss->numprobes_replied_to++;
/* Adjust window */ /* Adjust window */
if (probe->tryno > 0 || !rcvdtime) { if (probe->tryno > 0 || !rcvdtime) {
@@ -1859,10 +1868,12 @@ static void ultrascan_adjust_timing(UltraScanInfo *USI, HostScanStats *hss,
appropriate. */ appropriate. */
if (hss->timing.cwnd < hss->timing.ccthresh) { if (hss->timing.cwnd < hss->timing.ccthresh) {
/* In quick start mode */ /* In quick start mode */
hss->timing.cwnd += ping_magnifier * USI->perf.quick_incr; hss->timing.cwnd += ping_magnifier * USI->perf.quick_incr * hss->cc_scale();
if (hss->timing.cwnd > hss->timing.ccthresh)
hss->timing.cwnd = hss->timing.ccthresh;
} else { } else {
/* Congestion control mode */ /* Congestion control mode */
hss->timing.cwnd += ping_magnifier * USI->perf.cc_incr / hss->timing.cwnd; hss->timing.cwnd += ping_magnifier * USI->perf.cc_incr / hss->timing.cwnd * hss->cc_scale();
} }
if (hss->timing.cwnd > USI->perf.max_cwnd) if (hss->timing.cwnd > USI->perf.max_cwnd)
hss->timing.cwnd = USI->perf.max_cwnd; hss->timing.cwnd = USI->perf.max_cwnd;
@@ -2197,6 +2208,20 @@ static bool ultrascan_port_pspec_update(UltraScanInfo *USI,
return oldstate != newstate; return oldstate != newstate;
} }
/* Returns the scaling factor to use when incrementing the congestion window.
This is the minimum of
(numprobes_sent + numpings_sent) / numprobes_replied_to and cc_scale_max. */
double HostScanStats::cc_scale() {
double ratio;
if (numprobes_replied_to == 0)
return USI->perf.cc_scale_max;
ratio = (double) (numprobes_sent + numpings_sent) / numprobes_replied_to;
return MIN(ratio, USI->perf.cc_scale_max);
}
/* Boost the scan delay for this host, usually because too many packet /* Boost the scan delay for this host, usually because too many packet
drops were detected. */ drops were detected. */
void HostScanStats::boostScanDelay() { void HostScanStats::boostScanDelay() {