Skip to content

Commit

Permalink
Fine-tuning estimations
Browse files Browse the repository at this point in the history
  • Loading branch information
Saluki committed Jun 20, 2021
1 parent 7aa9c6b commit 44b248d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ The features below will be shipped in the next releases of the project.
- Complete VLAN support
- ~~Exports (JSON & YAML)~~ - released in 0.7.0
- Full ARP packet customization (Ethernet protocol, ARP operation, ...)
- Time estimations & bandwidth
- ~~MAC vendor lookup in the results~~ - released in 0.9.0
- ~~Fine-grained scan timings (interval)~~ - released in 0.8.0
- Wide network range support
Expand Down
1 change: 1 addition & 0 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ impl ScanOptions {
}),
None => match profile {
ProfileType::Stealth => REQUEST_MS_INTERVAL * 2,
ProfileType::Fast => 0,
_ => REQUEST_MS_INTERVAL
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ fn main() {
if scan_options.is_plain_output() {

let estimations = network::compute_scan_estimation(network_size, &scan_options);
println!("Estimated scan time {}ms (sending {} bytes, {} bytes/s)", estimations.duration_ms, estimations.request_size, estimations.bandwidth);
println!("Estimated scan time {}ms ({} bytes, {} bytes/s)", estimations.duration_ms, estimations.request_size, estimations.bandwidth);

println!("Sending {} ARP requests (waiting at least {}ms, {}ms request interval)", network_size, scan_options.timeout_ms, scan_options.interval_ms);
}
Expand Down
16 changes: 9 additions & 7 deletions src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,24 +64,26 @@ pub struct TargetDetails {
* estimation of the scan impact (timing, bandwidth, ...). Keep in mind that
* this is only an estimation, real results may vary based on the network.
*/
pub fn compute_scan_estimation(network_size: u128, options: &Arc<ScanOptions>) -> ScanEstimation {
pub fn compute_scan_estimation(host_count: u128, options: &Arc<ScanOptions>) -> ScanEstimation {

let interval: u128 = options.interval_ms.into();
let timeout: u128 = options.timeout_ms.into();
let packet_size: u128 = match options.has_vlan() {
true => ETHERNET_VLAN_PACKET_SIZE.try_into().unwrap(),
false => ETHERNET_STD_PACKET_SIZE.try_into().unwrap()
true => ETHERNET_VLAN_PACKET_SIZE.try_into().expect("Internal number conversion failed for VLAN packet size"),
false => ETHERNET_STD_PACKET_SIZE.try_into().expect("Internal number conversion failed for Ethernet packet size")
};
let retry_count: u128 = options.retry_count.try_into().unwrap();

// The values below are averages based on an amount of performed network
// scans. This may of course vary based on network configurations.
let avg_arp_request_ms = 3;
let avg_resolve_ms = 500;

let request_duration_ms: u128 = (network_size * (interval+avg_arp_request_ms)) * retry_count;
let duration_ms = request_duration_ms + timeout + avg_resolve_ms;
let request_size: u128 = network_size * packet_size;
let request_phase_ms = (host_count * (avg_arp_request_ms+ interval)) * retry_count;
let duration_ms = request_phase_ms + timeout + avg_resolve_ms;
let request_size = host_count * packet_size;

let bandwidth = (request_size / request_duration_ms) * 1000;
let bandwidth = (request_size * 1000) / request_phase_ms;

ScanEstimation {
duration_ms,
Expand Down

0 comments on commit 44b248d

Please sign in to comment.