Skip to content

Commit

Permalink
Merge pull request #2 from tiiuae/v3_updates
Browse files Browse the repository at this point in the history
QoS-OLSRv3.0 updates
  • Loading branch information
mbaddeley authored Dec 6, 2024
2 parents 3d9cce6 + ff6484b commit 23323f7
Show file tree
Hide file tree
Showing 15 changed files with 264 additions and 85 deletions.
13 changes: 9 additions & 4 deletions src/link_set.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ get_neighbor_status(const union olsr_ip_addr *address)
}
}


return 0;
}

Expand Down Expand Up @@ -549,7 +550,7 @@ add_link_entry(const union olsr_ip_addr *local, const union olsr_ip_addr *remote
#ifdef DEBUG
{
struct ipaddr_str localbuf, rembuf;
OLSR_PRINTF(1, "Adding %s=>%s to link set\n", olsr_ip_to_string(&localbuf, local), olsr_ip_to_string(&rembuf, remote));
// OLSR_PRINTF(1, "Adding %s=>%s to link set\n", olsr_ip_to_string(&localbuf, local), olsr_ip_to_string(&rembuf, remote));
}
#endif /* DEBUG */

Expand Down Expand Up @@ -605,7 +606,7 @@ add_link_entry(const union olsr_ip_addr *local, const union olsr_ip_addr *remote
new_link->linkcost = LINK_COST_BROKEN;

//OLSR_PRINTF(1, "\n \n *** printing link broken cost %d\n", LINK_COST_BROKEN);
//new_link->estimated_linkcost = LINK_COST_BROKEN;
new_link->estimated_linkcost = LINK_COST_BROKEN;
// new_link->estimated_linkcost = 0;
// new_link->dev_linkcost = 50000;

Expand Down Expand Up @@ -743,9 +744,13 @@ update_link_entry(const union olsr_ip_addr *local, const union olsr_ip_addr *rem
olsr_process_hysteresis(entry);

}
/* Update neighbor */
/* Update neighbor */
update_neighbor_status(entry->neighbor, get_neighbor_status(remote));

// check the status to change when a head becomes not symmetric
// int sym_status=update_neighbor_status(entry->neighbor, get_neighbor_status(remote));
// if(entry->neighbor->my_head && sym_status==0){
// changes_in_head_status=true;
// }
return entry;
}

Expand Down
2 changes: 2 additions & 0 deletions src/link_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ struct link_entry {

int8_t rssi;

//
// int8_t mob_trend;

/* cost of this link */
olsr_linkcost linkcost;
Expand Down
28 changes: 18 additions & 10 deletions src/lq_mpr.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,28 +161,36 @@ olsr_calculate_lq_mpr(void)
/* Found a 1-hop neighbor that we haven't previously selected.
* Use it as MPR only when the 2-hop path through it is better than
* any existing 1-hop path. */
OLSR_PRINTF(1,"The broken cost: %d\n",LINK_COST_BROKEN);
struct ipaddr_str buf;
OLSR_PRINTF(1, "\nNeighbor: %s\nThree hop head: %d\ncost: %d\n", olsr_ip_to_string(&buf, &neigh2->neighbor_2_addr),neigh2->is_2hop, best);

if ((neigh != NULL) && (best < best_1hop)) {
neigh->is_mpr = true;
neigh->skip = true;



if (neigh->is_mpr != neigh->was_mpr)
mpr_changes = true;
break; //It means we have found an mpr so ne need for more checks
}
//this part allows us to select mprs for 3-hop head when there is no cost for the link
/*else if(!neigh2->is_2hop && neigh == NULL)
{
neigh = neigh2->neighbor_2_nblist.next->neighbor;
neigh->is_mpr = true;
neigh->skip = true;
if (neigh->is_mpr != neigh->was_mpr)
mpr_changes = true;
}*/
// else if(!neigh2->is_2hop) //This is a quick fix to remedy the infinite cost problem
// {
// neigh = neigh2->neighbor_2_nblist.next->neighbor;
// neigh->is_mpr = true;
// neigh->skip = true;
// if (neigh->is_mpr != neigh->was_mpr)
// mpr_changes = true;
// break;//It means we have found an mpr so ne need for more checks
// }

/* no neighbour found => the requested MPR coverage cannot
* be satisfied => stop */

else
break;
// else
// break;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/lq_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ create_lq_hello(struct lq_hello_message *lq_hello, struct interface_olsr *outif)
// initialize the static fields

lq_hello->comm.type = LQ_HELLO_MESSAGE;
lq_hello->comm.vtime = me_to_reltime(outif->valtimes.hello);
lq_hello->comm.size = 0;
lq_hello->comm.vtime = me_to_reltime(outif->valtimes.hello); //NEIGHB_HOLD_TIME
lq_hello->comm.size = 0;

lq_hello->comm.orig = olsr_cnf->main_addr;

Expand Down
49 changes: 48 additions & 1 deletion src/lq_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,54 @@ void olsr_deserialize_hello_lq_pair(const uint8_t **curr, struct hello_neighbor
{
assert((const char *)neigh + sizeof(*neigh) >= (const char *)neigh->linkquality);
active_lq_handler->deserialize_hello_lq(curr, neigh->linkquality);
neigh->cost = active_lq_handler->calc_hello_cost(neigh->linkquality);
olsr_linkcost sampledLC;
if (neigh->status == TWO_HEAD){
neigh->cost = neigh->linkquality[0];
struct ipaddr_str buf;
OLSR_PRINTF(1, "3 hop head: %s\nThe status: %d", olsr_ip_to_string(&buf, &neigh->address),neigh->status);
OLSR_PRINTF(1,"In Plugin- three hop head: %d sampled cost\n",sampledLC);
}
else{
sampledLC = active_lq_handler->calc_hello_cost(neigh->linkquality);


const struct lq_ffeth *lq = neigh->linkquality;

OLSR_PRINTF(1,"In Plugin- Trend: %d, previous cost %d, sampled cost %d, ",lq->valueBandwidth, neigh->cost,sampledLC);

// if the previous cost is 0, set it as the current cost
if (neigh->cost==0){
neigh->cost=sampledLC;
}

// if there's a trend, set the neighbor cost as the current cost
// sampledLC is usually in the range up to 10 or 11 based on the max penalty value of 7 and the LQ cost (converges to 1)
if(lq->valueBandwidth!=0){
neigh->cost = sampledLC;
}
// else if we don't have a trend, degrade the cost gradually
else{

// if the current cost is higher than 10.x, set the neighbor cost and the sampledLC
if(sampledLC > 41000)
{
neigh->cost= sampledLC;
}
// if the previous neighbor cost is high, set it to the current value
// this is important for when we suddenly drop the sampledLC cost
if(neigh->cost > 41000)
{
neigh->cost= sampledLC;
}
// in this case, if the sampled is higher than 10, the neigh cost will be the same value
neigh->cost = (0.99*neigh->cost) +(0.01*sampledLC);
}
}

OLSR_PRINTF(1,"weighted cost: %f \n",neigh->cost*1.0/1024.0);

// neigh->cost = (0.7*neigh->cost) +(0.3*sampledLC);
// neigh->cost=sampledLC;
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/lq_plugin_default_ffeth.c
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ default_lq_clear_ffeth_hello(void *target)
default_lq_clear_ffeth(&local->lq);
default_lq_clear_ffeth(&local->smoothed_lq);
local->windowSize = LQ_FFETH_QUICKSTART_INIT;

for (i = 0; i < LQ_FFETH_WINDOW; i++) {
local->total[i] = 3;
}
Expand Down
84 changes: 60 additions & 24 deletions src/mpr.c
Original file line number Diff line number Diff line change
Expand Up @@ -489,20 +489,29 @@ olsr_calculate_mpr(void)
//find head when the node joins in the middle of the calculation period or when it loses its head
void olsr_find_head(void){
OLSR_PRINTF(1,"Finding Existing Cluster head\n");
//problem: the previous disconnected head needs its is_mpr and is_head status set to false here

struct neighbor_entry *a_neighbor, *temp_neighbor;
uint16_t max_qos = olsr_cnf->qos;
union olsr_ip_addr max_ip = olsr_cnf->main_addr;
struct ipaddr_str buf;

//uint16_t max_qos = olsr_cnf->qos;
//union olsr_ip_addr max_ip = olsr_cnf->main_addr;
uint16_t max_qos = 0;
union olsr_ip_addr max_ip ;
struct ipaddr_str buf;
bool head_found=false;
// loop through all neighbor entries
OLSR_FOR_ALL_NBR_ENTRIES(a_neighbor) {
// check this syntax ?
// if the neighbor is not a head continue
if(a_neighbor->is_head==0){
if(a_neighbor->is_head==0 || a_neighbor->status == NOT_SYM){
//update: changing the is_mpr and is_head status of the previous disconnected head
if(a_neighbor->is_head){
a_neighbor->is_mpr = false;
a_neighbor->my_head = false;
}
//update end
continue;
}

head_found=true;
OLSR_PRINTF(1,"Head Neighbor: %s with qos: %d \n", olsr_ip_to_string(&buf, &a_neighbor->neighbor_main_addr),a_neighbor->qos);
// if the neighbor is a head then check their qos
if (a_neighbor->qos >= max_qos) {
Expand All @@ -512,29 +521,41 @@ void olsr_find_head(void){

}
OLSR_FOR_ALL_NBR_ENTRIES_END(a_neighbor);
if(max_qos==0)
return;
// if(max_qos==0)
// return;
OLSR_PRINTF(1,"For node: %s with qos: %d ", olsr_ip_to_string(&buf, &olsr_cnf->main_addr),olsr_cnf->qos);

// if selected neighbor is in the neighbor list, set their mpr and head status
temp_neighbor = olsr_lookup_neighbor_table(&max_ip);
//cout<<olsr_cnf->main_addr<<" my qos is "<<olsr_cnf->qos<<", ";
if(temp_neighbor != NULL)
{
struct ipaddr_str buf1;
OLSR_PRINTF(1," new head is %s with qos: %d ", olsr_ip_to_string(&buf1, &temp_neighbor->neighbor_main_addr),temp_neighbor->qos);
temp_neighbor->is_mpr = true;
temp_neighbor->my_head = true;
}

if(head_found){
// if selected neighbor is in the neighbor list, set their mpr and head status
temp_neighbor = olsr_lookup_neighbor_table(&max_ip);
//cout<<olsr_cnf->main_addr<<" my qos is "<<olsr_cnf->qos<<", ";
if(temp_neighbor != NULL)
{
struct ipaddr_str buf1;
OLSR_PRINTF(1," new head is %s with qos: %d ", olsr_ip_to_string(&buf1, &temp_neighbor->neighbor_main_addr),temp_neighbor->qos);
temp_neighbor->is_mpr = true;
temp_neighbor->my_head = true;
}

}
else{
olsr_calculate_head();
}
/*if(olsr_cnf->qos==max_qos && olsr_cnf->is_head !=1 && olsr_cnf->is_head <3){
olsr_cnf->is_head =olsr_cnf->is_head+1;
}
if(olsr_cnf->is_head ==1){
olsr_calculate_lq_mpr();
}
*/
}

//head calculation
void
olsr_calculate_head(void){
// find the neighbor with max qos
// set the max qos neighbor as mpr.
OLSR_PRINTF(1,"Calculating Cluster head\n");
OLSR_PRINTF(1,"Calculating Cluster head\n my qos is %d\n",olsr_cnf->qos);

struct neighbor_entry *a_neighbor, *temp_neighbor,*temp_neighbor2;
uint16_t max_qos = olsr_cnf->qos;
Expand All @@ -558,26 +579,39 @@ olsr_calculate_head(void){
{
continue;
}*/

//update: this is creating a problem
//update: The is_mpr and is_head of the not symetric node should be also changed
if(a_neighbor->status == NOT_SYM){
//changes start:
a_neighbor->is_mpr = false;
a_neighbor->my_head = false;
//changes end:
continue;
}


if(a_neighbor->my_head){
prev_head_ip=a_neighbor->neighbor_main_addr;
max_prev_head_qos=a_neighbor->qos;
}

struct ipaddr_str buf3;
OLSR_PRINTF(1,"neighbor %s has QoS %d \n",olsr_ip_to_string(&buf3,&a_neighbor->neighbor_main_addr),a_neighbor->qos);
a_neighbor->is_mpr = false;
a_neighbor->my_head = false;

if (a_neighbor->qos > max_qos) {
max_qos = a_neighbor->qos;
max_ip = a_neighbor->neighbor_main_addr;
}

}
}
OLSR_FOR_ALL_NBR_ENTRIES_END(a_neighbor);

if(max_qos==0)
return;

struct ipaddr_str buf2;
OLSR_PRINTF(1,"max qos neighbor is: %s with qos: %d\n",olsr_ip_to_string(&buf2,&max_ip),max_qos);
// check if previous head still exists
temp_neighbor2 = olsr_lookup_neighbor_table(&prev_head_ip);

Expand Down Expand Up @@ -616,7 +650,9 @@ olsr_calculate_head(void){
olsr_cnf->is_head =olsr_cnf->is_head-1;
}


// if(olsr_cnf->is_head ==1){
// olsr_calculate_lq_mpr();
// }

}

Expand Down
2 changes: 1 addition & 1 deletion src/mpr_selector_set.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ bool olsr_get_mpr_sel_set_size(){

if(mprs_list.next == &mprs_list)
{
OLSR_PRINTF(1,"my MPR Selectors Set is empty");
// OLSR_PRINTF(1,"my MPR Selectors Set is empty");
return false;
}
else{
Expand Down
11 changes: 9 additions & 2 deletions src/neighbor_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ olsr_delete_neighbor_table(const union olsr_ip_addr *neighbor_addr)
olsr_update_qos(NULL);
// if the node lost its head, then find an alternative head from the existing ones
if (find_head)
olsr_find_head();
olsr_find_head();
OLSR_PRINTF(1,"delete neighbor, new num is: %d\n",olsr_cnf->neighnum);
changes_neighborhood = true;
signal_link_changes(true);
Expand Down Expand Up @@ -361,16 +361,23 @@ update_neighbor_status(struct neighbor_entry *entry, int lnk)
signal_link_changes(true);
}
entry->status = SYM;
} else {
} else {
if (entry->status == SYM) {
changes_neighborhood = true;
changes_topology = true;
//update: tapping here to signal the changes in head
if(entry->is_head){
OLSR_PRINTF(1,"My head is assymetric now!");
changes_in_head_status = true;
}
if (olsr_cnf->tc_redundancy > 1)
signal_link_changes(true);
}
/* else N_status is set to NOT_SYM */
entry->status = NOT_SYM;
/* remove neighbor from routing list */


}

return entry->status;
Expand Down
Loading

0 comments on commit 23323f7

Please sign in to comment.