pub fn new(
        worker_name: String,
        worker_id: String,
        active_route_timeout: Option<i64>,
        net_diameter: Option<usize>,
        node_traversal_time: Option<i64>,
        next_hop_wait: Option<i64>,
        allowed_hello_loss: Option<usize>,
        rreq_retries: Option<usize>,
        tx_queue: Sender<Transmission>,
        rng: Arc<Mutex<StdRng>>,
        last_transmission: Arc<AtomicI64>,
        logger: Logger,
    ) -> Self {
        // let starting_rreq_id: u32 = thread_rng().gen_range(0, std::u32::MAX);
        let starting_rreq_id: u32 = {
            let mut rng = rng.lock().expect("Could not lock RNG");
            rng.gen_range(0..std::u32::MAX)
        };
        let ts_rt_maintenance = Utc::now() + Duration::milliseconds(MAINTENANCE_RT_MAINTENANCE);
        let ts_rt_maintenance = AtomicI64::new(ts_rt_maintenance.timestamp_nanos());
        let ts_rd_retransmission =
            Utc::now() + Duration::milliseconds(MAINTENANCE_RD_RETRANSMISSION);
        let ts_rd_retransmission = AtomicI64::new(ts_rd_retransmission.timestamp_nanos());
        let ts_last_hello_msg = Utc::now() + Duration::milliseconds(MAINTENANCE_HELLO_THRESHOLD);
        let ts_last_hello_msg = AtomicI64::new(ts_last_hello_msg.timestamp_nanos());

        let active_route_timeout = active_route_timeout.unwrap_or(ACTIVE_ROUTE_TIMEOUT);
        let net_diameter = net_diameter.unwrap_or(NET_DIAMETER);
        let node_traversal_time = node_traversal_time.unwrap_or(NODE_TRAVERSAL_TIME);
        let next_hop_wait = next_hop_wait.unwrap_or(node_traversal_time + 10); //milliseconds
        let allowed_hello_loss = allowed_hello_loss.unwrap_or(ALLOWED_HELLO_LOSS);
        let rreq_retries = rreq_retries.unwrap_or(RREQ_RETRIES);
        let net_traversal_time = 2 * node_traversal_time * net_diameter as i64; //milliseconds
        let max_repair_ttl = (0.3f64 * net_diameter as f64).round() as usize;
        //Lifetime used for RREPs when responding to an RREQ to the current node
        let my_route_timeout = 2 * active_route_timeout;
        let path_discovery_time = 2 * net_traversal_time; //milliseconds

        let config = Config {
            active_route_timeout,
            net_diameter,
            node_traversal_time,
            allowed_hello_loss,
            rreq_retries,
            max_repair_ttl,
            my_route_timeout,
            path_discovery_time,
            next_hop_wait,
            net_traversal_time,
        };

        AODV {
            worker_name,
            worker_id,
            config,
            tx_queue,
            sequence_number: Arc::new(AtomicU32::new(0)),
            rreq_seq_no: Arc::new(AtomicU32::new(starting_rreq_id)),
            route_table: Arc::new(Mutex::new(HashMap::new())),
            pending_routes: Arc::new(Mutex::new(HashMap::new())),
            queued_transmissions: Arc::new(Mutex::new(HashMap::new())),
            rreq_cache: Arc::new(Mutex::new(HashMap::new())),
            data_cache: Arc::new(Mutex::new(HashMap::new())),
            ts_rt_maintenance,
            ts_rd_retransmission,
            ts_last_hello_msg,
            rng,
            last_transmission,
            logger,
        }
    }
/// Instantiate a new handler for the AODV protocol
Instantiate a new handler for the AODV protocol
Instantiate a new handler for the AODV protocol
pub fn new(
        worker_name: String,
        worker_id: String,
        active_route_timeout: Option<i64>,
        net_diameter: Option<usize>,
        node_traversal_time: Option<i64>,
        next_hop_wait: Option<i64>,
        allowed_hello_loss: Option<usize>,
        rreq_retries: Option<usize>,
        tx_queue: Sender<Transmission>,
        rng: Arc<Mutex<StdRng>>,
        last_transmission: Arc<AtomicI64>,
        logger: Logger,
    ) -> Self {
        // let starting_rreq_id: u32 = thread_rng().gen_range(0, std::u32::MAX);
        let starting_rreq_id: u32 = {
            let mut rng = rng.lock().expect("Could not lock RNG");
            rng.gen_range(0..std::u32::MAX)
        };
        let ts_rt_maintenance = Utc::now() + Duration::milliseconds(MAINTENANCE_RT_MAINTENANCE);
        let ts_rt_maintenance = AtomicI64::new(ts_rt_maintenance.timestamp_nanos());
        let ts_rd_retransmission =
            Utc::now() + Duration::milliseconds(MAINTENANCE_RD_RETRANSMISSION);
        let ts_rd_retransmission = AtomicI64::new(ts_rd_retransmission.timestamp_nanos());
        let ts_last_hello_msg = Utc::now() + Duration::milliseconds(MAINTENANCE_HELLO_THRESHOLD);
        let ts_last_hello_msg = AtomicI64::new(ts_last_hello_msg.timestamp_nanos());
        let active_route_timeout = active_route_timeout.unwrap_or(ACTIVE_ROUTE_TIMEOUT);
        let net_diameter = net_diameter.unwrap_or(NET_DIAMETER);
        let node_traversal_time = node_traversal_time.unwrap_or(NODE_TRAVERSAL_TIME);
        let next_hop_wait = next_hop_wait.unwrap_or(node_traversal_time + 10); //milliseconds
        let allowed_hello_loss = allowed_hello_loss.unwrap_or(ALLOWED_HELLO_LOSS);
        let rreq_retries = rreq_retries.unwrap_or(RREQ_RETRIES);
        let net_traversal_time = 2 * node_traversal_time * net_diameter as i64; //milliseconds
        let max_repair_ttl = (0.3f64 * net_diameter as f64).round() as usize;
        //Lifetime used for RREPs when responding to an RREQ to the current node
        let my_route_timeout = 2 * active_route_timeout;
        let path_discovery_time = 2 * net_traversal_time; //milliseconds
        let config = Config {
            active_route_timeout,
            net_diameter,
            node_traversal_time,
            allowed_hello_loss,
            rreq_retries,
            max_repair_ttl,
            my_route_timeout,
            path_discovery_time,
            next_hop_wait,
            net_traversal_time,
        };
        AODV {
            worker_name,
            worker_id,
            config,
            tx_queue,
            sequence_number: Arc::new(AtomicU32::new(0)),
            rreq_seq_no: Arc::new(AtomicU32::new(starting_rreq_id)),
            route_table: Arc::new(Mutex::new(HashMap::new())),
            pending_routes: Arc::new(Mutex::new(HashMap::new())),
            queued_transmissions: Arc::new(Mutex::new(HashMap::new())),
            rreq_cache: Arc::new(Mutex::new(HashMap::new())),
            data_cache: Arc::new(Mutex::new(HashMap::new())),
            ts_rt_maintenance,
            ts_rd_retransmission,
            ts_last_hello_msg,
            rng,
            last_transmission,
            logger,
        }
    }
