You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am interested in implementing the manual discovery with a list of initial peers, adding a branch in participant.rs in order to distinguish the multicast approach from the manual one.
In the manual branch I believe I should have something like the following
let mut discovery_listener = None;
let multicast_ip = "192.168.129.20";
let multicast_port = spdp_well_known_multicast_port(domain_id);
dbg!(&multicast_port);
// Magic value 120 below is from RTPS spec 2.5 Section "9.6.2.3 Default Port
// Numbers"
while discovery_listener.is_none() && participant_id < 120 {
discovery_listener = UDPListener::new_unicast(
multicast_ip,
multicast_port,
)
.ok();
if discovery_listener.is_none() {
participant_id += 1;
}
}
dbg!(&participant_id);
info!("ParticipantId {} selected.", participant_id);
// here discovery_listener is redefined (shadowed)
let discovery_listener = match discovery_listener {
Some(dl) => dl,
None => return log_and_err_internal!("Could not find free ParticipantId"),
};
dbg!(&discovery_listener);
listeners.insert(DISCOVERY_LISTENER_TOKEN, discovery_listener);
let addresses = vec![
"192.168.129.16",
"192.168.129.20",
"192.168.129.26",
];
let mut attempts: HashMap<&str, usize> = HashMap::new();
let mut known_ips: HashMap<&str, bool> = HashMap::new();
for addr in addresses.iter() {
known_ips.insert(addr, false);
attempts.insert(addr, 0);
}
const MAXITER: usize = 10;
// let port = spdp_well_known_unicast_port(domain_id, participant_id);
let port = 0;
let mut total_attemps = 0;
loop {
for (ip, connected) in known_ips.iter_mut() {
if *connected == true { continue; }
else {
// increment number of attempts
*attempts.entry(ip).or_default() += 1;
total_attemps += attempts.get(ip).unwrap();
let ip_attempt = attempts.get(ip).unwrap();
println!("Attempt #{}\tConnecting to {}:{}", ip_attempt, ip, port);
let user_traffic_listener = UDPListener::new_unicast(ip, port);
if let Ok(l) = user_traffic_listener {
println!("Connected! {:?}", &l);
listeners.insert(USER_TRAFFIC_LISTENER_TOKEN, l);
*connected = true;
}
else {
let delay = time::Duration::from_millis(1000);
thread::sleep(delay);
}
}
}
if total_attemps >= addresses.len() * MAXITER { break; }
}
// construct our own Locators
self_locators = listeners
.iter()
.map(|(t, l)|
{
dbg!(&t);
dbg!(&l);
match l.to_locator_address() {
Ok(locs) => {
dbg!("self_locator: {}", &locs);
(*t, locs)
},
Err(e) => {
error!("No local network address for token {:?}: {:?}", t, e);
(*t, vec![])
}
}
}
)
.collect();
}
But this code never finds any of the peers in the list listening at any port.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am interested in implementing the manual discovery with a list of initial peers, adding a branch in
participant.rs
in order to distinguish the multicast approach from the manual one.In the manual branch I believe I should have something like the following
But this code never finds any of the peers in the list listening at any port.
Is there anything nasty I am missing?
Beta Was this translation helpful? Give feedback.
All reactions