Only update the saved link quality values after the 10-percent threshold
authorThomas Lopatic <thomas@lopatic.de>
Wed, 10 Nov 2004 14:53:21 +0000 (14:53 +0000)
committerThomas Lopatic <thomas@lopatic.de>
Wed, 10 Nov 2004 14:53:21 +0000 (14:53 +0000)
has been reached. Otherwise keep the old saved link quality values.

src/link_set.c
src/link_set.h
src/process_package.c
src/tc_set.c
src/tc_set.h
src/two_hop_neighbor_table.h

index 758afd9..aea119d 100644 (file)
@@ -19,7 +19,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  * 
  * 
- * $Id: link_set.c,v 1.25 2004/11/10 14:07:48 tlopatic Exp $
+ * $Id: link_set.c,v 1.26 2004/11/10 14:53:20 tlopatic Exp $
  *
  */
 
@@ -487,6 +487,9 @@ add_new_entry(union olsr_ip_addr *local, union olsr_ip_addr *remote, union olsr_
 
   new_link->loss_link_quality = 0.0;
   new_link->neigh_link_quality = 0.0;
+
+  new_link->saved_loss_link_quality = 0.0;
+  new_link->saved_neigh_link_quality = 0.0;
 #endif
 
   /* Add to queue */
@@ -940,7 +943,7 @@ static void update_packet_loss_worker(struct link_entry *entry, int lost)
 {
   unsigned char mask = 1 << (entry->loss_index & 7);
   int index = entry->loss_index >> 3;
-  double saved_lq, rel_lq;
+  double rel_lq, saved_lq;
 
   if (lost == 0)
     {
@@ -984,9 +987,9 @@ static void update_packet_loss_worker(struct link_entry *entry, int lost)
   if (entry->total_packets < entry->loss_window_size)
     entry->total_packets++;
 
-  // memorize the current link quality
+  // the current reference link quality
 
-  saved_lq = entry->loss_link_quality;
+  saved_lq = entry->saved_loss_link_quality;
 
   if (saved_lq == 0.0)
     saved_lq = -1.0;
@@ -1003,6 +1006,8 @@ static void update_packet_loss_worker(struct link_entry *entry, int lost)
 
   if (rel_lq > 1.1 || rel_lq < 0.9)
     {
+      entry->saved_loss_link_quality = entry->loss_link_quality;
+
       changes_neighborhood = OLSR_TRUE;
       changes_topology = OLSR_TRUE;
 
index 35a91a2..8c84b4b 100644 (file)
@@ -19,7 +19,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  * 
  * 
- * $Id: link_set.h,v 1.14 2004/11/10 12:35:30 tlopatic Exp $
+ * $Id: link_set.h,v 1.15 2004/11/10 14:53:21 tlopatic Exp $
  *
  */
 
@@ -76,6 +76,9 @@ struct link_entry
   unsigned char loss_bitmap[16];
 
   double neigh_link_quality;
+
+  double saved_loss_link_quality;
+  double saved_neigh_link_quality;
 #endif
 
   /*
index c83aae9..a3ef086 100644 (file)
@@ -19,7 +19,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  * 
  * 
- * $Id: process_package.c,v 1.19 2004/11/10 13:09:40 tlopatic Exp $
+ * $Id: process_package.c,v 1.20 2004/11/10 14:53:21 tlopatic Exp $
  *
  */
 
@@ -96,9 +96,9 @@ olsr_hello_tap(struct hello_message *message, struct interface *in_if,
         if (COMP_IP(&walker->address, &in_if->ip_addr))
           break;
 
-      // memorize the currently stored link quality value
+      // the current reference link quality
 
-      saved_lq = link->neigh_link_quality;
+      saved_lq = link->saved_neigh_link_quality;
 
       if (saved_lq == 0.0)
         saved_lq = -1.0;
@@ -119,6 +119,8 @@ olsr_hello_tap(struct hello_message *message, struct interface *in_if,
 
       if (rel_lq > 1.1 || rel_lq < 0.9)
         {
+          link->saved_neigh_link_quality = link->neigh_link_quality;
+
           changes_neighborhood = OLSR_TRUE;
           changes_topology = OLSR_TRUE;
 
@@ -627,7 +629,7 @@ olsr_process_message_neighbors(struct neighbor_entry *neighbor,
 
                       // saved previous total link quality
 
-                      saved_lq = walker->full_link_quality;
+                      saved_lq = walker->saved_full_link_quality;
 
                       if (saved_lq == 0.0)
                         saved_lq = -1.0;
@@ -647,6 +649,9 @@ olsr_process_message_neighbors(struct neighbor_entry *neighbor,
 
                       if (rel_lq > 1.1 || rel_lq < 0.9)
                         {
+                          walker->saved_full_link_quality =
+                            walker->full_link_quality;
+
                           changes_neighborhood = OLSR_TRUE;
                           changes_topology = OLSR_TRUE;
                         }
@@ -686,6 +691,7 @@ olsr_linking_this_2_entries(struct neighbor_entry *neighbor,struct neighbor_2_en
 
 #if defined USE_LINK_QUALITY
   list_of_1_neighbors->full_link_quality = 0.0;
+  list_of_1_neighbors->saved_full_link_quality = 0.0;
 #endif
 
   /* Queue */
index b328b40..c9e459b 100644 (file)
@@ -19,7 +19,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  * 
  * 
- * $Id: tc_set.c,v 1.10 2004/11/10 12:35:30 tlopatic Exp $
+ * $Id: tc_set.c,v 1.11 2004/11/10 14:53:21 tlopatic Exp $
  *
  */
 
@@ -247,6 +247,10 @@ olsr_tc_update_mprs(struct tc_entry *entry, struct tc_message *msg)
       {
         new_topo_dst->link_quality = mprs->neigh_link_quality;
         new_topo_dst->inverse_link_quality = mprs->link_quality;
+
+        new_topo_dst->saved_link_quality = new_topo_dst->link_quality;
+        new_topo_dst->saved_inverse_link_quality =
+          new_topo_dst->inverse_link_quality;
       }
 #endif
 
@@ -269,7 +273,7 @@ olsr_tc_update_mprs(struct tc_entry *entry, struct tc_message *msg)
             {
               double saved_lq, rel_lq;
 
-              saved_lq = existing_dst->link_quality;
+              saved_lq = existing_dst->saved_link_quality;
 
               if (saved_lq == 0.0)
                 saved_lq = -1.0;
@@ -279,9 +283,14 @@ olsr_tc_update_mprs(struct tc_entry *entry, struct tc_message *msg)
               rel_lq = existing_dst->link_quality / saved_lq;
 
               if (rel_lq > 1.1 || rel_lq < 0.9)
-                retval = 1;
+                {
+                  existing_dst->saved_link_quality =
+                    existing_dst->link_quality;
+
+                  retval = 1;
+                }
 
-              saved_lq = existing_dst->inverse_link_quality;
+              saved_lq = existing_dst->saved_inverse_link_quality;
 
               if (saved_lq == 0.0)
                 saved_lq = -1.0;
@@ -291,7 +300,12 @@ olsr_tc_update_mprs(struct tc_entry *entry, struct tc_message *msg)
               rel_lq = existing_dst->inverse_link_quality / saved_lq;
 
               if (rel_lq > 1.1 || rel_lq < 0.9)
-                retval = 1;
+                {
+                  existing_dst->saved_inverse_link_quality =
+                    existing_dst->inverse_link_quality;
+
+                  retval = 1;
+                }
             }
 #endif
        }
index a158077..9bb3907 100644 (file)
@@ -19,7 +19,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  * 
  * 
- * $Id: tc_set.h,v 1.7 2004/11/07 17:51:20 tlopatic Exp $
+ * $Id: tc_set.h,v 1.8 2004/11/10 14:53:21 tlopatic Exp $
  *
  */
 
@@ -41,6 +41,8 @@ struct topo_dst
 #if defined USE_LINK_QUALITY
   double link_quality;
   double inverse_link_quality;
+  double saved_link_quality;
+  double saved_inverse_link_quality;
 #endif
 };
 
index ba08ce1..1938ab1 100644 (file)
@@ -19,7 +19,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  * 
  * 
- * $Id: two_hop_neighbor_table.h,v 1.7 2004/11/05 20:58:10 tlopatic Exp $
+ * $Id: two_hop_neighbor_table.h,v 1.8 2004/11/10 14:53:21 tlopatic Exp $
  *
  */
 
@@ -37,6 +37,7 @@ struct neighbor_list_entry
   struct       neighbor_entry *neighbor;
 #if defined USE_LINK_QUALITY
   double full_link_quality;
+  double saved_full_link_quality;
 #endif
   struct       neighbor_list_entry *next;
   struct       neighbor_list_entry *prev;