pub fn new ( worker_name : String , worker_id : String , active_route_timeout : Option < i64 > , net_diameter : Option < usize > , node_traversal_time : Option < i64 > , next_hop_wait : Option < i64 > , allowed_hello_loss : Option < usize > , rreq_retries : Option < usize > , tx_queue : Sender < Transmission > , rng : Arc < Mutex < StdRng > > , last_transmission : Arc < AtomicI64 > , logger : Logger , ) -> Self { // let starting_rreq_id: u32 = thread_rng().gen_range(0, std::u32::MAX); let starting_rreq_id : u32 = { let mut rng = rng . lock ( ) . expect ( " " ) ; rng . gen_range ( 0 .. std :: u32 :: MAX ) } ; let ts_rt_maintenance = Utc :: now ( ) + Duration :: milliseconds ( MAINTENANCE_RT_MAINTENANCE ) ; let ts_rt_maintenance = AtomicI64 :: new ( ts_rt_maintenance . timestamp_nanos ( ) ) ; let ts_rd_retransmission = Utc :: now ( ) + Duration :: milliseconds ( MAINTENANCE_RD_RETRANSMISSION ) ; let ts_rd_retransmission = AtomicI64 :: new ( ts_rd_retransmission . timestamp_nanos ( ) ) ; let ts_last_hello_msg = Utc :: now ( ) + Duration :: milliseconds ( MAINTENANCE_HELLO_THRESHOLD ) ; let ts_last_hello_msg = AtomicI64 :: new ( ts_last_hello_msg . timestamp_nanos ( ) ) ; let active_route_timeout = active_route_timeout . unwrap_or ( ACTIVE_ROUTE_TIMEOUT ) ; let net_diameter = net_diameter . unwrap_or ( NET_DIAMETER ) ; let node_traversal_time = node_traversal_time . unwrap_or ( NODE_TRAVERSAL_TIME ) ; let next_hop_wait = next_hop_wait . unwrap_or ( node_traversal_time + 10 ) ; //milliseconds let allowed_hello_loss = allowed_hello_loss . unwrap_or ( ALLOWED_HELLO_LOSS ) ; let rreq_retries = rreq_retries . unwrap_or ( RREQ_RETRIES ) ; let net_traversal_time = 2 * node_traversal_time * net_diameter as i64 ; //milliseconds let max_repair_ttl = ( 0.3f64 * net_diameter as f64 ) . round ( ) as usize ; //Lifetime used for RREPs when responding to an RREQ to the current node let my_route_timeout = 2 * active_route_timeout ; let path_discovery_time = 2 * net_traversal_time ; //milliseconds let config = Config { active_route_timeout , net_diameter , node_traversal_time , allowed_hello_loss , rreq_retries , max_repair_ttl , my_route_timeout , path_discovery_time , next_hop_wait , net_traversal_time , } ; AODV { worker_name , worker_id , config , tx_queue , sequence_number : Arc :: new ( AtomicU32 :: new ( 0 ) ) , rreq_seq_no : Arc :: new ( AtomicU32 :: new ( starting_rreq_id ) ) , route_table : Arc :: new ( Mutex :: new ( HashMap :: new ( ) ) ) , pending_routes : Arc :: new ( Mutex :: new ( HashMap :: new ( ) ) ) , queued_transmissions : Arc :: new ( Mutex :: new ( HashMap :: new ( ) ) ) , rreq_cache : Arc :: new ( Mutex :: new ( HashMap :: new ( ) ) ) , data_cache : Arc :: new ( Mutex :: new ( HashMap :: new ( ) ) ) , ts_rt_maintenance , ts_rd_retransmission , ts_last_hello_msg , rng , last_transmission , logger , } }
Instantiate a new handler for the AODV protocol
Instantiate a new handler for the AODV protocol
worker_name
String
worker_id
String
active_route_timeout
Option<i64>
net_diameter
Option<usize>
node_traversal_time
Option<i64>
next_hop_wait
Option<i64>
allowed_hello_loss
Option<usize>
rreq_retries
Option<usize>
tx_queue
Sender<Transmission>
rng
Arc<Mutex<StdRng>>
last_transmission
Arc<AtomicI64>
logger
Logger