src/routing/olsr/olsr-routing-protocol.cc
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Mon, 23 Mar 2009 14:37:43 +0100
changeset 4364 579bbfe8bb65
parent 4362 src/routing/olsr/olsr-agent-impl.cc@9e9c734b927e
child 4365 f71fd5bfc4ad
permissions -rw-r--r--
rename
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"
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    41
#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
    42
#include "ns3/inet-socket-address.h"
2484
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2308
diff changeset
    43
#include "ns3/boolean.h"
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2308
diff changeset
    44
#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
    45
#include "ns3/enum.h"
2484
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2308
diff changeset
    46
#include "ns3/trace-source-accessor.h"
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
    47
#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
    48
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    49
/********** 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
    50
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    51
///
9757633a85da Add OLSR routing support, (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
/// \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
    53
///
9757633a85da Add OLSR routing support, (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
/// 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
    55
/// 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
    56
///
9757633a85da Add OLSR routing support, (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
#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
    58
                     (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
    59
9757633a85da Add OLSR routing support, (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
9757633a85da Add OLSR routing support, (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
///
9757633a85da Add OLSR routing support, (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
/// \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
    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
/// 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
    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
#define OLSR_REFRESH_INTERVAL	Seconds (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
    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
9757633a85da Add OLSR routing support, (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
/********** 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
    71
9757633a85da Add OLSR routing support, (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
/// Neighbor holding 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
    73
#define OLSR_NEIGHB_HOLD_TIME	(Scalar (3) * OLSR_REFRESH_INTERVAL)
9757633a85da Add OLSR routing support, (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
/// Top holding time.
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
    75
#define OLSR_TOP_HOLD_TIME	(Scalar (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
    76
/// Dup holding 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
    77
#define OLSR_DUP_HOLD_TIME	Seconds (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
    78
/// MID holding time.
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
    79
#define OLSR_MID_HOLD_TIME	(Scalar (3) * 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
    80
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    81
9757633a85da Add OLSR routing support, (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
/********** 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
    83
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    84
/// Unspecified link 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
    85
#define OLSR_UNSPEC_LINK	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
    86
/// Asymmetric link 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
    87
#define OLSR_ASYM_LINK		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
    88
/// Symmetric link 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
    89
#define OLSR_SYM_LINK		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
    90
/// Lost link 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
    91
#define OLSR_LOST_LINK		3
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    92
9757633a85da Add OLSR routing support, (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
/********** 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
    94
9757633a85da Add OLSR routing support, (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
/// Not 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
    96
#define OLSR_NOT_NEIGH		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
    97
/// Symmetric 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
    98
#define OLSR_SYM_NEIGH		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
    99
/// Asymmetric 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
   100
#define OLSR_MPR_NEIGH		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
   101
9757633a85da Add OLSR routing support, (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
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   103
/********** 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
   104
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   105
/// Willingness for forwarding packets from other nodes: 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
   106
#define OLSR_WILL_NEVER		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
   107
/// Willingness for forwarding packets from other nodes: low.
9757633a85da Add OLSR routing support, (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
#define OLSR_WILL_LOW		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
   109
/// Willingness for forwarding packets from other nodes: medium.
9757633a85da Add OLSR routing support, (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
#define OLSR_WILL_DEFAULT	3
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   111
/// Willingness for forwarding packets from other nodes: high.
9757633a85da Add OLSR routing support, (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
#define OLSR_WILL_HIGH		6
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   113
/// Willingness for forwarding packets from other nodes: always.
9757633a85da Add OLSR routing support, (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
#define OLSR_WILL_ALWAYS	7
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   115
9757633a85da Add OLSR routing support, (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
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   117
/********** 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
   118
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   119
/// Maximum allowed jitter.
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
   120
#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
   121
/// Maximum allowed sequence number.
9757633a85da Add OLSR routing support, (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
#define OLSR_MAX_SEQ_NUM	65535
9757633a85da Add OLSR routing support, (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
/// 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
   124
#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
   125
9757633a85da Add OLSR routing support, (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
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   127
#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
   128
/// Maximum number of messages per 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
   129
#define OLSR_MAX_MSGS		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
   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
/// Maximum number of hellos per message (4 possible link types * 3 possible nb 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
   132
#define OLSR_MAX_HELLOS		12
9757633a85da Add OLSR routing support, (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
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   134
/// Maximum number of addresses advertised on a 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
   135
#define OLSR_MAX_ADDRS		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
   136
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   137
9757633a85da Add OLSR routing support, (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
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
   139
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
   140
1804
9c11e776f501 bug 96: debug.h duplicates functionality from log.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1803
diff changeset
   141
NS_LOG_COMPONENT_DEFINE ("OlsrAgent");
1716
9757633a85da Add OLSR routing support, (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
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   144
/********** 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
   145
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   146
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
   147
2250
18f432098389 InterfaceId -> TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2249
diff changeset
   148
TypeId 
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   149
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
   150
{
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   151
  static TypeId tid = TypeId ("ns3::olsr::RoutingProtocol")
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
   152
    .SetParent<Ipv4RoutingProtocol> ()
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   153
    .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
   154
    .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
   155
                   TimeValue (Seconds (2)),
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   156
                   MakeTimeAccessor (&RoutingProtocol::m_helloInterval),
2484
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2308
diff changeset
   157
                   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
   158
    .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
   159
                   TimeValue (Seconds (5)),
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   160
                   MakeTimeAccessor (&RoutingProtocol::m_tcInterval),
2484
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2308
diff changeset
   161
                   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
   162
    .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
   163
                   TimeValue (Seconds (5)),
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   164
                   MakeTimeAccessor (&RoutingProtocol::m_midInterval),
2484
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2308
diff changeset
   165
                   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
   166
    .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
   167
                   EnumValue (OLSR_WILL_DEFAULT),
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   168
                   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
   169
                   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
   170
                                    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
   171
                                    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
   172
                                    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
   173
                                    OLSR_WILL_ALWAYS, "always"))
2484
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2308
diff changeset
   174
    .AddTraceSource ("Rx", "Receive OLSR packet.",
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   175
                     MakeTraceSourceAccessor (&RoutingProtocol::m_rxPacketTrace))
2484
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2308
diff changeset
   176
    .AddTraceSource ("Tx", "Send OLSR packet.",
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   177
                     MakeTraceSourceAccessor (&RoutingProtocol::m_txPacketTrace))
2503
e667dc0f350e merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2334 2484
diff changeset
   178
    .AddTraceSource ("RoutingTableChanged", "The OLSR routing table has changed.",
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   179
		     MakeTraceSourceAccessor (&RoutingProtocol::m_routingTableChanged))
2484
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2308
diff changeset
   180
    ;
2252
80595448707a iid -> tid
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
   181
  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
   182
}
3a1da26d61dc replace ComponentManager::Create and ClassId with InterfaceId::CreateObjest and InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2232
diff changeset
   183
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   184
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   185
RoutingProtocol::RoutingProtocol ()
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   186
  :
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
   187
  m_helloTimer (Timer::CANCEL_ON_DESTROY),
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
   188
  m_tcTimer (Timer::CANCEL_ON_DESTROY),
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
   189
  m_midTimer (Timer::CANCEL_ON_DESTROY)
2484
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2308
diff changeset
   190
{}
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2308
diff changeset
   191
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   192
RoutingProtocol::~RoutingProtocol ()
2900
b5deaba7280e add destructor. Easier to plant a breakpoint in there.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2827
diff changeset
   193
{}
b5deaba7280e add destructor. Easier to plant a breakpoint in there.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2827
diff changeset
   194
2484
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2308
diff changeset
   195
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   196
RoutingProtocol::SetNode (Ptr<Node> node)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   197
{
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   198
  NS_LOG_DEBUG ("Created olsr::RoutingProtocol");
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   199
  m_helloTimer.SetFunction (&RoutingProtocol::HelloTimerExpire, this);
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   200
  m_tcTimer.SetFunction (&RoutingProtocol::TcTimerExpire, this);
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   201
  m_midTimer.SetFunction (&RoutingProtocol::MidTimerExpire, this);
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   202
  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
   203
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   204
  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
   205
  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
   206
  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
   207
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   208
  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
   209
2257
71a58e70c671 QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   210
  m_ipv4 = node->GetObject<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
   211
  NS_ASSERT (m_ipv4);
9757633a85da Add OLSR routing support, (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
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   213
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   214
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
   215
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   216
  m_ipv4 = 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
   217
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   218
  for (std::map< Ptr<Socket>, Ipv4Address >::iterator iter = m_socketAddresses.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
   219
       iter != m_socketAddresses.end (); iter++)
1779
85fd2b8c9e76 Fix OLSR agent finalization issues.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1778
diff changeset
   220
    {
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
   221
      iter->first->Close ();
1779
85fd2b8c9e76 Fix OLSR agent finalization issues.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1778
diff changeset
   222
    }
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
   223
  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
   224
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
   225
  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
   226
}
9757633a85da Add OLSR routing support, (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
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   228
void RoutingProtocol::Start ()
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   229
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   230
  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
   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
      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
   233
      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
   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
          Ipv4Address addr = m_ipv4->GetAddress (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
   236
          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
   237
            {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   238
              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
   239
              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
   240
            }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   241
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   242
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   243
      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
   244
    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   245
1804
9c11e776f501 bug 96: debug.h duplicates functionality from log.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1803
diff changeset
   246
  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
   247
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
   248
  Ipv4Address loopback ("127.0.0.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
   249
  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
   250
    {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   251
      Ipv4Address addr = m_ipv4->GetAddress (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
   252
      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
   253
        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
   254
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   255
      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
   256
        {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   257
          // 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
   258
          // 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
   259
          // 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
   260
          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
   261
          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
   262
          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
   263
          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
   264
          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
   265
        }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   266
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   267
      // 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
   268
      Ptr<Socket> socket = Socket::CreateSocket (GetObject<Node> (), 
3125
d2d8a36cfd23 s/ns3::Udp/ns3::UdpSocketFactory
Tom Henderson <tomh@tomh.org>
parents: 3116
diff changeset
   269
        UdpSocketFactory::GetTypeId()); 
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   270
      socket->SetRecvCallback (MakeCallback (&RoutingProtocol::RecvOlsr,  this));
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
   271
      if (socket->Bind (InetSocketAddress (addr, OLSR_PORT_NUMBER)))
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   272
        {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   273
          NS_FATAL_ERROR ("Failed to bind() OLSR receive socket");
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   274
        }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   275
      socket->Connect (InetSocketAddress (Ipv4Address (0xffffffff), OLSR_PORT_NUMBER));
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   276
      m_socketAddresses[socket] = 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
   277
    }
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
   278
b5ff7d8efe27 Adapt OLSR code to use SingleEvent instead of Timer, and EventCollector.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1716
diff changeset
   279
  HelloTimerExpire ();
b5ff7d8efe27 Adapt OLSR code to use SingleEvent instead of Timer, and EventCollector.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1716
diff changeset
   280
  TcTimerExpire ();
b5ff7d8efe27 Adapt OLSR code to use SingleEvent instead of Timer, and EventCollector.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1716
diff changeset
   281
  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
   282
1804
9c11e776f501 bug 96: debug.h duplicates functionality from log.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1803
diff changeset
   283
  NS_LOG_DEBUG ("OLSR on node " << m_mainAddress << " started");
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   284
}
9757633a85da Add OLSR routing support, (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
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   286
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
   287
{
9757633a85da Add OLSR routing support, (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
  m_mainAddress = m_ipv4->GetAddress (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
   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
//
9757633a85da Add OLSR routing support, (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
// \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
   294
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   295
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
   296
{
3098
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 2972
diff changeset
   297
  Ptr<Packet> receivedPacket;
3270
e01d2843b3a0 Change OLSR to use RecvFrom
Tom Henderson <tomh@tomh.org>
parents: 3269
diff changeset
   298
  Address sourceAddress;
e01d2843b3a0 Change OLSR to use RecvFrom
Tom Henderson <tomh@tomh.org>
parents: 3269
diff changeset
   299
  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
   300
1740
3d3168e8fef6 Update OLSR code to NS-3 API changes.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1732
diff changeset
   301
  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
   302
  Ipv4Address senderIfaceAddr = 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
   303
  Ipv4Address receiverIfaceAddr = m_socketAddresses[socket];
caa15068fb3b OLSR: code cleanup, more 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
  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
   305
  NS_LOG_DEBUG ("OLSR node " << m_mainAddress << " received a OLSR packet from "
caa15068fb3b OLSR: code cleanup, more 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
                << senderIfaceAddr << " to " << receiverIfaceAddr);
1740
3d3168e8fef6 Update OLSR code to NS-3 API changes.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1732
diff changeset
   307
  
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   308
  // 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
   309
  // 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
   310
  NS_ASSERT (inetSourceAddr.GetPort () == OLSR_PORT_NUMBER);
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   311
  
1868
06027fd6a68c olsr gets new packet
Craig Dowell <craigdo@ee.washington.edu>
parents: 1803
diff changeset
   312
  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
   313
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
   314
  olsr::PacketHeader olsrPacketHeader;
1868
06027fd6a68c olsr gets new packet
Craig Dowell <craigdo@ee.washington.edu>
parents: 1803
diff changeset
   315
  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
   316
  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
   317
  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
   318
4078e5efdfc6 Add OLSR message tracing, as discussed on ns-developers list.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1801
diff changeset
   319
  MessageList messages;
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   320
  
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   321
  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
   322
    {
1803
4078e5efdfc6 Add OLSR message tracing, as discussed on ns-developers list.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1801
diff changeset
   323
      MessageHeader messageHeader;
1868
06027fd6a68c olsr gets new packet
Craig Dowell <craigdo@ee.washington.edu>
parents: 1803
diff changeset
   324
      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
   325
        NS_ASSERT (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
   326
      
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
   327
      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
   328
1804
9c11e776f501 bug 96: debug.h duplicates functionality from log.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1803
diff changeset
   329
      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
   330
                << 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
   331
                << " 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
   332
                << " 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
   333
      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
   334
    }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   335
1803
4078e5efdfc6 Add OLSR message tracing, as discussed on ns-developers list.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1801
diff changeset
   336
  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
   337
4078e5efdfc6 Add OLSR message tracing, as discussed on ns-developers list.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1801
diff changeset
   338
  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
   339
       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
   340
    {
4078e5efdfc6 Add OLSR message tracing, as discussed on ns-developers list.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1801
diff changeset
   341
      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
   342
      // 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
   343
      // 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
   344
      // 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
   345
      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
   346
          || 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
   347
        {
1868
06027fd6a68c olsr gets new packet
Craig Dowell <craigdo@ee.washington.edu>
parents: 1803
diff changeset
   348
          packet->RemoveAtStart (messageHeader.GetSerializedSize ()
06027fd6a68c olsr gets new packet
Craig Dowell <craigdo@ee.washington.edu>
parents: 1803
diff changeset
   349
                                 - 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
   350
          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
   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
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   353
      // 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
   354
      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
   355
      DuplicateTuple *duplicated = m_state.FindDuplicateTuple
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   356
        (messageHeader.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
   357
         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
   358
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
   359
      // 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
   360
//       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
   361
//       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
   362
//       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
   363
//         {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   364
//           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
   365
//         }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   366
//       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
   367
//         {
caa15068fb3b OLSR: code cleanup, more 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
//           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
   369
//         }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   370
      
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   371
      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
   372
        {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   373
          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
   374
            {
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
   375
            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
   376
              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
   377
                            << "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
   378
                            << " 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
   379
              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
   380
              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
   381
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
   382
            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
   383
              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
   384
                            << "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
   385
                            << " 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
   386
              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
   387
              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
   388
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
   389
            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
   390
              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
   391
                            << "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
   392
                            <<  " 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
   393
              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
   394
              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
   395
9757633a85da Add OLSR routing support, (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
            default:
1804
9c11e776f501 bug 96: debug.h duplicates functionality from log.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1803
diff changeset
   397
              NS_LOG_DEBUG ("OLSR message 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
   398
                        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
   399
                        " not implemented");
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   400
            }
9757633a85da Add OLSR routing support, (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
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   402
      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
   403
        {
1804
9c11e776f501 bug 96: debug.h duplicates functionality from log.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1803
diff changeset
   404
          NS_LOG_DEBUG ("OLSR message is duplicated, not reading 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
   405
      
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   406
          // 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
   407
          // 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
   408
          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
   409
               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
   410
            {
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
   411
              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
   412
                {
9757633a85da Add OLSR routing support, (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
                  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
   414
                  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
   415
                }
9757633a85da Add OLSR routing support, (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
            }
9757633a85da Add OLSR routing support, (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 (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
   420
        {
9757633a85da Add OLSR routing support, (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
          // 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
   422
          // 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
   423
          // 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
   424
          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
   425
            {
caa15068fb3b OLSR: code cleanup, more 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
              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
   427
                              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
   428
            }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   429
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   430
	
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   431
    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   432
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   433
  // 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
   434
  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
   435
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   436
9757633a85da Add OLSR routing support, (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
///
9757633a85da Add OLSR routing support, (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
/// \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
   439
///
9757633a85da Add OLSR routing support, (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
/// \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
   441
/// \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
   442
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   443
int
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   444
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
   445
{
9757633a85da Add OLSR routing support, (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
  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
   447
  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
   448
       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
   449
    {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   450
      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
   451
      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
   452
        {
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   453
          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
   454
            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
   455
          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
   456
            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
   457
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   458
    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   459
  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
   460
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   461
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   462
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   463
/// \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
   464
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   465
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   466
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
   467
{
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   468
  NS_LOG_FUNCTION (this);
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   469
  
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   470
  // 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
   471
  // (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
   472
  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
   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
  
9757633a85da Add OLSR routing support, (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
  // 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
   476
  // 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
   477
  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
   478
  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
   479
       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
   480
    {
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
   481
      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
   482
        {
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
   483
          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
   484
        }
1716
9757633a85da Add OLSR routing support, (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
    }
9757633a85da Add OLSR routing support, (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
	
9757633a85da Add OLSR routing support, (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
  // 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
   488
  // 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
   489
  // (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
   490
  // (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
   491
  // (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
   492
  //       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
   493
  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
   494
  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
   495
       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
   496
    {
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
   497
      // 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
   498
      // (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
   499
      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
   500
        {
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
   501
          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
   502
        }
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
   503
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
   504
      //  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
   505
      // (i)   the nodes only reachable by members of N with willingness 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
   506
      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
   507
      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
   508
           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
   509
        {
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
   510
          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
   511
            {
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
   512
              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
   513
                {
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
   514
                  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
   515
                  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
   516
                }
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
   517
              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
   518
                {
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
   519
                  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
   520
                  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
   521
                }
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
   522
            }
1716
9757633a85da Add OLSR routing support, (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
        }
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
   524
      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
   525
        {
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
   526
          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
   527
        }
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
   528
      
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
   529
      // 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
   530
      // (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
   531
      //       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
   532
      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
   533
           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
   534
        {
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
   535
          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
   536
            {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   537
              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
   538
              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
   539
            }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   540
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   541
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   542
      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
   543
        {
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
   544
          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
   545
        }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   546
    }
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
   547
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   548
  NS_LOG_DEBUG ("Size of N2: " << N2.size ());  
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   549
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   550
  // 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
   551
  // 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
   552
  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
   553
    {
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
   554
      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
   555
        {
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
   556
          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
   557
          // (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
   558
          // neighbors reachable by the MPR from 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
   559
          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
   560
               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
   561
            {
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
   562
              if (twoHopNeigh->neighborMainAddr == 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
   563
                {
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
   564
                  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
   565
                }
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
   566
              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
   567
                {
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
   568
                  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
   569
                }
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
   570
            }
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
   571
        }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   572
    }
9757633a85da Add OLSR routing support, (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
  
9757633a85da Add OLSR routing support, (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
  // 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
   575
  // (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
   576
	
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   577
  // 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
   578
  // 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
   579
  std::set<Ipv4Address> coveredTwoHopNeighbors;
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
   580
  for (TwoHopNeighborSet::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
   581
    {
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
   582
      NeighborSet::const_iterator onlyNeighbor = N.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
   583
      
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
      for (NeighborSet::const_iterator neighbor = 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
   585
           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
   586
        {
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
   587
          if (neighbor->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
   588
            {
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
   589
              if (onlyNeighbor == N.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
   590
                {
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
   591
                  onlyNeighbor = 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
   592
                }
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
   593
              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
   594
                {
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
   595
                  onlyNeighbor = N.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
   596
                  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
   597
                }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   598
            }
9757633a85da Add OLSR routing support, (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
      if (onlyNeighbor != N.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
   601
        {
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
          mprSet.insert (onlyNeighbor->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
   603
          coveredTwoHopNeighbors.insert (twoHopNeigh->twoHopNeighborAddr);
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
        }
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
  // 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
   607
  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
   608
       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
   609
    {
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
      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
   611
        {
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
   612
          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
   613
        }
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
   614
      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
   615
        {
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
   616
          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
   617
        }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   618
    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   619
	
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   620
  // 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
   621
  // 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
   622
  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
   623
    {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   624
      // 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
   625
      // 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
   626
      // 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
   627
      // 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
   628
      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
   629
      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
   630
      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
   631
        {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   632
          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
   633
          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
   634
          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
   635
            {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   636
              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
   637
              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
   638
                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
   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
          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
   641
          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
   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
      // 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
   645
      // 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
   646
      // 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
   647
      // 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
   648
      // 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
   649
      // 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
   650
      // 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
   651
      // 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
   652
      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
   653
      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
   654
      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
   655
        {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   656
          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
   657
          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
   658
            {
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
   659
              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
   660
            }
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
   661
          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
   662
               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
   663
            {
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
   664
              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
   665
              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
   666
                {
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
   667
                  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
   668
                  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
   669
                }
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
   670
              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
   671
                {
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
   672
                  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
   673
                    {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   674
                      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
   675
                      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
   676
                    }
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
   677
                  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
   678
                    {
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
                      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
   680
                        {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   681
                          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
   682
                          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
   683
                        }
9757633a85da Add OLSR routing support, (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
                }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   686
            }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   687
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   688
9757633a85da Add OLSR routing support, (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
      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
   690
        {
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
   691
          mprSet.insert (max->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
   692
          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
   693
               twoHopNeigh != N2.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
   694
            {
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
   695
              if (twoHopNeigh->neighborMainAddr == max->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
                {
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
   697
                  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
   698
                }
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
   699
              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
   700
                {
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
   701
                  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
   702
                }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   703
            }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   704
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   705
    }
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
   706
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   707
#ifdef NS3_LOG_ENABLE
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   708
  {
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   709
    std::ostringstream os;
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   710
    os << "[";
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   711
    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
   712
         iter != mprSet.end (); iter++)
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   713
      {
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   714
        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
   715
        next++;
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   716
        os << *iter;
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   717
        if (next != mprSet.end ())
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   718
          os << ", ";
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   719
      }
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   720
    os << "]";
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   721
    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
   722
  }
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   723
#endif
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   724
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
   725
  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
   726
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   727
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   728
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   729
/// \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
   730
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   731
/// \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
   732
/// \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
   733
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   734
Ipv4Address
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   735
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
   736
{
1798
7bb07f0d0e9f Make OlsrAgentImpl::GetMainAddress const
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1779
diff changeset
   737
  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
   738
    m_state.FindIfaceAssocTuple (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
   739
  
9757633a85da Add OLSR routing support, (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
  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
   741
    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
   742
  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
   743
    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
   744
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   745
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   746
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   747
/// \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
   748
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   749
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   750
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
   751
{
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
   752
  NS_LOG_DEBUG (Simulator::Now ().GetSeconds () << " s: 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
   753
                << ": RoutingTableComputation 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
   754
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   755
  // 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
   756
  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
   757
	
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   758
  // 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
   759
  // 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
   760
  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
   761
  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
   762
       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
   763
    {
9757633a85da Add OLSR routing support, (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
      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
   765
      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
   766
      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
   767
        {
9757633a85da Add OLSR routing support, (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
          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
   769
          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
   770
          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
   771
          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
   772
               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
   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
              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
   775
              NS_LOG_DEBUG ("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
   776
                            << (link_tuple.time >= Simulator::Now ()? "" : " (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
   777
              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
   778
                  && 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
   779
                {
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
   780
                  NS_LOG_LOGIC ("Link tuple matches neighbor " << 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
   781
                                << " => 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
   782
                  lt = &link_tuple;
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
   783
                  AddEntry (link_tuple.neighborIfaceAddr,
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
   784
                            link_tuple.neighborIfaceAddr,
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
   785
                            link_tuple.localIfaceAddr,
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
   786
                            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
   787
                  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
   788
                    {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   789
                      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
   790
                    }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   791
                }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   792
              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
   793
                {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   794
                  NS_LOG_LOGIC ("Link tuple: linkMainAddress= " << GetMainAddress (link_tuple.neighborIfaceAddr)
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   795
                                << "; neighborMainAddr =  " << 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
   796
                                << "; expired=" << int (link_tuple.time < Simulator::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
   797
                                << " => 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
   798
                }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   799
            }
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
   800
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   801
          // 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
   802
          // 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
   803
          // 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
   804
          //      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
   805
          //      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
   806
          //                     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
   807
          //      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
   808
          //      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
   809
          //                     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
   810
          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
   811
            {
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
   812
              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
   813
                            "=> adding additional routing entry");
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
   814
              AddEntry(nb_tuple.neighborMainAddr,
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
   815
                       lt->neighborIfaceAddr,
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
   816
                       lt->localIfaceAddr,
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
   817
                       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
   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
        }
9757633a85da Add OLSR routing support, (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
    }
9757633a85da Add OLSR routing support, (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
  
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
   822
  //  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
   823
  //  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
   824
  //  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
   825
  //  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
   826
  //  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
   827
  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
   828
  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
   829
       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
   830
    {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   831
      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
   832
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   833
      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
   834
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   835
      // a 2-hop neighbor which is not a neighbor node or 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
   836
      if (m_state.FindNeighborTuple (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
   837
        {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   838
          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
   839
          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
   840
        }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   841
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   842
      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
   843
        {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   844
          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
   845
          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
   846
        }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   847
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   848
      // ...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
   849
      // 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
   850
      // 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
   851
      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
   852
      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
   853
           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
   854
        {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   855
          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
   856
              && 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
   857
            {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   858
              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
   859
              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
   860
            }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   861
        }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   862
      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
   863
        {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   864
          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
   865
                        << 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
   866
                        << " 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
   867
                        << ", 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
   868
          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
   869
        }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   870
      
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   871
      // 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
   872
      //                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
   873
      //                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
   874
      //                               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
   875
      //                                   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
   876
      //                                                  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
   877
      //                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
   878
      //                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
   879
      //                               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
   880
      //                                   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
   881
      //                                                  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
   882
      RoutingTableEntry entry;
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
   883
      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
   884
      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
   885
        {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   886
          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
   887
          AddEntry (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
   888
                                    entry.nextAddr,
caa15068fb3b OLSR: code cleanup, more 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
                                    entry.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
   890
                                    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
   891
        }
1716
9757633a85da Add OLSR routing support, (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
      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
   893
        {
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
   894
          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
   895
                        << 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
   896
                        << " 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
   897
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   898
    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   899
  
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   900
  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
   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
      bool added = 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
   903
		
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
   904
      // 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
   905
      // 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
   906
      // 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
   907
      // 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
   908
      // 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
   909
      // 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
   910
      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
   911
      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
   912
           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
   913
        {
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
   914
          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
   915
          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
   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
          RoutingTableEntry destAddrEntry, lastAddrEntry;
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
   918
          bool have_destAddrEntry = Lookup (topology_tuple.destAddr, destAddrEntry);
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
   919
          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
   920
          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
   921
            {
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
   922
              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
   923
              // 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
   924
              //                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
   925
              //                     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
   926
              //                     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
   927
              //                                    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
   928
              //                                    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
   929
              //                     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
   930
              //                     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
   931
              //                                    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
   932
              //                                       R_dest_addr == T_last_addr.
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
   933
              AddEntry (topology_tuple.destAddr,
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
   934
                        lastAddrEntry.nextAddr,
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
   935
                        lastAddrEntry.interface,
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
   936
                        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
   937
              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
   938
            }
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
   939
          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
   940
            {
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
   941
              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
   942
                            "have_destAddrEntry=" << have_destAddrEntry
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   943
                            << " have_lastAddrEntry=" << have_lastAddrEntry
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   944
                            << " lastAddrEntry.distance=" << (int) lastAddrEntry.distance
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   945
                            << " (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
   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
        }
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
   948
      
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   949
      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
   950
        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
   951
    }
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
   952
caa15068fb3b OLSR: code cleanup, more 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
  // 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
   954
  // 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
   955
  //	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
   956
  // 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
   957
  //	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
   958
  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
   959
  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
   960
       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
   961
    {
caa15068fb3b OLSR: code cleanup, more 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
      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
   963
      RoutingTableEntry entry1, entry2;
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
   964
      bool have_entry1 = Lookup (tuple.mainAddr, entry1);
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
   965
      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
   966
      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
   967
        {
caa15068fb3b OLSR: code cleanup, more 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
          // 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
   969
          //       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
   970
          //                                     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
   971
          //       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
   972
          //       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
   973
          //       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
   974
          AddEntry (tuple.ifaceAddr,
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
   975
                    entry1.nextAddr,
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
   976
                    entry1.interface,
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
   977
                    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
   978
        }
caa15068fb3b OLSR: code cleanup, more 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
    }
caa15068fb3b OLSR: code cleanup, more 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
caa15068fb3b OLSR: code cleanup, more 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
  NS_LOG_DEBUG ("Node " << m_mainAddress << ": RoutingTableComputation end.");
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
   982
  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
   983
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   984
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   985
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   986
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   987
/// \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
   988
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   989
/// 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
   990
/// 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
   991
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   992
/// \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
   993
/// \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
   994
/// \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
   995
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   996
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   997
RoutingProtocol::ProcessHello (const olsr::MessageHeader &msg,
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
   998
                         const Ipv4Address &receiverIface,
caa15068fb3b OLSR: code cleanup, more 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
                         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
  1000
{
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
  1001
  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
  1002
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1003
  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
  1004
caa15068fb3b OLSR: code cleanup, more 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
#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
  1006
  {
caa15068fb3b OLSR: code cleanup, more 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
    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
  1008
    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
  1009
                  << "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
  1010
    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
  1011
      {
caa15068fb3b OLSR: code cleanup, more 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
        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
  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_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
  1015
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1016
    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
  1017
    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
  1018
                  << "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
  1019
    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
  1020
      {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1021
        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
  1022
      }
caa15068fb3b OLSR: code cleanup, more 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
    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
  1024
  }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1025
#endif
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1026
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1027
  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
  1028
  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
  1029
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1030
#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
  1031
  {
caa15068fb3b OLSR: code cleanup, more 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
    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
  1033
    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
  1034
                  << "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
  1035
    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
  1036
         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
  1037
      {
caa15068fb3b OLSR: code cleanup, more 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
        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
  1039
      }
caa15068fb3b OLSR: code cleanup, more 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
    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
  1041
  }
caa15068fb3b OLSR: code cleanup, more 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
#endif
caa15068fb3b OLSR: code cleanup, more 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
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1044
  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
  1045
  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
  1046
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1047
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1048
///
9757633a85da Add OLSR routing support, (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
/// \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
  1050
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1051
/// 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
  1052
/// 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
  1053
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1054
/// \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
  1055
/// \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
  1056
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1057
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1058
RoutingProtocol::ProcessTc (const olsr::MessageHeader &msg,
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
  1059
                      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
  1060
{
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
  1061
  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
  1062
  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
  1063
	
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1064
  // 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
  1065
  // 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
  1066
  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
  1067
  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
  1068
    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
  1069
	
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1070
  // 2. If there exist some tuple 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
  1071
  // 	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
  1072
  // 	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
  1073
  // 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
  1074
  // performed.
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  1075
  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
  1076
    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
  1077
  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
  1078
    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
  1079
	
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1080
  // 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
  1081
  //	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
  1082
  //	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
  1083
  // 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
  1084
  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
  1085
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1086
  // 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
  1087
  // 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
  1088
  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
  1089
       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
  1090
    {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1091
      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
  1092
      // 4.1. If there exist some tuple 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
  1093
      // 	T_dest_addr == advertised neighbor main 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
  1094
      // 	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
  1095
      // then the holding time of that tuple MUST be set 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
  1096
      // 	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
  1097
      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
  1098
        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
  1099
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1100
      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
  1101
        {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1102
          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
  1103
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1104
      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
  1105
        {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1106
          // 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
  1107
          // 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
  1108
          //	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
  1109
          //	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
  1110
          //	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
  1111
          //	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
  1112
          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
  1113
          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
  1114
          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
  1115
          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
  1116
          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
  1117
          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
  1118
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1119
          // 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
  1120
          m_events.Track (Simulator::Schedule (DELAY (topologyTuple.expirationTime),
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1121
                                               &RoutingProtocol::TopologyTupleTimerExpire,
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  1122
                                               this,
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  1123
                                               topologyTuple.destAddr,
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  1124
                                               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
  1125
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1126
    }
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
  1127
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1128
#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
  1129
  {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1130
    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
  1131
    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
  1132
                  << "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
  1133
    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
  1134
         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
  1135
      {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1136
        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
  1137
      }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1138
    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
  1139
  }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1140
#endif
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1141
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1142
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1143
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1144
/// \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
  1145
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1146
/// 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
  1147
/// 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
  1148
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1149
/// \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
  1150
/// \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
  1151
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1152
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1153
RoutingProtocol::ProcessMid (const olsr::MessageHeader &msg,
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
  1154
                       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
  1155
{
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
  1156
  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
  1157
  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
  1158
  
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1159
  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
  1160
  // 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
  1161
  // 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
  1162
  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
  1163
  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
  1164
    {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1165
      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
  1166
                    ": 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
  1167
                    "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
  1168
                    " 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
  1169
      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
  1170
    }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1171
	
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1172
  // 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
  1173
  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
  1174
       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
  1175
    {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1176
      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
  1177
      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
  1178
      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
  1179
           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
  1180
        {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1181
          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
  1182
              && 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
  1183
            {
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
  1184
              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
  1185
              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
  1186
              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
  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
        }
9757633a85da Add OLSR routing support, (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
      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
  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
          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
  1192
          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
  1193
          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
  1194
          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
  1195
          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
  1196
          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
  1197
          // 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
  1198
          Simulator::Schedule (DELAY (tuple.time),
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1199
                               &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
  1200
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1201
    }
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
  1202
caa15068fb3b OLSR: code cleanup, more 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
  // 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
  1204
  // 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
  1205
  // 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
  1206
  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
  1207
  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
  1208
    {
caa15068fb3b OLSR: code cleanup, more 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
      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
  1210
    }
caa15068fb3b OLSR: code cleanup, more 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
caa15068fb3b OLSR: code cleanup, more 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
  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
  1213
  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
  1214
       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
  1215
    {
caa15068fb3b OLSR: code cleanup, more 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
      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
  1217
      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
  1218
    }
caa15068fb3b OLSR: code cleanup, more 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
  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
  1220
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1221
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1222
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1223
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1224
/// \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
  1225
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1226
/// 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
  1227
///
9757633a85da Add OLSR routing support, (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
/// \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
  1229
/// \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
  1230
/// \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
  1231
/// 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
  1232
/// \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
  1233
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1234
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1235
RoutingProtocol::ForwardDefault (olsr::MessageHeader olsrMessage,
1732
5eb67772a3e5 fix indentation in some places (was broken due to class rename)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1731
diff changeset
  1236
                               DuplicateTuple *duplicated,
5eb67772a3e5 fix indentation in some places (was broken due to class rename)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1731
diff changeset
  1237
                               const Ipv4Address &localIface,
5eb67772a3e5 fix indentation in some places (was broken due to class rename)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1731
diff changeset
  1238
                               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
  1239
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1240
  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
  1241
  
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1242
  // 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
  1243
  // 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
  1244
  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
  1245
  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
  1246
    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
  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
  // 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
  1249
  // 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
  1250
  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
  1251
    {
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
  1252
      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
  1253
                    " 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
  1254
      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
  1255
    }
9757633a85da Add OLSR routing support, (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
	
9757633a85da Add OLSR routing support, (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
  // 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
  1258
  // 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
  1259
  // 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
  1260
  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
  1261
  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
  1262
    {
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  1263
      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
  1264
        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
  1265
      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
  1266
        {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1267
          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
  1268
          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
  1269
          // 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
  1270
          // 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
  1271
          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
  1272
          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
  1273
        }
9757633a85da Add OLSR routing support, (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
    }
9757633a85da Add OLSR routing support, (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
	
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1276
  // 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
  1277
  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
  1278
    {
9757633a85da Add OLSR routing support, (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
      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
  1280
      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
  1281
      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
  1282
    }
9757633a85da Add OLSR routing support, (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
  // ...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
  1284
  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
  1285
    {
9757633a85da Add OLSR routing support, (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
      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
  1287
      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
  1288
      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
  1289
      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
  1290
      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
  1291
      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
  1292
      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
  1293
      // 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
  1294
      Simulator::Schedule (OLSR_DUP_HOLD_TIME,
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1295
                           &RoutingProtocol::DupTupleTimerExpire, this,
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  1296
                           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
  1297
    }
9757633a85da Add OLSR routing support, (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
}
9757633a85da Add OLSR routing support, (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
9757633a85da Add OLSR routing support, (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
/// \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
  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
/// 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
  1304
/// 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
  1305
///
9757633a85da Add OLSR routing support, (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
/// \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
  1307
/// \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
  1308
///
9757633a85da Add OLSR routing support, (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
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1310
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
  1311
{
9757633a85da Add OLSR routing support, (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
  m_queuedMessages.push_back (message);
1730
163aab5f1129 solve some merge problems
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1723
diff changeset
  1313
  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
  1314
    {
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
  1315
      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
  1316
      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
  1317
    }
9757633a85da Add OLSR routing support, (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
}
9757633a85da Add OLSR routing support, (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
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1321
RoutingProtocol::SendPacket (Ptr<Packet> packet, 
1868
06027fd6a68c olsr gets new packet
Craig Dowell <craigdo@ee.washington.edu>
parents: 1803
diff changeset
  1322
                       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
  1323
{
1804
9c11e776f501 bug 96: debug.h duplicates functionality from log.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1803
diff changeset
  1324
  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
  1325
1716
9757633a85da Add OLSR routing support, (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
  // 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
  1327
  olsr::PacketHeader header;
1868
06027fd6a68c olsr gets new packet
Craig Dowell <craigdo@ee.washington.edu>
parents: 1803
diff changeset
  1328
  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
  1329
  header.SetPacketSequenceNumber (GetPacketSequenceNumber ());
1868
06027fd6a68c olsr gets new packet
Craig Dowell <craigdo@ee.washington.edu>
parents: 1803
diff changeset
  1330
  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
  1331
4078e5efdfc6 Add OLSR message tracing, as discussed on ns-developers list.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1801
diff changeset
  1332
  // 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
  1333
  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
  1334
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1335
  // Send 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
  1336
  m_socketAddresses.begin ()->first->Send (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
  1337
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1338
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1339
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1340
/// \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
  1341
/// %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
  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
/// 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
  1344
/// 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
  1345
///
9757633a85da Add OLSR routing support, (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
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1347
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
  1348
{
1868
06027fd6a68c olsr gets new packet
Craig Dowell <craigdo@ee.washington.edu>
parents: 1803
diff changeset
  1349
  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
  1350
  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
  1351
1804
9c11e776f501 bug 96: debug.h duplicates functionality from log.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1803
diff changeset
  1352
  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
  1353
1803
4078e5efdfc6 Add OLSR message tracing, as discussed on ns-developers list.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1801
diff changeset
  1354
  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
  1355
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
  1356
  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
  1357
       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
  1358
       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
  1359
    {
1868
06027fd6a68c olsr gets new packet
Craig Dowell <craigdo@ee.washington.edu>
parents: 1803
diff changeset
  1360
      Ptr<Packet> p = Create<Packet> ();
06027fd6a68c olsr gets new packet
Craig Dowell <craigdo@ee.washington.edu>
parents: 1803
diff changeset
  1361
      p->AddHeader (*message);
06027fd6a68c olsr gets new packet
Craig Dowell <craigdo@ee.washington.edu>
parents: 1803
diff changeset
  1362
      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
  1363
      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
  1364
      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
  1365
        {
1803
4078e5efdfc6 Add OLSR message tracing, as discussed on ns-developers list.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1801
diff changeset
  1366
          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
  1367
          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
  1368
          // 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
  1369
          numMessages = 0;
1868
06027fd6a68c olsr gets new packet
Craig Dowell <craigdo@ee.washington.edu>
parents: 1803
diff changeset
  1370
          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
  1371
        }
9757633a85da Add OLSR routing support, (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
1868
06027fd6a68c olsr gets new packet
Craig Dowell <craigdo@ee.washington.edu>
parents: 1803
diff changeset
  1374
  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
  1375
    {
1803
4078e5efdfc6 Add OLSR message tracing, as discussed on ns-developers list.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1801
diff changeset
  1376
      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
  1377
    }
9757633a85da Add OLSR routing support, (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
9757633a85da Add OLSR routing support, (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
  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
  1380
}
9757633a85da Add OLSR routing support, (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
///
9757633a85da Add OLSR routing support, (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
/// \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
  1384
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1385
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1386
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
  1387
{
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  1388
  NS_LOG_FUNCTION (this);
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  1389
  
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
  1390
  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
  1391
  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
  1392
9757633a85da Add OLSR routing support, (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
  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
  1394
  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
  1395
  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
  1396
  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
  1397
  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
  1398
  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
  1399
3487
6f68f1044df1 OLSR: HELLO messages hold time should be 3 times hello interval, not hello interval.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3270
diff changeset
  1400
  hello.SetHTime (Scalar (3) * 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
  1401
  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
  1402
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
  1403
  std::vector<olsr::MessageHeader::Hello::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
  1404
    &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
  1405
	
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
  1406
  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
  1407
  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
  1408
       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
  1409
    {
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
  1410
      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
  1411
            && 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
  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
          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
  1414
        }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1415
1762
6410d2be8cbf Fix a couple more warnings in OLSR
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1755
diff changeset
  1416
      uint8_t link_type, nb_type = 0xff;
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1417
			
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1418
      // 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
  1419
      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
  1420
        {
9757633a85da Add OLSR routing support, (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
          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
  1422
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1423
      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
  1424
        {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1425
          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
  1426
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1427
      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
  1428
        {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1429
          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
  1430
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1431
      // 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
  1432
      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
  1433
        {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1434
          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
  1435
          NS_LOG_DEBUG ("I consider neighbor " << GetMainAddress (link_tuple->neighborIfaceAddr)
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  1436
                        << " 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
  1437
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1438
      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
  1439
        {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1440
          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
  1441
          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
  1442
               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
  1443
               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
  1444
            {
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
  1445
              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
  1446
                {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1447
                  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
  1448
                    {
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  1449
                      NS_LOG_DEBUG ("I consider neighbor " << GetMainAddress (link_tuple->neighborIfaceAddr)
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  1450
                                    << " 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
  1451
                      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
  1452
                    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1453
                  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
  1454
                    {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1455
                      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
  1456
                      NS_LOG_DEBUG ("I consider neighbor " << GetMainAddress (link_tuple->neighborIfaceAddr)
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  1457
                                    << " 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
  1458
                    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1459
                  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
  1460
                    {
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
  1461
                      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
  1462
                    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1463
                  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
  1464
                  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
  1465
                }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1466
            }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1467
          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
  1468
            {
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  1469
              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
  1470
              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
  1471
            }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1472
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1473
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
  1474
      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
  1475
      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
  1476
      linkMessage.neighborInterfaceAddresses.push_back
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1477
        (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
  1478
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1479
      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
  1480
        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
  1481
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1482
      linkMessage.neighborInterfaceAddresses.insert
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1483
        (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
  1484
         interfaces.begin (), interfaces.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
  1485
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1486
      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
  1487
    }
1804
9c11e776f501 bug 96: debug.h duplicates functionality from log.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1803
diff changeset
  1488
  NS_LOG_DEBUG ("OLSR HELLO message size: " << int (msg.GetSerializedSize ())
9c11e776f501 bug 96: debug.h duplicates functionality from log.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1803
diff changeset
  1489
                << " (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
  1490
  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
  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
9757633a85da Add OLSR routing support, (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
/// \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
  1495
///
9757633a85da Add OLSR routing support, (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
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1497
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
  1498
{
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  1499
  NS_LOG_FUNCTION (this);
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  1500
  
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
  1501
  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
  1502
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1503
  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
  1504
  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
  1505
  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
  1506
  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
  1507
  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
  1508
  
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
  1509
  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
  1510
  tc.ansn = m_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
  1511
  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
  1512
       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
  1513
    {
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
  1514
      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
  1515
    }
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
  1516
  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
  1517
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1518
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1519
///
9757633a85da Add OLSR routing support, (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
/// \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
  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
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1523
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
  1524
{
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
  1525
  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
  1526
  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
  1527
9757633a85da Add OLSR routing support, (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
  // 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
  1529
  // 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
  1530
  // 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
  1531
9757633a85da Add OLSR routing support, (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
  // 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
  1533
  // 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
  1534
  // 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
  1535
  // 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
  1536
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1537
  // 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
  1538
  // 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
  1539
  // 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
  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
  // [ 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
  1542
  // 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
  1543
9757633a85da Add OLSR routing support, (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
  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
  1545
  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
  1546
    {
9757633a85da Add OLSR routing support, (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
      Ipv4Address addr = m_ipv4->GetAddress (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
  1548
      if (addr != m_mainAddress && addr != loopback)
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
  1549
        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
  1550
    }
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
  1551
  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
  1552
    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
  1553
  
9757633a85da Add OLSR routing support, (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
  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
  1555
  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
  1556
  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
  1557
  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
  1558
  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
  1559
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
  1560
  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
  1561
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1562
9757633a85da Add OLSR routing support, (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
/// \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
  1565
///		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
  1566
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1567
RoutingProtocol::LinkSensing (const olsr::MessageHeader &msg,
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
  1568
                        const olsr::MessageHeader::Hello &hello,
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1569
                        const Ipv4Address &receiverIface,
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1570
                        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
  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
  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
  1573
  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
  1574
  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
  1575
  NS_LOG_DEBUG ("@" << now.GetSeconds () << ": 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
  1576
                << ": LinkSensing(receiverIface=" << receiverIface
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1577
                << ", 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
  1578
	
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
  1579
  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
  1580
  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
  1581
  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
  1582
    {
9757633a85da Add OLSR routing support, (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
      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
  1584
      // 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
  1585
      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
  1586
      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
  1587
      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
  1588
      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
  1589
      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
  1590
      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
  1591
      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
  1592
    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1593
  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
  1594
    {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1595
      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
  1596
      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
  1597
    }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1598
	
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1599
  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
  1600
  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
  1601
         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
  1602
       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
  1603
       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
  1604
    {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1605
      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
  1606
      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
  1607
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1608
#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
  1609
      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
  1610
      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
  1611
        {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1612
        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
  1613
        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
  1614
        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
  1615
        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
  1616
        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
  1617
        }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1618
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1619
      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
  1620
      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
  1621
        {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1622
        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
  1623
        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
  1624
        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
  1625
        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
  1626
        }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1627
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1628
      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
  1629
                    << 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
  1630
                    << ") 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
  1631
                    << " (" << 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
  1632
#endif
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1633
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1634
      // 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
  1635
      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
  1636
          (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
  1637
           && 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
  1638
        {
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
  1639
          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
  1640
          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
  1641
        }
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
  1642
      
1716
9757633a85da Add OLSR routing support, (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
      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
  1644
             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
  1645
           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
  1646
           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
  1647
        {
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
  1648
          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
  1649
          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
  1650
            {
9757633a85da Add OLSR routing support, (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
              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
  1652
                {
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
  1653
                  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
  1654
                  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
  1655
                  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
  1656
                }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1657
              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
  1658
                {
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
  1659
                  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
  1660
                                " (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
  1661
                  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
  1662
                  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
  1663
                  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
  1664
                }
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
  1665
              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
  1666
                {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1667
                  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
  1668
                }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1669
              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
  1670
            }
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
  1671
          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
  1672
            {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1673
              NS_LOG_DEBUG ("     \\-> *neighIfaceAddr (" << *neighIfaceAddr
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1674
                            << " != receiverIface (" << receiverIface << ") => IGNORING!");
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1675
            }
1716
9757633a85da Add OLSR routing support, (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
      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
  1678
    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1679
  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
  1680
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1681
  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
  1682
    {
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  1683
      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
  1684
    }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1685
9757633a85da Add OLSR routing support, (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
  // 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
  1687
  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
  1688
    {
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
  1689
      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
  1690
      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
  1691
                                           &RoutingProtocol::LinkTupleTimerExpire, this,
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  1692
                                           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
  1693
    }
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
  1694
  NS_LOG_DEBUG ("@" << now.GetSeconds () << ": 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
  1695
                << ": 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
  1696
}
9757633a85da Add OLSR routing support, (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
///
9757633a85da Add OLSR routing support, (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
/// \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
  1700
///		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
  1701
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1702
RoutingProtocol::PopulateNeighborSet (const olsr::MessageHeader &msg,
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
  1703
                                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
  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
  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
  1706
  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
  1707
    {
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  1708
      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
  1709
    }
1716
9757633a85da Add OLSR routing support, (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
9757633a85da Add OLSR routing support, (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
9757633a85da Add OLSR routing support, (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
///
9757633a85da Add OLSR routing support, (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
/// \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
  1715
///		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
  1716
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1717
RoutingProtocol::PopulateTwoHopNeighborSet (const olsr::MessageHeader &msg,
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
  1718
                                      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
  1719
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1720
  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
  1721
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1722
  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
  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
  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
  1725
       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
  1726
    {
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
  1727
      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
  1728
      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
  1729
        {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1730
          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
  1731
                        "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
  1732
          NS_LOG_LOGIC ("(GetMainAddress(" << link_tuple->neighborIfaceAddr << "): "
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1733
                        << GetMainAddress (link_tuple->neighborIfaceAddr)
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1734
                        << "; msg.GetOriginatorAddress (): " << 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
  1735
          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
  1736
        }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1737
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1738
      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
  1739
        {
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
  1740
          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
  1741
          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
  1742
        }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1743
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1744
      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
  1745
      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
  1746
           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
  1747
        {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1748
          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
  1749
#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
  1750
          const char *neighborTypeNames[3] = { "NOT_NEIGH", "SYM_NEIGH", "MPR_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
  1751
          const char *neighborTypeName = ((neighborType < 3)?
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1752
                                          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
  1753
                                          : "(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
  1754
          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
  1755
                        << neighborType << " (" << 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
  1756
#endif
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1757
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1758
          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
  1759
                 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
  1760
               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
  1761
               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
  1762
            {
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
  1763
              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
  1764
              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
  1765
                            << *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
  1766
                            << " (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
  1767
              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
  1768
                {
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
  1769
                  // 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
  1770
                  // 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
  1771
                  // neighbor 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
  1772
                  if (nb2hop_addr == m_routingAgentAddr)
1716
9757633a85da Add OLSR routing support, (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
                    {
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
  1774
                      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
  1775
                      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
  1776
                    }
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
  1777
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1778
                  // 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
  1779
                  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
  1780
                    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
  1781
                  NS_LOG_LOGIC ("Adding 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
  1782
                                << (nb2hop_tuple? " (refreshing existing 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
  1783
                  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
  1784
                    {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1785
                      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
  1786
                      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
  1787
                      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
  1788
                      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
  1789
                      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
  1790
                      // 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
  1791
                      m_events.Track (Simulator::Schedule (DELAY (new_nb2hop_tuple.expirationTime),
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1792
                                                           &RoutingProtocol::Nb2hopTupleTimerExpire, this,
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  1793
                                                           new_nb2hop_tuple.neighborMainAddr,
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  1794
                                                           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
  1795
                    }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1796
                  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
  1797
                    {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1798
                      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
  1799
                    }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1800
                }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1801
              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
  1802
                {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1803
                  // 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
  1804
                  // 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
  1805
                  // 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
  1806
                  // 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
  1807
                  // 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
  1808
                  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
  1809
                  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
  1810
                }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1811
              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
  1812
                {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1813
                  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
  1814
                                " 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
  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
            }
9757633a85da Add OLSR routing support, (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
        }
9757633a85da Add OLSR routing support, (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
    }
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
  1819
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1820
  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
  1821
}
9757633a85da Add OLSR routing support, (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
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1823
9757633a85da Add OLSR routing support, (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
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1825
///
9757633a85da Add OLSR routing support, (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
/// \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
  1827
///		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
  1828
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1829
RoutingProtocol::PopulateMprSelectorSet (const olsr::MessageHeader &msg,
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
  1830
                                       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
  1831
{
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  1832
  NS_LOG_FUNCTION (this);
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  1833
  
1716
9757633a85da Add OLSR routing support, (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
  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
  1835
	
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
  1836
  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
  1837
  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
  1838
       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
  1839
       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
  1840
    {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1841
      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
  1842
      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
  1843
        {
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  1844
          NS_LOG_DEBUG ("Processing a link message with neighbor type MPR_NEIGH");
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  1845
          
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1846
          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
  1847
                 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
  1848
               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
  1849
               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
  1850
            {
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
  1851
              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
  1852
                {
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  1853
                  NS_LOG_DEBUG ("Adding entry to mpr selector set for neighbor " << *nb_iface_addr);
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  1854
                  
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1855
                  // 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
  1856
                  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
  1857
                    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
  1858
                  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
  1859
                    {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1860
                      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
  1861
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1862
                      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
  1863
                      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
  1864
                      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
  1865
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1866
                      // 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
  1867
                      m_events.Track (Simulator::Schedule
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
  1868
                                      (DELAY (mprsel_tuple.expirationTime),
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1869
                                       &RoutingProtocol::MprSelTupleTimerExpire, this,
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  1870
                                       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
  1871
                    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1872
                  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
  1873
                    {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1874
                      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
  1875
                    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1876
                }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1877
            }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1878
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1879
    }
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  1880
  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
  1881
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1882
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1883
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1884
#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
  1885
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1886
/// \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
  1887
///		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
  1888
///		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
  1889
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1890
/// \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
  1891
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1892
void
1868
06027fd6a68c olsr gets new packet
Craig Dowell <craigdo@ee.washington.edu>
parents: 1803
diff changeset
  1893
OLSR::mac_failed(Ptr<Packet> 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
  1894
	double 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
  1895
	struct hdr_ip* ih	= HDR_IP(p);
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1896
	struct hdr_cmn* ch	= HDR_CMN(p);
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1897
	
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1898
	debug("%f: Node %d MAC Layer detects a breakage on link to %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
  1899
		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
  1900
		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
  1901
		OLSR::node_id(ch->next_hop()));
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1902
	
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1903
	if ((u_int32_t)ih->daddr() == IP_BROADCAST) {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1904
		drop(p, DROP_RTR_MAC_CALLBACK);
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1905
		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
  1906
	}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1907
	
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1908
	OLSR_link_tuple* link_tuple = state_.find_link_tuple(ch->next_hop());
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1909
	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
  1910
		link_tuple->lost_time()	= now + 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
  1911
		link_tuple->time()	= now + 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
  1912
		nb_loss(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
  1913
	}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1914
	drop(p, DROP_RTR_MAC_CALLBACK);
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1915
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1916
#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
  1917
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1918
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1919
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1920
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1921
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1922
/// \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
  1923
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1924
/// 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
  1925
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1926
/// \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
  1927
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1928
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1929
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
  1930
{
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
  1931
  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
  1932
                << "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
  1933
                << " 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
  1934
  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
  1935
  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
  1936
  m_state.EraseMprSelectorTuples (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
  1937
  
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
  1938
  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
  1939
  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
  1940
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1941
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1942
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1943
/// \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
  1944
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1945
/// \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
  1946
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1947
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1948
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
  1949
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1950
	/*debug("%f: Node %d adds 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
  1951
		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
  1952
		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
  1953
		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
  1954
		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
  1955
  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
  1956
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1957
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1958
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1959
/// \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
  1960
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1961
/// \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
  1962
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1963
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1964
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
  1965
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1966
  /*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
  1967
    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
  1968
    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
  1969
    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
  1970
    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
  1971
  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
  1972
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1973
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
  1974
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1975
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
  1976
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1977
  // 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
  1978
  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
  1979
  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
  1980
  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
  1981
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1982
  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
  1983
    {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1984
      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
  1985
    }
1716
9757633a85da Add OLSR routing support, (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
  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
  1987
    {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1988
      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
  1989
    }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1990
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1991
  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
  1992
}
9757633a85da Add OLSR routing support, (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
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1994
///
9757633a85da Add OLSR routing support, (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
/// \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
  1996
///
9757633a85da Add OLSR routing support, (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
/// \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
  1998
///
9757633a85da Add OLSR routing support, (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
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2000
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
  2001
{
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
  2002
  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
  2003
                << "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
  2004
                << " 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
  2005
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2006
  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
  2007
  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
  2008
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2009
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2010
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2011
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2012
/// \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
  2013
///		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
  2014
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2015
/// \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
  2016
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2017
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2018
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
  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
  // 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
  2021
caa15068fb3b OLSR: code cleanup, more 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
  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
  2023
                << "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
  2024
                << " 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
  2025
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2026
  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
  2027
    m_state.FindNeighborTuple (GetMainAddress (tuple.neighborIfaceAddr));
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2028
  
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2029
  if (nb_tuple == NULL)
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2030
    {
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2031
      LinkTupleAdded (tuple, willingness);
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2032
      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
  2033
    }
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
  2034
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2035
  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
  2036
    {
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
  2037
#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
  2038
      int statusBefore = nb_tuple->status;
caa15068fb3b OLSR: code cleanup, more 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
#endif
caa15068fb3b OLSR: code cleanup, more 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
      if (tuple.symTime >= 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
  2041
        {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2042
          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
  2043
          NS_LOG_DEBUG (*nb_tuple << "->status = STATUS_SYM; changed:"
caa15068fb3b OLSR: code cleanup, more 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
                        << 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
  2045
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2046
      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
  2047
        {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2048
          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
  2049
          NS_LOG_DEBUG (*nb_tuple << "->status = STATUS_NOT_SYM; changed:"
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2050
                        << 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
  2051
        }
9757633a85da Add OLSR routing support, (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
    }
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2053
  else
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2054
    {
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2055
      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
  2056
    }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2057
}
9757633a85da Add OLSR routing support, (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
9757633a85da Add OLSR routing support, (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
///
9757633a85da Add OLSR routing support, (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
/// \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
  2061
///
9757633a85da Add OLSR routing support, (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
/// \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
  2063
///
9757633a85da Add OLSR routing support, (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
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2065
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
  2066
{
9757633a85da Add OLSR routing support, (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
//   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
  2068
//         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
  2069
//         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
  2070
//         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
  2071
//         ((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
  2072
  
9757633a85da Add OLSR routing support, (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
  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
  2074
  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
  2075
}
9757633a85da Add OLSR routing support, (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
9757633a85da Add OLSR routing support, (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
///
9757633a85da Add OLSR routing support, (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
/// \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
  2079
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2080
/// \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
  2081
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2082
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2083
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
  2084
{
9757633a85da Add OLSR routing support, (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
//   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
  2086
//         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
  2087
//         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
  2088
//         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
  2089
//         ((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
  2090
	
9757633a85da Add OLSR routing support, (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
  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
  2092
  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
  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
9757633a85da Add OLSR routing support, (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
/// \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
  2097
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2098
/// \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
  2099
///
9757633a85da Add OLSR routing support, (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
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2101
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
  2102
{
9757633a85da Add OLSR routing support, (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
//   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
  2104
//         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
  2105
//         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
  2106
//         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
  2107
//         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
  2108
  
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2109
  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
  2110
}
9757633a85da Add OLSR routing support, (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
/// \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
  2114
///
9757633a85da Add OLSR routing support, (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
/// \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
  2116
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2117
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2118
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
  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
//   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
  2121
//         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
  2122
//         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
  2123
//         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
  2124
//         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
  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
  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
  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
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
  2129
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2130
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
  2131
{
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2132
  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
  2133
}
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2134
1716
9757633a85da Add OLSR routing support, (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
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2136
/// \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
  2137
///
9757633a85da Add OLSR routing support, (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
/// 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
  2139
///
9757633a85da Add OLSR routing support, (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
/// \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
  2141
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2142
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2143
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
  2144
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2145
//   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
  2146
//         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
  2147
//         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
  2148
//         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
  2149
  
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2150
  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
  2151
  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
  2152
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2153
9757633a85da Add OLSR routing support, (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
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2155
/// \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
  2156
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2157
/// 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
  2158
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2159
/// \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
  2160
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2161
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2162
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
  2163
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2164
//   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
  2165
//         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
  2166
//         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
  2167
//         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
  2168
  
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2169
  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
  2170
  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
  2171
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2172
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2173
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2174
/// \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
  2175
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2176
/// \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
  2177
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2178
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2179
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
  2180
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2181
//   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
  2182
//         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
  2183
//         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
  2184
//         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
  2185
//         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
  2186
//         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
  2187
9757633a85da Add OLSR routing support, (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
  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
  2189
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2190
9757633a85da Add OLSR routing support, (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
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2192
/// \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
  2193
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2194
/// \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
  2195
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2196
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2197
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
  2198
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2199
//   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
  2200
//         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
  2201
//         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
  2202
//         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
  2203
//         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
  2204
//         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
  2205
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2206
  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
  2207
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2208
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2209
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2210
/// \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
  2211
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2212
/// \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
  2213
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2214
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2215
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
  2216
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2217
//   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
  2218
//         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
  2219
//         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
  2220
//         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
  2221
//         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
  2222
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2223
  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
  2224
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2225
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2226
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2227
/// \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
  2228
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2229
/// \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
  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
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2232
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
  2233
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2234
//   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
  2235
//         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
  2236
//         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
  2237
//         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
  2238
//         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
  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
  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
  2241
}
9757633a85da Add OLSR routing support, (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
9757633a85da Add OLSR routing support, (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
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2244
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
  2245
{
9757633a85da Add OLSR routing support, (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
  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
  2247
  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
  2248
}
9757633a85da Add OLSR routing support, (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
9757633a85da Add OLSR routing support, (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
/// Increments message sequence number and returns the new value.
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2251
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
  2252
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2253
  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
  2254
  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
  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
9757633a85da Add OLSR routing support, (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
9757633a85da Add OLSR routing support, (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
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2259
/// \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
  2260
/// \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
  2261
///
9757633a85da Add OLSR routing support, (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
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2263
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
  2264
{
9757633a85da Add OLSR routing support, (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
  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
  2266
  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
  2267
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2268
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2269
///
9757633a85da Add OLSR routing support, (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
/// \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
  2271
/// \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
  2272
///
9757633a85da Add OLSR routing support, (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
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2274
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
  2275
{
9757633a85da Add OLSR routing support, (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
  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
  2277
    {
763f8d1bb058 Adapt the OLSR agent code to use the new Timer class.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1763
diff changeset
  2278
      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
  2279
    }
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2280
  else
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2281
    {
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2282
      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
  2283
    }
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
  2284
  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
  2285
}
9757633a85da Add OLSR routing support, (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
///
9757633a85da Add OLSR routing support, (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
/// \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
  2289
/// \warning Currently it does nothing because there is no support for multiple 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
  2290
/// \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
  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
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2293
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
  2294
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2295
  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
  2296
  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
  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
///
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
  2300
/// \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
  2301
///
9757633a85da Add OLSR routing support, (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
/// 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
  2303
///
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
  2304
/// \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
  2305
///
9757633a85da Add OLSR routing support, (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
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2307
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
  2308
{
2329
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2309
  DuplicateTuple *tuple =
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  2310
    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
  2311
  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
  2312
    {
2329
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2313
      return;
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2314
    }
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2315
  if (tuple->expirationTime < Simulator::Now ())
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2316
    {
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2317
      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
  2318
    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2319
  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
  2320
    {
2329
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2321
      m_events.Track (Simulator::Schedule (DELAY (tuple->expirationTime),
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2322
                                           &RoutingProtocol::DupTupleTimerExpire, this,
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  2323
                                           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
  2324
    }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2325
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2326
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2327
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2328
/// \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
  2329
/// 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
  2330
/// 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
  2331
/// 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
  2332
/// 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
  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
/// 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
  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
/// \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
  2337
///
9757633a85da Add OLSR routing support, (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
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2339
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
  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
  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
  2342
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2343
  // 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
  2344
  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
  2345
  if (tuple == NULL)
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2346
    {
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2347
      return;
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2348
    }
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2349
  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
  2350
    {
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
  2351
      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
  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
  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
  2354
    {
9757633a85da Add OLSR routing support, (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
      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
  2356
        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
  2357
      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
  2358
        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
  2359
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
  2360
      m_events.Track (Simulator::Schedule (DELAY (tuple->time),
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2361
                                           &RoutingProtocol::LinkTupleTimerExpire, this,
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  2362
                                           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
  2363
    }
9757633a85da Add OLSR routing support, (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
  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
  2365
    {
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
  2366
      m_events.Track (Simulator::Schedule (DELAY (std::min (tuple->time, tuple->symTime)),
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2367
                                           &RoutingProtocol::LinkTupleTimerExpire, this,
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  2368
                                           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
  2369
    }
1716
9757633a85da Add OLSR routing support, (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
}
9757633a85da Add OLSR routing support, (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
/// \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
  2374
///
9757633a85da Add OLSR routing support, (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
/// 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
  2376
///
9757633a85da Add OLSR routing support, (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
/// \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
  2378
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2379
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2380
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
  2381
{
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
  2382
  TwoHopNeighborTuple *tuple;
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  2383
  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
  2384
  if (tuple == NULL)
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2385
    {
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2386
      return;
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2387
    }
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2388
  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
  2389
    {
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
  2390
      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
  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
  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
  2393
    {
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
  2394
      m_events.Track (Simulator::Schedule (DELAY (tuple->expirationTime),
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2395
                                           &RoutingProtocol::Nb2hopTupleTimerExpire,
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  2396
                                           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
  2397
    }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2398
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2399
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2400
///
9757633a85da Add OLSR routing support, (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
/// \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
  2402
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2403
/// 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
  2404
///
9757633a85da Add OLSR routing support, (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
/// \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
  2406
///
9757633a85da Add OLSR routing support, (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
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2408
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
  2409
{
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  2410
  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
  2411
  if (tuple == NULL)
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2412
    {
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2413
      return;
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2414
    }
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2415
  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
  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
      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
  2418
    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2419
  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
  2420
    {
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
  2421
      m_events.Track (Simulator::Schedule (DELAY (tuple->expirationTime),
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2422
                                           &RoutingProtocol::MprSelTupleTimerExpire,
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  2423
                                           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
  2424
    }
1716
9757633a85da Add OLSR routing support, (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
///
9757633a85da Add OLSR routing support, (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
/// \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
  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
/// 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
  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
/// \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
  2433
///
9757633a85da Add OLSR routing support, (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
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2435
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
  2436
{
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  2437
  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
  2438
  if (tuple == NULL)
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2439
    {
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2440
      return;
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2441
    }
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2442
  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
  2443
    {
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
  2444
      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
  2445
    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2446
  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
  2447
    {
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
  2448
      m_events.Track (Simulator::Schedule (DELAY (tuple->expirationTime),
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2449
                                           &RoutingProtocol::TopologyTupleTimerExpire,
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  2450
                                           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
  2451
    }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2452
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2453
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2454
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2455
/// \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
  2456
/// \warning Actually this is never invoked because there is no support for multiple 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
  2457
/// \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
  2458
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2459
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2460
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
  2461
{
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  2462
  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
  2463
  if (tuple == NULL)
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2464
    {
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2465
      return;
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2466
    }
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2467
  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
  2468
    {
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
  2469
      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
  2470
    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2471
  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
  2472
    {
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
  2473
      m_events.Track (Simulator::Schedule (DELAY (tuple->time),
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2474
                                           &RoutingProtocol::IfaceAssocTupleTimerExpire,
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  2475
                                           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
  2476
    }
1716
9757633a85da Add OLSR routing support, (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
}
9757633a85da Add OLSR routing support, (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
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2479
///
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2480
/// \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
  2481
///
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2482
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2483
RoutingProtocol::Clear ()
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2484
{
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2485
  NS_LOG_FUNCTION_NOARGS ();
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2486
  m_table.clear ();
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2487
}
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2488
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2489
///
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2490
/// \brief Deletes the entry whose destination address is given.
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2491
/// \param dest	address of the destination node.
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2492
///
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2493
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2494
RoutingProtocol::RemoveEntry (Ipv4Address const &dest)
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2495
{
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2496
  m_table.erase (dest);
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2497
}
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2498
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2499
///
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2500
/// \brief Looks up an entry for the specified destination address.
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2501
/// \param dest	destination address.
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2502
/// \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
  2503
/// \return	true if found, false if not found
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2504
///
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2505
bool
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2506
RoutingProtocol::Lookup (Ipv4Address const &dest,
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2507
                      RoutingTableEntry &outEntry) const
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2508
{
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2509
  // Get the iterator at "dest" position
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2510
  std::map<Ipv4Address, RoutingTableEntry>::const_iterator it =
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2511
    m_table.find (dest);
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2512
  // If there is no route to "dest", return NULL
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2513
  if (it == m_table.end ())
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2514
    return false;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2515
  outEntry = it->second;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2516
  return true;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2517
}
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2518
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2519
///
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2520
/// \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
  2521
///		a data packet to a next hop (given a destination).
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2522
///
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2523
/// 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
  2524
/// 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
  2525
/// [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
  2526
/// 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
  2527
/// 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
  2528
///
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2529
/// \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
  2530
///			we are interested in.
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2531
/// \return		the appropiate routing table entry which indicates the next
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2532
///			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
  2533
///			if there is no such entry.
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2534
///
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2535
bool
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2536
RoutingProtocol::FindSendEntry (RoutingTableEntry const &entry,
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2537
                             RoutingTableEntry &outEntry) const
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2538
{
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2539
  outEntry = entry;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2540
  while (outEntry.destAddr != outEntry.nextAddr)
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2541
    {
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2542
      if (not Lookup(outEntry.nextAddr, outEntry))
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2543
        return false;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2544
    }
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2545
  return true;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2546
}
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2547
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2548
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2549
bool
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2550
RoutingProtocol::RequestRoute (uint32_t ifIndex,
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2551
                            const Ipv4Header &ipHeader,
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2552
                            Ptr<Packet> packet,
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2553
                            RouteReplyCallback routeReply)
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
  2554
{
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2555
  RoutingTableEntry entry1, entry2;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2556
  if (Lookup (ipHeader.GetDestination (), entry1))
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2557
    {
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2558
      bool foundSendEntry = FindSendEntry (entry1, entry2);
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2559
      if (!foundSendEntry)
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2560
        NS_FATAL_ERROR ("FindSendEntry failure");
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2561
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2562
      Ipv4Route route = Ipv4Route::CreateHostRouteTo
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2563
        (ipHeader.GetDestination (), entry2.nextAddr, entry2.interface);
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2564
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2565
      NS_LOG_DEBUG ("Olsr node " << m_mainAddress
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2566
                    << ": RouteRequest for dest=" << ipHeader.GetDestination ()
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2567
                    << " --> nestHop=" << entry2.nextAddr
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2568
                    << " interface=" << entry2.interface);
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2569
      
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2570
      routeReply (true, route, packet, ipHeader);
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2571
      return true;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2572
    }
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2573
  else
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2574
    {
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2575
#ifdef NS3_LOG_ENABLE
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2576
      NS_LOG_DEBUG ("Olsr node " << m_mainAddress
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2577
                    << ": RouteRequest for dest=" << ipHeader.GetDestination ()
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2578
                    << " --> NOT FOUND; ** Dumping routing table...");
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2579
      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
  2580
           iter != m_table.end (); iter++)
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2581
        {
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2582
          NS_LOG_DEBUG ("dest=" << iter->first << " --> next=" << iter->second.nextAddr
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2583
                        << " via interface " << iter->second.interface);
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2584
        }
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2585
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2586
      NS_LOG_DEBUG ("** Routing table dump end.");
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2587
#endif
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2588
      return false;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2589
    }
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2590
}
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2591
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2592
bool
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2593
RoutingProtocol::RequestIfIndex (Ipv4Address destination,
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2594
                              uint32_t& ifIndex)
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2595
{
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2596
  RoutingTableEntry entry1, entry2;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2597
  if (Lookup (destination, entry1))
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2598
    {
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2599
      bool foundSendEntry = FindSendEntry (entry1, entry2);
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2600
      if (!foundSendEntry)
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2601
        NS_FATAL_ERROR ("FindSendEntry failure");
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2602
      ifIndex = entry2.interface;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2603
      return true;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2604
    }
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2605
  else
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2606
    {
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2607
      return false;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2608
    }
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
  2609
}
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2610
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2611
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2612
///
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2613
/// \brief Adds a new entry into the routing table.
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2614
///
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2615
/// 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
  2616
///
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2617
/// \param dest		address of the destination node.
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2618
/// \param next		address of the next hop node.
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2619
/// \param iface	address of the local interface.
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2620
/// \param dist		distance to the destination node.
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2621
///
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2622
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2623
RoutingProtocol::AddEntry (Ipv4Address const &dest,
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2624
                        Ipv4Address const &next,
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2625
                        uint32_t interface,
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2626
                        uint32_t distance)
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2627
{
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2628
  NS_LOG_FUNCTION (this << dest << next << interface << distance << m_mainAddress);
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2629
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2630
  NS_ASSERT (distance > 0);
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2631
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2632
  // Creates a new rt entry with specified values
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2633
  RoutingTableEntry &entry = m_table[dest];
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2634
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2635
  entry.destAddr = dest;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2636
  entry.nextAddr = next;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2637
  entry.interface = interface;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2638
  entry.distance = distance;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2639
}
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2640
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2641
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2642
RoutingProtocol::AddEntry (Ipv4Address const &dest,
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2643
                        Ipv4Address const &next,
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2644
                        Ipv4Address const &interfaceAddress,
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2645
                        uint32_t distance)
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2646
{
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2647
  NS_LOG_FUNCTION (this << dest << next << interfaceAddress << distance << m_mainAddress);
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2648
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2649
  NS_ASSERT (distance > 0);
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2650
  NS_ASSERT (m_ipv4);
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2651
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2652
  RoutingTableEntry entry;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2653
  for (uint32_t i = 0; i < m_ipv4->GetNInterfaces (); i++)
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2654
    {
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2655
      if (m_ipv4->GetAddress (i) == interfaceAddress)
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2656
        {
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2657
          AddEntry (dest, next, i, distance);
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2658
          return;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2659
        }
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2660
    }
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2661
  NS_ASSERT (false); // should not be reached
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2662
  AddEntry (dest, next, 0, distance);
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2663
}
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2664
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2665
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2666
std::vector<RoutingTableEntry>
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2667
RoutingProtocol::GetEntries () const
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2668
{
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2669
  std::vector<RoutingTableEntry> retval;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2670
  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
  2671
       iter != m_table.end (); iter++)
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2672
    {
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2673
      retval.push_back (iter->second);
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2674
    }
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2675
  return retval;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2676
}
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2677
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2678
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
  2679
}} // namespace olsr, ns3
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2680
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2681