src/olsr/model/olsr-routing-protocol.cc
author Josh Pelkey <jpelkey@gatech.edu>
Fri, 13 May 2011 14:58:13 -0400
changeset 7184 a15feb312428
parent 7045 d13fa06886ce
child 7226 6396b9384525
permissions -rw-r--r--
olsr coding style changes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
     1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
1752
d9115729b7d6 Cleanup copyright headers and some unused includes.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1740
diff changeset
     2
/*
d9115729b7d6 Cleanup copyright headers and some unused includes.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1740
diff changeset
     3
 * Copyright (c) 2004 Francisco J. Ros 
d9115729b7d6 Cleanup copyright headers and some unused includes.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1740
diff changeset
     4
 * Copyright (c) 2007 INESC Porto
d9115729b7d6 Cleanup copyright headers and some unused includes.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1740
diff changeset
     5
 *
d9115729b7d6 Cleanup copyright headers and some unused includes.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1740
diff changeset
     6
 * This program is free software; you can redistribute it and/or modify
d9115729b7d6 Cleanup copyright headers and some unused includes.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1740
diff changeset
     7
 * it under the terms of the GNU General Public License version 2 as
d9115729b7d6 Cleanup copyright headers and some unused includes.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1740
diff changeset
     8
 * published by the Free Software Foundation;
d9115729b7d6 Cleanup copyright headers and some unused includes.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1740
diff changeset
     9
 *
d9115729b7d6 Cleanup copyright headers and some unused includes.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1740
diff changeset
    10
 * This program is distributed in the hope that it will be useful,
d9115729b7d6 Cleanup copyright headers and some unused includes.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1740
diff changeset
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
d9115729b7d6 Cleanup copyright headers and some unused includes.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1740
diff changeset
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
d9115729b7d6 Cleanup copyright headers and some unused includes.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1740
diff changeset
    13
 * GNU General Public License for more details.
d9115729b7d6 Cleanup copyright headers and some unused includes.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1740
diff changeset
    14
 *
d9115729b7d6 Cleanup copyright headers and some unused includes.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1740
diff changeset
    15
 * You should have received a copy of the GNU General Public License
d9115729b7d6 Cleanup copyright headers and some unused includes.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1740
diff changeset
    16
 * along with this program; if not, write to the Free Software
d9115729b7d6 Cleanup copyright headers and some unused includes.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1740
diff changeset
    17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
d9115729b7d6 Cleanup copyright headers and some unused includes.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1740
diff changeset
    18
 *
d9115729b7d6 Cleanup copyright headers and some unused includes.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1740
diff changeset
    19
 * Authors: Francisco J. Ros  <fjrm@dif.um.es>
d9115729b7d6 Cleanup copyright headers and some unused includes.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1740
diff changeset
    20
 *          Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
d9115729b7d6 Cleanup copyright headers and some unused includes.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1740
diff changeset
    21
 */
d9115729b7d6 Cleanup copyright headers and some unused includes.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1740
diff changeset
    22
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    23
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    24
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    25
/// \file	OLSR.cc
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    26
/// \brief	Implementation of OLSR agent and related classes.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    27
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    28
/// This is the main file of this software because %OLSR's behaviour is
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    29
/// implemented here.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    30
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    31
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
    32
#define NS_LOG_APPEND_CONTEXT                                   \
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
    33
  if (GetObject<Node> ()) { std::clog << "[node " << GetObject<Node> ()->GetId () << "] "; }
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
    34
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
    35
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
    36
#include "olsr-routing-protocol.h"
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    37
#include "ns3/socket-factory.h"
3125
d2d8a36cfd23 s/ns3::Udp/ns3::UdpSocketFactory
Tom Henderson <tomh@tomh.org>
parents: 3116
diff changeset
    38
#include "ns3/udp-socket-factory.h"
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    39
#include "ns3/simulator.h"
1804
9c11e776f501 bug 96: debug.h duplicates functionality from log.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1803
diff changeset
    40
#include "ns3/log.h"
6701
a590022a1536 [bug 947] Pretty-print IPv4 routing tables (patch originated by Hemanth Narra)
Tom Henderson <tomh@tomh.org>
parents: 6634
diff changeset
    41
#include "ns3/names.h"
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    42
#include "ns3/random-variable.h"
1740
3d3168e8fef6 Update OLSR code to NS-3 API changes.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1732
diff changeset
    43
#include "ns3/inet-socket-address.h"
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
    44
#include "ns3/ipv4-routing-protocol.h"
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
    45
#include "ns3/ipv4-routing-table-entry.h"
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
    46
#include "ns3/ipv4-route.h"
2484
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2308
diff changeset
    47
#include "ns3/boolean.h"
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2308
diff changeset
    48
#include "ns3/uinteger.h"
3233
35ba9a71bcb5 Add OLSR attribute documentation; make Willingness an enum attribute instead of uint. Closes #211
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3145
diff changeset
    49
#include "ns3/enum.h"
2484
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2308
diff changeset
    50
#include "ns3/trace-source-accessor.h"
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
    51
#include "ns3/ipv4-header.h"
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    52
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    53
/********** Useful macros **********/
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    54
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    55
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    56
/// \brief Gets the delay between a given time and the current time.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    57
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    58
/// If given time is previous to the current one, then this macro returns
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    59
/// a number close to 0. This is used for scheduling events at a certain moment.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    60
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    61
#define DELAY(time) (((time) < (Simulator::Now ())) ? Seconds (0.000001) : \
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    62
                     (time - Simulator::Now () + Seconds (0.000001)))
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    63
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    64
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    65
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    66
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    67
/// \brief Period at which a node must cite every link and every neighbor.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    68
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    69
/// We only use this value in order to define OLSR_NEIGHB_HOLD_TIME.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    70
///
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
    71
#define OLSR_REFRESH_INTERVAL   Seconds (2)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    72
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    73
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    74
/********** Holding times **********/
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    75
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    76
/// Neighbor holding time.
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
    77
#define OLSR_NEIGHB_HOLD_TIME   Time (3 * OLSR_REFRESH_INTERVAL)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    78
/// Top holding time.
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
    79
#define OLSR_TOP_HOLD_TIME      Time (3 * m_tcInterval)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    80
/// Dup holding time.
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
    81
#define OLSR_DUP_HOLD_TIME      Seconds (30)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    82
/// MID holding time.
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
    83
#define OLSR_MID_HOLD_TIME      Time (3 * m_midInterval)
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
    84
/// HNA holding time.
7044
f94b264549d1 introduce implicit conversion operator
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 7040
diff changeset
    85
#define OLSR_HNA_HOLD_TIME      Time (3 * m_hnaInterval)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    86
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    87
/********** Link types **********/
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    88
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    89
/// Unspecified link type.
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
    90
#define OLSR_UNSPEC_LINK        0
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    91
/// Asymmetric link type.
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
    92
#define OLSR_ASYM_LINK          1
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    93
/// Symmetric link type.
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
    94
#define OLSR_SYM_LINK           2
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    95
/// Lost link type.
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
    96
#define OLSR_LOST_LINK          3
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    97
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    98
/********** Neighbor types **********/
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    99
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   100
/// Not neighbor type.
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   101
#define OLSR_NOT_NEIGH          0
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   102
/// Symmetric neighbor type.
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   103
#define OLSR_SYM_NEIGH          1
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   104
/// Asymmetric neighbor type.
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   105
#define OLSR_MPR_NEIGH          2
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   106
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   107
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   108
/********** Willingness **********/
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   109
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   110
/// Willingness for forwarding packets from other nodes: never.
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   111
#define OLSR_WILL_NEVER         0
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   112
/// Willingness for forwarding packets from other nodes: low.
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   113
#define OLSR_WILL_LOW           1
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   114
/// Willingness for forwarding packets from other nodes: medium.
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   115
#define OLSR_WILL_DEFAULT       3
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   116
/// Willingness for forwarding packets from other nodes: high.
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   117
#define OLSR_WILL_HIGH          6
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   118
/// Willingness for forwarding packets from other nodes: always.
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   119
#define OLSR_WILL_ALWAYS        7
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   120
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   121
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   122
/********** Miscellaneous constants **********/
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   123
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   124
/// Maximum allowed jitter.
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   125
#define OLSR_MAXJITTER          (m_helloInterval.GetSeconds () / 4)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   126
/// Maximum allowed sequence number.
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   127
#define OLSR_MAX_SEQ_NUM        65535
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   128
/// Random number between [0-OLSR_MAXJITTER] used to jitter OLSR packet transmission.
4218
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3970
diff changeset
   129
