From aec77b87e864c2c22f8f9df3d609ea65e646d543 Mon Sep 17 00:00:00 2001 From: fyodor Date: Fri, 11 Jul 2008 07:30:00 +0000 Subject: [PATCH] increase scan group sizes in many cases, also make them normally powers of two to better align with common network boundaries (e.g. /24, /25, etc.) --- scan_engine.cc | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/scan_engine.cc b/scan_engine.cc index 2048c8b8e..470b5f8a6 100644 --- a/scan_engine.cc +++ b/scan_engine.cc @@ -1665,15 +1665,23 @@ int UltraScanInfo::removeCompletedHosts() { levels. */ int determineScanGroupSize(int hosts_scanned_so_far, struct scan_lists *ports) { - int groupsize = 10; + int groupsize = 16; if (o.UDPScan()) - groupsize = 50; + groupsize = 128; else if (o.TCPScan()) { - groupsize = MAX(1024 / (ports->tcp_count ? ports->tcp_count : 1), 30); - if (ports->tcp_count > 1000 && hosts_scanned_so_far == 0 && - o.timing_level < 4) - groupsize = 5; // Give quick results for the very first batch + groupsize = MAX(1024 / (ports->tcp_count ? ports->tcp_count : 1), 64); + if (ports->tcp_count > 1000 && o.timing_level <= 4) { + int quickgroupsz = 4; + if (o.timing_level == 4) quickgroupsz = 8; + if (hosts_scanned_so_far == 0) + groupsize = quickgroupsz; // Give quick results for the very first batch + else if (hosts_scanned_so_far == quickgroupsz && + groupsize > quickgroupsz * 2) + /* account for initial quick-scan to keep us aligned + on common network boundaries (e.g. /24) */ + groupsize -= quickgroupsz; + } } groupsize = box(o.minHostGroupSz(), o.maxHostGroupSz(), groupsize);