mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 04:31:29 +00:00
Avoid showing the sending rate in bytes per second if no sent bytes have been
recorded. This applies during a TCP connect scan, where we have a count of packets sent but not of bytes (which we cannot measure, and will vary from platform to platform).
This commit is contained in:
@@ -611,6 +611,21 @@ public:
|
|||||||
bool numIncompleteHostsLessThan(unsigned int n);
|
bool numIncompleteHostsLessThan(unsigned int n);
|
||||||
|
|
||||||
unsigned int numInitialHosts() { return numInitialTargets; }
|
unsigned int numInitialHosts() { return numInitialTargets; }
|
||||||
|
|
||||||
|
void log_overall_rates(int logt) {
|
||||||
|
log_write(logt, "Overall sending rates: %.2f packets / s", send_rate_meter.getOverallPacketRate(&now));
|
||||||
|
if (send_rate_meter.getNumBytes()> 0)
|
||||||
|
log_write(logt, ", %.2f bytes / s", send_rate_meter.getOverallByteRate(&now));
|
||||||
|
log_write(logt, ".\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void log_current_rates(int logt, bool update = true) {
|
||||||
|
log_write(logt, "Current sending rates: %.2f packets / s", send_rate_meter.getCurrentPacketRate(&now, update));
|
||||||
|
if (send_rate_meter.getNumBytes()> 0)
|
||||||
|
log_write(logt, ", %.2f bytes / s", send_rate_meter.getCurrentByteRate(&now));
|
||||||
|
log_write(logt, ".\n");
|
||||||
|
}
|
||||||
|
|
||||||
/* Any function which messes with (removes elements from)
|
/* Any function which messes with (removes elements from)
|
||||||
incompleteHosts may have to manipulate nextI */
|
incompleteHosts may have to manipulate nextI */
|
||||||
list<HostScanStats *> incompleteHosts;
|
list<HostScanStats *> incompleteHosts;
|
||||||
@@ -3208,12 +3223,8 @@ static void printAnyStats(UltraScanInfo *USI) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log_write(LOG_PLAIN, "Current sending rates: %.2f packets / s, %.2f bytes / s.\n",
|
USI->log_current_rates(LOG_PLAIN);
|
||||||
USI->send_rate_meter.getCurrentPacketRate(),
|
USI->log_overall_rates(LOG_PLAIN);
|
||||||
USI->send_rate_meter.getCurrentByteRate());
|
|
||||||
log_write(LOG_PLAIN, "Overall sending rates: %.2f packets / s, %.2f bytes / s.\n",
|
|
||||||
USI->send_rate_meter.getOverallPacketRate(),
|
|
||||||
USI->send_rate_meter.getOverallByteRate());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now time to figure out how close we are to completion ... */
|
/* Now time to figure out how close we are to completion ... */
|
||||||
@@ -4838,9 +4849,7 @@ void ultra_scan(vector<Target *> &Targets, struct scan_lists *ports,
|
|||||||
/* Don't update when getting the current rates, otherwise we can get
|
/* Don't update when getting the current rates, otherwise we can get
|
||||||
anomalies (rates are too low) from having just done a potentially
|
anomalies (rates are too low) from having just done a potentially
|
||||||
long waitForResponses without sending any packets. */
|
long waitForResponses without sending any packets. */
|
||||||
log_write(LOG_STDOUT, "Current sending rates: %.2f packets / s, %.2f bytes / s.\n",
|
USI->log_current_rates(LOG_STDOUT, false);
|
||||||
USI->send_rate_meter.getCurrentPacketRate(&USI->now, false),
|
|
||||||
USI->send_rate_meter.getCurrentByteRate(&USI->now, false));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log_flush(LOG_STDOUT);
|
log_flush(LOG_STDOUT);
|
||||||
@@ -4869,11 +4878,8 @@ void ultra_scan(vector<Target *> &Targets, struct scan_lists *ports,
|
|||||||
(USI->gstats->num_hosts_timedout == 1)? "host" : "hosts");
|
(USI->gstats->num_hosts_timedout == 1)? "host" : "hosts");
|
||||||
USI->SPM->endTask(NULL, additional_info);
|
USI->SPM->endTask(NULL, additional_info);
|
||||||
}
|
}
|
||||||
if (o.debugging) {
|
if (o.debugging)
|
||||||
log_write(LOG_STDOUT, "Overall sending rates: %.2f packets / s, %.2f bytes / s.\n",
|
USI->log_overall_rates(LOG_STDOUT);
|
||||||
USI->send_rate_meter.getOverallPacketRate(),
|
|
||||||
USI->send_rate_meter.getOverallByteRate());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (o.debugging > 2 && USI->pd != NULL)
|
if (o.debugging > 2 && USI->pd != NULL)
|
||||||
pcap_print_stats(LOG_PLAIN, USI->pd);
|
pcap_print_stats(LOG_PLAIN, USI->pd);
|
||||||
|
|||||||
@@ -307,6 +307,14 @@ double RateMeter::getCurrentByteRate(const struct timeval *now, bool update) {
|
|||||||
return current_byte_rate;
|
return current_byte_rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned long long RateMeter::getNumPackets(void) const {
|
||||||
|
return num_packets;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long long RateMeter::getNumBytes(void) const {
|
||||||
|
return num_bytes;
|
||||||
|
}
|
||||||
|
|
||||||
/* Update the rates to include packets additional packets and bytes additional
|
/* Update the rates to include packets additional packets and bytes additional
|
||||||
bytes. If now is not NULL, use it as the time the packets and bytes were
|
bytes. If now is not NULL, use it as the time the packets and bytes were
|
||||||
received rather than calling gettimeofday. */
|
received rather than calling gettimeofday. */
|
||||||
|
|||||||
2
timing.h
2
timing.h
@@ -142,6 +142,8 @@ class RateMeter {
|
|||||||
double getCurrentPacketRate(const struct timeval *now = NULL, bool update =true);
|
double getCurrentPacketRate(const struct timeval *now = NULL, bool update =true);
|
||||||
double getOverallByteRate(const struct timeval *now = NULL) const;
|
double getOverallByteRate(const struct timeval *now = NULL) const;
|
||||||
double getCurrentByteRate(const struct timeval *now = NULL, bool update =true);
|
double getCurrentByteRate(const struct timeval *now = NULL, bool update =true);
|
||||||
|
unsigned long long getNumPackets(void) const;
|
||||||
|
unsigned long long getNumBytes(void) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/* How many seconds to look back when calculating the "current" rates. */
|
/* How many seconds to look back when calculating the "current" rates. */
|
||||||
|
|||||||
Reference in New Issue
Block a user