click_chatter("[Neighbors] Configure done. I have %d interfaces.\n", _nr_interfaces);
}
return 0;
}
int Neighbors::initialize(ErrorHandler *errh){
if(_debug)
click_chatter("[Neighbors] Initializing...\n");
Element::initialize(errh);
if(_eth_addr2_present && _addr2_is_plc)
set_plc_neighbor_groups();
_hello_timer.initialize(this);
_hello_timer.schedule_after_sec(1);
_frame_timer.initialize(this);
int wait_time_empty_frame = 60; // begin to send frames only after 60 seconds (to get all hellos)
_frame_timer.schedule_after_msec(click_random(wait_time_empty_frame*1000,15*wait_time_empty_frame*100)); //between 1* and 1.5* of wait_time_empty_frame
if((now - link->last_update).sec() < 1 || (_now - _begin).sec() < UPDATE_AFTER_SEC) goto done; // update at most every second and after UPDATE_AFTER_SEC seconds
*/
rssi = cwe->rssi;
known_field = cwe->rate1;
rateD = 0;
//mcs_index present is 2nd bit of mcs_known field
//mcs_bandwidth present is the 1st bit of mcs_known field
//mcs_guard_interval present is the 3rd bit of mcs_known field
// click_chatter("[Neighbors]: known fields = %d, bandwidth = %d, GI = %d, mcs_index = %d.", known_field, bandwidth, GI, mcs_index);
if(mcs_index < NR_MCS){ //check that we don't try to fetch too large a MCS
if(bandwidth == 0 && GI == 0){
rateD = _mcs_to_rate_20_LG[mcs_index];
_current_mcs_array.set(dst, _mcs_to_rate_20_LG);
}
if(bandwidth == 0 && GI > 0){
rateD = _mcs_to_rate_20_SG[mcs_index];
_current_mcs_array.set(dst, _mcs_to_rate_20_SG);
}
if(bandwidth == 1 && GI == 0){
rateD = _mcs_to_rate_40_LG[mcs_index];
_current_mcs_array.set(dst, _mcs_to_rate_40_LG);
}
else if(bandwidth == 1 && GI > 0){
rateD = _mcs_to_rate_40_SG[mcs_index];
_current_mcs_array.set(dst, _mcs_to_rate_40_SG);
}
}
}
// else {
// if(_debug)
// click_chatter("[Neighbors] WARNING: rate is 0 for neighbors %s, unknown field %d.", link->eth_addr.unparse().c_str(), known_field);
// }
// update success proba based on retry field
// if(!is_in_hash_table(_nb_retry, dst)) {
// _nb_retry.set(dst,0);
// _nb_packets.set(dst,0);
// _nb_packets_rate.set(dst,0);
// }
if (retry>0) {
_nb_retry[dst]++;
}
_nb_packets[dst]++;
//link->update_success_proba(retry>0, _debug);
if(_verb_debug) {
click_chatter("[Neighbors] Parsed wifi frame sent by me (%s) to dst %s at PHY rate %d and RSSI %d. Retry = %d\n", src.unparse().c_str(), dst.unparse().c_str(), rateD, rssi, retry);
if(_debug) click_chatter("[Neighbors]: Neighbor (%s) has been silent for more than %d seconds. adding to remove list...", it.key().unparse().c_str(), _timeout_duration);
VERB_DEBUG_CHATTER("[Neighbors] For eth %s, MCS %d, has %d packets (was %d)", eth.unparse().c_str(), mcs_idx, nb_packets, _last_packets[eth][mcs_idx]);
}
else {
_now.assign_now();
uint32_t capa = 0;
if(is_in_hash_table(_neighbors, eth))
capa = _neighbors[eth].capa;
click_chatter("[Neighbors %s] WARNING: for %s (capa %d), mcs index %d, nb_packets=%d, last_packets=%d", _now.unparse().c_str(),