| 
					
				 | 
			
			
				@@ -1,4 +1,4 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-use std::{path::{Path, PathBuf}, fs::{File, self, OpenOptions}, io::{BufWriter, Write, self, Read, BufRead}, net::Ipv4Addr, process::{Command, self, Stdio}, time::{Instant, Duration}, thread}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+use std::{path::{Path, PathBuf}, fs::{File, self, OpenOptions}, io::{BufWriter, Write, self, Read, BufRead}, net::Ipv4Addr, process::{Command, self, Stdio}, time::{Instant, Duration}, thread::{self, sleep}}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 use json::JsonValue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 use log::info; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 use rand::prelude::*; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -10,7 +10,7 @@ pub use crate::run::args::*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 pub use crate::run::error::*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 pub use crate::run::args::TestType::*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-pub const BENCH_BASE_PATH: &str = "bench"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+pub const BENCH_BASE_PATH: &str = "./bench"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 pub const BENCH_DATA_PATH: &str = "data"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 pub const BENCH_BIN_PATH: &str = "bin"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 pub const BENCH_LOG_PATH: &str = "log"; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -88,9 +88,17 @@ pub fn run() -> Result<(), anyhow::Error> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 build_binaries(data_args, bloom_args) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     .context(format!("Failed to build binaries for {} {}", data_args, bloom_args))?; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                info!("Building filter for {} {}", data_args, bloom_args); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                let filter_path = build_filter(data_args, bloom_args, ip_file_path.as_path()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    .context(format!("Failed to build filter for {} {}", data_args, bloom_args))?; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                let filter_path = match test_type { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    Normal(_) | EmptyFilter | BpfStats(_) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        info!("Building filter for {} {}", data_args, bloom_args); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        let filter_path = build_filter(data_args, bloom_args, ip_file_path.as_path()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            .context(format!("Failed to build filter for {} {}", data_args, bloom_args))?; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        Some(filter_path) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    Baseline => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        None 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 for scan_rate in &scan_rates { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     let scan_args = ScanArgs::new(*scan_rate); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     let args = BenchArgs {data_args, bloom_filter_args: bloom_args, scan_args}; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -103,7 +111,7 @@ pub fn run() -> Result<(), anyhow::Error> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         let (handle, stderr_handle, stdout_handle)  = match test_type { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             Normal(_) | EmptyFilter | BpfStats(_) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 info!("Loading XDP program for {}", args); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                let (handle, stderr_handle, stdout_handle) = load_xdp(args, Some(filter_path.as_path())) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                let (handle, stderr_handle, stdout_handle) = load_xdp(args, Some(filter_path.clone().unwrap().as_path())) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                     .map_err(|(h, e)| (h, e.context(format!("Loading XDP program for {}", args))))?; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 (Some(handle), Some(stderr_handle), Some(stdout_handle)) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -203,7 +211,10 @@ pub fn run() -> Result<(), anyhow::Error> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 fn clean() -> anyhow::Result<()> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    fs::remove_dir_all(PathBuf::from(BENCH_BASE_PATH)).context(format!("Failed to clean path: {:?}", BENCH_BASE_PATH))?; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    let path = PathBuf::from(BENCH_BASE_PATH); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if (&path).exists() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        fs::remove_dir_all(&path).context(format!("Failed to clean path: {:?}", &path))?; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     Ok(()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -211,7 +222,7 @@ fn next_ip(rng: &mut SmallRng, mask: u32) -> u32 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     loop { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         let ip = rng.next_u32() & mask; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if ip & 0xff000000 != 0x7f000000 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            // can not have ips in 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // can not have ips in 127.0.0.0/8 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             break ip; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -231,7 +242,7 @@ fn build_ip_file(data_args: DataArgs) -> anyhow::Result<(PathBuf, Ipv4Addr)> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     let mut rng = SmallRng::seed_from_u64(data_args.seed); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    let lower_subnet_mask = (1 << (data_args.scan_subnet_size as u32)) - 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    let lower_subnet_mask = ((1u64 << (data_args.scan_subnet_size)) - 1u64) as u32; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     let upper_subnet_mask = u32::MAX - lower_subnet_mask; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     let subnet = next_ip(&mut rng, upper_subnet_mask); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -490,6 +501,7 @@ fn run_zmap(bench_args: BenchArgs, subnet: Ipv4Addr) -> anyhow::Result<process:: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         "--sender-threads=7", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         "--cooldown-time=1", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         "--seed", seed.as_str(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        "--max-sendto-failures=-1" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     ]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     let output = Command::new(args.remove(0)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         .args(args) 
			 |