#define JITTER (Seconds (UniformVariable().GetValue (0, OLSR_MAXJITTER)))
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   130
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   131
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   132
#define OLSR_PORT_NUMBER 698
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   133
/// Maximum number of messages per packet.
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   134
#define OLSR_MAX_MSGS           64
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   135
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   136
/// Maximum number of hellos per message (4 possible link types * 3 possible nb types).
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   137
#define OLSR_MAX_HELLOS         12
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   138
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   139
/// Maximum number of addresses advertised on a message.
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   140
#define OLSR_MAX_ADDRS          64
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   141
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   142
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   143
namespace ns3 {
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
   144
namespace olsr {
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   145
5867
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
   146
NS_LOG_COMPONENT_DEFINE ("OlsrRoutingProtocol");
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   147
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   148
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   149
/********** OLSR class **********/
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   150
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   151
NS_OBJECT_ENSURE_REGISTERED (RoutingProtocol);
2249
3a1da26d61dc replace ComponentManager::Create and ClassId with InterfaceId::CreateObjest and InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2232
diff changeset
   152
2250
18f432098389 InterfaceId -> TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2249
diff changeset
   153
TypeId 
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   154
RoutingProtocol::GetTypeId (void)
2249
3a1da26d61dc replace ComponentManager::Create and ClassId with InterfaceId::CreateObjest and InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2232
diff changeset
   155
{
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   156
  static TypeId tid = TypeId ("ns3::olsr::RoutingProtocol")
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
   157
    .SetParent<Ipv4RoutingProtocol> ()
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   158
    .AddConstructor<RoutingProtocol> ()
3233
35ba9a71bcb5 Add OLSR attribute documentation; make Willingness an enum attribute instead of uint. Closes #211
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3145
diff changeset
   159
    .AddAttribute ("HelloInterval", "HELLO messages emission interval.",
35ba9a71bcb5 Add OLSR attribute documentation; make Willingness an enum attribute instead of uint. Closes #211
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3145
diff changeset
   160
                   TimeValue (Seconds (2)),
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   161
                   MakeTimeAccessor (&RoutingProtocol::m_helloInterval),
2484
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2308
diff changeset
   162
                   MakeTimeChecker ())
3233
35ba9a71bcb5 Add OLSR attribute documentation; make Willingness an enum attribute instead of uint. Closes #211
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3145
diff changeset
   163
    .AddAttribute ("TcInterval", "TC messages emission interval.",
35ba9a71bcb5 Add OLSR attribute documentation; make Willingness an enum attribute instead of uint. Closes #211
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3145
diff changeset
   164
                   TimeValue (Seconds (5)),
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   165
                   MakeTimeAccessor (&RoutingProtocol::m_tcInterval),
2484
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2308
diff changeset
   166
                   MakeTimeChecker ())
3233
35ba9a71bcb5 Add OLSR attribute documentation; make Willingness an enum attribute instead of uint. Closes #211
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3145
diff changeset
   167
    .AddAttribute ("MidInterval", "MID messages emission interval.  Normally it is equal to TcInterval.",
35ba9a71bcb5 Add OLSR attribute documentation; make Willingness an enum attribute instead of uint. Closes #211
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3145
diff changeset
   168
                   TimeValue (Seconds (5)),
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   169
                   MakeTimeAccessor (&RoutingProtocol::m_midInterval),
2484
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2308
diff changeset
   170
                   MakeTimeChecker ())
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   171
    .AddAttribute ("HnaInterval", "HNA messages emission interval.  Normally it is equal to TcInterval.",
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   172
                   TimeValue (Seconds (5)),
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   173
                   MakeTimeAccessor (&RoutingProtocol::m_hnaInterval),
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   174
                   MakeTimeChecker ())
3233
35ba9a71bcb5 Add OLSR attribute documentation; make Willingness an enum attribute instead of uint. Closes #211
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3145
diff changeset
   175
    .AddAttribute ("Willingness", "Willingness of a node to carry and forward traffic for other nodes.",
35ba9a71bcb5 Add OLSR attribute documentation; make Willingness an enum attribute instead of uint. Closes #211
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3145
diff changeset
   176
                   EnumValue (OLSR_WILL_DEFAULT),
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   177
                   MakeEnumAccessor (&RoutingProtocol::m_willingness),
3233
35ba9a71bcb5 Add OLSR attribute documentation; make Willingness an enum attribute instead of uint. Closes #211
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3145
diff changeset
   178
                   MakeEnumChecker (OLSR_WILL_NEVER, "never",
35ba9a71bcb5 Add OLSR attribute documentation; make Willingness an enum attribute instead of uint. Closes #211
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3145
diff changeset
   179
                                    OLSR_WILL_LOW, "low",
35ba9a71bcb5 Add OLSR attribute documentation; make Willingness an enum attribute instead of uint. Closes #211
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3145
diff changeset
   180
                                    OLSR_WILL_DEFAULT, "default",
35ba9a71bcb5 Add OLSR attribute documentation; make Willingness an enum attribute instead of uint. Closes #211
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3145
diff changeset
   181
                                    OLSR_WILL_HIGH, "high",
35ba9a71bcb5 Add OLSR attribute documentation; make Willingness an enum attribute instead of uint. Closes #211
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3145
diff changeset
   182
                                    OLSR_WILL_ALWAYS, "always"))
2484
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2308
diff changeset
   183
    .AddTraceSource ("Rx", "Receive OLSR packet.",
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   184
                     MakeTraceSourceAccessor (&RoutingProtocol::m_rxPacketTrace))
2484
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2308
diff changeset
   185
    .AddTraceSource ("Tx", "Send OLSR packet.",
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   186
                     MakeTraceSourceAccessor (&RoutingProtocol::m_txPacketTrace))
2503
e667dc0f350e merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2334 2484
diff changeset
   187
    .AddTraceSource ("RoutingTableChanged", "The OLSR routing table has changed.",
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   188
                     MakeTraceSourceAccessor (&RoutingProtocol::m_routingTableChanged))
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   189
  ;
2252
80595448707a iid -> tid
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
   190
  return tid;
2249
3a1da26d61dc replace ComponentManager::Create and ClassId with InterfaceId::CreateObjest and InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2232
diff changeset
   191
}
3a1da26d61dc replace ComponentManager::Create and ClassId with InterfaceId::CreateObjest and InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2232
diff changeset
   192
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   193
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   194
RoutingProtocol::RoutingProtocol ()
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   195
  : m_routingTableAssociation (0),
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   196
    m_ipv4 (0),
4560
2f106fd728ab Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4472
diff changeset
   197
    m_helloTimer (Timer::CANCEL_ON_DESTROY),
2f106fd728ab Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4472
diff changeset
   198
    m_tcTimer (Timer::CANCEL_ON_DESTROY),
2f106fd728ab Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4472
diff changeset
   199
    m_midTimer (Timer::CANCEL_ON_DESTROY),
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   200
    m_hnaTimer (Timer::CANCEL_ON_DESTROY),
4560
2f106fd728ab Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4472
diff changeset
   201
    m_queuedMessagesTimer (Timer::CANCEL_ON_DESTROY)
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   202
{
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   203
  m_hnaRoutingTable = Create<Ipv4StaticRouting> ();
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   204
}
2484
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2308
diff changeset
   205
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   206
RoutingProtocol::~RoutingProtocol ()
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   207
{
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   208
}
2900
b5deaba7280e add destructor. Easier to plant a breakpoint in there.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2827
diff changeset
   209
2484
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2308
diff changeset
   210
void
4560
2f106fd728ab Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4472
diff changeset
   211
RoutingProtocol::SetIpv4 (Ptr<Ipv4> ipv4)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   212
{
4560
2f106fd728ab Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4472
diff changeset
   213
  NS_ASSERT (ipv4 != 0);
2f106fd728ab Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4472
diff changeset
   214
  NS_ASSERT (m_ipv4 == 0);
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   215
  NS_LOG_DEBUG ("Created olsr::RoutingProtocol");
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   216
  m_helloTimer.SetFunction (&RoutingProtocol::HelloTimerExpire, this);
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   217
  m_tcTimer.SetFunction (&RoutingProtocol::TcTimerExpire, this);
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   218
  m_midTimer.SetFunction (&RoutingProtocol::MidTimerExpire, this);
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   219
  m_hnaTimer.SetFunction (&RoutingProtocol::HnaTimerExpire, this);
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   220
  m_queuedMessagesTimer.SetFunction (&RoutingProtocol::SendQueuedMessages, this);
1765
763f8d1bb058 Adapt the OLSR agent code to use the new Timer class.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1763
diff changeset
   221
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   222
  m_packetSequenceNumber = OLSR_MAX_SEQ_NUM;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   223
  m_messageSequenceNumber = OLSR_MAX_SEQ_NUM;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   224
  m_ansn = OLSR_MAX_SEQ_NUM;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   225
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   226
  m_linkTupleTimerFirstTime = true;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   227
4560
2f106fd728ab Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4472
diff changeset
   228
  m_ipv4 = ipv4;
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   229
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   230
  m_hnaRoutingTable->SetIpv4 (ipv4);
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   231
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   232
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   233
void RoutingProtocol::DoDispose ()
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   234
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   235
  m_ipv4 = 0;
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   236
  m_hnaRoutingTable = 0;
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   237
  m_routingTableAssociation = 0;
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   238
5761
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
   239
  for (std::map< Ptr<Socket>, Ipv4InterfaceAddress >::iterator iter = m_socketAddresses.begin ();
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   240
       iter != m_socketAddresses.end (); iter++)
1779
85fd2b8c9e76 Fix OLSR agent finalization issues.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1778
diff changeset
   241
    {
4362
9e9c734b927e good god, there should be no reason to call Dispose directly here.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4358
diff changeset
   242
      iter->first->Close ();
1779
85fd2b8c9e76 Fix OLSR agent finalization issues.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1778
diff changeset
   243
    }
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   244
  m_socketAddresses.clear ();
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   245
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
   246
  Ipv4RoutingProtocol::DoDispose ();
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   247
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   248
6701
a590022a1536 [bug 947] Pretty-print IPv4 routing tables (patch originated by Hemanth Narra)
Tom Henderson <tomh@tomh.org>
parents: 6634
diff changeset
   249
void
a590022a1536 [bug 947] Pretty-print IPv4 routing tables (patch originated by Hemanth Narra)
Tom Henderson <tomh@tomh.org>
parents: 6634
diff changeset
   250
RoutingProtocol::PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const
a590022a1536 [bug 947] Pretty-print IPv4 routing tables (patch originated by Hemanth Narra)
Tom Henderson <tomh@tomh.org>
parents: 6634
diff changeset
   251
{
6814
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
   252
  std::ostream* os = stream->GetStream ();
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
   253
  *os << "Destination\t\tNextHop\t\tInterface\tDistance\n";
6701
a590022a1536 [bug 947] Pretty-print IPv4 routing tables (patch originated by Hemanth Narra)
Tom Henderson <tomh@tomh.org>
parents: 6634
diff changeset
   254
a590022a1536 [bug 947] Pretty-print IPv4 routing tables (patch originated by Hemanth Narra)
Tom Henderson <tomh@tomh.org>
parents: 6634
diff changeset
   255
  for (std::map<Ipv4Address, RoutingTableEntry>::const_iterator iter = m_table.begin ();
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   256
       iter != m_table.end (); iter++)
6701
a590022a1536 [bug 947] Pretty-print IPv4 routing tables (patch originated by Hemanth Narra)
Tom Henderson <tomh@tomh.org>
parents: 6634
diff changeset
   257
    {
6814
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
   258
      *os << iter->first << "\t\t";
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
   259
      *os << iter->second.nextAddr << "\t\t";
6701
a590022a1536 [bug 947] Pretty-print IPv4 routing tables (patch originated by Hemanth Narra)
Tom Henderson <tomh@tomh.org>
parents: 6634
diff changeset
   260
      if (Names::FindName (m_ipv4->GetNetDevice (iter->second.interface)) != "")
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   261
        {
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   262
          *os << Names::FindName (m_ipv4->GetNetDevice (iter->second.interface)) << "\t\t";
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   263
        }
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   264
      else
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   265
        {
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   266
          *os << iter->second.interface << "\t\t";
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   267
        }
6701
a590022a1536 [bug 947] Pretty-print IPv4 routing tables (patch originated by Hemanth Narra)
Tom Henderson <tomh@tomh.org>
parents: 6634
diff changeset
   268
      *os << iter->second.distance << "\t";
a590022a1536 [bug 947] Pretty-print IPv4 routing tables (patch originated by Hemanth Narra)
Tom Henderson <tomh@tomh.org>
parents: 6634
diff changeset
   269
      *os << "\n";
a590022a1536 [bug 947] Pretty-print IPv4 routing tables (patch originated by Hemanth Narra)
Tom Henderson <tomh@tomh.org>
parents: 6634
diff changeset
   270
    }
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   271
  // Also print the HNA routing table
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   272
  *os << " HNA Routing Table:\n";
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   273
  m_hnaRoutingTable->PrintRoutingTable (stream);
6701
a590022a1536 [bug 947] Pretty-print IPv4 routing tables (patch originated by Hemanth Narra)
Tom Henderson <tomh@tomh.org>
parents: 6634
diff changeset
   274
}
a590022a1536 [bug 947] Pretty-print IPv4 routing tables (patch originated by Hemanth Narra)
Tom Henderson <tomh@tomh.org>
parents: 6634
diff changeset
   275
5524
efed7493f2c1 Make applications generate traffic within their associated context/node
Guillaume Seguin <guillaume@segu.in>
parents: 5510
diff changeset
   276
void RoutingProtocol::DoStart ()
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   277
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   278
  if (m_mainAddress == Ipv4Address ())
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   279
    {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   280
      Ipv4Address loopback ("127.0.0.1");
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   281
      for (uint32_t i = 0; i < m_ipv4->GetNInterfaces (); i++)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   282
        {
4375
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4218
diff changeset
   283
          // Use primary address, if multiple
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4218
diff changeset
   284
          Ipv4Address addr = m_ipv4->GetAddress (i, 0).GetLocal ();
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   285
          if (addr != loopback)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   286
            {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   287
              m_mainAddress = addr;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   288
              break;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   289
            }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   290
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   291
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   292
      NS_ASSERT (m_mainAddress != Ipv4Address ());
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   293
    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   294
1804
9c11e776f501 bug 96: debug.h duplicates functionality from log.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1803
diff changeset
   295
  NS_LOG_DEBUG ("Starting OLSR on node " << m_mainAddress);
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   296
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   297
  Ipv4Address loopback ("127.0.0.1");
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   298
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   299
  bool canRunOlsr = false;
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   300
  for (uint32_t i = 0; i < m_ipv4->GetNInterfaces (); i++)
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   301
    {
4375
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4218
diff changeset
   302
      Ipv4Address addr = m_ipv4->GetAddress (i, 0).GetLocal ();
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   303
      if (addr == loopback)
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   304
        continue;
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   305
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   306
      if (addr != m_mainAddress)
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   307
        {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   308
          // Create never expiring interface association tuple entries for our
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   309
          // own network interfaces, so that GetMainAddress () works to
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   310
          // translate the node's own interface addresses into the main address.
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   311
          IfaceAssocTuple tuple;
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   312
          tuple.ifaceAddr = addr;
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   313
          tuple.mainAddr = m_mainAddress;
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   314
          AddIfaceAssocTuple (tuple);
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   315
          NS_ASSERT (GetMainAddress (addr) == m_mainAddress);
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   316
        }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   317
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   318
      if(m_interfaceExclusions.find (i) != m_interfaceExclusions.end ())
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   319
        continue;
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   320
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   321
      // Create a socket to listen only on this interface
3116
c33b6d2775b7 Move API for socket factory to a Socket::CreateSocket () factory method
Tom Henderson <tomh@tomh.org>
parents: 3103
diff changeset
   322
      Ptr<Socket> socket = Socket::CreateSocket (GetObject<Node> (), 
6438
96f612b05035 Fix OLSR socket usage: use the new SetAllowBroadcast socket option; Bind to interface bcast address instead of local address, use SendTo instead of Send. This is how things have to work with real world sockets.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6324
diff changeset
   323
                                                 UdpSocketFactory::GetTypeId());
96f612b05035 Fix OLSR socket usage: use the new SetAllowBroadcast socket option; Bind to interface bcast address instead of local address, use SendTo instead of Send. This is how things have to work with real world sockets.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6324
diff changeset
   324
      socket->SetAllowBroadcast (true);
6441
f555caf874dc Fix regression tests after bug 943 changes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6438
diff changeset
   325
      InetSocketAddress inetAddr (m_ipv4->GetAddress (i, 0).GetLocal (), OLSR_PORT_NUMBER);
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   326
      socket->SetRecvCallback (MakeCallback (&RoutingProtocol::RecvOlsr,  this));
6438
96f612b05035 Fix OLSR socket usage: use the new SetAllowBroadcast socket option; Bind to interface bcast address instead of local address, use SendTo instead of Send. This is how things have to work with real world sockets.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6324
diff changeset
   327
      if (socket->Bind (inetAddr))
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   328
        {
6438
96f612b05035 Fix OLSR socket usage: use the new SetAllowBroadcast socket option; Bind to interface bcast address instead of local address, use SendTo instead of Send. This is how things have to work with real world sockets.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6324
diff changeset
   329
          NS_FATAL_ERROR ("Failed to bind() OLSR socket");
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   330
        }
6917
b19cd9a1d6f6 Bug 1040 - Olsr and multiple interfaces
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6852
diff changeset
   331
      socket->BindToNetDevice (m_ipv4->GetNetDevice (i));
5761
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
   332
      m_socketAddresses[socket] = m_ipv4->GetAddress (i, 0);
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   333
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   334
      canRunOlsr = true;
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   335
    }
1723
b5ff7d8efe27 Adapt OLSR code to use SingleEvent instead of Timer, and EventCollector.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1716
diff changeset
   336
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   337
  if(canRunOlsr)
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   338
    {
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   339
      HelloTimerExpire ();
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   340
      TcTimerExpire ();
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   341
      MidTimerExpire ();
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   342
      HnaTimerExpire ();
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   343
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   344
      NS_LOG_DEBUG ("OLSR on node " << m_mainAddress << " started");
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   345
    }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   346
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   347
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   348
void RoutingProtocol::SetMainInterface (uint32_t interface)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   349
{
4375
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4218
diff changeset
   350
  m_mainAddress = m_ipv4->GetAddress (interface, 0).GetLocal ();
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   351
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   352
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   353
void RoutingProtocol::SetInterfaceExclusions (std::set<uint32_t> exceptions)
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   354
{
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   355
  m_interfaceExclusions = exceptions;
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   356
}
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   357
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   358
//
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   359
// \brief Processes an incoming %OLSR packet following RFC 3626 specification.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   360
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   361
RoutingProtocol::RecvOlsr (Ptr<Socket> socket)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   362
{
3098
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 2972
diff changeset
   363
  Ptr<Packet> receivedPacket;
3270
e01d2843b3a0 Change OLSR to use RecvFrom
Tom Henderson <tomh@tomh.org>
parents: 3269
diff changeset
   364
  Address sourceAddress;
e01d2843b3a0 Change OLSR to use RecvFrom
Tom Henderson <tomh@tomh.org>
parents: 3269
diff changeset
   365
  receivedPacket = socket->RecvFrom (sourceAddress);
3098
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 2972
diff changeset
   366
1740
3d3168e8fef6 Update OLSR code to NS-3 API changes.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1732
diff changeset
   367
  InetSocketAddress inetSourceAddr = InetSocketAddress::ConvertFrom (sourceAddress);
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   368
  Ipv4Address senderIfaceAddr = inetSourceAddr.GetIpv4 ();
5761
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
   369
  Ipv4Address receiverIfaceAddr = m_socketAddresses[socket].GetLocal ();
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   370
  NS_ASSERT (receiverIfaceAddr != Ipv4Address ());
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   371
  NS_LOG_DEBUG ("OLSR node " << m_mainAddress << " received a OLSR packet from "
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   372
                             << senderIfaceAddr << " to " << receiverIfaceAddr);
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   373
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   374
  // All routing messages are sent from and to port RT_PORT,
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   375
  // so we check it.
1740
3d3168e8fef6 Update OLSR code to NS-3 API changes.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1732
diff changeset
   376
  NS_ASSERT (inetSourceAddr.GetPort () == OLSR_PORT_NUMBER);
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   377
1868
06027fd6a68c olsr gets new packet
Craig Dowell <craigdo@ee.washington.edu>
parents: 1803
diff changeset
   378
  Ptr<Packet> packet = receivedPacket;
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   379
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
   380
  olsr::PacketHeader olsrPacketHeader;
1868
06027fd6a68c olsr gets new packet
Craig Dowell <craigdo@ee.washington.edu>
parents: 1803
diff changeset
   381
  packet->RemoveHeader (olsrPacketHeader);
1740
3d3168e8fef6 Update OLSR code to NS-3 API changes.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1732
diff changeset
   382
  NS_ASSERT (olsrPacketHeader.GetPacketLength () >= olsrPacketHeader.GetSerializedSize ());
3d3168e8fef6 Update OLSR code to NS-3 API changes.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1732
diff changeset
   383
  uint32_t sizeLeft = olsrPacketHeader.GetPacketLength () - olsrPacketHeader.GetSerializedSize ();
1803
4078e5efdfc6 Add OLSR message tracing, as discussed on ns-developers list.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1801
diff changeset
   384
4078e5efdfc6 Add OLSR message tracing, as discussed on ns-developers list.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1801
diff changeset
   385
  MessageList messages;
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   386
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   387
  while (sizeLeft)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   388
    {
1803
4078e5efdfc6 Add OLSR message tracing, as discussed on ns-developers list.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1801
diff changeset
   389
      MessageHeader messageHeader;
1868
06027fd6a68c olsr gets new packet
Craig Dowell <craigdo@ee.washington.edu>
parents: 1803
diff changeset
   390
      if (packet->RemoveHeader (messageHeader) == 0)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   391
        NS_ASSERT (false);
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   392
1755
262febe2f1c9 Make the OLSR headers usable from the AciiTracing point of view
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1752
diff changeset
   393
      sizeLeft -= messageHeader.GetSerializedSize ();
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   394
1804
9c11e776f501 bug 96: debug.h duplicates functionality from log.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1803
diff changeset
   395
      NS_LOG_DEBUG ("Olsr Msg received with type "
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   396
                << std::dec << int (messageHeader.GetMessageType ())
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   397
                << " TTL=" << int (messageHeader.GetTimeToLive ())
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   398
                << " origAddr=" << messageHeader.GetOriginatorAddress ());
1803
4078e5efdfc6 Add OLSR message tracing, as discussed on ns-developers list.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1801
diff changeset
   399
      messages.push_back (messageHeader);
4078e5efdfc6 Add OLSR message tracing, as discussed on ns-developers list.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1801
diff changeset
   400
    }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   401
1803
4078e5efdfc6 Add OLSR message tracing, as discussed on ns-developers list.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1801
diff changeset
   402
  m_rxPacketTrace (olsrPacketHeader, messages);
4078e5efdfc6 Add OLSR message tracing, as discussed on ns-developers list.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1801
diff changeset
   403
4078e5efdfc6 Add OLSR message tracing, as discussed on ns-developers list.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1801
diff changeset
   404
  for (MessageList::const_iterator messageIter = messages.begin ();
4078e5efdfc6 Add OLSR message tracing, as discussed on ns-developers list.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1801
diff changeset
   405
       messageIter != messages.end (); messageIter++)
4078e5efdfc6 Add OLSR message tracing, as discussed on ns-developers list.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1801
diff changeset
   406
    {
4078e5efdfc6 Add OLSR message tracing, as discussed on ns-developers list.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1801
diff changeset
   407
      const MessageHeader &messageHeader = *messageIter;
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   408
      // If ttl is less than or equal to zero, or
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   409
      // the receiver is the same as the originator,
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   410
      // the message must be silently dropped
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   411
      if (messageHeader.GetTimeToLive () == 0
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   412
          || messageHeader.GetOriginatorAddress () == m_mainAddress)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   413
        {
1868
06027fd6a68c olsr gets new packet
Craig Dowell <craigdo@ee.washington.edu>
parents: 1803
diff changeset
   414
          packet->RemoveAtStart (messageHeader.GetSerializedSize ()
06027fd6a68c olsr gets new packet
Craig Dowell <craigdo@ee.washington.edu>
parents: 1803
diff changeset
   415
                                 - messageHeader.GetSerializedSize ());
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   416
          continue;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   417
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   418
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   419
      // If the message has been processed it must not be processed again
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   420
      bool do_forwarding = true;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   421
      DuplicateTuple *duplicated = m_state.FindDuplicateTuple
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   422
              (messageHeader.GetOriginatorAddress (),
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   423
              messageHeader.GetMessageSequenceNumber ());
2306
6f947d8c8f41 OLSR: get main address of the peer from the UDP source address and the 'interface association' table; this way the UDP source address need not be the same as the main address.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2296
diff changeset
   424
6f947d8c8f41 OLSR: get main address of the peer from the UDP source address and the 'interface association' table; this way the UDP source address need not be the same as the main address.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2296
diff changeset
   425
      // Get main address of the peer, which may be different from the packet source address
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   426
//       const IfaceAssocTuple *ifaceAssoc = m_state.FindIfaceAssocTuple (inetSourceAddr.GetIpv4 ());
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   427
//       Ipv4Address peerMainAddress;
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   428
//       if (ifaceAssoc != NULL)
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   429
//         {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   430
//           peerMainAddress = ifaceAssoc->mainAddr;
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   431
//         }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   432
//       else
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   433
//         {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   434
//           peerMainAddress = inetSourceAddr.GetIpv4 () ;
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   435
//         }
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   436
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   437
      if (duplicated == NULL)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   438
        {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   439
          switch (messageHeader.GetMessageType ())
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   440
            {
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
   441
            case olsr::MessageHeader::HELLO_MESSAGE:
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   442
              NS_LOG_DEBUG (Simulator::Now ().GetSeconds ()
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   443
                            << "s OLSR node " << m_mainAddress
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   444
                            << " received HELLO message of size " << messageHeader.GetSerializedSize ());
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   445
              ProcessHello (messageHeader, receiverIfaceAddr, senderIfaceAddr);
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   446
              break;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   447
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
   448
            case olsr::MessageHeader::TC_MESSAGE:
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   449
              NS_LOG_DEBUG (Simulator::Now ().GetSeconds ()
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   450
                            << "s OLSR node " << m_mainAddress
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   451
                            << " received TC message of size " << messageHeader.GetSerializedSize ());
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   452
              ProcessTc (messageHeader, senderIfaceAddr);
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   453
              break;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   454
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
   455
            case olsr::MessageHeader::MID_MESSAGE:
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   456
              NS_LOG_DEBUG (Simulator::Now ().GetSeconds ()
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   457
                            << "s OLSR node " << m_mainAddress
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   458
                            <<  " received MID message of size " << messageHeader.GetSerializedSize ());
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   459
              ProcessMid (messageHeader, senderIfaceAddr);
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   460
              break;
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   461
            case olsr::MessageHeader::HNA_MESSAGE:
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   462
              NS_LOG_DEBUG (Simulator::Now ().GetSeconds ()
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   463
                            << "s OLSR node " << m_mainAddress
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   464
                            <<  " received HNA message of size " << messageHeader.GetSerializedSize ());
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   465
              ProcessHna (messageHeader, senderIfaceAddr);
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   466
              break; 
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   467
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   468
            default:
1804
9c11e776f501 bug 96: debug.h duplicates functionality from log.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1803
diff changeset
   469
              NS_LOG_DEBUG ("OLSR message type " <<
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   470
                            int (messageHeader.GetMessageType ()) <<
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   471
                            " not implemented");
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   472
            }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   473
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   474
      else
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   475
        {
1804
9c11e776f501 bug 96: debug.h duplicates functionality from log.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1803
diff changeset
   476
          NS_LOG_DEBUG ("OLSR message is duplicated, not reading it.");
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   477
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   478
          // If the message has been considered for forwarding, it should
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   479
          // not be retransmitted again
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   480
          for (std::vector<Ipv4Address>::const_iterator it = duplicated->ifaceList.begin ();
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   481
               it != duplicated->ifaceList.end(); it++)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   482
            {
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   483
              if (*it == receiverIfaceAddr)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   484
                {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   485
                  do_forwarding = false;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   486
                  break;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   487
                }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   488
            }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   489
        }
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   490
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   491
      if (do_forwarding)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   492
        {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   493
          // HELLO messages are never forwarded.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   494
          // TC and MID messages are forwarded using the default algorithm.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   495
          // Remaining messages are also forwarded using the default algorithm.
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
   496
          if (messageHeader.GetMessageType ()  != olsr::MessageHeader::HELLO_MESSAGE)
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   497
            {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   498
              ForwardDefault (messageHeader, duplicated,
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   499
                              receiverIfaceAddr, inetSourceAddr.GetIpv4 ());
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   500
            }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   501
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   502
	
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   503
    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   504
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   505
  // After processing all OLSR messages, we must recompute the routing table
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   506
  RoutingTableComputation ();
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   507
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   508
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   509
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   510
/// \brief This auxiliary function (defined in RFC 3626) is used for calculating the MPR Set.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   511
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   512
/// \param tuple the neighbor tuple which has the main address of the node we are going to calculate its degree to.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   513
/// \return the degree of the node.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   514
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   515
int
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   516
RoutingProtocol::Degree (NeighborTuple const &tuple)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   517
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   518
  int degree = 0;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   519
  for (TwoHopNeighborSet::const_iterator it = m_state.GetTwoHopNeighbors ().begin ();
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   520
       it != m_state.GetTwoHopNeighbors ().end (); it++)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   521
    {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   522
      TwoHopNeighborTuple const &nb2hop_tuple = *it;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   523
      if (nb2hop_tuple.neighborMainAddr == tuple.neighborMainAddr)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   524
        {
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   525
          const NeighborTuple *nb_tuple =
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   526
            m_state.FindNeighborTuple (nb2hop_tuple.neighborMainAddr);
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   527
          if (nb_tuple == NULL)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   528
            degree++;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   529
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   530
    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   531
  return degree;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   532
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   533
5756
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   534
namespace {
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   535
///
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   536
/// \brief Remove all covered 2-hop neighbors from N2 set. This is a helper function used by MprComputation algorithm.
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   537
///
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   538
void 
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   539
CoverTwoHopNeighbors (Ipv4Address neighborMainAddr, TwoHopNeighborSet & N2)
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   540
{
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   541
  // first gather all 2-hop neighbors to be removed
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   542
  std::set<Ipv4Address> toRemove;
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   543
  for (TwoHopNeighborSet::iterator twoHopNeigh = N2.begin (); twoHopNeigh != N2.end (); twoHopNeigh++)
5756
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   544
    {
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   545
      if (twoHopNeigh->neighborMainAddr == neighborMainAddr)
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   546
        {
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   547
          toRemove.insert (twoHopNeigh->twoHopNeighborAddr);
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   548
        }
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   549
    }
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   550
  // Now remove all matching records from N2
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   551
  for (TwoHopNeighborSet::iterator twoHopNeigh = N2.begin (); twoHopNeigh != N2.end (); )
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   552
    {
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   553
      if (toRemove.find (twoHopNeigh->twoHopNeighborAddr) != toRemove.end ())
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   554
        {
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   555
          twoHopNeigh = N2.erase (twoHopNeigh);
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   556
        }
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   557
      else
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   558
        {
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   559
          twoHopNeigh++;
5756
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   560
        }
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   561
    }
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   562
}
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   563
} // anonymous namespace
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   564
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   565
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   566
/// \brief Computates MPR set of a node following RFC 3626 hints.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   567
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   568
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   569
RoutingProtocol::MprComputation()
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   570
{
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   571
  NS_LOG_FUNCTION (this);
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   572
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   573
  // MPR computation should be done for each interface. See section 8.3.1
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   574
  // (RFC 3626) for details.
2361
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   575
  MprSet mprSet;
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   576
	
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   577
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   578
  // N is the subset of neighbors of the node, which are
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   579
  // neighbor "of the interface I"
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   580
  NeighborSet N;
2361
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   581
  for (NeighborSet::const_iterator neighbor = m_state.GetNeighbors ().begin();
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   582
       neighbor != m_state.GetNeighbors ().end (); neighbor++)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   583
    {
2361
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   584
      if (neighbor->status == NeighborTuple::STATUS_SYM) // I think that we need this check
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   585
        {
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   586
          N.push_back (*neighbor);
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   587
        }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   588
    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   589
	
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   590
  // N2 is the set of 2-hop neighbors reachable from "the interface
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   591
  // I", excluding:
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   592
  // (i)   the nodes only reachable by members of N with willingness WILL_NEVER
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   593
  // (ii)  the node performing the computation
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   594
  // (iii) all the symmetric neighbors: the nodes for which there exists a symmetric
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   595
  //       link to this node on some interface.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   596
  TwoHopNeighborSet N2;
2361
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   597
  for (TwoHopNeighborSet::const_iterator twoHopNeigh = m_state.GetTwoHopNeighbors ().begin ();
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   598
       twoHopNeigh != m_state.GetTwoHopNeighbors ().end (); twoHopNeigh++)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   599
    {
2361
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   600
      // excluding:
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   601
      // (ii)  the node performing the computation
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   602
      if (twoHopNeigh->twoHopNeighborAddr == m_mainAddress)
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   603
        {
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   604
          continue;
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   605
        }
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   606
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   607
      //  excluding:
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   608
      // (i)   the nodes only reachable by members of N with willingness WILL_NEVER
2361
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   609
      bool ok = false;
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   610
      for (NeighborSet::const_iterator neigh = N.begin ();
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   611
           neigh != N.end (); neigh++)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   612
        {
2361
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   613
          if (neigh->neighborMainAddr == twoHopNeigh->neighborMainAddr)
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   614
            {
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   615
              if (neigh->willingness == OLSR_WILL_NEVER)
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   616
                {
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   617
                  ok = false;
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   618
                  break;
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   619
                }
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   620
              else
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   621
                {
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   622
                  ok = true;
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   623
                  break;
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   624
                }
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   625
            }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   626
        }
2361
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   627
      if (!ok)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   628
        {
2361
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   629
          continue;
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   630
        }
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   631
2361
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   632
      // excluding:
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   633
      // (iii) all the symmetric neighbors: the nodes for which there exists a symmetric
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   634
      //       link to this node on some interface.
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   635
      for (NeighborSet::const_iterator neigh = N.begin ();
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   636
           neigh != N.end (); neigh++)
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   637
        {
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   638
          if (neigh->neighborMainAddr == twoHopNeigh->twoHopNeighborAddr)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   639
            {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   640
              ok = false;
2361
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   641
              break;
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   642
            }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   643
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   644
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   645
      if (ok)
2361
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   646
        {
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   647
          N2.push_back (*twoHopNeigh);
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   648
        }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   649
    }
2361
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   650
5471
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   651
#ifdef NS3_LOG_ENABLE
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   652
  {
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   653
    std::ostringstream os;
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   654
    os << "[";
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   655
    for (TwoHopNeighborSet::const_iterator iter = N2.begin ();
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   656
         iter != N2.end (); iter++)
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   657
      {
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   658
        TwoHopNeighborSet::const_iterator next = iter;
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   659
        next++;
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   660
        os << iter->neighborMainAddr << "->" << iter->twoHopNeighborAddr;
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   661
        if (next != N2.end ())
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   662
          os << ", ";
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   663
      }
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   664
    os << "]";
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   665
    NS_LOG_DEBUG ("N2: " << os.str ());
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   666
  }
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   667
#endif  //NS3_LOG_ENABLE
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   668
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   669
  // 1. Start with an MPR set made of all members of N with
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   670
  // N_willingness equal to WILL_ALWAYS
2361
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   671
  for (NeighborSet::const_iterator neighbor = N.begin (); neighbor != N.end (); neighbor++)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   672
    {
2361
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   673
      if (neighbor->willingness == OLSR_WILL_ALWAYS)
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   674
        {
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   675
          mprSet.insert (neighbor->neighborMainAddr);
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   676
          // (not in RFC but I think is needed: remove the 2-hop
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   677
          // neighbors reachable by the MPR from N2)
5756
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   678
          CoverTwoHopNeighbors (neighbor->neighborMainAddr, N2);
2361
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   679
        }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   680
    }
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   681
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   682
  // 2. Calculate D(y), where y is a member of N, for all nodes in N.
2361
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   683
  // (we do this later)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   684
	
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   685
  // 3. Add to the MPR set those nodes in N, which are the *only*
2361
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   686
  // nodes to provide reachability to a node in N2.
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   687
  std::set<Ipv4Address> coveredTwoHopNeighbors;
5471
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   688
  for (TwoHopNeighborSet::const_iterator twoHopNeigh = N2.begin (); twoHopNeigh != N2.end (); twoHopNeigh++)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   689
    {
5471
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   690
      bool onlyOne = true;
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   691
      // try to find another neighbor that can reach twoHopNeigh->twoHopNeighborAddr
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   692
      for (TwoHopNeighborSet::const_iterator otherTwoHopNeigh = N2.begin (); otherTwoHopNeigh != N2.end (); otherTwoHopNeigh++)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   693
        {
5471
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   694
          if (otherTwoHopNeigh->twoHopNeighborAddr == twoHopNeigh->twoHopNeighborAddr
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   695
              && otherTwoHopNeigh->neighborMainAddr != twoHopNeigh->neighborMainAddr)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   696
            {
5471
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   697
              onlyOne = false;
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   698
              break;
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   699
            }
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   700
        }
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   701
      if (onlyOne)
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   702
        {
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   703
          NS_LOG_LOGIC ("Neighbor " << twoHopNeigh->neighborMainAddr
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   704
                                    << " is the only that can reach 2-hop neigh. "
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   705
                                    << twoHopNeigh->twoHopNeighborAddr
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   706
                                    << " => select as MPR.");
5471
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   707
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   708
          mprSet.insert (twoHopNeigh->neighborMainAddr);
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   709
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   710
          // take note of all the 2-hop neighbors reachable by the newly elected MPR
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   711
          for (TwoHopNeighborSet::const_iterator otherTwoHopNeigh = N2.begin ();
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   712
               otherTwoHopNeigh != N2.end (); otherTwoHopNeigh++)
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   713
            {
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   714
              if (otherTwoHopNeigh->neighborMainAddr == twoHopNeigh->neighborMainAddr)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   715
                {
5471
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   716
                  coveredTwoHopNeighbors.insert (otherTwoHopNeigh->twoHopNeighborAddr);
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   717
                }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   718
            }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   719
        }
2361
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   720
    }
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   721
  // Remove the nodes from N2 which are now covered by a node in the MPR set.
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   722
  for (TwoHopNeighborSet::iterator twoHopNeigh = N2.begin ();
2916
5d4ff983595b Fix bad usage of std container iteration and erase () all over OLSR code; closes #171; thanks to Liu Jian for spotting and submitting an initial patch.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2900
diff changeset
   723
       twoHopNeigh != N2.end (); )
2361
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   724
    {
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   725
      if (coveredTwoHopNeighbors.find (twoHopNeigh->twoHopNeighborAddr) != coveredTwoHopNeighbors.end ())
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   726
        {
5756
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   727
          // This works correctly only because it is known that twoHopNeigh is reachable by exactly one neighbor, 
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   728
          // so only one record in N2 exists for each of them. This record is erased here.
5471
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   729
          NS_LOG_LOGIC ("2-hop neigh. " << twoHopNeigh->twoHopNeighborAddr << " is already covered by an MPR.");
2361
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   730
          twoHopNeigh = N2.erase (twoHopNeigh);
2916
5d4ff983595b Fix bad usage of std container iteration and erase () all over OLSR code; closes #171; thanks to Liu Jian for spotting and submitting an initial patch.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2900
diff changeset
   731
        }
5d4ff983595b Fix bad usage of std container iteration and erase () all over OLSR code; closes #171; thanks to Liu Jian for spotting and submitting an initial patch.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2900
diff changeset
   732
      else
5d4ff983595b Fix bad usage of std container iteration and erase () all over OLSR code; closes #171; thanks to Liu Jian for spotting and submitting an initial patch.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2900
diff changeset
   733
        {
5d4ff983595b Fix bad usage of std container iteration and erase () all over OLSR code; closes #171; thanks to Liu Jian for spotting and submitting an initial patch.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2900
diff changeset
   734
          twoHopNeigh++;
2361
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   735
        }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   736
    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   737
	
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   738
  // 4. While there exist nodes in N2 which are not covered by at
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   739
  // least one node in the MPR set:
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   740
  while (N2.begin () != N2.end ())
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   741
    {
5471
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   742
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   743
#ifdef NS3_LOG_ENABLE
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   744
      {
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   745
        std::ostringstream os;
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   746
        os << "[";
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   747
        for (TwoHopNeighborSet::const_iterator iter = N2.begin ();
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   748
             iter != N2.end (); iter++)
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   749
          {
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   750
            TwoHopNeighborSet::const_iterator next = iter;
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   751
            next++;
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   752
            os << iter->neighborMainAddr << "->" << iter->twoHopNeighborAddr;
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   753
            if (next != N2.end ())
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   754
              os << ", ";
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   755
          }
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   756
        os << "]";
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   757
        NS_LOG_DEBUG ("Step 4 iteration: N2=" << os.str ());
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   758
      }
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   759
#endif  //NS3_LOG_ENABLE
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   760
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   761
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   762
      // 4.1. For each node in N, calculate the reachability, i.e., the
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   763
      // number of nodes in N2 which are not yet covered by at
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   764
      // least one node in the MPR set, and which are reachable
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   765
      // through this 1-hop neighbor
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   766
      std::map<int, std::vector<const NeighborTuple *> > reachability;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   767
      std::set<int> rs;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   768
      for (NeighborSet::iterator it = N.begin(); it != N.end(); it++)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   769
        {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   770
          NeighborTuple const &nb_tuple = *it;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   771
          int r = 0;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   772
          for (TwoHopNeighborSet::iterator it2 = N2.begin (); it2 != N2.end (); it2++)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   773
            {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   774
              TwoHopNeighborTuple const &nb2hop_tuple = *it2;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   775
              if (nb_tuple.neighborMainAddr == nb2hop_tuple.neighborMainAddr)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   776
                r++;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   777
            }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   778
          rs.insert (r);
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   779
          reachability[r].push_back (&nb_tuple);
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   780
        }
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   781
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   782
      // 4.2. Select as a MPR the node with highest N_willingness among
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   783
      // the nodes in N with non-zero reachability. In case of
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   784
      // multiple choice select the node which provides
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   785
      // reachability to the maximum number of nodes in N2. In
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   786
      // case of multiple nodes providing the same amount of
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   787
      // reachability, select the node as MPR whose D(y) is
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   788
      // greater. Remove the nodes from N2 which are now covered
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   789
      // by a node in the MPR set.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   790
      NeighborTuple const *max = NULL;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   791
      int max_r = 0;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   792
      for (std::set<int>::iterator it = rs.begin (); it != rs.end (); it++)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   793
        {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   794
          int r = *it;
2361
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   795
          if (r == 0)
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   796
            {
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   797
              continue;
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   798
            }
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   799
          for (std::vector<const NeighborTuple *>::iterator it2 = reachability[r].begin ();
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   800
               it2 != reachability[r].end (); it2++)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   801
            {
2361
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   802
              const NeighborTuple *nb_tuple = *it2;
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   803
              if (max == NULL || nb_tuple->willingness > max->willingness)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   804
                {
2361
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   805
                  max = nb_tuple;
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   806
                  max_r = r;
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   807
                }
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   808
              else if (nb_tuple->willingness == max->willingness)
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   809
                {
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   810
                  if (r > max_r)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   811
                    {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   812
                      max = nb_tuple;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   813
                      max_r = r;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   814
                    }
2361
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   815
                  else if (r == max_r)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   816
                    {
2361
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   817
                      if (Degree (*nb_tuple) > Degree (*max))
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   818
                        {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   819
                          max = nb_tuple;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   820
                          max_r = r;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   821
                        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   822
                    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   823
                }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   824
            }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   825
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   826
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   827
      if (max != NULL)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   828
        {
2361
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   829
          mprSet.insert (max->neighborMainAddr);
5756
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   830
          CoverTwoHopNeighbors (max->neighborMainAddr, N2);
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   831
          NS_LOG_LOGIC (N2.size () << " 2-hop neighbors left to cover!");
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   832
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   833
    }
2361
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   834
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   835
#ifdef NS3_LOG_ENABLE
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   836
  {
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   837
    std::ostringstream os;
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   838
    os << "[";
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   839
    for (MprSet::const_iterator iter = mprSet.begin ();
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   840
         iter != mprSet.end (); iter++)
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   841
      {
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   842
        MprSet::const_iterator next = iter;
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   843
        next++;
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   844
        os << *iter;
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   845
        if (next != mprSet.end ())
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   846
          os << ", ";
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   847
      }
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   848
    os << "]";
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   849
    NS_LOG_DEBUG ("Computed MPR set for node " << m_mainAddress << ": " << os.str ());
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   850
  }
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
   851
#endif  //NS3_LOG_ENABLE
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   852
2361
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   853
  m_state.SetMprSet (mprSet);
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   854
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   855
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   856
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   857
/// \brief Gets the main address associated with a given interface address.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   858
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   859
/// \param iface_addr the interface address.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   860
/// \return the corresponding main address.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   861
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   862
Ipv4Address
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   863
RoutingProtocol::GetMainAddress (Ipv4Address iface_addr) const
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   864
{
1798
7bb07f0d0e9f Make OlsrAgentImpl::GetMainAddress const
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1779
diff changeset
   865
  const IfaceAssocTuple *tuple =
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   866
    m_state.FindIfaceAssocTuple (iface_addr);
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   867
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   868
  if (tuple != NULL)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   869
    return tuple->mainAddr;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   870
  else
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   871
    return iface_addr;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   872
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   873
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   874
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   875
/// \brief Creates the routing table of the node following RFC 3626 hints.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   876
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   877
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   878
RoutingProtocol::RoutingTableComputation ()
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   879
{
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   880
  NS_LOG_DEBUG (Simulator::Now ().GetSeconds () << " s: Node " << m_mainAddress
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   881
                                                << ": RoutingTableComputation begin...");
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   882
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   883
  // 1. All the entries from the routing table are removed.
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
   884
  Clear ();
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   885
	
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   886
  // 2. The new routing entries are added starting with the
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   887
  // symmetric neighbors (h=1) as the destination nodes.
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   888
  const NeighborSet &neighborSet = m_state.GetNeighbors ();
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   889
  for (NeighborSet::const_iterator it = neighborSet.begin ();
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   890
       it != neighborSet.end(); it++)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   891
    {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   892
      NeighborTuple const &nb_tuple = *it;
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   893
      NS_LOG_DEBUG ("Looking at neighbor tuple: " << nb_tuple);
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   894
      if (nb_tuple.status == NeighborTuple::STATUS_SYM)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   895
        {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   896
          bool nb_main_addr = false;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   897
          const LinkTuple *lt = NULL;
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   898
          const LinkSet &linkSet = m_state.GetLinks ();
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   899
          for (LinkSet::const_iterator it2 = linkSet.begin();
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   900
               it2 != linkSet.end(); it2++)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   901
            {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   902
              LinkTuple const &link_tuple = *it2;
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   903
              NS_LOG_DEBUG ("Looking at link tuple: " << link_tuple
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   904
                                                      << (link_tuple.time >= Simulator::Now () ? "" : " (expired)"));
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   905
              if ((GetMainAddress (link_tuple.neighborIfaceAddr) == nb_tuple.neighborMainAddr)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   906
                  && link_tuple.time >= Simulator::Now ())
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   907
                {
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   908
                  NS_LOG_LOGIC ("Link tuple matches neighbor " << nb_tuple.neighborMainAddr
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   909
                                                               << " => adding routing table entry to neighbor");
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   910
                  lt = &link_tuple;
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
   911
                  AddEntry (link_tuple.neighborIfaceAddr,
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
   912
                            link_tuple.neighborIfaceAddr,
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
   913
                            link_tuple.localIfaceAddr,
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
   914
                            1);
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   915
                  if (link_tuple.neighborIfaceAddr == nb_tuple.neighborMainAddr)
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   916
                    {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   917
                      nb_main_addr = true;
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   918
                    }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   919
                }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   920
              else
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   921
                {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   922
                  NS_LOG_LOGIC ("Link tuple: linkMainAddress= " << GetMainAddress (link_tuple.neighborIfaceAddr)
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   923
                                                                << "; neighborMainAddr =  " << nb_tuple.neighborMainAddr
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   924
                                                                << "; expired=" << int (link_tuple.time < Simulator::Now ())
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   925
                                                                << " => IGNORE");
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   926
                }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   927
            }
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   928
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   929
          // If, in the above, no R_dest_addr is equal to the main
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   930
          // address of the neighbor, then another new routing entry
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   931
          // with MUST be added, with:
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   932
          //      R_dest_addr  = main address of the neighbor;
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   933
          //      R_next_addr  = L_neighbor_iface_addr of one of the
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   934
          //                     associated link tuple with L_time >= current time;
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   935
          //      R_dist       = 1;
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   936
          //      R_iface_addr = L_local_iface_addr of the
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   937
          //                     associated link tuple.
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   938
          if (!nb_main_addr && lt != NULL)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   939
            {
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   940
              NS_LOG_LOGIC ("no R_dest_addr is equal to the main address of the neighbor "
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   941
                            "=> adding additional routing entry");
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
   942
              AddEntry(nb_tuple.neighborMainAddr,
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
   943
                       lt->neighborIfaceAddr,
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
   944
                       lt->localIfaceAddr,
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
   945
                       1);
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   946
            }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   947
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   948
    }
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   949
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   950
  //  3. for each node in N2, i.e., a 2-hop neighbor which is not a
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   951
  //  neighbor node or the node itself, and such that there exist at
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   952
  //  least one entry in the 2-hop neighbor set where
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   953
  //  N_neighbor_main_addr correspond to a neighbor node with
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   954
  //  willingness different of WILL_NEVER,
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   955
  const TwoHopNeighborSet &twoHopNeighbors = m_state.GetTwoHopNeighbors ();
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   956
  for (TwoHopNeighborSet::const_iterator it = twoHopNeighbors.begin ();
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   957
       it != twoHopNeighbors.end (); it++)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   958
    {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   959
      TwoHopNeighborTuple const &nb2hop_tuple = *it;
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   960
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   961
      NS_LOG_LOGIC ("Looking at two-hop neighbor tuple: " << nb2hop_tuple);
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   962
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   963
      // a 2-hop neighbor which is not a neighbor node or the node itself
5867
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
   964
      if (m_state.FindSymNeighborTuple (nb2hop_tuple.twoHopNeighborAddr))
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   965
        {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   966
          NS_LOG_LOGIC ("Two-hop neighbor tuple is also neighbor; skipped.");
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   967
          continue;
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   968
        }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   969
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   970
      if (nb2hop_tuple.twoHopNeighborAddr == m_mainAddress)
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   971
        {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   972
          NS_LOG_LOGIC ("Two-hop neighbor is self; skipped.");
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   973
          continue;
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   974
        }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   975
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   976
      // ...and such that there exist at least one entry in the 2-hop
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   977
      // neighbor set where N_neighbor_main_addr correspond to a
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   978
      // neighbor node with willingness different of WILL_NEVER...
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   979
      bool nb2hopOk = false;
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   980
      for (NeighborSet::const_iterator neighbor = neighborSet.begin ();
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   981
           neighbor != neighborSet.end(); neighbor++)
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   982
        {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   983
          if (neighbor->neighborMainAddr == nb2hop_tuple.neighborMainAddr
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   984
              && neighbor->willingness != OLSR_WILL_NEVER)
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   985
            {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   986
              nb2hopOk = true;
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   987
              break;
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   988
            }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   989
        }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   990
      if (!nb2hopOk)
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   991
        {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   992
          NS_LOG_LOGIC ("Two-hop neighbor tuple skipped: 2-hop neighbor "
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   993
                        << nb2hop_tuple.twoHopNeighborAddr
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   994
                        << " is attached to neighbor " << nb2hop_tuple.neighborMainAddr
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   995
                        << ", which was not found in the Neighbor Set.");
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   996
          continue;
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   997
        }
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
   998
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   999
      // one selects one 2-hop tuple and creates one entry in the routing table with:
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1000
      //                R_dest_addr  =  the main address of the 2-hop neighbor;
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1001
      //                R_next_addr  = the R_next_addr of the entry in the
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1002
      //                               routing table with:
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1003
      //                                   R_dest_addr == N_neighbor_main_addr
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1004
      //                                                  of the 2-hop tuple;
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1005
      //                R_dist       = 2;
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1006
      //                R_iface_addr = the R_iface_addr of the entry in the
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1007
      //                               routing table with:
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1008
      //                                   R_dest_addr == N_neighbor_main_addr
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1009
      //                                                  of the 2-hop tuple;
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1010
      RoutingTableEntry entry;
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  1011
      bool foundEntry = Lookup (nb2hop_tuple.neighborMainAddr, entry);
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1012
      if (foundEntry)
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1013
        {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1014
          NS_LOG_LOGIC ("Adding routing entry for two-hop neighbor.");
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  1015
          AddEntry (nb2hop_tuple.twoHopNeighborAddr,
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1016
                    entry.nextAddr,
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1017
                    entry.interface,
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1018
                    2);
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1019
        }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1020
      else
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1021
        {
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1022
          NS_LOG_LOGIC ("NOT adding routing entry for two-hop neighbor ("
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1023
                        << nb2hop_tuple.twoHopNeighborAddr
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1024
                        << " not found in the routing table)");
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1025
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1026
    }
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1027
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1028
  for (uint32_t h = 2; ; h++)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1029
    {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1030
      bool added = false;
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1031
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1032
      // 3.1. For each topology entry in the topology table, if its
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1033
      // T_dest_addr does not correspond to R_dest_addr of any
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1034
      // route entry in the routing table AND its T_last_addr
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1035
      // corresponds to R_dest_addr of a route entry whose R_dist
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1036
      // is equal to h, then a new route entry MUST be recorded in
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1037
      // the routing table (if it does not already exist)
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1038
      const TopologySet &topology = m_state.GetTopologySet ();
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1039
      for (TopologySet::const_iterator it = topology.begin ();
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1040
           it != topology.end (); it++)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1041
        {
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1042
          const TopologyTuple &topology_tuple = *it;
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1043
          NS_LOG_LOGIC ("Looking at topology tuple: " << topology_tuple);
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1044
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1045
          RoutingTableEntry destAddrEntry, lastAddrEntry;
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  1046
          bool have_destAddrEntry = Lookup (topology_tuple.destAddr, destAddrEntry);
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  1047
          bool have_lastAddrEntry = Lookup (topology_tuple.lastAddr, lastAddrEntry);
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1048
          if (!have_destAddrEntry && have_lastAddrEntry && lastAddrEntry.distance == h)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1049
            {
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1050
              NS_LOG_LOGIC ("Adding routing table entry based on the topology tuple.");
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1051
              // then a new route entry MUST be recorded in
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1052
              //                the routing table (if it does not already exist) where:
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1053
              //                     R_dest_addr  = T_dest_addr;
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1054
              //                     R_next_addr  = R_next_addr of the recorded
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1055
              //                                    route entry where:
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1056
              //                                    R_dest_addr == T_last_addr
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1057
              //                     R_dist       = h+1; and
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1058
              //                     R_iface_addr = R_iface_addr of the recorded
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1059
              //                                    route entry where:
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1060
              //                                       R_dest_addr == T_last_addr.
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  1061
              AddEntry (topology_tuple.destAddr,
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  1062
                        lastAddrEntry.nextAddr,
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  1063
                        lastAddrEntry.interface,
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  1064
                        h + 1);
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1065
              added = true;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1066
            }
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1067
          else
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1068
            {
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1069
              NS_LOG_LOGIC ("NOT adding routing table entry based on the topology tuple: "
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1070
                            "have_destAddrEntry=" << have_destAddrEntry
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1071
                                                  << " have_lastAddrEntry=" << have_lastAddrEntry
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1072
                                                  << " lastAddrEntry.distance=" << (int) lastAddrEntry.distance
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1073
                                                  << " (h=" << h << ")");
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1074
            }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1075
        }
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1076
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1077
      if (!added)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1078
        break;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1079
    }
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1080
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1081
  // 4. For each entry in the multiple interface association base
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1082
  // where there exists a routing entry such that:
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1083
  //	R_dest_addr  == I_main_addr  (of the multiple interface association entry)
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1084
  // AND there is no routing entry such that:
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1085
  //	R_dest_addr  == I_iface_addr
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1086
  const IfaceAssocSet &ifaceAssocSet = m_state.GetIfaceAssocSet ();
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1087
  for (IfaceAssocSet::const_iterator it = ifaceAssocSet.begin ();
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1088
       it != ifaceAssocSet.end (); it++)
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1089
    {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1090
      IfaceAssocTuple const &tuple = *it;
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1091
      RoutingTableEntry entry1, entry2;
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  1092
      bool have_entry1 = Lookup (tuple.mainAddr, entry1);
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  1093
      bool have_entry2 = Lookup (tuple.ifaceAddr, entry2);
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1094
      if (have_entry1 && !have_entry2)
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1095
        {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1096
          // then a route entry is created in the routing table with:
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1097
          //       R_dest_addr  =  I_iface_addr (of the multiple interface
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1098
          //                                     association entry)
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1099
          //       R_next_addr  =  R_next_addr  (of the recorded route entry)
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1100
          //       R_dist       =  R_dist       (of the recorded route entry)
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1101
          //       R_iface_addr =  R_iface_addr (of the recorded route entry).
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  1102
          AddEntry (tuple.ifaceAddr,
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  1103
                    entry1.nextAddr,
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  1104
                    entry1.interface,
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  1105
                    entry1.distance);
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1106
        }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1107
    }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1108
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1109
  // 5. For each tuple in the association set,
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1110
  //    If there is no entry in the routing table with:
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1111
  //        R_dest_addr     == A_network_addr/A_netmask
6814
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1112
  //   and if the announced network is not announced by the node itself,
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1113
  //   then a new routing entry is created.
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1114
  const AssociationSet &associationSet = m_state.GetAssociationSet ();
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1115
  for (AssociationSet::const_iterator it = associationSet.begin ();
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1116
       it != associationSet.end (); it++)
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1117
    {
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1118
      AssociationTuple const &tuple = *it;
6814
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1119
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1120
      // Test if HNA associations received from other gateways
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1121
      // are also announced by this node. In such a case, no route
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1122
      // is created for this association tuple (go to the next one).
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1123
      bool goToNextAssociationTuple = false;
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1124
      const Associations &localHnaAssociations = m_state.GetAssociations ();
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1125
      NS_LOG_DEBUG ("Nb local associations: " << localHnaAssociations.size ());
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1126
      for (Associations::const_iterator assocIterator = localHnaAssociations.begin ();
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1127
           assocIterator != localHnaAssociations.end (); assocIterator++)
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1128
        {
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1129
          Association const &localHnaAssoc = *assocIterator;
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1130
          if (localHnaAssoc.networkAddr == tuple.networkAddr && localHnaAssoc.netmask == tuple.netmask)
6814
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1131
            {
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1132
              NS_LOG_DEBUG ("HNA association received from another GW is part of local HNA associations: no route added for network "
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1133
                                  << tuple.networkAddr << "/" << tuple.netmask);
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1134
              goToNextAssociationTuple = true;
6814
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1135
            }
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1136
        }
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1137
      if (goToNextAssociationTuple)
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1138
        {
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1139
          continue;
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1140
        }
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1141
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1142
      RoutingTableEntry gatewayEntry;
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1143
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1144
      bool gatewayEntryExists = Lookup (tuple.gatewayAddr, gatewayEntry);
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1145
      bool addRoute = false;
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1146
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1147
      uint32_t routeIndex = 0;
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1148
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1149
      for (routeIndex = 0; routeIndex < m_hnaRoutingTable->GetNRoutes (); routeIndex++)
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1150
        {
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1151
          Ipv4RoutingTableEntry route = m_hnaRoutingTable->GetRoute (routeIndex);
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1152
          if (route.GetDestNetwork () == tuple.networkAddr &&
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1153
              route.GetDestNetworkMask () == tuple.netmask)
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1154
            {
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1155
              break;
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1156
            }
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1157
        }
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1158
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1159
      if (routeIndex == m_hnaRoutingTable->GetNRoutes ())
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1160
        {
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1161
          addRoute = true;
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1162
        }
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1163
      else if(gatewayEntryExists && m_hnaRoutingTable->GetMetric (routeIndex) > gatewayEntry.distance)
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1164
        {
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1165
          m_hnaRoutingTable->RemoveRoute(routeIndex);
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1166
          addRoute = true;
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1167
        }
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1168
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1169
      if(addRoute && gatewayEntryExists)
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1170
        {
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1171
          m_hnaRoutingTable->AddNetworkRouteTo (tuple.networkAddr,
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1172
                                                tuple.netmask,
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1173
                                                gatewayEntry.nextAddr,
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1174
                                                gatewayEntry.interface,
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1175
                                                gatewayEntry.distance);
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1176
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1177
        }
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1178
    }
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1179
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1180
  NS_LOG_DEBUG ("Node " << m_mainAddress << ": RoutingTableComputation end.");
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  1181
  m_routingTableChanged (GetSize ());
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1182
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1183
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1184
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1185
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1186
/// \brief Processes a HELLO message following RFC 3626 specification.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1187
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1188
/// Link sensing and population of the Neighbor Set, 2-hop Neighbor Set and MPR
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1189
/// Selector Set are performed.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1190
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1191
/// \param msg the %OLSR message which contains the HELLO message.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1192
/// \param receiver_iface the address of the interface where the message was received from.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1193
/// \param sender_iface the address of the interface where the message was sent from.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1194
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1195
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1196
RoutingProtocol::ProcessHello (const olsr::MessageHeader &msg,
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1197
                               const Ipv4Address &receiverIface,
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1198
                               const Ipv4Address &senderIface)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1199
{
6438
96f612b05035 Fix OLSR socket usage: use the new SetAllowBroadcast socket option; Bind to interface bcast address instead of local address, use SendTo instead of Send. This is how things have to work with real world sockets.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6324
diff changeset
  1200
  NS_LOG_FUNCTION (msg << receiverIface << senderIface);
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1201
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
  1202
  const olsr::MessageHeader::Hello &hello = msg.GetHello ();
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1203
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1204
  LinkSensing (msg, hello, receiverIface, senderIface);
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1205
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1206
#ifdef NS3_LOG_ENABLE
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1207
  {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1208
    const LinkSet &links = m_state.GetLinks ();
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1209
    NS_LOG_DEBUG (Simulator::Now ().GetSeconds ()
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1210
                  << "s ** BEGIN dump Link Set for OLSR Node " << m_mainAddress);
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1211
    for (LinkSet::const_iterator link = links.begin (); link != links.end (); link++)
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1212
      {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1213
        NS_LOG_DEBUG(*link);
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1214
      }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1215
    NS_LOG_DEBUG ("** END dump Link Set for OLSR Node " << m_mainAddress);
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1216
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1217
    const NeighborSet &neighbors = m_state.GetNeighbors ();
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1218
    NS_LOG_DEBUG (Simulator::Now ().GetSeconds ()
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1219
                  << "s ** BEGIN dump Neighbor Set for OLSR Node " << m_mainAddress);
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1220
    for (NeighborSet::const_iterator neighbor = neighbors.begin (); neighbor != neighbors.end (); neighbor++)
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1221
      {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1222
        NS_LOG_DEBUG(*neighbor);
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1223
      }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1224
    NS_LOG_DEBUG ("** END dump Neighbor Set for OLSR Node " << m_mainAddress);
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1225
  }
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  1226
#endif // NS3_LOG_ENABLE
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1227
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1228
  PopulateNeighborSet (msg, hello);
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1229
  PopulateTwoHopNeighborSet (msg, hello);
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1230
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1231
#ifdef NS3_LOG_ENABLE
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1232
  {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1233
    const TwoHopNeighborSet &twoHopNeighbors = m_state.GetTwoHopNeighbors ();
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1234
    NS_LOG_DEBUG (Simulator::Now ().GetSeconds ()
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1235
                  << "s ** BEGIN dump TwoHopNeighbor Set for OLSR Node " << m_mainAddress);
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1236
    for (TwoHopNeighborSet::const_iterator tuple = twoHopNeighbors.begin ();
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1237
         tuple != twoHopNeighbors.end (); tuple++)
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1238
      {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1239
        NS_LOG_DEBUG(*tuple);
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1240
      }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1241
    NS_LOG_DEBUG ("** END dump TwoHopNeighbor Set for OLSR Node " << m_mainAddress);
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1242
  }
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  1243
#endif // NS3_LOG_ENABLE
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1244
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1245
  MprComputation ();
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1246
  PopulateMprSelectorSet (msg, hello);
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1247
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1248
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1249
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1250
/// \brief Processes a TC message following RFC 3626 specification.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1251
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1252
/// The Topology Set is updated (if needed) with the information of
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1253
/// the received TC message.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1254
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1255
/// \param msg the %OLSR message which contains the TC message.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1256
/// \param sender_iface the address of the interface where the message was sent from.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1257
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1258
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1259
RoutingProtocol::ProcessTc (const olsr::MessageHeader &msg,
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1260
                            const Ipv4Address &senderIface)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1261
{
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
  1262
  const olsr::MessageHeader::Tc &tc = msg.GetTc ();
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1263
  Time now = Simulator::Now ();
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1264
	
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1265
  // 1. If the sender interface of this message is not in the symmetric
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1266
  // 1-hop neighborhood of this node, the message MUST be discarded.
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  1267
  const LinkTuple *link_tuple = m_state.FindSymLinkTuple (senderIface, now);
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1268
  if (link_tuple == NULL)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1269
    return;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1270
	
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1271
  // 2. If there exist some tuple in the topology set where:
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1272
  //    T_last_addr == originator address AND
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1273
  //    T_seq       >  ANSN,
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1274
  // then further processing of this TC message MUST NOT be
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1275
  // performed.
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  1276
  const TopologyTuple *topologyTuple =
1755
262febe2f1c9 Make the OLSR headers usable from the AciiTracing point of view
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1752
diff changeset
  1277
    m_state.FindNewerTopologyTuple (msg.GetOriginatorAddress (), tc.ansn);
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1278
  if (topologyTuple != NULL)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1279
    return;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1280
	
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1281
  // 3. All tuples in the topology set where:
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1282
  //	T_last_addr == originator address AND
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1283
  //	T_seq       <  ANSN
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1284
  // MUST be removed from the topology set.
1755
262febe2f1c9 Make the OLSR headers usable from the AciiTracing point of view
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1752
diff changeset
  1285
  m_state.EraseOlderTopologyTuples (msg.GetOriginatorAddress (), tc.ansn);
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1286
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1287
  // 4. For each of the advertised neighbor main address received in
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1288
  // the TC message:
1755
262febe2f1c9 Make the OLSR headers usable from the AciiTracing point of view
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1752
diff changeset
  1289
  for (std::vector<Ipv4Address>::const_iterator i = tc.neighborAddresses.begin ();
262febe2f1c9 Make the OLSR headers usable from the AciiTracing point of view
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1752
diff changeset
  1290
       i != tc.neighborAddresses.end (); i++)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1291
    {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1292
      const Ipv4Address &addr = *i;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1293
      // 4.1. If there exist some tuple in the topology set where:
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1294
      //        T_dest_addr == advertised neighbor main address, AND
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1295
      //        T_last_addr == originator address,
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1296
      // then the holding time of that tuple MUST be set to:
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1297
      //        T_time      =  current time + validity time.
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1298
      TopologyTuple *topologyTuple =
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1299
        m_state.FindTopologyTuple (addr, msg.GetOriginatorAddress ());
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1300
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1301
      if (topologyTuple != NULL)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1302
        {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1303
          topologyTuple->expirationTime = now + msg.GetVTime ();
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1304
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1305
      else
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1306
        {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1307
          // 4.2. Otherwise, a new tuple MUST be recorded in the topology
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1308
          // set where:
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1309
          //	T_dest_addr = advertised neighbor main address,
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1310
          //	T_last_addr = originator address,
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1311
          //	T_seq       = ANSN,
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1312
          //	T_time      = current time + validity time.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1313
          TopologyTuple topologyTuple;;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1314
          topologyTuple.destAddr = addr;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1315
          topologyTuple.lastAddr = msg.GetOriginatorAddress ();
1755
262febe2f1c9 Make the OLSR headers usable from the AciiTracing point of view
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1752
diff changeset
  1316
          topologyTuple.sequenceNumber = tc.ansn;
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1317
          topologyTuple.expirationTime = now + msg.GetVTime ();
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1318
          AddTopologyTuple (topologyTuple);
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1319
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1320
          // Schedules topology tuple deletion
1768
1664a9db93b9 Make EventGarbageCollector private to the olsr module; adapt olsr to Timer API changes.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1765
diff changeset
  1321
          m_events.Track (Simulator::Schedule (DELAY (topologyTuple.expirationTime),
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1322
                                               &RoutingProtocol::TopologyTupleTimerExpire,
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  1323
                                               this,
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  1324
                                               topologyTuple.destAddr,
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  1325
                                               topologyTuple.lastAddr));
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1326
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1327
    }
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1329
#ifdef NS3_LOG_ENABLE
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1330
  {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1331
    const TopologySet &topology = m_state.GetTopologySet ();
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1332
    NS_LOG_DEBUG (Simulator::Now ().GetSeconds ()
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1333
                  << "s ** BEGIN dump TopologySet for OLSR Node " << m_mainAddress);
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1334
    for (TopologySet::const_iterator tuple = topology.begin ();
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1335
         tuple != topology.end (); tuple++)
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1336
      {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1337
        NS_LOG_DEBUG (*tuple);
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1338
      }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1339
    NS_LOG_DEBUG ("** END dump TopologySet Set for OLSR Node " << m_mainAddress);
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1340
  }
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  1341
#endif // NS3_LOG_ENABLE
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1342
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1343
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1344
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1345
/// \brief Processes a MID message following RFC 3626 specification.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1346
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1347
/// The Interface Association Set is updated (if needed) with the information
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1348
/// of the received MID message.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1349
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1350
/// \param msg the %OLSR message which contains the MID message.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1351
/// \param sender_iface the address of the interface where the message was sent from.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1352
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1353
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1354
RoutingProtocol::ProcessMid (const olsr::MessageHeader &msg,
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1355
                             const Ipv4Address &senderIface)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1356
{
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
  1357
  const olsr::MessageHeader::Mid &mid = msg.GetMid ();
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1358
  Time now = Simulator::Now ();
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1359
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1360
  NS_LOG_DEBUG ("Node " << m_mainAddress << " ProcessMid from " << senderIface);
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1361
  // 1. If the sender interface of this message is not in the symmetric
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1362
  // 1-hop neighborhood of this node, the message MUST be discarded.
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  1363
  const LinkTuple *linkTuple = m_state.FindSymLinkTuple (senderIface, now);
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1364
  if (linkTuple == NULL)
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1365
    {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1366
      NS_LOG_LOGIC ("Node " << m_mainAddress <<
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1367
                    ": the sender interface of this message is not in the "
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1368
                    "symmetric 1-hop neighborhood of this node,"
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1369
                    " the message MUST be discarded.");
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1370
      return;
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1371
    }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1372
	
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1373
  // 2. For each interface address listed in the MID message
1755
262febe2f1c9 Make the OLSR headers usable from the AciiTracing point of view
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1752
diff changeset
  1374
  for (std::vector<Ipv4Address>::const_iterator i = mid.interfaceAddresses.begin ();
262febe2f1c9 Make the OLSR headers usable from the AciiTracing point of view
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1752
diff changeset
  1375
       i != mid.interfaceAddresses.end (); i++)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1376
    {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1377
      bool updated = false;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1378
      IfaceAssocSet &ifaceAssoc = m_state.GetIfaceAssocSetMutable ();
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1379
      for (IfaceAssocSet::iterator tuple = ifaceAssoc.begin();
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1380
           tuple != ifaceAssoc.end(); tuple++)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1381
        {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1382
          if (tuple->ifaceAddr == *i
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1383
              && tuple->mainAddr == msg.GetOriginatorAddress ())
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1384
            {
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1385
              NS_LOG_LOGIC ("IfaceAssoc updated: " << *tuple);
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1386
              tuple->time = now + msg.GetVTime ();
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1387
              updated = true;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1388
            }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1389
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1390
      if (!updated)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1391
        {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1392
          IfaceAssocTuple tuple;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1393
          tuple.ifaceAddr = *i;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1394
          tuple.mainAddr = msg.GetOriginatorAddress ();
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1395
          tuple.time = now + msg.GetVTime ();
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1396
          AddIfaceAssocTuple (tuple);
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1397
          NS_LOG_LOGIC ("New IfaceAssoc added: " << tuple);
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1398
          // Schedules iface association tuple deletion
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1399
          Simulator::Schedule (DELAY (tuple.time),
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1400
                               &RoutingProtocol::IfaceAssocTupleTimerExpire, this, tuple.ifaceAddr);
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1401
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1402
    }
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1403
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1404
  // 3. (not part of the RFC) iterate over all NeighborTuple's and
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1405
  // TwoHopNeighborTuples, update the neighbor addresses taking into account
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1406
  // the new MID information.
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1407
  NeighborSet &neighbors = m_state.GetNeighbors ();
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1408
  for (NeighborSet::iterator neighbor = neighbors.begin (); neighbor != neighbors.end(); neighbor++)
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1409
    {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1410
      neighbor->neighborMainAddr = GetMainAddress (neighbor->neighborMainAddr);
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1411
    }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1412
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1413
  TwoHopNeighborSet &twoHopNeighbors = m_state.GetTwoHopNeighbors ();
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1414
  for (TwoHopNeighborSet::iterator twoHopNeighbor = twoHopNeighbors.begin ();
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1415
       twoHopNeighbor != twoHopNeighbors.end(); twoHopNeighbor++)
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1416
    {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1417
      twoHopNeighbor->neighborMainAddr = GetMainAddress (twoHopNeighbor->neighborMainAddr);
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1418
      twoHopNeighbor->twoHopNeighborAddr = GetMainAddress (twoHopNeighbor->twoHopNeighborAddr);
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1419
    }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1420
  NS_LOG_DEBUG ("Node " << m_mainAddress << " ProcessMid from " << senderIface << " -> END.");
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1421
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1422
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1423
///
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1424
/// \brief Processes a HNA message following RFC 3626 specification.
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1425
///
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1426
/// The Host Network Association Set is updated (if needed) with the information
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1427
/// of the received HNA message.
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1428
///
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1429
/// \param msg the %OLSR message which contains the HNA message.
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1430
/// \param sender_iface the address of the interface where the message was sent from.
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1431
///
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1432
void
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1433
RoutingProtocol::ProcessHna (const olsr::MessageHeader &msg,
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1434
                             const Ipv4Address &senderIface)
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1435
{
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1436
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1437
  const olsr::MessageHeader::Hna &hna = msg.GetHna ();
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1438
  Time now = Simulator::Now ();
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1439
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1440
  // 1. If the sender interface of this message is not in the symmetric
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1441
  // 1-hop neighborhood of this node, the message MUST be discarded.
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1442
  const LinkTuple *link_tuple = m_state.FindSymLinkTuple (senderIface, now);
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1443
  if (link_tuple == NULL)
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1444
    return;
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1445
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1446
  // 2. Otherwise, for each (network address, netmask) pair in the
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1447
  // message:
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1448
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1449
  for (std::vector<olsr::MessageHeader::Hna::Association>::const_iterator it = hna.associations.begin();
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1450
       it != hna.associations.end() ; it++)
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1451
    {
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1452
      AssociationTuple *tuple = m_state.FindAssociationTuple(msg.GetOriginatorAddress(),it->address,it->mask);
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1453
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1454
      // 2.1  if an entry in the association set already exists, where:
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1455
      //          A_gateway_addr == originator address
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1456
      //          A_network_addr == network address
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1457
      //          A_netmask      == netmask
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1458
      //      then the holding time for that tuple MUST be set to:
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1459
      //          A_time         =  current time + validity time
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1460
      if(tuple != NULL)
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1461
        {
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1462
          tuple->expirationTime = now + msg.GetVTime ();
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1463
        }
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1464
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1465
      // 2.2 otherwise, a new tuple MUST be recorded with:
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1466
      //          A_gateway_addr =  originator address
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1467
      //          A_network_addr =  network address
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1468
      //          A_netmask      =  netmask
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1469
      //          A_time         =  current time + validity time
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1470
      else
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1471
        {
6143
ad316b5cfb5a Fix compilation error: ISO C++ forbids use of initializer list to initialize reference assocTuple
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6142
diff changeset
  1472
          AssociationTuple assocTuple = {
ad316b5cfb5a Fix compilation error: ISO C++ forbids use of initializer list to initialize reference assocTuple
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6142
diff changeset
  1473
            msg.GetOriginatorAddress(),
ad316b5cfb5a Fix compilation error: ISO C++ forbids use of initializer list to initialize reference assocTuple
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6142
diff changeset
  1474
            it->address,
ad316b5cfb5a Fix compilation error: ISO C++ forbids use of initializer list to initialize reference assocTuple
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6142
diff changeset
  1475
            it->mask,
ad316b5cfb5a Fix compilation error: ISO C++ forbids use of initializer list to initialize reference assocTuple
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6142
diff changeset
  1476
            now + msg.GetVTime ()
ad316b5cfb5a Fix compilation error: ISO C++ forbids use of initializer list to initialize reference assocTuple
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6142
diff changeset
  1477
          };
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1478
          AddAssociationTuple (assocTuple);
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1479
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1480
          //Schedule Association Tuple deletion
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1481
          Simulator::Schedule (DELAY (assocTuple.expirationTime),
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1482
                               &RoutingProtocol::AssociationTupleTimerExpire, this,
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1483
                               assocTuple.gatewayAddr,assocTuple.networkAddr,assocTuple.netmask);
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1484
        }
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1485
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1486
    }
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1487
}
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1488
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1489
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1490
/// \brief OLSR's default forwarding algorithm.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1491
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1492
/// See RFC 3626 for details.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1493
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1494
/// \param p the %OLSR packet which has been received.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1495
/// \param msg the %OLSR message which must be forwarded.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1496
/// \param dup_tuple NULL if the message has never been considered for forwarding,
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1497
/// or a duplicate tuple in other case.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1498
/// \param local_iface the address of the interface where the message was received from.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1499
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1500
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1501
RoutingProtocol::ForwardDefault (olsr::MessageHeader olsrMessage,
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1502
                                 DuplicateTuple *duplicated,
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1503
                                 const Ipv4Address &localIface,
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1504
                                 const Ipv4Address &senderAddress)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1505
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1506
  Time now = Simulator::Now ();
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1507
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1508
  // If the sender interface address is not in the symmetric
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1509
  // 1-hop neighborhood the message must not be forwarded
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  1510
  const LinkTuple *linkTuple = m_state.FindSymLinkTuple (senderAddress, now);
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1511
  if (linkTuple == NULL)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1512
    return;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1513
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1514
  // If the message has already been considered for forwarding,
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1515
  // it must not be retransmitted again
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1516
  if (duplicated != NULL && duplicated->retransmitted)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1517
    {
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1518
      NS_LOG_LOGIC (Simulator::Now () << "Node " << m_mainAddress << " does not forward a message received"
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1519
                    " from " << olsrMessage.GetOriginatorAddress () << " because it is duplicated");
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1520
      return;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1521
    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1522
	
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1523
  // If the sender interface address is an interface address
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1524
  // of a MPR selector of this node and ttl is greater than 1,
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1525
  // the message must be retransmitted
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1526
  bool retransmitted = false;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1527
  if (olsrMessage.GetTimeToLive () > 1)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1528
    {
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  1529
      const MprSelectorTuple *mprselTuple =
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1530
        m_state.FindMprSelectorTuple (GetMainAddress (senderAddress));
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1531
      if (mprselTuple != NULL)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1532
        {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1533
          olsrMessage.SetTimeToLive (olsrMessage.GetTimeToLive () - 1);
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1534
          olsrMessage.SetHopCount (olsrMessage.GetHopCount () + 1);
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1535
          // We have to introduce a random delay to avoid
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1536
          // synchronization with neighbors.
1755
262febe2f1c9 Make the OLSR headers usable from the AciiTracing point of view
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1752
diff changeset
  1537
          QueueMessage (olsrMessage, JITTER);
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1538
          retransmitted = true;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1539
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1540
    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1541
	
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1542
  // Update duplicate tuple...
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1543
  if (duplicated != NULL)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1544
    {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1545
      duplicated->expirationTime = now + OLSR_DUP_HOLD_TIME;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1546
      duplicated->retransmitted = retransmitted;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1547
      duplicated->ifaceList.push_back (localIface);
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1548
    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1549
  // ...or create a new one
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1550
  else
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1551
    {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1552
      DuplicateTuple newDup;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1553
      newDup.address = olsrMessage.GetOriginatorAddress ();
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1554
      newDup.sequenceNumber = olsrMessage.GetMessageSequenceNumber ();
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1555
      newDup.expirationTime = now + OLSR_DUP_HOLD_TIME;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1556
      newDup.retransmitted = retransmitted;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1557
      newDup.ifaceList.push_back (localIface);
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1558
      AddDuplicateTuple (newDup);
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1559
      // Schedule dup tuple deletion
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1560
      Simulator::Schedule (OLSR_DUP_HOLD_TIME,
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1561
                           &RoutingProtocol::DupTupleTimerExpire, this,
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  1562
                           newDup.address, newDup.sequenceNumber);
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1563
    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1564
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1565
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1566
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1567
/// \brief Enques an %OLSR message which will be sent with a delay of (0, delay].
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1568
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1569
/// This buffering system is used in order to piggyback several %OLSR messages in
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1570
/// a same %OLSR packet.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1571
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1572
/// \param msg the %OLSR message which must be sent.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1573
/// \param delay maximum delay the %OLSR message is going to be buffered.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1574
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1575
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1576
RoutingProtocol::QueueMessage (const olsr::MessageHeader &message, Time delay)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1577
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1578
  m_queuedMessages.push_back (message);
1730
163aab5f1129 solve some merge problems
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1723
diff changeset
  1579
  if (not m_queuedMessagesTimer.IsRunning ())
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1580
    {
1765
763f8d1bb058 Adapt the OLSR agent code to use the new Timer class.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1763
diff changeset
  1581
      m_queuedMessagesTimer.SetDelay (delay);
763f8d1bb058 Adapt the OLSR agent code to use the new Timer class.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1763
diff changeset
  1582
      m_queuedMessagesTimer.Schedule ();
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1583
    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1584
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1585
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1586
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1587
RoutingProtocol::SendPacket (Ptr<Packet> packet, 
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1588
                             const MessageList &containedMessages)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1589
{
1804
9c11e776f501 bug 96: debug.h duplicates functionality from log.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1803
diff changeset
  1590
  NS_LOG_DEBUG ("OLSR node " << m_mainAddress << " sending a OLSR packet");
1803
4078e5efdfc6 Add OLSR message tracing, as discussed on ns-developers list.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1801
diff changeset
  1591
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1592
  // Add a header
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
  1593
  olsr::PacketHeader header;
1868
06027fd6a68c olsr gets new packet
Craig Dowell <craigdo@ee.washington.edu>
parents: 1803
diff changeset
  1594
  header.SetPacketLength (header.GetSerializedSize () + packet->GetSize ());
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1595
  header.SetPacketSequenceNumber (GetPacketSequenceNumber ());
1868
06027fd6a68c olsr gets new packet
Craig Dowell <craigdo@ee.washington.edu>
parents: 1803
diff changeset
  1596
  packet->AddHeader (header);
1803
4078e5efdfc6 Add OLSR message tracing, as discussed on ns-developers list.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1801
diff changeset
  1597
4078e5efdfc6 Add OLSR message tracing, as discussed on ns-developers list.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1801
diff changeset
  1598
  // Trace it
4078e5efdfc6 Add OLSR message tracing, as discussed on ns-developers list.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1801
diff changeset
  1599
  m_txPacketTrace (header, containedMessages);
4078e5efdfc6 Add OLSR message tracing, as discussed on ns-developers list.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1801
diff changeset
  1600
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1601
  // Send it
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1602
  for (std::map<Ptr<Socket>, Ipv4InterfaceAddress>::const_iterator i =
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1603
         m_socketAddresses.begin (); i != m_socketAddresses.end (); i++)
6303
4ef0052694b9 Bug Fix: OLSR messages generated on non-OLSR interfaces
Lalith Suresh
parents: 6143
diff changeset
  1604
    {
6438
96f612b05035 Fix OLSR socket usage: use the new SetAllowBroadcast socket option; Bind to interface bcast address instead of local address, use SendTo instead of Send. This is how things have to work with real world sockets.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6324
diff changeset
  1605
      Ipv4Address bcast = i->second.GetLocal ().GetSubnetDirectedBroadcast (i->second.GetMask ());
96f612b05035 Fix OLSR socket usage: use the new SetAllowBroadcast socket option; Bind to interface bcast address instead of local address, use SendTo instead of Send. This is how things have to work with real world sockets.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6324
diff changeset
  1606
      i->first->SendTo (packet, 0, InetSocketAddress (bcast, OLSR_PORT_NUMBER));
6303
4ef0052694b9 Bug Fix: OLSR messages generated on non-OLSR interfaces
Lalith Suresh
parents: 6143
diff changeset
  1607
    }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1608
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1609
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1610
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1611
/// \brief Creates as many %OLSR packets as needed in order to send all buffered
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1612
/// %OLSR messages.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1613
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1614
/// Maximum number of messages which can be contained in an %OLSR packet is
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1615
/// dictated by OLSR_MAX_MSGS constant.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1616
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1617
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1618
RoutingProtocol::SendQueuedMessages ()
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1619
{
1868
06027fd6a68c olsr gets new packet
Craig Dowell <craigdo@ee.washington.edu>
parents: 1803
diff changeset
  1620
  Ptr<Packet> packet = Create<Packet> ();
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1621
  int numMessages = 0;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1622
1804
9c11e776f501 bug 96: debug.h duplicates functionality from log.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1803
diff changeset
  1623
  NS_LOG_DEBUG ("Olsr node " << m_mainAddress << ": SendQueuedMessages");
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1624
1803
4078e5efdfc6 Add OLSR message tracing, as discussed on ns-developers list.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1801
diff changeset
  1625
  MessageList msglist;
4078e5efdfc6 Add OLSR message tracing, as discussed on ns-developers list.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1801
diff changeset
  1626
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
  1627
  for (std::vector<olsr::MessageHeader>::const_iterator message = m_queuedMessages.begin ();
1755
262febe2f1c9 Make the OLSR headers usable from the AciiTracing point of view
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1752
diff changeset
  1628
       message != m_queuedMessages.end ();
262febe2f1c9 Make the OLSR headers usable from the AciiTracing point of view
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1752
diff changeset
  1629
       message++)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1630
    {
1868
06027fd6a68c olsr gets new packet
Craig Dowell <craigdo@ee.washington.edu>
parents: 1803
diff changeset
  1631
      Ptr<Packet> p = Create<Packet> ();
06027fd6a68c olsr gets new packet
Craig Dowell <craigdo@ee.washington.edu>
parents: 1803
diff changeset
  1632
      p->AddHeader (*message);
06027fd6a68c olsr gets new packet
Craig Dowell <craigdo@ee.washington.edu>
parents: 1803
diff changeset
  1633
      packet->AddAtEnd (p);
1803
4078e5efdfc6 Add OLSR message tracing, as discussed on ns-developers list.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1801
diff changeset
  1634
      msglist.push_back (*message);
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1635
      if (++numMessages == OLSR_MAX_MSGS)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1636
        {
1803
4078e5efdfc6 Add OLSR message tracing, as discussed on ns-developers list.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1801
diff changeset
  1637
          SendPacket (packet, msglist);
4078e5efdfc6 Add OLSR message tracing, as discussed on ns-developers list.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1801
diff changeset
  1638
          msglist.clear ();
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1639
          // Reset variables for next packet
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1640
          numMessages = 0;
1868
06027fd6a68c olsr gets new packet
Craig Dowell <craigdo@ee.washington.edu>
parents: 1803
diff changeset
  1641
          packet = Create<Packet> ();
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1642
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1643
    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1644
1868
06027fd6a68c olsr gets new packet
Craig Dowell <craigdo@ee.washington.edu>
parents: 1803
diff changeset
  1645
  if (packet->GetSize ())
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1646
    {
1803
4078e5efdfc6 Add OLSR message tracing, as discussed on ns-developers list.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1801
diff changeset
  1647
      SendPacket (packet, msglist);
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1648
    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1649
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1650
  m_queuedMessages.clear ();
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1651
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1652
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1653
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1654
/// \brief Creates a new %OLSR HELLO message which is buffered for being sent later on.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1655
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1656
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1657
RoutingProtocol::SendHello ()
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1658
{
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  1659
  NS_LOG_FUNCTION (this);
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1660
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
  1661
  olsr::MessageHeader msg;
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1662
  Time now = Simulator::Now ();
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1663
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1664
  msg.SetVTime (OLSR_NEIGHB_HOLD_TIME);
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1665
  msg.SetOriginatorAddress (m_mainAddress);
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1666
  msg.SetTimeToLive (1);
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1667
  msg.SetHopCount (0);
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1668
  msg.SetMessageSequenceNumber (GetMessageSequenceNumber ());
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
  1669
  olsr::MessageHeader::Hello &hello = msg.GetHello ();
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1670
5772
a8245e39c546 Bug 739 - OLSR: Strange HTime value in HELLO messages (thanks to Pavel Boyko)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5761
diff changeset
  1671
  hello.SetHTime (m_helloInterval);
1755
262febe2f1c9 Make the OLSR headers usable from the AciiTracing point of view
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1752
diff changeset
  1672
  hello.willingness = m_willingness;
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1673
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
  1674
  std::vector<olsr::MessageHeader::Hello::LinkMessage>
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1675
  &linkMessages = hello.linkMessages;
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1676
	
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1677
  const LinkSet &links = m_state.GetLinks ();
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1678
  for (LinkSet::const_iterator link_tuple = links.begin ();
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1679
       link_tuple != links.end (); link_tuple++)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1680
    {
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1681
      if (!(GetMainAddress (link_tuple->localIfaceAddr) == m_mainAddress
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1682
            && link_tuple->time >= now))
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1683
        {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1684
          continue;
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1685
        }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1686
1762
6410d2be8cbf Fix a couple more warnings in OLSR
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1755
diff changeset
  1687
      uint8_t link_type, nb_type = 0xff;
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1688
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1689
      // Establishes link type
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1690
      if (link_tuple->symTime >= now)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1691
        {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1692
          link_type = OLSR_SYM_LINK;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1693
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1694
      else if (link_tuple->asymTime >= now)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1695
        {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1696
          link_type = OLSR_ASYM_LINK;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1697
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1698
      else
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1699
        {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1700
          link_type = OLSR_LOST_LINK;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1701
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1702
      // Establishes neighbor type.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1703
      if (m_state.FindMprAddress (GetMainAddress (link_tuple->neighborIfaceAddr)))
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1704
        {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1705
          nb_type = OLSR_MPR_NEIGH;
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  1706
          NS_LOG_DEBUG ("I consider neighbor " << GetMainAddress (link_tuple->neighborIfaceAddr)
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1707
                                               << " to be MPR_NEIGH.");
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1708
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1709
      else
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1710
        {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1711
          bool ok = false;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1712
          for (NeighborSet::const_iterator nb_tuple = m_state.GetNeighbors ().begin ();
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1713
               nb_tuple != m_state.GetNeighbors ().end ();
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1714
               nb_tuple++)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1715
            {
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1716
              if (nb_tuple->neighborMainAddr == GetMainAddress (link_tuple->neighborIfaceAddr))
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1717
                {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1718
                  if (nb_tuple->status == NeighborTuple::STATUS_SYM)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1719
                    {
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  1720
                      NS_LOG_DEBUG ("I consider neighbor " << GetMainAddress (link_tuple->neighborIfaceAddr)
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1721
                                                           << " to be SYM_NEIGH.");
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1722
                      nb_type = OLSR_SYM_NEIGH;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1723
                    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1724
                  else if (nb_tuple->status == NeighborTuple::STATUS_NOT_SYM)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1725
                    {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1726
                      nb_type = OLSR_NOT_NEIGH;
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  1727
                      NS_LOG_DEBUG ("I consider neighbor " << GetMainAddress (link_tuple->neighborIfaceAddr)
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1728
                                                           << " to be NOT_NEIGH.");
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1729
                    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1730
                  else
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1731
                    {
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1732
                      NS_FATAL_ERROR ("There is a neighbor tuple with an unknown status!\n");
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1733
                    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1734
                  ok = true;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1735
                  break;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1736
                }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1737
            }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1738
          if (!ok)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1739
            {
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  1740
              NS_LOG_WARN ("I don't know the neighbor " << GetMainAddress (link_tuple->neighborIfaceAddr) << "!!!");
2308
7c34ef595e3e OLSR: remove the 'Link tuple has no corresponding neighbor tuple' assertion; it happens now because MID messages may occasionally not arrive in time, but it's normal.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2307
diff changeset
  1741
              continue;
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1742
            }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1743
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1744
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
  1745
      olsr::MessageHeader::Hello::LinkMessage linkMessage;
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1746
      linkMessage.linkCode = (link_type & 0x03) | ((nb_type << 2) & 0x0f);
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1747
      linkMessage.neighborInterfaceAddresses.push_back
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1748
              (link_tuple->neighborIfaceAddr);
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1749
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1750
      std::vector<Ipv4Address> interfaces =
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1751
        m_state.FindNeighborInterfaces (link_tuple->neighborIfaceAddr);
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1752
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1753
      linkMessage.neighborInterfaceAddresses.insert
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1754
              (linkMessage.neighborInterfaceAddresses.end (),
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1755
              interfaces.begin (), interfaces.end ());
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1756
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1757
      linkMessages.push_back (linkMessage);
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1758
    }
1804
9c11e776f501 bug 96: debug.h duplicates functionality from log.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1803
diff changeset
  1759
  NS_LOG_DEBUG ("OLSR HELLO message size: " << int (msg.GetSerializedSize ())
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1760
                                            << " (with " << int (linkMessages.size ()) << " link messages)");
1755
262febe2f1c9 Make the OLSR headers usable from the AciiTracing point of view
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1752
diff changeset
  1761
  QueueMessage (msg, JITTER);
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1762
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1763
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1764
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1765
/// \brief Creates a new %OLSR TC message which is buffered for being sent later on.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1766
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1767
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1768
RoutingProtocol::SendTc ()
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1769
{
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  1770
  NS_LOG_FUNCTION (this);
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1771
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
  1772
  olsr::MessageHeader msg;
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1773
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1774
  msg.SetVTime (OLSR_TOP_HOLD_TIME);
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1775
  msg.SetOriginatorAddress (m_mainAddress);
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1776
  msg.SetTimeToLive (255);
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1777
  msg.SetHopCount (0);
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1778
  msg.SetMessageSequenceNumber (GetMessageSequenceNumber ());
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1779
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
  1780
  olsr::MessageHeader::Tc &tc = msg.GetTc ();
1755
262febe2f1c9 Make the OLSR headers usable from the AciiTracing point of view
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1752
diff changeset
  1781
  tc.ansn = m_ansn;
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1782
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1783
  for (MprSelectorSet::const_iterator mprsel_tuple = m_state.GetMprSelectors ().begin();
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1784
       mprsel_tuple != m_state.GetMprSelectors ().end(); mprsel_tuple++)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1785
    {
1755
262febe2f1c9 Make the OLSR headers usable from the AciiTracing point of view
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1752
diff changeset
  1786
      tc.neighborAddresses.push_back (mprsel_tuple->mainAddr);
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1787
    }
1755
262febe2f1c9 Make the OLSR headers usable from the AciiTracing point of view
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1752
diff changeset
  1788
  QueueMessage (msg, JITTER);
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1789
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1790
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1791
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1792
/// \brief Creates a new %OLSR MID message which is buffered for being sent later on.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1793
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1794
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1795
RoutingProtocol::SendMid ()
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1796
{
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
  1797
  olsr::MessageHeader msg;
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
  1798
  olsr::MessageHeader::Mid &mid = msg.GetMid ();
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1799
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1800
  // A node which has only a single interface address participating in
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1801
  // the MANET (i.e., running OLSR), MUST NOT generate any MID
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1802
  // message.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1803
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1804
  // A node with several interfaces, where only one is participating
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1805
  // in the MANET and running OLSR (e.g., a node is connected to a
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1806
  // wired network as well as to a MANET) MUST NOT generate any MID
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1807
  // messages.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1808
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1809
  // A node with several interfaces, where more than one is
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1810
  // participating in the MANET and running OLSR MUST generate MID
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1811
  // messages as specified.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1812
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1813
  // [ Note: assuming here that all interfaces participate in the
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1814
  // MANET; later we may want to make this configurable. ]
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1815
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1816
  Ipv4Address loopback ("127.0.0.1");
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1817
  for (uint32_t i = 0; i < m_ipv4->GetNInterfaces (); i++)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1818
    {
4375
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4218
diff changeset
  1819
      Ipv4Address addr = m_ipv4->GetAddress (i, 0).GetLocal ();
6142
c5b36fbaa9c8 Bug 407 postfix: filter out non-OLSR interfaces when generating MID messages
Lalith Suresh <suresh.lalith@gmail.com>
parents: 6140
diff changeset
  1820
      if (addr != m_mainAddress && addr != loopback && m_interfaceExclusions.find (i) == m_interfaceExclusions.end ())
1755
262febe2f1c9 Make the OLSR headers usable from the AciiTracing point of view
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1752
diff changeset
  1821
        mid.interfaceAddresses.push_back (addr);
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1822
    }
1755
262febe2f1c9 Make the OLSR headers usable from the AciiTracing point of view
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1752
diff changeset
  1823
  if (mid.interfaceAddresses.size () == 0)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1824
    return;
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1825
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1826
  msg.SetVTime (OLSR_MID_HOLD_TIME);
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1827
  msg.SetOriginatorAddress (m_mainAddress);
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1828
  msg.SetTimeToLive (255);
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1829
  msg.SetHopCount (0);
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1830
  msg.SetMessageSequenceNumber (GetMessageSequenceNumber ());
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1831
1755
262febe2f1c9 Make the OLSR headers usable from the AciiTracing point of view
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1752
diff changeset
  1832
  QueueMessage (msg, JITTER);
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1833
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1834
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1835
///
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1836
/// \brief Creates a new %OLSR HNA message which is buffered for being sent later on.
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1837
///
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1838
void
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1839
RoutingProtocol::SendHna ()
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1840
{
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1841
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1842
  olsr::MessageHeader msg;
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1843
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1844
  msg.SetVTime (OLSR_HNA_HOLD_TIME);
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1845
  msg.SetOriginatorAddress (m_mainAddress);
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1846
  msg.SetTimeToLive (255);
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1847
  msg.SetHopCount (0);
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1848
  msg.SetMessageSequenceNumber (GetMessageSequenceNumber ());
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1849
  olsr::MessageHeader::Hna &hna = msg.GetHna ();
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1850
6814
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1851
  std::vector<olsr::MessageHeader::Hna::Association> &associations = hna.associations;
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1852
6814
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1853
  // Add all local HNA associations to the HNA message
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1854
  const Associations &localHnaAssociations = m_state.GetAssociations ();
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1855
  for (Associations::const_iterator it = localHnaAssociations.begin ();
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1856
       it != localHnaAssociations.end (); it++)
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1857
    {
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1858
      olsr::MessageHeader::Hna::Association assoc = { it->networkAddr, it->netmask};
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1859
      associations.push_back (assoc);
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1860
    }
6814
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1861
  // If there is no HNA associations to send, return without queuing the message
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1862
  if (associations.size () == 0)
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1863
    {
6814
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1864
      return;
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1865
    }
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1866
6814
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1867
  // Else, queue the message to be sent later on
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1868
  QueueMessage (msg, JITTER);
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1869
}
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1870
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1871
///
6814
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1872
/// \brief Injects the specified (networkAddr, netmask) tuple in the list of
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1873
///        local HNA associations to be sent by the node via HNA messages.
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1874
///        If this tuple already exists, nothing is done.
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1875
///
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1876
void
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1877
RoutingProtocol::AddHostNetworkAssociation (Ipv4Address networkAddr, Ipv4Mask netmask)
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1878
{
6814
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1879
  // Check if the (networkAddr, netmask) tuple already exist
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1880
  // in the list of local HNA associations
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1881
  const Associations &localHnaAssociations = m_state.GetAssociations ();
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1882
  for (Associations::const_iterator assocIterator = localHnaAssociations.begin ();
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1883
       assocIterator != localHnaAssociations.end (); assocIterator++)
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1884
    {
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1885
      Association const &localHnaAssoc = *assocIterator;
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1886
      if (localHnaAssoc.networkAddr == networkAddr && localHnaAssoc.netmask == netmask)
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1887
        {
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1888
          NS_LOG_INFO ("HNA association for network " << networkAddr << "/" << netmask << " already exists.");
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1889
          return;
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1890
        }
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1891
    }
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1892
  // If the tuple does not already exist, add it to the list of local HNA associations.
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1893
  NS_LOG_INFO ("Adding HNA association for network " << networkAddr << "/" << netmask << ".");
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1894
  m_state.InsertAssociation ( (Association) { networkAddr, netmask} );
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1895
}
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1896
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1897
///
6814
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1898
/// \brief Removes the specified (networkAddr, netmask) tuple from the list of
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1899
///        local HNA associations to be sent by the node via HNA messages.
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1900
///        If this tuple does not exist, nothing is done (see "OlsrState::EraseAssociation()").
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1901
///
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1902
void
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1903
RoutingProtocol::RemoveHostNetworkAssociation (Ipv4Address networkAddr, Ipv4Mask netmask)
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1904
{
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1905
  NS_LOG_INFO ("Removing HNA association for network " << networkAddr << "/" << netmask << ".");
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1906
  m_state.EraseAssociation ( (Association) { networkAddr, netmask} );
6814
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1907
}
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1908
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1909
///
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1910
/// \brief Associates the specified Ipv4StaticRouting routing table
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1911
///        to the OLSR routing protocol. Entries from this associated
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1912
///        routing table that use non-olsr outgoing interfaces are added
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1913
///        to the list of local HNA associations so that they are included
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1914
///        in HNA messages sent by the node.
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1915
///        If this method is called more than once, entries from the old
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1916
///        association are deleted before entries from the new one are added.
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1917
/// \param the Ipv4StaticRouting routing table to be associated.
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1918
///
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1919
void
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1920
RoutingProtocol::SetRoutingTableAssociation (Ptr<Ipv4StaticRouting> routingTable)
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1921
{
6814
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1922
  // If a routing table has already been associated, remove
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1923
  // corresponding entries from the list of local HNA associations
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1924
  if (m_routingTableAssociation != 0)
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1925
    {
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1926
      NS_LOG_INFO ("Removing HNA entries coming from the old routing table association.");
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1927
      for (uint32_t i = 0; i < m_routingTableAssociation->GetNRoutes (); i++)
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1928
        {
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1929
          Ipv4RoutingTableEntry route = m_routingTableAssociation->GetRoute (i);
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1930
          // If the outgoing interface for this route is a non-olsr interface
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1931
          if (UsesNonOlsrOutgoingInterface (route))
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1932
            {
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1933
              // remove the corresponding entry
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1934
              RemoveHostNetworkAssociation (route.GetDestNetwork (), route.GetDestNetworkMask ());
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1935
            }
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1936
        }
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1937
    }
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1938
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1939
  // Sets the routingTableAssociation to its new value
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1940
  m_routingTableAssociation = routingTable;
6814
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1941
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1942
  // Iterate over entries of the associated routing table and
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1943
  // add the routes using non-olsr outgoing interfaces to the list
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1944
  // of local HNA associations
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1945
  NS_LOG_DEBUG ("Nb local associations before adding some entries from"
6815
38d2dbcde9c1 fix optimized build
Tom Henderson <tomh@tomh.org>
parents: 6814
diff changeset
  1946
                " the associated routing table: " << m_state.GetAssociations ().size ());
6814
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1947
  for (uint32_t i = 0; i < m_routingTableAssociation->GetNRoutes (); i++)
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1948
    {
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1949
      Ipv4RoutingTableEntry route = m_routingTableAssociation->GetRoute (i);
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1950
      Ipv4Address destNetworkAddress = route.GetDestNetwork ();
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1951
      Ipv4Mask destNetmask = route.GetDestNetworkMask ();
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1952
6814
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1953
      // If the outgoing interface for this route is a non-olsr interface,
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1954
      if (UsesNonOlsrOutgoingInterface (route))
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1955
        {
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1956
          // Add this entry's network address and netmask to the list of local HNA entries
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1957
          AddHostNetworkAssociation (destNetworkAddress, destNetmask);
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1958
        }
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1959
    }
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1960
  NS_LOG_DEBUG ("Nb local associations after having added some entries from "
6815
38d2dbcde9c1 fix optimized build
Tom Henderson <tomh@tomh.org>
parents: 6814
diff changeset
  1961
                "the associated routing table: " << m_state.GetAssociations ().size ());
6814
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1962
}
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1963
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1964
///
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1965
/// \brief Tests whether or not the specified route uses a non-OLSR outgoing interface.
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1966
///        Returns true if the outgoing interface of the specified route is a non-OLSR interface.
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1967
///        Returns false otherwise.
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1968
///
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1969
bool
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1970
RoutingProtocol::UsesNonOlsrOutgoingInterface (const Ipv4RoutingTableEntry &route)
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1971
{
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1972
  std::set<uint32_t>::const_iterator ci = m_interfaceExclusions.find (route.GetInterface ());
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1973
  // The outgoing interface is a non-OLSR interface if a match is found
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1974
  // before reaching the end of the list of excluded interfaces
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  1975
  return ci != m_interfaceExclusions.end ();
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1976
}
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1977
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1978
///
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1979
/// \brief	Updates Link Set according to a new received HELLO message (following RFC 3626
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1980
///		specification). Neighbor Set is also updated if needed.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1981
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1982
RoutingProtocol::LinkSensing (const olsr::MessageHeader &msg,
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1983
                              const olsr::MessageHeader::Hello &hello,
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1984
                              const Ipv4Address &receiverIface,
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1985
                              const Ipv4Address &senderIface)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1986
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1987
  Time now = Simulator::Now ();
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1988
  bool updated = false;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1989
  bool created = false;
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1990
  NS_LOG_DEBUG ("@" << now.GetSeconds () << ": Olsr node " << m_mainAddress
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1991
                    << ": LinkSensing(receiverIface=" << receiverIface
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  1992
                    << ", senderIface=" << senderIface << ") BEGIN");
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1993
	
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1994
  NS_ASSERT (msg.GetVTime () > Seconds (0));
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1995
  LinkTuple *link_tuple = m_state.FindLinkTuple (senderIface);
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1996
  if (link_tuple == NULL)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1997
    {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1998
      LinkTuple newLinkTuple;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1999
      // We have to create a new tuple
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2000
      newLinkTuple.neighborIfaceAddr = senderIface;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2001
      newLinkTuple.localIfaceAddr = receiverIface;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2002
      newLinkTuple.symTime = now - Seconds (1);
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2003
      newLinkTuple.time = now + msg.GetVTime ();
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2004
      link_tuple = &m_state.InsertLinkTuple (newLinkTuple);
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2005
      created = true;
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2006
      NS_LOG_LOGIC ("Existing link tuple did not exist => creating new one");
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2007
    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2008
  else
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2009
    {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2010
      NS_LOG_LOGIC ("Existing link tuple already exists => will update it");
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2011
      updated = true;
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2012
    }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2013
	
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2014
  link_tuple->asymTime = now + msg.GetVTime ();
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
  2015
  for (std::vector<olsr::MessageHeader::Hello::LinkMessage>::const_iterator linkMessage =
1755
262febe2f1c9 Make the OLSR headers usable from the AciiTracing point of view
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1752
diff changeset
  2016
         hello.linkMessages.begin ();
262febe2f1c9 Make the OLSR headers usable from the AciiTracing point of view
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1752
diff changeset
  2017
       linkMessage != hello.linkMessages.end ();
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2018
       linkMessage++)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2019
    {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2020
      int lt = linkMessage->linkCode & 0x03; // Link Type
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2021
      int nt = (linkMessage->linkCode >> 2) & 0x03; // Neighbor Type
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2022
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2023
#ifdef NS3_LOG_ENABLE
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2024
      const char *linkTypeName;
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2025
      switch (lt)
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2026
        {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2027
        case OLSR_UNSPEC_LINK: linkTypeName = "UNSPEC_LINK"; break;
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2028
        case OLSR_ASYM_LINK: linkTypeName = "ASYM_LINK"; break;
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2029
        case OLSR_SYM_LINK: linkTypeName = "SYM_LINK"; break;
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2030
        case OLSR_LOST_LINK: linkTypeName = "LOST_LINK"; break;
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2031
        default: linkTypeName = "(invalid value!)";
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2032
        }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2033
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2034
      const char *neighborTypeName;
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2035
      switch (nt)
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2036
        {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2037
        case OLSR_NOT_NEIGH: neighborTypeName = "NOT_NEIGH"; break;
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2038
        case OLSR_SYM_NEIGH: neighborTypeName = "SYM_NEIGH"; break;
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2039
        case OLSR_MPR_NEIGH: neighborTypeName = "MPR_NEIGH"; break;
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2040
        default: neighborTypeName = "(invalid value!)";
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2041
        }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2042
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2043
      NS_LOG_DEBUG ("Looking at HELLO link messages with Link Type "
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2044
                    << lt << " (" << linkTypeName
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2045
                    << ") and Neighbor Type " << nt
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2046
                    << " (" << neighborTypeName << ")");
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  2047
#endif // NS3_LOG_ENABLE
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2048
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2049
      // We must not process invalid advertised links
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2050
      if ((lt == OLSR_SYM_LINK && nt == OLSR_NOT_NEIGH) ||
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2051
          (nt != OLSR_SYM_NEIGH && nt != OLSR_MPR_NEIGH
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2052
           && nt != OLSR_NOT_NEIGH))
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2053
        {
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2054
          NS_LOG_LOGIC ("HELLO link code is invalid => IGNORING");
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2055
          continue;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2056
        }
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  2057
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2058
      for (std::vector<Ipv4Address>::const_iterator neighIfaceAddr =
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2059
             linkMessage->neighborInterfaceAddresses.begin ();
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2060
           neighIfaceAddr != linkMessage->neighborInterfaceAddresses.end ();
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2061
           neighIfaceAddr++)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2062
        {
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2063
          NS_LOG_DEBUG ("   -> Neighbor: " << *neighIfaceAddr);
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2064
          if (*neighIfaceAddr == receiverIface)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2065
            {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2066
              if (lt == OLSR_LOST_LINK)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2067
                {
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2068
                  NS_LOG_LOGIC ("link is LOST => expiring it");
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2069
                  link_tuple->symTime = now - Seconds (1);
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2070
                  updated = true;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2071
                }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2072
              else if (lt == OLSR_SYM_LINK || lt == OLSR_ASYM_LINK)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2073
                {
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2074
                  NS_LOG_DEBUG (*link_tuple << ": link is SYM or ASYM => should become SYM now"
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2075
                                " (symTime being increased to " << now + msg.GetVTime ());
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2076
                  link_tuple->symTime = now + msg.GetVTime ();
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2077
                  link_tuple->time = link_tuple->symTime + OLSR_NEIGHB_HOLD_TIME;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2078
                  updated = true;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2079
                }
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2080
              else
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2081
                {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2082
                  NS_FATAL_ERROR ("bad link type");
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2083
                }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2084
              break;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2085
            }
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2086
          else
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2087
            {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2088
              NS_LOG_DEBUG ("     \\-> *neighIfaceAddr (" << *neighIfaceAddr
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  2089
                                                          << " != receiverIface (" << receiverIface << ") => IGNORING!");
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2090
            }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2091
        }
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2092
      NS_LOG_DEBUG ("Link tuple updated: " << int (updated));
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2093
    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2094
  link_tuple->time = std::max(link_tuple->time, link_tuple->asymTime);
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2095
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2096
  if (updated)
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2097
    {
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2098
      LinkTupleUpdated (*link_tuple, hello.willingness);
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2099
    }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2100
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2101
  // Schedules link tuple deletion
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2102
  if (created && link_tuple != NULL)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2103
    {
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2104
      LinkTupleAdded (*link_tuple, hello.willingness);
1768
1664a9db93b9 Make EventGarbageCollector private to the olsr module; adapt olsr to Timer API changes.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1765
diff changeset
  2105
      m_events.Track (Simulator::Schedule (DELAY (std::min (link_tuple->time, link_tuple->symTime)),
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2106
                                           &RoutingProtocol::LinkTupleTimerExpire, this,
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  2107
                                           link_tuple->neighborIfaceAddr));
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2108
    }
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2109
  NS_LOG_DEBUG ("@" << now.GetSeconds () << ": Olsr node " << m_mainAddress
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  2110
                    << ": LinkSensing END");
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2111
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2112
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2113
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2114
/// \brief	Updates the Neighbor Set according to the information contained in a new received
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2115
///		HELLO message (following RFC 3626).
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2116
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2117
RoutingProtocol::PopulateNeighborSet (const olsr::MessageHeader &msg,
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  2118
                                      const olsr::MessageHeader::Hello &hello)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2119
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2120
  NeighborTuple *nb_tuple = m_state.FindNeighborTuple (msg.GetOriginatorAddress ());
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2121
  if (nb_tuple != NULL)
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2122
    {
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2123
      nb_tuple->willingness = hello.willingness;
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2124
    }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2125
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2126
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2127
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2128
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2129
/// \brief	Updates the 2-hop Neighbor Set according to the information contained in a new
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2130
///		received HELLO message (following RFC 3626).
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2131
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2132
RoutingProtocol::PopulateTwoHopNeighborSet (const olsr::MessageHeader &msg,
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  2133
                                            const olsr::MessageHeader::Hello &hello)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2134
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2135
  Time now = Simulator::Now ();
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2136
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2137
  NS_LOG_DEBUG ("Olsr node " << m_mainAddress << ": PopulateTwoHopNeighborSet BEGIN");
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2138
	
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2139
  for (LinkSet::const_iterator link_tuple = m_state.GetLinks ().begin ();
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2140
       link_tuple != m_state.GetLinks ().end (); link_tuple++)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2141
    {
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2142
      NS_LOG_LOGIC ("Looking at link tuple: " << *link_tuple);
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2143
      if (GetMainAddress (link_tuple->neighborIfaceAddr) != msg.GetOriginatorAddress ())
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2144
        {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2145
          NS_LOG_LOGIC ("Link tuple ignored: "
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2146
                        "GetMainAddress (link_tuple->neighborIfaceAddr) != msg.GetOriginatorAddress ()");
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2147
          NS_LOG_LOGIC ("(GetMainAddress(" << link_tuple->neighborIfaceAddr << "): "
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  2148
                                           << GetMainAddress (link_tuple->neighborIfaceAddr)
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  2149
                                           << "; msg.GetOriginatorAddress (): " << msg.GetOriginatorAddress ());
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2150
          continue;
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2151
        }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2152
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2153
      if (link_tuple->symTime < now)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2154
        {
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2155
          NS_LOG_LOGIC ("Link tuple ignored: expired.");
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2156
          continue;
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2157
        }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2158
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2159
      typedef std::vector<olsr::MessageHeader::Hello::LinkMessage> LinkMessageVec;
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2160
      for (LinkMessageVec::const_iterator linkMessage = hello.linkMessages.begin ();
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2161
           linkMessage != hello.linkMessages.end (); linkMessage++)
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2162
        {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2163
          int neighborType = (linkMessage->linkCode >> 2) & 0x3;
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2164
#ifdef NS3_LOG_ENABLE
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2165
          const char *neighborTypeNames[3] = { "NOT_NEIGH", "SYM_NEIGH", "MPR_NEIGH" };
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  2166
          const char *neighborTypeName = ((neighborType < 3) ?
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2167
                                          neighborTypeNames[neighborType]
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2168
                                          : "(invalid value)");
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2169
          NS_LOG_DEBUG ("Looking at Link Message from HELLO message: neighborType="
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2170
                        << neighborType << " (" << neighborTypeName << ")");
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  2171
#endif // NS3_LOG_ENABLE
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2172
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2173
          for (std::vector<Ipv4Address>::const_iterator nb2hop_addr_iter =
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2174
                 linkMessage->neighborInterfaceAddresses.begin ();
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2175
               nb2hop_addr_iter != linkMessage->neighborInterfaceAddresses.end ();
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2176
               nb2hop_addr_iter++)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2177
            {
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2178
              Ipv4Address nb2hop_addr = GetMainAddress (*nb2hop_addr_iter);
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2179
              NS_LOG_DEBUG ("Looking at 2-hop neighbor address from HELLO message: "
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2180
                            << *nb2hop_addr_iter
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2181
                            << " (main address is " << nb2hop_addr << ")");
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2182
              if (neighborType == OLSR_SYM_NEIGH || neighborType == OLSR_MPR_NEIGH)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2183
                {
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2184
                  // If the main address of the 2-hop neighbor address == main address
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2185
                  // of the receiving node, silently discard the 2-hop
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2186
                  // neighbor address.
6812
a3140070b40a OLSR: fix bad usage of uninitialized m_routingAgentAddr. Spotted by chei_med--yahoo-fr on ns-3-users thread 'm_routingAgentAddr and OLSR'
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6775
diff changeset
  2187
                  if (nb2hop_addr == m_mainAddress)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2188
                    {
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2189
                      NS_LOG_LOGIC ("Ignoring 2-hop neighbor (it is the node itself)");
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2190
                      continue;
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2191
                    }
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2192
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2193
                  // Otherwise, a 2-hop tuple is created
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2194
                  TwoHopNeighborTuple *nb2hop_tuple =
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2195
                    m_state.FindTwoHopNeighborTuple (msg.GetOriginatorAddress (), nb2hop_addr);
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2196
                  NS_LOG_LOGIC ("Adding the 2-hop neighbor"
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  2197
                                << (nb2hop_tuple ? " (refreshing existing entry)" : ""));
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2198
                  if (nb2hop_tuple == NULL)
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2199
                    {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2200
                      TwoHopNeighborTuple new_nb2hop_tuple;
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2201
                      new_nb2hop_tuple.neighborMainAddr = msg.GetOriginatorAddress ();
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2202
                      new_nb2hop_tuple.twoHopNeighborAddr = nb2hop_addr;
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2203
                      new_nb2hop_tuple.expirationTime = now + msg.GetVTime ();
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2204
                      AddTwoHopNeighborTuple (new_nb2hop_tuple);
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2205
                      // Schedules nb2hop tuple deletion
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2206
                      m_events.Track (Simulator::Schedule (DELAY (new_nb2hop_tuple.expirationTime),
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2207
                                                           &RoutingProtocol::Nb2hopTupleTimerExpire, this,
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  2208
                                                           new_nb2hop_tuple.neighborMainAddr,
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  2209
                                                           new_nb2hop_tuple.twoHopNeighborAddr));
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2210
                    }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2211
                  else
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2212
                    {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2213
                      nb2hop_tuple->expirationTime = now + msg.GetVTime ();
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2214
                    }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2215
                }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2216
              else if (neighborType == OLSR_NOT_NEIGH)
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2217
                {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2218
                  // For each 2-hop node listed in the HELLO message
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2219
                  // with Neighbor Type equal to NOT_NEIGH all 2-hop
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2220
                  // tuples where: N_neighbor_main_addr == Originator
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2221
                  // Address AND N_2hop_addr == main address of the
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2222
                  // 2-hop neighbor are deleted.
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2223
                  NS_LOG_LOGIC ("2-hop neighbor is NOT_NEIGH => deleting matching 2-hop neighbor state");
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2224
                  m_state.EraseTwoHopNeighborTuples (msg.GetOriginatorAddress (), nb2hop_addr);
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2225
                }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2226
              else
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2227
                {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2228
                  NS_LOG_LOGIC ("*** WARNING *** Ignoring link message (inside HELLO) with bad"
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2229
                                " neighbor type value: " << neighborType);
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2230
                }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2231
            }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2232
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2233
    }
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2234
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2235
  NS_LOG_DEBUG ("Olsr node " << m_mainAddress << ": PopulateTwoHopNeighborSet END");
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2236
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2237
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2238
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2239
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2240
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2241
/// \brief	Updates the MPR Selector Set according to the information contained in a new
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2242
///		received HELLO message (following RFC 3626).
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2243
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2244
RoutingProtocol::PopulateMprSelectorSet (const olsr::MessageHeader &msg,
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  2245
                                         const olsr::MessageHeader::Hello &hello)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2246
{
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2247
  NS_LOG_FUNCTION (this);
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  2248
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2249
  Time now = Simulator::Now ();
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2250
	
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
  2251
  typedef std::vector<olsr::MessageHeader::Hello::LinkMessage> LinkMessageVec;
1755
262febe2f1c9 Make the OLSR headers usable from the AciiTracing point of view
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1752
diff changeset
  2252
  for (LinkMessageVec::const_iterator linkMessage = hello.linkMessages.begin ();
262febe2f1c9 Make the OLSR headers usable from the AciiTracing point of view
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1752
diff changeset
  2253
       linkMessage != hello.linkMessages.end ();
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2254
       linkMessage++)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2255
    {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2256
      int nt = linkMessage->linkCode >> 2;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2257
      if (nt == OLSR_MPR_NEIGH)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2258
        {
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2259
          NS_LOG_DEBUG ("Processing a link message with neighbor type MPR_NEIGH");
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  2260
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2261
          for (std::vector<Ipv4Address>::const_iterator nb_iface_addr =
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2262
                 linkMessage->neighborInterfaceAddresses.begin ();
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2263
               nb_iface_addr != linkMessage->neighborInterfaceAddresses.end ();
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2264
               nb_iface_addr++)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2265
            {
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2266
              if (GetMainAddress (*nb_iface_addr) == m_mainAddress)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2267
                {
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2268
                  NS_LOG_DEBUG ("Adding entry to mpr selector set for neighbor " << *nb_iface_addr);
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  2269
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2270
                  // We must create a new entry into the mpr selector set
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2271
                  MprSelectorTuple *existing_mprsel_tuple =
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2272
                    m_state.FindMprSelectorTuple (msg.GetOriginatorAddress ());
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2273
                  if (existing_mprsel_tuple == NULL)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2274
                    {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2275
                      MprSelectorTuple mprsel_tuple;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2276
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2277
                      mprsel_tuple.mainAddr = msg.GetOriginatorAddress ();
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2278
                      mprsel_tuple.expirationTime = now + msg.GetVTime ();
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2279
                      AddMprSelectorTuple (mprsel_tuple);
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2280
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2281
                      // Schedules mpr selector tuple deletion
1768
1664a9db93b9 Make EventGarbageCollector private to the olsr module; adapt olsr to Timer API changes.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1765
diff changeset
  2282
                      m_events.Track (Simulator::Schedule
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  2283
                                            (DELAY (mprsel_tuple.expirationTime),
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  2284
                                            &RoutingProtocol::MprSelTupleTimerExpire, this,
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  2285
                                            mprsel_tuple.mainAddr));
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2286
                    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2287
                  else
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2288
                    {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2289
                      existing_mprsel_tuple->expirationTime = now + msg.GetVTime ();
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2290
                    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2291
                }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2292
            }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2293
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2294
    }
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2295
  NS_LOG_DEBUG ("Computed MPR selector set for node " << m_mainAddress << ": " << m_state.PrintMprSelectorSet ());
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2296
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2297
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2298
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2299
#if 0
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2300
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2301
/// \brief	Drops a given packet because it couldn't be delivered to the corresponding
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2302
///		destination by the MAC layer. This may cause a neighbor loss, and appropiate
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2303
///		actions are then taken.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2304
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2305
/// \param p the packet which couldn't be delivered by the MAC layer.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2306
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2307
void
1868
06027fd6a68c olsr gets new packet
Craig Dowell <craigdo@ee.washington.edu>
parents: 1803
diff changeset
  2308
OLSR::mac_failed(Ptr<Packet> p) {
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  2309
  double now              = Simulator::Now ();
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  2310
  struct hdr_ip* ih       = HDR_IP(p);
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  2311
  struct hdr_cmn* ch      = HDR_CMN(p);
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2312
	
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  2313
  debug("%f: Node %d MAC Layer detects a breakage on link to %d\n",
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  2314
        now,
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  2315
        OLSR::node_id(ra_addr()),
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  2316
        OLSR::node_id(ch->next_hop()));
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2317
	
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  2318
  if ((u_int32_t)ih->daddr() == IP_BROADCAST) {
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  2319
      drop(p, DROP_RTR_MAC_CALLBACK);
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  2320
      return;
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  2321
    }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2322
	
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  2323
  OLSR_link_tuple* link_tuple = state_.find_link_tuple(ch->next_hop());
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  2324
  if (link_tuple != NULL) {
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  2325
      link_tuple->lost_time() = now + OLSR_NEIGHB_HOLD_TIME;
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  2326
      link_tuple->time()      = now + OLSR_NEIGHB_HOLD_TIME;
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  2327
      nb_loss(link_tuple);
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  2328
    }
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  2329
  drop(p, DROP_RTR_MAC_CALLBACK);
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2330
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2331
#endif
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2332
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2333
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2334
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2335
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2336
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2337
/// \brief Performs all actions needed when a neighbor loss occurs.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2338
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2339
/// Neighbor Set, 2-hop Neighbor Set, MPR Set and MPR Selector Set are updated.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2340
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2341
/// \param tuple link tuple with the information of the link to the neighbor which has been lost.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2342
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2343
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2344
RoutingProtocol::NeighborLoss (const LinkTuple &tuple)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2345
{
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2346
  NS_LOG_DEBUG (Simulator::Now ().GetSeconds ()
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2347
                << "s: OLSR Node " << m_mainAddress
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2348
                << " LinkTuple " << tuple.neighborIfaceAddr << " -> neighbor loss.");
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2349
  LinkTupleUpdated (tuple, OLSR_WILL_DEFAULT);
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2350
  m_state.EraseTwoHopNeighborTuples (GetMainAddress (tuple.neighborIfaceAddr));
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2351
  m_state.EraseMprSelectorTuples (GetMainAddress (tuple.neighborIfaceAddr));
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  2352
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2353
  MprComputation ();
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2354
  RoutingTableComputation ();
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2355
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2356
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2357
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2358
/// \brief Adds a duplicate tuple to the Duplicate Set.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2359
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2360
/// \param tuple the duplicate tuple to be added.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2361
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2362
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2363
RoutingProtocol::AddDuplicateTuple (const DuplicateTuple &tuple)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2364
{
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  2365
  /*debug("%f: Node %d adds dup tuple: addr = %d seq_num = %d\n",
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  2366
          Simulator::Now (),
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  2367
          OLSR::node_id(ra_addr()),
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  2368
          OLSR::node_id(tuple->addr()),
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  2369
          tuple->seq_num());*/
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2370
  m_state.InsertDuplicateTuple (tuple);
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2371
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2372
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2373
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2374
/// \brief Removes a duplicate tuple from the Duplicate Set.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2375
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2376
/// \param tuple the duplicate tuple to be removed.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2377
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2378
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2379
RoutingProtocol::RemoveDuplicateTuple (const DuplicateTuple &tuple)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2380
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2381
  /*debug("%f: Node %d removes dup tuple: addr = %d seq_num = %d\n",
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2382
    Simulator::Now (),
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2383
    OLSR::node_id(ra_addr()),
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2384
    OLSR::node_id(tuple->addr()),
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2385
    tuple->seq_num());*/
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2386
  m_state.EraseDuplicateTuple (tuple);
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2387
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2388
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2389
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2390
RoutingProtocol::LinkTupleAdded (const LinkTuple &tuple, uint8_t willingness)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2391
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2392
  // Creates associated neighbor tuple
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2393
  NeighborTuple nb_tuple;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2394
  nb_tuple.neighborMainAddr = GetMainAddress (tuple.neighborIfaceAddr);
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2395
  nb_tuple.willingness = willingness;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2396
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2397
  if (tuple.symTime >= Simulator::Now ())
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2398
    {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2399
      nb_tuple.status = NeighborTuple::STATUS_SYM;
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2400
    }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2401
  else
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2402
    {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2403
      nb_tuple.status = NeighborTuple::STATUS_NOT_SYM;
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2404
    }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2405
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2406
  AddNeighborTuple (nb_tuple);
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2407
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2408
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2409
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2410
/// \brief Removes a link tuple from the Link Set.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2411
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2412
/// \param tuple the link tuple to be removed.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2413
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2414
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2415
RoutingProtocol::RemoveLinkTuple (const LinkTuple &tuple)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2416
{
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2417
  NS_LOG_DEBUG (Simulator::Now ().GetSeconds ()
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2418
                << "s: OLSR Node " << m_mainAddress
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2419
                << " LinkTuple " << tuple << " REMOVED.");
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2420
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2421
  m_state.EraseLinkTuple (tuple);
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2422
  m_state.EraseNeighborTuple (GetMainAddress (tuple.neighborIfaceAddr));
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2423
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2424
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2425
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2426
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2427
/// \brief	This function is invoked when a link tuple is updated. Its aim is to
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2428
///		also update the corresponding neighbor tuple if it is needed.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2429
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2430
/// \param tuple the link tuple which has been updated.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2431
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2432
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2433
RoutingProtocol::LinkTupleUpdated (const LinkTuple &tuple, uint8_t willingness)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2434
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2435
  // Each time a link tuple changes, the associated neighbor tuple must be recomputed
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2436
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2437
  NS_LOG_DEBUG (Simulator::Now ().GetSeconds ()
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2438
                << "s: OLSR Node " << m_mainAddress
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2439
                << " LinkTuple " << tuple << " UPDATED.");
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2440
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2441
  NeighborTuple *nb_tuple =
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2442
    m_state.FindNeighborTuple (GetMainAddress (tuple.neighborIfaceAddr));
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  2443
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2444
  if (nb_tuple == NULL)
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2445
    {
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2446
      LinkTupleAdded (tuple, willingness);
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2447
      nb_tuple = m_state.FindNeighborTuple (GetMainAddress (tuple.neighborIfaceAddr));
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2448
    }
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2449
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2450
  if (nb_tuple != NULL)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2451
    {
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2452
#ifdef NS3_LOG_ENABLE
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2453
      int statusBefore = nb_tuple->status;
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  2454
#endif // NS3_LOG_ENABLE
6820
a09e1a107172 Bug 1052 - olsr::RoutingProtocol::LinkTupleUpdated incorrect detection of asymmetric link with multiple interface node
Lalith Suresh <suresh.lalith@gmail.com>
parents: 6815
diff changeset
  2455
a09e1a107172 Bug 1052 - olsr::RoutingProtocol::LinkTupleUpdated incorrect detection of asymmetric link with multiple interface node
Lalith Suresh <suresh.lalith@gmail.com>
parents: 6815
diff changeset
  2456
      bool hasSymmetricLink = false;
a09e1a107172 Bug 1052 - olsr::RoutingProtocol::LinkTupleUpdated incorrect detection of asymmetric link with multiple interface node
Lalith Suresh <suresh.lalith@gmail.com>
parents: 6815
diff changeset
  2457
a09e1a107172 Bug 1052 - olsr::RoutingProtocol::LinkTupleUpdated incorrect detection of asymmetric link with multiple interface node
Lalith Suresh <suresh.lalith@gmail.com>
parents: 6815
diff changeset
  2458
      const LinkSet &linkSet = m_state.GetLinks ();
a09e1a107172 Bug 1052 - olsr::RoutingProtocol::LinkTupleUpdated incorrect detection of asymmetric link with multiple interface node
Lalith Suresh <suresh.lalith@gmail.com>
parents: 6815
diff changeset
  2459
      for (LinkSet::const_iterator it = linkSet.begin();
a09e1a107172 Bug 1052 - olsr::RoutingProtocol::LinkTupleUpdated incorrect detection of asymmetric link with multiple interface node
Lalith Suresh <suresh.lalith@gmail.com>
parents: 6815
diff changeset
  2460
           it != linkSet.end(); it++)
a09e1a107172 Bug 1052 - olsr::RoutingProtocol::LinkTupleUpdated incorrect detection of asymmetric link with multiple interface node
Lalith Suresh <suresh.lalith@gmail.com>
parents: 6815
diff changeset
  2461
        {
a09e1a107172 Bug 1052 - olsr::RoutingProtocol::LinkTupleUpdated incorrect detection of asymmetric link with multiple interface node
Lalith Suresh <suresh.lalith@gmail.com>
parents: 6815
diff changeset
  2462
          const LinkTuple &link_tuple = *it;
a09e1a107172 Bug 1052 - olsr::RoutingProtocol::LinkTupleUpdated incorrect detection of asymmetric link with multiple interface node
Lalith Suresh <suresh.lalith@gmail.com>
parents: 6815
diff changeset
  2463
          if (GetMainAddress (link_tuple.neighborIfaceAddr) == nb_tuple->neighborMainAddr
a09e1a107172 Bug 1052 - olsr::RoutingProtocol::LinkTupleUpdated incorrect detection of asymmetric link with multiple interface node
Lalith Suresh <suresh.lalith@gmail.com>
parents: 6815
diff changeset
  2464
              && link_tuple.symTime >= Simulator::Now ())
a09e1a107172 Bug 1052 - olsr::RoutingProtocol::LinkTupleUpdated incorrect detection of asymmetric link with multiple interface node
Lalith Suresh <suresh.lalith@gmail.com>
parents: 6815
diff changeset
  2465
            {
a09e1a107172 Bug 1052 - olsr::RoutingProtocol::LinkTupleUpdated incorrect detection of asymmetric link with multiple interface node
Lalith Suresh <suresh.lalith@gmail.com>
parents: 6815
diff changeset
  2466
              hasSymmetricLink = true;
a09e1a107172 Bug 1052 - olsr::RoutingProtocol::LinkTupleUpdated incorrect detection of asymmetric link with multiple interface node
Lalith Suresh <suresh.lalith@gmail.com>
parents: 6815
diff changeset
  2467
              break;
a09e1a107172 Bug 1052 - olsr::RoutingProtocol::LinkTupleUpdated incorrect detection of asymmetric link with multiple interface node
Lalith Suresh <suresh.lalith@gmail.com>
parents: 6815
diff changeset
  2468
            }
a09e1a107172 Bug 1052 - olsr::RoutingProtocol::LinkTupleUpdated incorrect detection of asymmetric link with multiple interface node
Lalith Suresh <suresh.lalith@gmail.com>
parents: 6815
diff changeset
  2469
        }
a09e1a107172 Bug 1052 - olsr::RoutingProtocol::LinkTupleUpdated incorrect detection of asymmetric link with multiple interface node
Lalith Suresh <suresh.lalith@gmail.com>
parents: 6815
diff changeset
  2470
a09e1a107172 Bug 1052 - olsr::RoutingProtocol::LinkTupleUpdated incorrect detection of asymmetric link with multiple interface node
Lalith Suresh <suresh.lalith@gmail.com>
parents: 6815
diff changeset
  2471
      if (hasSymmetricLink)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2472
        {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2473
          nb_tuple->status = NeighborTuple::STATUS_SYM;
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2474
          NS_LOG_DEBUG (*nb_tuple << "->status = STATUS_SYM; changed:"
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  2475
                                  << int (statusBefore != nb_tuple->status));
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2476
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2477
      else
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2478
        {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2479
          nb_tuple->status = NeighborTuple::STATUS_NOT_SYM;
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2480
          NS_LOG_DEBUG (*nb_tuple << "->status = STATUS_NOT_SYM; changed:"
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  2481
                                  << int (statusBefore != nb_tuple->status));
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2482
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2483
    }
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2484
  else
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2485
    {
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2486
      NS_LOG_WARN ("ERROR! Wanted to update a NeighborTuple but none was found!");
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2487
    }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2488
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2489
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2490
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2491
/// \brief Adds a neighbor tuple to the Neighbor Set.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2492
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2493
/// \param tuple the neighbor tuple to be added.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2494
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2495
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2496
RoutingProtocol::AddNeighborTuple (const NeighborTuple &tuple)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2497
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2498
//   debug("%f: Node %d adds neighbor tuple: nb_addr = %d status = %s\n",
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2499
//         Simulator::Now (),
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2500
//         OLSR::node_id(ra_addr()),
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2501
//         OLSR::node_id(tuple->neighborMainAddr),
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2502
//         ((tuple->status() == OLSR_STATUS_SYM) ? "sym" : "not_sym"));
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  2503
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2504
  m_state.InsertNeighborTuple (tuple);
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2505
  IncrementAnsn ();
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2506
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2507
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2508
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2509
/// \brief Removes a neighbor tuple from the Neighbor Set.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2510
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2511
/// \param tuple the neighbor tuple to be removed.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2512
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2513
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2514
RoutingProtocol::RemoveNeighborTuple (const NeighborTuple &tuple)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2515
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2516
//   debug("%f: Node %d removes neighbor tuple: nb_addr = %d status = %s\n",
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2517
//         Simulator::Now (),
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2518
//         OLSR::node_id(ra_addr()),
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2519
//         OLSR::node_id(tuple->neighborMainAddr),
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2520
//         ((tuple->status() == OLSR_STATUS_SYM) ? "sym" : "not_sym"));
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2521
	
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2522
  m_state.EraseNeighborTuple (tuple);
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2523
  IncrementAnsn ();
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2524
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2525
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2526
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2527
/// \brief Adds a 2-hop neighbor tuple to the 2-hop Neighbor Set.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2528
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2529
/// \param tuple the 2-hop neighbor tuple to be added.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2530
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2531
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2532
RoutingProtocol::AddTwoHopNeighborTuple (const TwoHopNeighborTuple &tuple)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2533
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2534
//   debug("%f: Node %d adds 2-hop neighbor tuple: nb_addr = %d nb2hop_addr = %d\n",
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2535
//         Simulator::Now (),
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2536
//         OLSR::node_id(ra_addr()),
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2537
//         OLSR::node_id(tuple->neighborMainAddr),
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2538
//         OLSR::node_id(tuple->twoHopNeighborAddr));
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  2539
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2540
  m_state.InsertTwoHopNeighborTuple (tuple);
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2541
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2542
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2543
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2544
/// \brief Removes a 2-hop neighbor tuple from the 2-hop Neighbor Set.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2545
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2546
/// \param tuple the 2-hop neighbor tuple to be removed.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2547
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2548
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2549
RoutingProtocol::RemoveTwoHopNeighborTuple (const TwoHopNeighborTuple &tuple)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2550
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2551
//   debug("%f: Node %d removes 2-hop neighbor tuple: nb_addr = %d nb2hop_addr = %d\n",
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2552
//         Simulator::Now (),
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2553
//         OLSR::node_id(ra_addr()),
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2554
//         OLSR::node_id(tuple->neighborMainAddr),
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2555
//         OLSR::node_id(tuple->twoHopNeighborAddr));
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2556
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2557
  m_state.EraseTwoHopNeighborTuple (tuple);
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2558
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2559
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2560
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2561
RoutingProtocol::IncrementAnsn ()
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2562
{
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2563
  m_ansn = (m_ansn + 1) % (OLSR_MAX_SEQ_NUM + 1);
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2564
}
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2565
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2566
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2567
/// \brief Adds an MPR selector tuple to the MPR Selector Set.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2568
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2569
/// Advertised Neighbor Sequence Number (ANSN) is also updated.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2570
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2571
/// \param tuple the MPR selector tuple to be added.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2572
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2573
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2574
RoutingProtocol::AddMprSelectorTuple (const MprSelectorTuple  &tuple)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2575
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2576
//   debug("%f: Node %d adds MPR selector tuple: nb_addr = %d\n",
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2577
//         Simulator::Now (),
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2578
//         OLSR::node_id(ra_addr()),
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2579
//         OLSR::node_id(tuple->main_addr()));
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  2580
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2581
  m_state.InsertMprSelectorTuple (tuple);
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2582
  IncrementAnsn ();
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2583
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2584
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2585
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2586
/// \brief Removes an MPR selector tuple from the MPR Selector Set.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2587
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2588
/// Advertised Neighbor Sequence Number (ANSN) is also updated.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2589
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2590
/// \param tuple the MPR selector tuple to be removed.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2591
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2592
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2593
RoutingProtocol::RemoveMprSelectorTuple (const MprSelectorTuple &tuple)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2594
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2595
//   debug("%f: Node %d removes MPR selector tuple: nb_addr = %d\n",
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2596
//         Simulator::Now (),
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2597
//         OLSR::node_id(ra_addr()),
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2598
//         OLSR::node_id(tuple->main_addr()));
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  2599
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2600
  m_state.EraseMprSelectorTuple (tuple);
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2601
  IncrementAnsn ();
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2602
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2603
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2604
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2605
/// \brief Adds a topology tuple to the Topology Set.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2606
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2607
/// \param tuple the topology tuple to be added.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2608
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2609
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2610
RoutingProtocol::AddTopologyTuple (const TopologyTuple &tuple)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2611
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2612
//   debug("%f: Node %d adds topology tuple: dest_addr = %d last_addr = %d seq = %d\n",
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2613
//         Simulator::Now (),
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2614
//         OLSR::node_id(ra_addr()),
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2615
//         OLSR::node_id(tuple->dest_addr()),
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2616
//         OLSR::node_id(tuple->last_addr()),
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2617
//         tuple->seq());
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2618
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2619
  m_state.InsertTopologyTuple(tuple);
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2620
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2621
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2622
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2623
/// \brief Removes a topology tuple from the Topology Set.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2624
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2625
/// \param tuple the topology tuple to be removed.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2626
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2627
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2628
RoutingProtocol::RemoveTopologyTuple (const TopologyTuple &tuple)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2629
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2630
//   debug("%f: Node %d removes topology tuple: dest_addr = %d last_addr = %d seq = %d\n",
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2631
//         Simulator::Now (),
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2632
//         OLSR::node_id(ra_addr()),
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2633
//         OLSR::node_id(tuple->dest_addr()),
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2634
//         OLSR::node_id(tuple->last_addr()),
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2635
//         tuple->seq());
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2636
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2637
  m_state.EraseTopologyTuple (tuple);
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2638
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2639
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2640
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2641
/// \brief Adds an interface association tuple to the Interface Association Set.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2642
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2643
/// \param tuple the interface association tuple to be added.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2644
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2645
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2646
RoutingProtocol::AddIfaceAssocTuple (const IfaceAssocTuple &tuple)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2647
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2648
//   debug("%f: Node %d adds iface association tuple: main_addr = %d iface_addr = %d\n",
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2649
//         Simulator::Now (),
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2650
//         OLSR::node_id(ra_addr()),
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2651
//         OLSR::node_id(tuple->main_addr()),
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2652
//         OLSR::node_id(tuple->iface_addr()));
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2653
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2654
  m_state.InsertIfaceAssocTuple (tuple);
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2655
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2656
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2657
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2658
/// \brief Removes an interface association tuple from the Interface Association Set.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2659
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2660
/// \param tuple the interface association tuple to be removed.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2661
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2662
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2663
RoutingProtocol::RemoveIfaceAssocTuple (const IfaceAssocTuple &tuple)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2664
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2665
//   debug("%f: Node %d removes iface association tuple: main_addr = %d iface_addr = %d\n",
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2666
//         Simulator::Now (),
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2667
//         OLSR::node_id(ra_addr()),
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2668
//         OLSR::node_id(tuple->main_addr()),
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2669
//         OLSR::node_id(tuple->iface_addr()));
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2670
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2671
  m_state.EraseIfaceAssocTuple (tuple);
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2672
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2673
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2674
///
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2675
/// \brief Adds a host network association tuple to the Association Set.
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2676
///
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2677
/// \param tuple the host network association tuple to be added.
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2678
///
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2679
void
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2680
RoutingProtocol::AddAssociationTuple (const AssociationTuple &tuple)
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2681
{
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2682
  m_state.InsertAssociationTuple (tuple);
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2683
}
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2684
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2685
///
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2686
/// \brief Removes a host network association tuple from the Association Set.
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2687
///
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2688
/// \param tuple the host network association tuple to be removed.
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2689
///
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2690
void
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2691
RoutingProtocol::RemoveAssociationTuple (const AssociationTuple &tuple)
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2692
{
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2693
  m_state.EraseAssociationTuple (tuple);
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2694
}
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2695
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2696
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2697
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2698
uint16_t RoutingProtocol::GetPacketSequenceNumber ()
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2699
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2700
  m_packetSequenceNumber = (m_packetSequenceNumber + 1) % (OLSR_MAX_SEQ_NUM + 1);
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2701
  return m_packetSequenceNumber;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2702
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2703
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2704
/// Increments message sequence number and returns the new value.
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2705
uint16_t RoutingProtocol::GetMessageSequenceNumber ()
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2706
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2707
  m_messageSequenceNumber = (m_messageSequenceNumber + 1) % (OLSR_MAX_SEQ_NUM + 1);
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2708
  return m_messageSequenceNumber;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2709
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2710
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2711
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2712
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2713
/// \brief Sends a HELLO message and reschedules the HELLO timer.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2714
/// \param e The event which has expired.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2715
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2716
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2717
RoutingProtocol::HelloTimerExpire ()
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2718
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2719
  SendHello ();
1765
763f8d1bb058 Adapt the OLSR agent code to use the new Timer class.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1763
diff changeset
  2720
  m_helloTimer.Schedule (m_helloInterval);
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2721
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2722
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2723
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2724
/// \brief Sends a TC message (if there exists any MPR selector) and reschedules the TC timer.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2725
/// \param e The event which has expired.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2726
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2727
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2728
RoutingProtocol::TcTimerExpire ()
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2729
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2730
  if (m_state.GetMprSelectors ().size () > 0)
1765
763f8d1bb058 Adapt the OLSR agent code to use the new Timer class.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1763
diff changeset
  2731
    {
763f8d1bb058 Adapt the OLSR agent code to use the new Timer class.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1763
diff changeset
  2732
      SendTc ();
763f8d1bb058 Adapt the OLSR agent code to use the new Timer class.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1763
diff changeset
  2733
    }
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2734
  else
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2735
    {
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2736
      NS_LOG_DEBUG ("Not sending any TC, no one selected me as MPR.");
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2737
    }
1765
763f8d1bb058 Adapt the OLSR agent code to use the new Timer class.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1763
diff changeset
  2738
  m_tcTimer.Schedule (m_tcInterval);
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2739
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2740
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2741
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2742
/// \brief Sends a MID message (if the node has more than one interface) and resets the MID timer.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2743
/// \param e The event which has expired.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2744
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2745
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2746
RoutingProtocol::MidTimerExpire ()
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2747
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2748
  SendMid ();
1765
763f8d1bb058 Adapt the OLSR agent code to use the new Timer class.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1763
diff changeset
  2749
  m_midTimer.Schedule (m_midInterval);
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2750
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2751
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2752
///
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2753
/// \brief Sends an HNA message (if the node has associated hosts/networks) and reschedules the HNA timer.
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2754
///
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2755
void
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2756
RoutingProtocol::HnaTimerExpire ()
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2757
{
6814
17ff75a3dcbf Bug 1049 - Issues with OLSR HNA messages sent by multiple gateways
Julien Boite <juboite@gmail.com>
parents: 6812
diff changeset
  2758
  if (m_state.GetAssociations ().size () > 0)
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2759
    {
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2760
      SendHna ();
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2761
    }
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2762
  else
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2763
    {
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2764
      NS_LOG_DEBUG ("Not sending any HNA, no associations to advertise.");
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2765
    }
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2766
  m_hnaTimer.Schedule (m_hnaInterval);
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2767
}
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2768
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2769
///
1765
763f8d1bb058 Adapt the OLSR agent code to use the new Timer class.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1763
diff changeset
  2770
/// \brief Removes tuple if expired. Else timer is rescheduled to expire at tuple.expirationTime.
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2771
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2772
/// The task of actually removing the tuple is left to the OLSR agent.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2773
///
1765
763f8d1bb058 Adapt the OLSR agent code to use the new Timer class.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1763
diff changeset
  2774
/// \param tuple The tuple which has expired.
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2775
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2776
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2777
RoutingProtocol::DupTupleTimerExpire (Ipv4Address address, uint16_t sequenceNumber)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2778
{
2329
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2779
  DuplicateTuple *tuple =
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  2780
    m_state.FindDuplicateTuple (address, sequenceNumber);
2329
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2781
  if (tuple == NULL)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2782
    {
2329
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2783
      return;
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2784
    }
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2785
  if (tuple->expirationTime < Simulator::Now ())
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2786
    {
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2787
      RemoveDuplicateTuple (*tuple);
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2788
    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2789
  else
1765
763f8d1bb058 Adapt the OLSR agent code to use the new Timer class.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1763
diff changeset
  2790
    {
2329
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2791
      m_events.Track (Simulator::Schedule (DELAY (tuple->expirationTime),
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2792
                                           &RoutingProtocol::DupTupleTimerExpire, this,
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  2793
                                           address, sequenceNumber));
1765
763f8d1bb058 Adapt the OLSR agent code to use the new Timer class.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1763
diff changeset
  2794
    }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2795
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2796
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2797
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2798
/// \brief Removes tuple_ if expired. Else if symmetric time
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2799
/// has expired then it is assumed a neighbor loss and agent_->nb_loss()
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2800
/// is called. In this case the timer is rescheduled to expire at
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2801
/// tuple_->time(). Otherwise the timer is rescheduled to expire at
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2802
/// the minimum between tuple_->time() and tuple_->sym_time().
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2803
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2804
/// The task of actually removing the tuple is left to the OLSR agent.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2805
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2806
/// \param e The event which has expired.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2807
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2808
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2809
RoutingProtocol::LinkTupleTimerExpire (Ipv4Address neighborIfaceAddr)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2810
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2811
  Time now = Simulator::Now ();
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2812
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2813
  // the tuple parameter may be a stale copy; get a newer version from m_state
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  2814
  LinkTuple *tuple = m_state.FindLinkTuple (neighborIfaceAddr);
2329
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2815
  if (tuple == NULL)
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2816
    {
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2817
      return;
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2818
    }
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2819
  if (tuple->time < now)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2820
    {
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2821
      RemoveLinkTuple (*tuple);
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2822
    }
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2823
  else if (tuple->symTime < now)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2824
    {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2825
      if (m_linkTupleTimerFirstTime)
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2826
        m_linkTupleTimerFirstTime = false;
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2827
      else
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2828
        NeighborLoss (*tuple);
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2829
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2830
      m_events.Track (Simulator::Schedule (DELAY (tuple->time),
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2831
                                           &RoutingProtocol::LinkTupleTimerExpire, this,
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  2832
                                           neighborIfaceAddr));
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2833
    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2834
  else
1765
763f8d1bb058 Adapt the OLSR agent code to use the new Timer class.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1763
diff changeset
  2835
    {
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2836
      m_events.Track (Simulator::Schedule (DELAY (std::min (tuple->time, tuple->symTime)),
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2837
                                           &RoutingProtocol::LinkTupleTimerExpire, this,
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  2838
                                           neighborIfaceAddr));
1765
763f8d1bb058 Adapt the OLSR agent code to use the new Timer class.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1763
diff changeset
  2839
    }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2840
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2841
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2842
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2843
/// \brief Removes tuple_ if expired. Else the timer is rescheduled to expire at tuple_->time().
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2844
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2845
/// The task of actually removing the tuple is left to the OLSR agent.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2846
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2847
/// \param e The event which has expired.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2848
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2849
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2850
RoutingProtocol::Nb2hopTupleTimerExpire (Ipv4Address neighborMainAddr, Ipv4Address twoHopNeighborAddr)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2851
{
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2852
  TwoHopNeighborTuple *tuple;
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  2853
  tuple = m_state.FindTwoHopNeighborTuple (neighborMainAddr, twoHopNeighborAddr);
2329
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2854
  if (tuple == NULL)
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2855
    {
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2856
      return;
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2857
    }
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2858
  if (tuple->expirationTime < Simulator::Now ())
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2859
    {
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2860
      RemoveTwoHopNeighborTuple (*tuple);
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2861
    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2862
  else
1765
763f8d1bb058 Adapt the OLSR agent code to use the new Timer class.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1763
diff changeset
  2863
    {
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2864
      m_events.Track (Simulator::Schedule (DELAY (tuple->expirationTime),
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2865
                                           &RoutingProtocol::Nb2hopTupleTimerExpire,
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  2866
                                           this, neighborMainAddr, twoHopNeighborAddr));
1765
763f8d1bb058 Adapt the OLSR agent code to use the new Timer class.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1763
diff changeset
  2867
    }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2868
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2869
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2870
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2871
/// \brief Removes tuple_ if expired. Else the timer is rescheduled to expire at tuple_->time().
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2872
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2873
/// The task of actually removing the tuple is left to the OLSR agent.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2874
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2875
/// \param e The event which has expired.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2876
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2877
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2878
RoutingProtocol::MprSelTupleTimerExpire (Ipv4Address mainAddr)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2879
{
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  2880
  MprSelectorTuple *tuple = m_state.FindMprSelectorTuple (mainAddr);
2329
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2881
  if (tuple == NULL)
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2882
    {
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2883
      return;
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2884
    }
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2885
  if (tuple->expirationTime < Simulator::Now ())
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2886
    {
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2887
      RemoveMprSelectorTuple (*tuple);
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2888
    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2889
  else
1765
763f8d1bb058 Adapt the OLSR agent code to use the new Timer class.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1763
diff changeset
  2890
    {
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2891
      m_events.Track (Simulator::Schedule (DELAY (tuple->expirationTime),
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2892
                                           &RoutingProtocol::MprSelTupleTimerExpire,
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  2893
                                           this, mainAddr));
1765
763f8d1bb058 Adapt the OLSR agent code to use the new Timer class.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1763
diff changeset
  2894
    }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2895
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2896
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2897
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2898
/// \brief Removes tuple_ if expired. Else the timer is rescheduled to expire at tuple_->time().
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2899
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2900
/// The task of actually removing the tuple is left to the OLSR agent.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2901
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2902
/// \param e The event which has expired.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2903
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2904
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2905
RoutingProtocol::TopologyTupleTimerExpire (Ipv4Address destAddr, Ipv4Address lastAddr)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2906
{
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  2907
  TopologyTuple *tuple = m_state.FindTopologyTuple (destAddr, lastAddr);
2329
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2908
  if (tuple == NULL)
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2909
    {
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2910
      return;
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2911
    }
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2912
  if (tuple->expirationTime < Simulator::Now ())
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2913
    {
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2914
      RemoveTopologyTuple (*tuple);
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2915
    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2916
  else
1765
763f8d1bb058 Adapt the OLSR agent code to use the new Timer class.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1763
diff changeset
  2917
    {
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2918
      m_events.Track (Simulator::Schedule (DELAY (tuple->expirationTime),
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2919
                                           &RoutingProtocol::TopologyTupleTimerExpire,
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  2920
                                           this, tuple->destAddr, tuple->lastAddr));
1765
763f8d1bb058 Adapt the OLSR agent code to use the new Timer class.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1763
diff changeset
  2921
    }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2922
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2923
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2924
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2925
/// \brief Removes tuple_ if expired. Else timer is rescheduled to expire at tuple_->time().
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2926
/// \param e The event which has expired.
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2927
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2928
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2929
RoutingProtocol::IfaceAssocTupleTimerExpire (Ipv4Address ifaceAddr)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2930
{
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  2931
  IfaceAssocTuple *tuple = m_state.FindIfaceAssocTuple (ifaceAddr);
2329
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2932
  if (tuple == NULL)
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2933
    {
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2934
      return;
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2935
    }
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2936
  if (tuple->time < Simulator::Now ())
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2937
    {
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2938
      RemoveIfaceAssocTuple (*tuple);
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2939
    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2940
  else
1765
763f8d1bb058 Adapt the OLSR agent code to use the new Timer class.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1763
diff changeset
  2941
    {
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2942
      m_events.Track (Simulator::Schedule (DELAY (tuple->time),
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2943
                                           &RoutingProtocol::IfaceAssocTupleTimerExpire,
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  2944
                                           this, ifaceAddr));
1765
763f8d1bb058 Adapt the OLSR agent code to use the new Timer class.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1763
diff changeset
  2945
    }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2946
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2947
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2948
/// \brief Removes tuple_ if expired. Else timer is rescheduled to expire at tuple_->time().
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2949
/// \param e The event which has expired.
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2950
///
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2951
void
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2952
RoutingProtocol::AssociationTupleTimerExpire (Ipv4Address gatewayAddr, Ipv4Address networkAddr, Ipv4Mask netmask)
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2953
{
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2954
  AssociationTuple *tuple = m_state.FindAssociationTuple (gatewayAddr, networkAddr, netmask);
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2955
  if (tuple == NULL)
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2956
    {
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2957
      return;
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2958
    }
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2959
  if (tuple->expirationTime < Simulator::Now ())
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2960
    {
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2961
      RemoveAssociationTuple (*tuple);
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2962
    }
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2963
  else
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2964
    {
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2965
      m_events.Track (Simulator::Schedule (DELAY (tuple->expirationTime),
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2966
                                           &RoutingProtocol::AssociationTupleTimerExpire,
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2967
                                           this, gatewayAddr, networkAddr, netmask));
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2968
    }
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2969
}
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2970
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2971
///
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2972
/// \brief Clears the routing table and frees the memory assigned to each one of its entries.
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2973
///
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2974
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2975
RoutingProtocol::Clear ()
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2976
{
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2977
  NS_LOG_FUNCTION_NOARGS ();
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2978
  m_table.clear ();
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2979
}
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2980
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2981
///
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2982
/// \brief Deletes the entry whose destination address is given.
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2983
/// \param dest	address of the destination node.
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2984
///
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2985
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2986
RoutingProtocol::RemoveEntry (Ipv4Address const &dest)
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2987
{
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2988
  m_table.erase (dest);
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2989
}
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2990
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2991
///
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2992
/// \brief Looks up an entry for the specified destination address.
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2993
/// \param dest	destination address.
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2994
/// \param outEntry output parameter to hold the routing entry result, if fuond
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2995
/// \return	true if found, false if not found
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2996
///
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2997
bool
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2998
RoutingProtocol::Lookup (Ipv4Address const &dest,
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  2999
                         RoutingTableEntry &outEntry) const
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3000
{
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3001
  // Get the iterator at "dest" position
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3002
  std::map<Ipv4Address, RoutingTableEntry>::const_iterator it =
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3003
    m_table.find (dest);
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3004
  // If there is no route to "dest", return NULL
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3005
  if (it == m_table.end ())
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3006
    return false;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3007
  outEntry = it->second;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3008
  return true;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3009
}
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3010
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3011
///
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3012
/// \brief	Finds the appropiate entry which must be used in order to forward
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3013
///		a data packet to a next hop (given a destination).
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3014
///
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3015
/// Imagine a routing table like this: [A,B] [B,C] [C,C]; being each pair of the
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3016
/// form [dest addr,next-hop addr]. In this case, if this function is invoked with
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3017
/// [A,B] then pair [C,C] is returned because C is the next hop that must be used
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3018
/// to forward a data packet destined to A. That is, C is a neighbor of this node,
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3019
/// but B isn't. This function finds the appropiate neighbor for forwarding a packet.
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3020
///
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3021
/// \param entry	the routing table entry which indicates the destination node
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3022
///			we are interested in.
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3023
/// \return		the appropiate routing table entry which indicates the next
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3024
///			hop which must be used for forwarding a data packet, or NULL
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3025
///			if there is no such entry.
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3026
///
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3027
bool
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  3028
RoutingProtocol::FindSendEntry (RoutingTableEntry const &entry,
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3029
                                RoutingTableEntry &outEntry) const
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3030
{
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3031
  outEntry = entry;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3032
  while (outEntry.destAddr != outEntry.nextAddr)
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3033
    {
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3034
      if (not Lookup(outEntry.nextAddr, outEntry))
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3035
        return false;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3036
    }
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3037
  return true;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3038
}
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3039
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3040
Ptr<Ipv4Route>
5856
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5772
diff changeset
  3041
RoutingProtocol::RouteOutput (Ptr<Packet> p, const Ipv4Header &header, Ptr<NetDevice> oif, Socket::SocketErrno &sockerr)
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3042
{
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3043
  NS_LOG_FUNCTION (this << " " << m_ipv4->GetObject<Node> ()->GetId() << " " << header.GetDestination () << " " << oif);
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3044
  Ptr<Ipv4Route> rtentry;
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3045
  RoutingTableEntry entry1, entry2;
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  3046
  bool found = false;
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3047
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3048
  if (Lookup (header.GetDestination (), entry1) != 0)
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3049
    {
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3050
      bool foundSendEntry = FindSendEntry (entry1, entry2);
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3051
      if (!foundSendEntry)
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3052
        {
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3053
          NS_FATAL_ERROR ("FindSendEntry failure");
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3054
        }
5946
4fef76630d66 Bug 778 - OLSR ignores specified outgoing interface in RouteOutput()
Tom Henderson <tomh@tomh.org>
parents: 5932
diff changeset
  3055
      uint32_t interfaceIdx = entry2.interface;
4fef76630d66 Bug 778 - OLSR ignores specified outgoing interface in RouteOutput()
Tom Henderson <tomh@tomh.org>
parents: 5932
diff changeset
  3056
      if (oif && m_ipv4->GetInterfaceForDevice (oif) != static_cast<int> (interfaceIdx))
4fef76630d66 Bug 778 - OLSR ignores specified outgoing interface in RouteOutput()
Tom Henderson <tomh@tomh.org>
parents: 5932
diff changeset
  3057
        {
4fef76630d66 Bug 778 - OLSR ignores specified outgoing interface in RouteOutput()
Tom Henderson <tomh@tomh.org>
parents: 5932
diff changeset
  3058
          // We do not attempt to perform a constrained routing search
4fef76630d66 Bug 778 - OLSR ignores specified outgoing interface in RouteOutput()
Tom Henderson <tomh@tomh.org>
parents: 5932
diff changeset
  3059
          // if the caller specifies the oif; we just enforce that 
4fef76630d66 Bug 778 - OLSR ignores specified outgoing interface in RouteOutput()
Tom Henderson <tomh@tomh.org>
parents: 5932
diff changeset
  3060
          // that the found route matches the requested outbound interface 
4fef76630d66 Bug 778 - OLSR ignores specified outgoing interface in RouteOutput()
Tom Henderson <tomh@tomh.org>
parents: 5932
diff changeset
  3061
          NS_LOG_DEBUG ("Olsr node " << m_mainAddress 
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3062
                                     << ": RouteOutput for dest=" << header.GetDestination ()
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3063
                                     << " Route interface " << interfaceIdx
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3064
                                     << " does not match requested output interface "
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3065
                                     << m_ipv4->GetInterfaceForDevice (oif));
5946
4fef76630d66 Bug 778 - OLSR ignores specified outgoing interface in RouteOutput()
Tom Henderson <tomh@tomh.org>
parents: 5932
diff changeset
  3066
          sockerr = Socket::ERROR_NOROUTETOHOST;
4fef76630d66 Bug 778 - OLSR ignores specified outgoing interface in RouteOutput()
Tom Henderson <tomh@tomh.org>
parents: 5932
diff changeset
  3067
          return rtentry;
4fef76630d66 Bug 778 - OLSR ignores specified outgoing interface in RouteOutput()
Tom Henderson <tomh@tomh.org>
parents: 5932
diff changeset
  3068
        }
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3069
      rtentry = Create<Ipv4Route> ();
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3070
      rtentry->SetDestination (header.GetDestination ());
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3071
      // the source address is the interface address that matches
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3072
      // the destination address (when multiple are present on the 
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3073
      // outgoing interface, one is selected via scoping rules)
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3074
      NS_ASSERT (m_ipv4);
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3075
      uint32_t numOifAddresses = m_ipv4->GetNAddresses (interfaceIdx);
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3076
      NS_ASSERT (numOifAddresses > 0);
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3077
      Ipv4InterfaceAddress ifAddr;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3078
      if (numOifAddresses == 1) {
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3079
          ifAddr = m_ipv4->GetAddress (interfaceIdx, 0);
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3080
        } else {
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3081
          NS_FATAL_ERROR ("XXX Not implemented yet:  IP aliasing and OLSR");
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3082
        }
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3083
      rtentry->SetSource (ifAddr.GetLocal ());
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3084
      rtentry->SetGateway (entry2.nextAddr);
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3085
      rtentry->SetOutputDevice (m_ipv4->GetNetDevice (interfaceIdx));
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3086
      sockerr = Socket::ERROR_NOTERROR;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3087
      NS_LOG_DEBUG ("Olsr node " << m_mainAddress 
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3088
                                 << ": RouteOutput for dest=" << header.GetDestination ()
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3089
                                 << " --> nextHop=" << entry2.nextAddr
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3090
                                 << " interface=" << entry2.interface);
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  3091
      NS_LOG_DEBUG ("Found route to " << rtentry->GetDestination () << " via nh " << rtentry->GetGateway () << " with source addr " << rtentry->GetSource () << " and output dev " << rtentry->GetOutputDevice());
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  3092
      found = true;
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3093
    }
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3094
  else
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3095
    { 
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  3096
      rtentry = m_hnaRoutingTable->RouteOutput (p, header, oif, sockerr);
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3097
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  3098
      if (rtentry)
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  3099
        {
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  3100
          found = true;
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  3101
          NS_LOG_DEBUG ("Found route to " << rtentry->GetDestination () << " via nh " << rtentry->GetGateway () << " with source addr " << rtentry->GetSource () << " and output dev " << rtentry->GetOutputDevice());
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  3102
        }
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  3103
    }
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3104
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  3105
  if (!found)
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  3106
    {
5867
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3107
      NS_LOG_DEBUG ("Olsr node " << m_mainAddress 
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3108
                                 << ": RouteOutput for dest=" << header.GetDestination ()
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3109
                                 << " No route to host");
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3110
      sockerr = Socket::ERROR_NOROUTETOHOST;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3111
    }
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3112
  return rtentry;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3113
}
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3114
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3115
bool RoutingProtocol::RouteInput  (Ptr<const Packet> p, 
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3116
                                   const Ipv4Header &header, Ptr<const NetDevice> idev,
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3117
                                   UnicastForwardCallback ucb, MulticastForwardCallback mcb,
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3118
                                   LocalDeliverCallback lcb, ErrorCallback ecb)
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3119
{
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3120
  NS_LOG_FUNCTION (this << " " << m_ipv4->GetObject<Node> ()->GetId() << " " << header.GetDestination ());
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3121
5761
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3122
  Ipv4Address dst = header.GetDestination ();
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3123
  Ipv4Address origin = header.GetSource ();
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3124
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3125
  // Consume self-originated packets
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3126
  if (IsMyOwnAddress (origin) == true)
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3127
    {
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3128
      return true; 
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3129
    }
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3130
5761
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3131
  // Local delivery
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3132
  NS_ASSERT (m_ipv4->GetInterfaceForDevice (idev) >= 0);
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3133
  uint32_t iif = m_ipv4->GetInterfaceForDevice (idev);
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3134
  if (m_ipv4->IsDestinationAddress (dst, iif))
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3135
    {
6324
e56ec0532fec Bug 926 - olsr handling of multicast packets
Ken Renard <kenneth.renard@arl.army.mil>
parents: 6303
diff changeset
  3136
      if (!lcb.IsNull ())
e56ec0532fec Bug 926 - olsr handling of multicast packets
Ken Renard <kenneth.renard@arl.army.mil>
parents: 6303
diff changeset
  3137
        {
e56ec0532fec Bug 926 - olsr handling of multicast packets
Ken Renard <kenneth.renard@arl.army.mil>
parents: 6303
diff changeset
  3138
          NS_LOG_LOGIC ("Local delivery to " << dst);
e56ec0532fec Bug 926 - olsr handling of multicast packets
Ken Renard <kenneth.renard@arl.army.mil>
parents: 6303
diff changeset
  3139
          lcb (p, header, iif);
e56ec0532fec Bug 926 - olsr handling of multicast packets
Ken Renard <kenneth.renard@arl.army.mil>
parents: 6303
diff changeset
  3140
          return true;
e56ec0532fec Bug 926 - olsr handling of multicast packets
Ken Renard <kenneth.renard@arl.army.mil>
parents: 6303
diff changeset
  3141
        }
e56ec0532fec Bug 926 - olsr handling of multicast packets
Ken Renard <kenneth.renard@arl.army.mil>
parents: 6303
diff changeset
  3142
      else
e56ec0532fec Bug 926 - olsr handling of multicast packets
Ken Renard <kenneth.renard@arl.army.mil>
parents: 6303
diff changeset
  3143
        {
e56ec0532fec Bug 926 - olsr handling of multicast packets
Ken Renard <kenneth.renard@arl.army.mil>
parents: 6303
diff changeset
  3144
          // The local delivery callback is null.  This may be a multicast
e56ec0532fec Bug 926 - olsr handling of multicast packets
Ken Renard <kenneth.renard@arl.army.mil>
parents: 6303
diff changeset
  3145
          // or broadcast packet, so return false so that another 
e56ec0532fec Bug 926 - olsr handling of multicast packets
Ken Renard <kenneth.renard@arl.army.mil>
parents: 6303
diff changeset
  3146
          // multicast routing protocol can handle it.  It should be possible
e56ec0532fec Bug 926 - olsr handling of multicast packets
Ken Renard <kenneth.renard@arl.army.mil>
parents: 6303
diff changeset
  3147
          // to extend this to explicitly check whether it is a unicast
e56ec0532fec Bug 926 - olsr handling of multicast packets
Ken Renard <kenneth.renard@arl.army.mil>
parents: 6303
diff changeset
  3148
          // packet, and invoke the error callback if so
e56ec0532fec Bug 926 - olsr handling of multicast packets
Ken Renard <kenneth.renard@arl.army.mil>
parents: 6303
diff changeset
  3149
          return false;
e56ec0532fec Bug 926 - olsr handling of multicast packets
Ken Renard <kenneth.renard@arl.army.mil>
parents: 6303
diff changeset
  3150
        }
5761
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3151
    }
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3152
5761
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3153
  // Forwarding
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3154
  Ptr<Ipv4Route> rtentry;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3155
  RoutingTableEntry entry1, entry2; 
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3156
  if (Lookup (header.GetDestination (), entry1))
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3157
    { 
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3158
      bool foundSendEntry = FindSendEntry (entry1, entry2);
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3159
      if (!foundSendEntry)
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3160
        NS_FATAL_ERROR ("FindSendEntry failure");
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3161
      rtentry = Create<Ipv4Route> ();
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3162
      rtentry->SetDestination (header.GetDestination ());
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3163
      uint32_t interfaceIdx = entry2.interface;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3164
      // the source address is the interface address that matches
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3165
      // the destination address (when multiple are present on the
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3166
      // outgoing interface, one is selected via scoping rules)
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3167
      NS_ASSERT (m_ipv4);
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3168
      uint32_t numOifAddresses = m_ipv4->GetNAddresses (interfaceIdx);
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3169
      NS_ASSERT (numOifAddresses > 0);
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3170
      Ipv4InterfaceAddress ifAddr;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3171
      if (numOifAddresses == 1) {
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3172
          ifAddr = m_ipv4->GetAddress (interfaceIdx, 0);
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3173
        } else {
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3174
          NS_FATAL_ERROR ("XXX Not implemented yet:  IP aliasing and OLSR");
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3175
        }
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3176
      rtentry->SetSource (ifAddr.GetLocal ());
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3177
      rtentry->SetGateway (entry2.nextAddr);
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3178
      rtentry->SetOutputDevice (m_ipv4->GetNetDevice (interfaceIdx));
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3179
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3180
      NS_LOG_DEBUG ("Olsr node " << m_mainAddress
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3181
                                 << ": RouteInput for dest=" << header.GetDestination ()
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3182
                                 << " --> nextHop=" << entry2.nextAddr
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3183
                                 << " interface=" << entry2.interface);
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3184
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3185
      ucb (rtentry, p, header);
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3186
      return true;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3187
    }
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3188
  else
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3189
    {
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  3190
      if(m_hnaRoutingTable->RouteInput (p, header, idev, ucb, mcb, lcb, ecb))
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  3191
        {
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  3192
          return true;
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  3193
        }
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  3194
      else
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  3195
        {
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3196
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3197
#ifdef NS3_LOG_ENABLE
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  3198
          NS_LOG_DEBUG ("Olsr node " << m_mainAddress 
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3199
                                     << ": RouteInput for dest=" << header.GetDestination ()
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3200
                                     << " --> NOT FOUND; ** Dumping routing table...");
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3201
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  3202
          for (std::map<Ipv4Address, RoutingTableEntry>::const_iterator iter = m_table.begin ();
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3203
               iter != m_table.end (); iter++)
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3204
            {
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3205
              NS_LOG_DEBUG ("dest=" << iter->first << " --> next=" << iter->second.nextAddr
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3206
                                    << " via interface " << iter->second.interface);
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3207
            }
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3208
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  3209
          NS_LOG_DEBUG ("** Routing table dump end.");
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  3210
#endif // NS3_LOG_ENABLE
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  3211
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  3212
          return false;
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3213
        }
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3214
    }
3853
f04e7f61b1ed Make olsr::RoutingTable public, add a method GetEntries to it, and add a method GetRoutingTable to OlsrAgent. This way it is possible to read the actual routing table that OLSR has discovered, for debugging/visualization purposes.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3487
diff changeset
  3215
}
4560
2f106fd728ab Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4472
diff changeset
  3216
void 
2f106fd728ab Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4472
diff changeset
  3217
RoutingProtocol::NotifyInterfaceUp (uint32_t i)
2f106fd728ab Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4472
diff changeset
  3218
{}
2f106fd728ab Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4472
diff changeset
  3219
void 
2f106fd728ab Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4472
diff changeset
  3220
RoutingProtocol::NotifyInterfaceDown (uint32_t i)
2f106fd728ab Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4472
diff changeset
  3221
{}
2f106fd728ab Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4472
diff changeset
  3222
void 
2f106fd728ab Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4472
diff changeset
  3223
RoutingProtocol::NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress address)
2f106fd728ab Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4472
diff changeset
  3224
{}
2f106fd728ab Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4472
diff changeset
  3225
void 
2f106fd728ab Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4472
diff changeset
  3226
RoutingProtocol::NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress address)
2f106fd728ab Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4472
diff changeset
  3227
{}
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  3228
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3229
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3230
///
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3231
/// \brief Adds a new entry into the routing table.
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3232
///
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3233
/// If an entry for the given destination existed, it is deleted and freed.
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3234
///
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3235
/// \param dest		address of the destination node.
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3236
/// \param next		address of the next hop node.
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3237
/// \param iface	address of the local interface.
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3238
/// \param dist		distance to the destination node.
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3239
///
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3240
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  3241
RoutingProtocol::AddEntry (Ipv4Address const &dest,
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3242
                           Ipv4Address const &next,
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3243
                           uint32_t interface,
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3244
                           uint32_t distance)
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3245
{
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3246
  NS_LOG_FUNCTION (this << dest << next << interface << distance << m_mainAddress);
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3247
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3248
  NS_ASSERT (distance > 0);
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3249
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3250
  // Creates a new rt entry with specified values
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3251
  RoutingTableEntry &entry = m_table[dest];
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3252
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3253
  entry.destAddr = dest;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3254
  entry.nextAddr = next;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3255
  entry.interface = interface;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3256
  entry.distance = distance;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3257
}
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3258
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3259
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  3260
RoutingProtocol::AddEntry (Ipv4Address const &dest,
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3261
                           Ipv4Address const &next,
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3262
                           Ipv4Address const &interfaceAddress,
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3263
                           uint32_t distance)
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3264
{
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3265
  NS_LOG_FUNCTION (this << dest << next << interfaceAddress << distance << m_mainAddress);
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3266
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3267
  NS_ASSERT (distance > 0);
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3268
  NS_ASSERT (m_ipv4);
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3269
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3270
  RoutingTableEntry entry;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3271
  for (uint32_t i = 0; i < m_ipv4->GetNInterfaces (); i++)
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3272
    {
4380
bbbc2e622f50 fix merge issues
Tom Henderson <tomh@tomh.org>
parents: 4379
diff changeset
  3273
      for (uint32_t j = 0; j < m_ipv4->GetNAddresses (i); j++)
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3274
        {
4380
bbbc2e622f50 fix merge issues
Tom Henderson <tomh@tomh.org>
parents: 4379
diff changeset
  3275
          if (m_ipv4->GetAddress (i,j).GetLocal () == interfaceAddress)
bbbc2e622f50 fix merge issues
Tom Henderson <tomh@tomh.org>
parents: 4379
diff changeset
  3276
            {
bbbc2e622f50 fix merge issues
Tom Henderson <tomh@tomh.org>
parents: 4379
diff changeset
  3277
              AddEntry (dest, next, i, distance);
bbbc2e622f50 fix merge issues
Tom Henderson <tomh@tomh.org>
parents: 4379
diff changeset
  3278
              return;
bbbc2e622f50 fix merge issues
Tom Henderson <tomh@tomh.org>
parents: 4379
diff changeset
  3279
            }
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3280
        }
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3281
    }
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3282
  NS_ASSERT (false); // should not be reached
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3283
  AddEntry (dest, next, 0, distance);
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3284
}
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3285
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3286
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3287
std::vector<RoutingTableEntry>
5985
42d6f24bd0f4 New API olsr::RoutingProtocol::GetRoutingTableEntries ()
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5946
diff changeset
  3288
RoutingProtocol::GetRoutingTableEntries () const
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3289
{
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3290
  std::vector<RoutingTableEntry> retval;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3291
  for (std::map<Ipv4Address, RoutingTableEntry>::const_iterator iter = m_table.begin ();
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3292
       iter != m_table.end (); iter++)
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3293
    {
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3294
      retval.push_back (iter->second);
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3295
    }
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3296
  return retval;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3297
}
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3298
5761
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3299
bool
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3300
RoutingProtocol::IsMyOwnAddress (const Ipv4Address & a) const
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3301
{
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3302
  for (std::map<Ptr<Socket>, Ipv4InterfaceAddress>::const_iterator j =
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3303
         m_socketAddresses.begin (); j != m_socketAddresses.end (); ++j)
5761
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3304
    {
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3305
      Ipv4InterfaceAddress iface = j->second;
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3306
      if (a == iface.GetLocal ())
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3307
        {
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3308
          return true;
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3309
        }
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3310
    }
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3311
  return false;
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3312
}
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3313
5867
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3314
void
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3315
RoutingProtocol::Dump (void)
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3316
{
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3317
  Time now = Simulator::Now ();
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3318
5867
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3319
#ifdef NS3_LOG_ENABLE
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3320
  NS_LOG_DEBUG ("Dumping for node with main address " << m_mainAddress);
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3321
  NS_LOG_DEBUG (" Neighbor set");
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3322
  for (NeighborSet::const_iterator iter = m_state.GetNeighbors ().begin ();
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3323
       iter != m_state.GetNeighbors ().end (); iter++)
5867
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3324
    {
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3325
      NS_LOG_DEBUG ("  " << *iter);
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3326
    }
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3327
  NS_LOG_DEBUG (" Two-hop neighbor set");
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3328
  for (TwoHopNeighborSet::const_iterator iter = m_state.GetTwoHopNeighbors ().begin ();
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3329
       iter != m_state.GetTwoHopNeighbors ().end (); iter++)
5867
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3330
    {
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3331
      if (now < iter->expirationTime)
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3332
        { 
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3333
          NS_LOG_DEBUG ("  " << *iter);
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3334
        }
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3335
    }
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3336
  NS_LOG_DEBUG (" Routing table");
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3337
  for (std::map<Ipv4Address, RoutingTableEntry>::const_iterator iter = m_table.begin (); iter != m_table.end (); iter++)
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3338
    {
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3339
      NS_LOG_DEBUG ("  dest=" << iter->first << " --> next=" << iter->second.nextAddr << " via interface " << iter->second.interface);
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3340
    }
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3341
  NS_LOG_DEBUG ("");
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3342
#endif  //NS3_LOG_ENABLE
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3343
}
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3344
7184
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3345
}
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3346
}  // namespace olsr, ns3
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3347
a15feb312428 olsr coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7045
diff changeset
  3348