[Olsr-cvs] olsrd-current/src link_set.h, 1.31, 1.32 link_set.c, 1.73, 1.74
Bernd Petrovitsch
(spam-protected)
Fri Oct 5 22:10:27 CEST 2007
Update of /cvsroot/olsrd/olsrd-current/src
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv17183/src
Modified Files:
link_set.h link_set.c
Log Message:
Misc changes:
- several fields in struct link_entry since I see no reason ot keep them
signed and it avoids warnings
- killed the "loss_window_size" field in struct link_entry since it is
only initalized and never changed.
- minimized constant strings in olsr_print_link_set().
cleanup stuff:
- const'ified parameters
- reformatted to make it (IMHO) more readable
Index: link_set.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/link_set.h,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -d -r1.31 -r1.32
*** link_set.h 10 Feb 2007 19:27:32 -0000 1.31
--- link_set.h 5 Oct 2007 20:10:24 -0000 1.32
***************
*** 84,95 ****
int loss_missed_hellos;
! int lost_packets;
! int total_packets;
double loss_link_quality, loss_link_quality2;
double loss_link_multiplier;
! int loss_window_size;
! int loss_index;
unsigned char loss_bitmap[16];
--- 84,94 ----
int loss_missed_hellos;
! unsigned int lost_packets;
! unsigned int total_packets;
double loss_link_quality, loss_link_quality2;
double loss_link_multiplier;
! unsigned int loss_index;
unsigned char loss_bitmap[16];
***************
*** 119,142 ****
void
! del_if_link_entries(union olsr_ip_addr *);
struct link_entry *
! get_best_link_to_neighbor(union olsr_ip_addr *);
struct link_entry *
! lookup_link_entry(union olsr_ip_addr *, union olsr_ip_addr *remote_main, struct interface *);
struct link_entry *
! update_link_entry(union olsr_ip_addr *, union olsr_ip_addr *, struct hello_message *, struct interface *);
int
! check_neighbor_link(union olsr_ip_addr *);
int
! replace_neighbor_link_set(struct neighbor_entry *,
struct neighbor_entry *);
int
! lookup_link_status(struct link_entry *);
void
--- 118,141 ----
void
! del_if_link_entries(const union olsr_ip_addr *);
struct link_entry *
! get_best_link_to_neighbor(const union olsr_ip_addr *);
struct link_entry *
! lookup_link_entry(const union olsr_ip_addr *, const union olsr_ip_addr *remote_main, const struct interface *);
struct link_entry *
! update_link_entry(const union olsr_ip_addr *, const union olsr_ip_addr *, const struct hello_message *, const struct interface *);
int
! check_neighbor_link(const union olsr_ip_addr *);
int
! replace_neighbor_link_set(const struct neighbor_entry *,
struct neighbor_entry *);
int
! lookup_link_status(const struct link_entry *);
void
***************
*** 144,148 ****
void
! olsr_update_packet_loss(union olsr_ip_addr *, struct interface *, olsr_u16_t);
void
--- 143,147 ----
void
! olsr_update_packet_loss(const union olsr_ip_addr *, const struct interface *, olsr_u16_t);
void
Index: link_set.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/link_set.c,v
retrieving revision 1.73
retrieving revision 1.74
diff -C2 -d -r1.73 -r1.74
*** link_set.c 17 Sep 2007 22:24:22 -0000 1.73
--- link_set.c 5 Oct 2007 20:10:24 -0000 1.74
***************
*** 62,66 ****
static int
! check_link_status(struct hello_message *message, struct interface *in_if);
static void
--- 62,66 ----
static int
! check_link_status(const struct hello_message *message, const struct interface *in_if);
static void
***************
*** 70,74 ****
static struct link_entry *
! add_link_entry(union olsr_ip_addr *, union olsr_ip_addr *, union olsr_ip_addr *, double, double, struct interface *);
static void
--- 70,74 ----
static struct link_entry *
! add_link_entry(const union olsr_ip_addr *, const union olsr_ip_addr *, const union olsr_ip_addr *, double, double, const struct interface *);
static void
***************
*** 76,80 ****
static int
! get_neighbor_status(union olsr_ip_addr *);
--- 76,80 ----
static int
! get_neighbor_status(const union olsr_ip_addr *);
***************
*** 121,125 ****
*/
int
! lookup_link_status(struct link_entry *entry)
{
--- 121,125 ----
*/
int
! lookup_link_status(const struct link_entry *entry)
{
***************
*** 182,188 ****
*/
static int
! get_neighbor_status(union olsr_ip_addr *address)
{
! union olsr_ip_addr *main_addr;
struct interface *ifs;
--- 182,188 ----
*/
static int
! get_neighbor_status(const union olsr_ip_addr *address)
{
! const union olsr_ip_addr *main_addr;
struct interface *ifs;
***************
*** 235,241 ****
struct link_entry *
! get_best_link_to_neighbor(union olsr_ip_addr *remote)
{
! union olsr_ip_addr *main_addr;
struct link_entry *walker, *good_link, *backup_link;
int curr_metric = MAX_IF_METRIC;
--- 235,241 ----
struct link_entry *
! get_best_link_to_neighbor(const union olsr_ip_addr *remote)
{
! const union olsr_ip_addr *main_addr;
struct link_entry *walker, *good_link, *backup_link;
int curr_metric = MAX_IF_METRIC;
***************
*** 390,394 ****
void
! del_if_link_entries(union olsr_ip_addr *int_addr)
{
struct link_entry *tmp_link_set, *last_link_entry;
--- 390,394 ----
void
! del_if_link_entries(const union olsr_ip_addr *int_addr)
{
struct link_entry *tmp_link_set, *last_link_entry;
***************
*** 459,469 ****
static struct link_entry *
! add_link_entry(union olsr_ip_addr *local, union olsr_ip_addr *remote, union olsr_ip_addr *remote_main, double vtime, double htime, struct interface *local_if)
{
! struct link_entry *tmp_link_set, *new_link;
struct neighbor_entry *neighbor;
!
! if((tmp_link_set = lookup_link_entry(remote, remote_main, local_if))) return tmp_link_set;
!
/*
* if there exists no link tuple with
--- 459,475 ----
static struct link_entry *
! add_link_entry(const union olsr_ip_addr *local,
! const union olsr_ip_addr *remote,
! const union olsr_ip_addr *remote_main,
! double vtime,
! double htime,
! const struct interface *local_if)
{
! struct link_entry *new_link;
struct neighbor_entry *neighbor;
! struct link_entry *tmp_link_set = lookup_link_entry(remote, remote_main, local_if);
! if (tmp_link_set) {
! return tmp_link_set;
! }
/*
* if there exists no link tuple with
***************
*** 532,536 ****
new_link->total_packets = 0;
- new_link->loss_window_size = olsr_cnf->lq_wsize;
new_link->loss_index = 0;
--- 538,541 ----
***************
*** 613,617 ****
int
! check_neighbor_link(union olsr_ip_addr *int_addr)
{
struct link_entry *tmp_link_set;
--- 618,622 ----
int
! check_neighbor_link(const union olsr_ip_addr *int_addr)
{
struct link_entry *tmp_link_set;
***************
*** 639,643 ****
*/
struct link_entry *
! lookup_link_entry(union olsr_ip_addr *remote, union olsr_ip_addr *remote_main, struct interface *local)
{
struct link_entry *tmp_link_set;
--- 644,648 ----
*/
struct link_entry *
! lookup_link_entry(const union olsr_ip_addr *remote, const union olsr_ip_addr *remote_main, const struct interface *local)
{
struct link_entry *tmp_link_set;
***************
*** 682,689 ****
*/
struct link_entry *
! update_link_entry(union olsr_ip_addr *local,
! union olsr_ip_addr *remote,
! struct hello_message *message,
! struct interface *in_if)
{
struct link_entry *entry;
--- 687,694 ----
*/
struct link_entry *
! update_link_entry(const union olsr_ip_addr *local,
! const union olsr_ip_addr *remote,
! const struct hello_message *message,
! const struct interface *in_if)
{
struct link_entry *entry;
***************
*** 755,759 ****
*/
int
! replace_neighbor_link_set(struct neighbor_entry *old,
struct neighbor_entry *new)
{
--- 760,764 ----
*/
int
! replace_neighbor_link_set(const struct neighbor_entry *old,
struct neighbor_entry *new)
{
***************
*** 793,797 ****
*/
static int
! check_link_status(struct hello_message *message, struct interface *in_if)
{
int ret = UNSPEC_LINK;
--- 798,802 ----
*/
static int
! check_link_status(const struct hello_message *message, const struct interface *in_if)
{
int ret = UNSPEC_LINK;
***************
*** 945,949 ****
{
struct link_entry *walker;
! char *fstr;
OLSR_PRINTF(1, "\n--- %02d:%02d:%02d.%02d ---------------------------------------------------- LINKS\n\n",
--- 950,954 ----
{
struct link_entry *walker;
! const int addrsize = olsr_cnf->ip_version == AF_INET ? 15 : 39;
OLSR_PRINTF(1, "\n--- %02d:%02d:%02d.%02d ---------------------------------------------------- LINKS\n\n",
***************
*** 951,967 ****
nowtm->tm_min,
nowtm->tm_sec,
! (int)now.tv_usec/10000);
!
! if (olsr_cnf->ip_version == AF_INET)
! {
! OLSR_PRINTF(1, "IP address hyst LQ lost total NLQ ETX\n");
! fstr = "%-15s %5.3f %5.3f %-3d %-3d %5.3f %.2f\n";
! }
!
! else
! {
! OLSR_PRINTF(1, "IP address hyst LQ lost total NLQ ETX\n");
! fstr = "%-39s %5.3f %5.3f %-3d %-3d %5.3f %.2f\n";
! }
for (walker = link_set; walker != NULL; walker = walker->next)
--- 956,961 ----
nowtm->tm_min,
nowtm->tm_sec,
! (int)now.tv_usec/10000U);
! OLSR_PRINTF(1, "%-*s %-6s %-6s %-6s %-6s %-6s %s\n", addrsize, "IP address", "hyst", "LQ", "lost", "total","NLQ", "ETX");
for (walker = link_set; walker != NULL; walker = walker->next)
***************
*** 969,983 ****
float etx;
! if (walker->loss_link_quality < MIN_LINK_QUALITY ||
! walker->neigh_link_quality < MIN_LINK_QUALITY)
etx = 0.0;
-
else
etx = 1.0 / (walker->loss_link_quality * walker->neigh_link_quality);
! OLSR_PRINTF(1, fstr, olsr_ip_to_string(&walker->neighbor_iface_addr),
! walker->L_link_quality, walker->loss_link_quality,
! walker->lost_packets, walker->total_packets,
! walker->neigh_link_quality, etx);
}
}
--- 963,979 ----
float etx;
! if (walker->loss_link_quality < MIN_LINK_QUALITY || walker->neigh_link_quality < MIN_LINK_QUALITY)
etx = 0.0;
else
etx = 1.0 / (walker->loss_link_quality * walker->neigh_link_quality);
! OLSR_PRINTF(1, "%-*s %5.3f %5.3f %-3d %-3d %5.3f %.2f\n",
! addrsize, olsr_ip_to_string(&walker->neighbor_iface_addr),
! walker->L_link_quality,
! walker->loss_link_quality,
! walker->lost_packets,
! walker->total_packets,
! walker->neigh_link_quality,
! etx);
}
}
***************
*** 1023,1032 ****
// wrap around at the end of the packet loss window
! if (entry->loss_index >= entry->loss_window_size)
entry->loss_index = 0;
// count the total number of handled packets up to the window size
! if (entry->total_packets < entry->loss_window_size)
entry->total_packets++;
--- 1019,1028 ----
// wrap around at the end of the packet loss window
! if (entry->loss_index >= olsr_cnf->lq_wsize)
entry->loss_index = 0;
// count the total number of handled packets up to the window size
! if (entry->total_packets < olsr_cnf->lq_wsize)
entry->total_packets++;
***************
*** 1042,1050 ****
// start slowly: receive the first packet => link quality = 1 / n
// (n = window size)
-
entry->loss_link_quality =
(float)(entry->total_packets - entry->lost_packets) /
! (float)(entry->loss_window_size < (2 * 4) ? entry->loss_window_size:
! 4 * (((float)entry->loss_window_size / 4 - 1) * entry->total_packets + entry->loss_window_size) / entry->loss_window_size);
// multiply the calculated link quality with the user-specified multiplier
--- 1038,1045 ----
// start slowly: receive the first packet => link quality = 1 / n
// (n = window size)
entry->loss_link_quality =
(float)(entry->total_packets - entry->lost_packets) /
! (float)(olsr_cnf->lq_wsize < (2 * 4) ? olsr_cnf->lq_wsize:
! 4 * (((float)olsr_cnf->lq_wsize / 4 - 1) * entry->total_packets + olsr_cnf->lq_wsize) / olsr_cnf->lq_wsize);
// multiply the calculated link quality with the user-specified multiplier
***************
*** 1088,1092 ****
}
! void olsr_update_packet_loss(union olsr_ip_addr *rem, struct interface *loc,
olsr_u16_t seqno)
{
--- 1083,1087 ----
}
! void olsr_update_packet_loss(const union olsr_ip_addr *rem, const struct interface *loc,
olsr_u16_t seqno)
{
More information about the Olsr-cvs
mailing list