diff --git a/osscan2.cc b/osscan2.cc index 41fc17de9..ab983cc36 100644 --- a/osscan2.cc +++ b/osscan2.cc @@ -1226,15 +1226,20 @@ void HostOsScan::adjust_times(HostOsScanStats *hss, OFProbe *probe, struct timev hss->timing.num_replies_expected++; hss->timing.num_updates++; - /* Adjust window */ - if (probe->tryno > 0 || !rcvdtime) { + /* Notice a drop if + 1. We get a response to a retransmitted probe (meaning the first reply was + dropped), or + 2. We get no response after a timeout (rcvdtime == NULL). */ + if (probe->tryno > 0 || rcvdtime == NULL) { if (TIMEVAL_AFTER(probe->sent, hss->timing.last_drop)) hss->timing.drop(hss->numProbesActive(), &perf, &now); if (TIMEVAL_AFTER(probe->sent, stats->timing.last_drop)) stats->timing.drop_group(stats->num_probes_active, &perf, &now); - } else { - /* Good news -- got a response to first try. Increase window as - appropriate. */ + } + + /* Increase the window for a positive reply. This can overlap with case (1) + above. */ + if (rcvdtime != NULL) { stats->timing.ack(&perf); hss->timing.ack(&perf); } diff --git a/scan_engine.cc b/scan_engine.cc index 3fb6bd3f4..30fc50a3f 100644 --- a/scan_engine.cc +++ b/scan_engine.cc @@ -2183,11 +2183,12 @@ static void ultrascan_adjust_timing(UltraScanInfo *USI, HostScanStats *hss, hss->timing.num_replies_expected++; hss->timing.num_updates++; + /* Notice a drop if + 1) We get a response to a retransmitted probe (meaning the first reply was + dropped), or + 2) We got no response to a timing ping. */ if ((probe->tryno > 0 && rcvdtime != NULL) || (probe->isPing() && rcvdtime == NULL)) { - /* We consider it a drop if - 1. We get a positive response to a retransmitted probe, or - 2. We get no response to a timing ping probe. */ if (o.debugging > 1) log_write(LOG_PLAIN, "Ultrascan DROPPED %sprobe packet to %s detected\n", probe->isPing()? "PING " : "", hss->target->targetipstr()); // Drops often come in big batches, but we only want one decrease per batch. @@ -2195,13 +2196,15 @@ static void ultrascan_adjust_timing(UltraScanInfo *USI, HostScanStats *hss, hss->timing.drop(hss->num_probes_active, &USI->perf, &USI->now); if (TIMEVAL_AFTER(probe->sent, USI->gstats->timing.last_drop)) USI->gstats->timing.drop_group(USI->gstats->num_probes_active, &USI->perf, &USI->now); - } else if (rcvdtime != NULL) { - /* Good news -- got a response to first try. Increase window as - appropriate. */ + } + /* If !probe->isPing() and rcvdtime == NULL, do nothing. */ + + /* Increase the window for a positive reply. This can overlap with case (1) + above. */ + if (rcvdtime != NULL) { USI->gstats->timing.ack(&USI->perf, ping_magnifier); hss->timing.ack(&USI->perf, ping_magnifier); } - /* If !probe->isPing() and rcvdtime == NULL, do nothing. */ /* If packet drops are particularly bad, enforce a delay between packet sends (useful for cases such as UDP scan where responses