Re-enabled and fixed max_jitter resulting in sending out larger OLSR packets
authorSven-Ola Tuecke <sven-ola@gmx.de>
Mon, 1 Sep 2008 20:01:42 +0000 (22:01 +0200)
committerSven-Ola Tuecke <sven-ola@gmx.de>
Mon, 1 Sep 2008 20:01:42 +0000 (22:01 +0200)
src/lq_packet.c
src/olsr.c
src/packet.c
src/unix/ifnet.c
src/win32/ifnet.c

index b3f5be7..6fdb528 100644 (file)
@@ -651,8 +651,14 @@ olsr_output_lq_hello(void *para)
   // destroy internal format
   destroy_lq_hello(&lq_hello);
 
-  if(net_output_pending(outif) && (!outif->immediate_send_tc || TIMED_OUT(outif->fwdtimer))) {
-    net_output(outif);
+  if (net_output_pending(outif)) {
+    if (outif->immediate_send_tc) {
+      if (TIMED_OUT(outif->fwdtimer))
+        set_buffer_timer(outif);
+    }
+    else {
+      net_output(outif);
+    }
   }
 }
 
@@ -682,7 +688,7 @@ olsr_output_lq_tc(void *para)
   } else if (prev_empty == 0) {
       // initialize timer
 
-      set_empty_tc_timer(GET_TIMESTAMP(olsr_cnf->max_tc_vtime * 3 * 1000));
+      set_empty_tc_timer(GET_TIMESTAMP(olsr_cnf->max_tc_vtime * 3 * MSEC_PER_SEC));
 
       prev_empty = 1;
 
@@ -698,8 +704,14 @@ olsr_output_lq_tc(void *para)
 
   destroy_lq_tc(&lq_tc);
 
-  if(net_output_pending(outif) && (outif->immediate_send_tc || TIMED_OUT(outif->fwdtimer))) {
-    set_buffer_timer(outif);
+  if (net_output_pending(outif)) {
+    if (!outif->immediate_send_tc) {
+      if (TIMED_OUT(outif->fwdtimer))
+        set_buffer_timer(outif);
+    }
+    else {
+      net_output(outif);
+    }
   }
 }
 
index c79091e..bf7e40d 100644 (file)
@@ -404,7 +404,7 @@ void
 set_buffer_timer(struct interface *ifn)
 {      
   /* Set timer */
-  ifn->fwdtimer = GET_TIMESTAMP(random() * olsr_cnf->max_jitter * 1000 / RAND_MAX);
+  ifn->fwdtimer = GET_TIMESTAMP(random() * olsr_cnf->max_jitter * MSEC_PER_SEC / RAND_MAX);
 }
 
 void
index 0780632..b69f82d 100644 (file)
@@ -389,7 +389,7 @@ olsr_build_tc_packet(struct tc_message *message)
     if (sending_tc) {
       /* Send empty TC */
       OLSR_PRINTF(3, "No more MPR selectors - will send empty TCs\n");
-      set_empty_tc_timer(GET_TIMESTAMP((olsr_cnf->max_tc_vtime*3)*1000));
+      set_empty_tc_timer(GET_TIMESTAMP((olsr_cnf->max_tc_vtime * 3) * MSEC_PER_SEC));
       sending_tc = OLSR_FALSE;
     }
   }
index 3722e2f..c146e52 100644 (file)
@@ -866,14 +866,19 @@ chk_if_up(struct olsr_if *iface, int debuglvl __attribute__((unused)))
   
   ifp = olsr_malloc(sizeof (struct interface), "Interface update 2");
   
-  ifp->immediate_send_tc = (iface->cnf->tc_params.emission_interval < iface->cnf->hello_params.emission_interval);
-
   iface->configured = 1;
   iface->interf = ifp;
 
   /* XXX bad code */
   memcpy(ifp, &ifs, sizeof(struct interface));
   
+  ifp->immediate_send_tc = (iface->cnf->tc_params.emission_interval < iface->cnf->hello_params.emission_interval);
+  if (olsr_cnf->max_jitter == 0)
+  {
+    /* max_jitter determines the max time to store to-be-send-messages, correlated with random() */
+    olsr_cnf->max_jitter = ifp->immediate_send_tc ? iface->cnf->tc_params.emission_interval : iface->cnf->hello_params.emission_interval;
+  }
+
   name_size = strlen(if_basename(ifr.ifr_name)) + 1;
   ifp->gen_properties = NULL;
   ifp->int_name = olsr_malloc(name_size, "Interface update 3");
index e2b4a72..13c0337 100644 (file)
@@ -915,6 +915,11 @@ int chk_if_up(struct olsr_if *IntConf, int DebugLevel __attribute__((unused)))
   New = olsr_malloc(sizeof (struct interface), "Interface 1");
 
   New->immediate_send_tc = (IntConf->cnf->tc_params.emission_interval < IntConf->cnf->hello_params.emission_interval);
+  if (olsr_cnf->max_jitter == 0)
+  {
+    /* max_jitter determines the max time to store to-be-send-messages, correlated with random() */
+    olsr_cnf->max_jitter = New->immediate_send_tc ? IntConf->cnf->tc_params.emission_interval : IntConf->cnf->hello_params.emission_interval;
+  }
 
   New->gen_properties = NULL;