src/routing/olsr/olsr-routing-protocol.cc
author Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
Tue, 15 Jun 2010 18:32:04 +0100
changeset 6438 96f612b05035
parent 6324 e56ec0532fec
child 6441 f555caf874dc
permissions -rw-r--r--
Fix OLSR socket usage: use the new SetAllowBroadcast socket option; Bind to interface bcast address instead of local address, use SendTo instead of Send. This is how things have to work with real world sockets.
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"
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
    43
#include "ns3/ipv4-routing-protocol.h"
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
    44
#include "ns3/ipv4-routing-table-entry.h"
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
    45
#include "ns3/ipv4-route.h"
2484
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2308
diff changeset
    46
#include "ns3/boolean.h"
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2308
diff changeset
    47
#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
    48
#include "ns3/enum.h"
2484
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2308
diff changeset
    49
#include "ns3/trace-source-accessor.h"
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
    50
#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
    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
/********** 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
    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
///
9757633a85da Add OLSR routing support, (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
/// \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
    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
/// 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
    58
/// 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
    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
#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
    61
                     (time - Simulator::Now () + Seconds (0.000001)))
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    62
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    63
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    64
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    65
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    66
/// \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
    67
///
9757633a85da Add OLSR routing support, (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
/// 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
    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
#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
    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
9757633a85da Add OLSR routing support, (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
/********** 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
    74
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    75
/// Neighbor holding time.
5932
462ca2c19a92 Bug 788: OLSR_NEIGH_HOLD_TIME should be 3 times OLSR_REFRESH_INTERVAL
Josh Pelkey <jpelkey@gatech.edu>
parents: 5867
diff changeset
    76
#define OLSR_NEIGHB_HOLD_TIME	(Scalar (3) * OLSR_REFRESH_INTERVAL)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    77
/// 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
    78
#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
    79
/// 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
    80
#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
    81
/// 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
    82
#define OLSR_MID_HOLD_TIME	(Scalar (3) * m_midInterval)
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
    83
/// HNA holding time.
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
    84
#define OLSR_HNA_HOLD_TIME  (Scalar (3) * m_hnaInterval)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    85
9757633a85da Add OLSR routing support, (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
/********** 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
    87
9757633a85da Add OLSR routing support, (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
/// 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
    89
#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
    90
/// 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
    91
#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
    92
/// 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
    93
#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
    94
/// 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
    95
#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
    96
9757633a85da Add OLSR routing support, (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
/********** 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
    98
9757633a85da Add OLSR routing support, (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
/// 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
   100
#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
   101
/// 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
   102
#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
   103
/// 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
   104
#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
   105
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   106
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   107
/********** 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
   108
9757633a85da Add OLSR routing support, (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: 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
   110
#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
   111
/// 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
   112
#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
   113
/// 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
   114
#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
   115
/// 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
   116
#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
   117
/// 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
   118
#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
   119
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   120
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   121
/********** 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
   122
9757633a85da Add OLSR routing support, (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
/// 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
   124
#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
   125
/// 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
   126
#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
   127
/// 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
   128
#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
   129
9757633a85da Add OLSR routing support, (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
#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
   132
/// 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
   133
#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
   134
9757633a85da Add OLSR routing support, (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
/// 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
   136
#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
   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
/// 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
   139
#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
   140
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   141
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   142
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
   143
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
   144
5867
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
   145
NS_LOG_COMPONENT_DEFINE ("OlsrRoutingProtocol");
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   146
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   147
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   148
/********** 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
   149
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   150
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
   151
2250
18f432098389 InterfaceId -> TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2249
diff changeset
   152
TypeId 
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   153
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
   154
{
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   155
  static TypeId tid = TypeId ("ns3::olsr::RoutingProtocol")
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
   156
    .SetParent<Ipv4RoutingProtocol> ()
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   157
    .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
   158
    .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
   159
                   TimeValue (Seconds (2)),
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   160
                   MakeTimeAccessor (&RoutingProtocol::m_helloInterval),
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 ("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
   163
                   TimeValue (Seconds (5)),
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   164
                   MakeTimeAccessor (&RoutingProtocol::m_tcInterval),
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 ("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
   167
                   TimeValue (Seconds (5)),
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   168
                   MakeTimeAccessor (&RoutingProtocol::m_midInterval),
2484
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2308
diff changeset
   169
                   MakeTimeChecker ())
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   170
    .AddAttribute ("HnaInterval", "HNA messages emission interval.  Normally it is equal to TcInterval.",
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   171
                   TimeValue (Seconds (5)),
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   172
                   MakeTimeAccessor (&RoutingProtocol::m_hnaInterval),
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   173
                   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
   174
    .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
   175
                   EnumValue (OLSR_WILL_DEFAULT),
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   176
                   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
   177
                   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
   178
                                    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
   179
                                    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
   180
                                    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
   181
                                    OLSR_WILL_ALWAYS, "always"))
2484
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2308
diff changeset
   182
    .AddTraceSource ("Rx", "Receive OLSR packet.",
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   183
                     MakeTraceSourceAccessor (&RoutingProtocol::m_rxPacketTrace))
2484
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2308
diff changeset
   184
    .AddTraceSource ("Tx", "Send OLSR packet.",
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   185
                     MakeTraceSourceAccessor (&RoutingProtocol::m_txPacketTrace))
2503
e667dc0f350e merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2334 2484
diff changeset
   186
    .AddTraceSource ("RoutingTableChanged", "The OLSR routing table has changed.",
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   187
		     MakeTraceSourceAccessor (&RoutingProtocol::m_routingTableChanged))
2484
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2308
diff changeset
   188
    ;
2252
80595448707a iid -> tid
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
   189
  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
   190
}
3a1da26d61dc replace ComponentManager::Create and ClassId with InterfaceId::CreateObjest and InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2232
diff changeset
   191
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   192
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   193
RoutingProtocol::RoutingProtocol ()
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   194
  : m_routingTableAssociation (0),
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   195
    m_ipv4 (0),
4560
2f106fd728ab Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4472
diff changeset
   196
    m_helloTimer (Timer::CANCEL_ON_DESTROY),
2f106fd728ab Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4472
diff changeset
   197
    m_tcTimer (Timer::CANCEL_ON_DESTROY),
2f106fd728ab Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4472
diff changeset
   198
    m_midTimer (Timer::CANCEL_ON_DESTROY),
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   199
    m_hnaTimer (Timer::CANCEL_ON_DESTROY),    
4560
2f106fd728ab Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4472
diff changeset
   200
    m_queuedMessagesTimer (Timer::CANCEL_ON_DESTROY)
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   201
{
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   202
  m_hnaRoutingTable = Create<Ipv4StaticRouting> ();
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   203
}
2484
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2308
diff changeset
   204
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   205
RoutingProtocol::~RoutingProtocol ()
2900
b5deaba7280e add destructor. Easier to plant a breakpoint in there.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2827
diff changeset
   206
{}
b5deaba7280e add destructor. Easier to plant a breakpoint in there.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2827
diff changeset
   207
2484
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2308
diff changeset
   208
void
4560
2f106fd728ab Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4472
diff changeset
   209
RoutingProtocol::SetIpv4 (Ptr<Ipv4> ipv4)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   210
{
4560
2f106fd728ab Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4472
diff changeset
   211
  NS_ASSERT (ipv4 != 0);
2f106fd728ab Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4472
diff changeset
   212
  NS_ASSERT (m_ipv4 == 0);
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   213
  NS_LOG_DEBUG ("Created olsr::RoutingProtocol");
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   214
  m_helloTimer.SetFunction (&RoutingProtocol::HelloTimerExpire, this);
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   215
  m_tcTimer.SetFunction (&RoutingProtocol::TcTimerExpire, this);
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   216
  m_midTimer.SetFunction (&RoutingProtocol::MidTimerExpire, this);
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   217
  m_hnaTimer.SetFunction (&RoutingProtocol::HnaTimerExpire, this);
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   218
  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
   219
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   220
  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
   221
  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
   222
  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
   223
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   224
  m_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
   225
4560
2f106fd728ab Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4472
diff changeset
   226
  m_ipv4 = ipv4;
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   227
  
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   228
  m_hnaRoutingTable->SetIpv4 (ipv4);
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   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
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   231
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
   232
{
9757633a85da Add OLSR routing support, (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
  m_ipv4 = 0;
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   234
  m_hnaRoutingTable = 0;
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   235
  m_routingTableAssociation = 0;
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   236
5761
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
   237
  for (std::map< Ptr<Socket>, Ipv4InterfaceAddress >::iterator iter = m_socketAddresses.begin ();
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   238
       iter != m_socketAddresses.end (); iter++)
1779
85fd2b8c9e76 Fix OLSR agent finalization issues.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1778
diff changeset
   239
    {
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
   240
      iter->first->Close ();
1779
85fd2b8c9e76 Fix OLSR agent finalization issues.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1778
diff changeset
   241
    }
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
   242
  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
   243
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
   244
  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
   245
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   246
5524
efed7493f2c1 Make applications generate traffic within their associated context/node
Guillaume Seguin <guillaume@segu.in>
parents: 5510
diff changeset
   247
void RoutingProtocol::DoStart ()
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   248
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   249
  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
   250
    {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   251
      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
   252
      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
   253
        {
4375
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4218
diff changeset
   254
          // Use primary address, if multiple
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4218
diff changeset
   255
          Ipv4Address addr = m_ipv4->GetAddress (i, 0).GetLocal ();
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   256
          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
   257
            {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   258
              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
   259
              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
   260
            }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   261
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   262
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   263
      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
   264
    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   265
1804
9c11e776f501 bug 96: debug.h duplicates functionality from log.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1803
diff changeset
   266
  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
   267
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
   268
  Ipv4Address loopback ("127.0.0.1");
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   269
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   270
  bool canRunOlsr = false;
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   271
  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
   272
    {
4375
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4218
diff changeset
   273
      Ipv4Address addr = m_ipv4->GetAddress (i, 0).GetLocal ();
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   274
      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
   275
        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
   276
caa15068fb3b OLSR: code cleanup, more 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
      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
   278
        {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   279
          // 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
   280
          // 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
   281
          // 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
   282
          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
   283
          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
   284
          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
   285
          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
   286
          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
   287
        }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   288
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   289
      if(m_interfaceExclusions.find (i) != m_interfaceExclusions.end ())
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   290
        continue;
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   291
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
   292
      // 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
   293
      Ptr<Socket> socket = Socket::CreateSocket (GetObject<Node> (), 
6438
96f612b05035 Fix OLSR socket usage: use the new SetAllowBroadcast socket option; Bind to interface bcast address instead of local address, use SendTo instead of Send. This is how things have to work with real world sockets.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6324
diff changeset
   294
                                                 UdpSocketFactory::GetTypeId());
96f612b05035 Fix OLSR socket usage: use the new SetAllowBroadcast socket option; Bind to interface bcast address instead of local address, use SendTo instead of Send. This is how things have to work with real world sockets.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6324
diff changeset
   295
      socket->SetAllowBroadcast (true);
96f612b05035 Fix OLSR socket usage: use the new SetAllowBroadcast socket option; Bind to interface bcast address instead of local address, use SendTo instead of Send. This is how things have to work with real world sockets.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6324
diff changeset
   296
      InetSocketAddress inetAddr (addr.GetSubnetDirectedBroadcast (m_ipv4->GetAddress (i, 0).GetMask ()), OLSR_PORT_NUMBER);
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   297
      socket->SetRecvCallback (MakeCallback (&RoutingProtocol::RecvOlsr,  this));
6438
96f612b05035 Fix OLSR socket usage: use the new SetAllowBroadcast socket option; Bind to interface bcast address instead of local address, use SendTo instead of Send. This is how things have to work with real world sockets.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6324
diff changeset
   298
      if (socket->Bind (inetAddr))
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   299
        {
6438
96f612b05035 Fix OLSR socket usage: use the new SetAllowBroadcast socket option; Bind to interface bcast address instead of local address, use SendTo instead of Send. This is how things have to work with real world sockets.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6324
diff changeset
   300
          NS_FATAL_ERROR ("Failed to bind() OLSR socket");
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   301
        }
5761
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
   302
      m_socketAddresses[socket] = m_ipv4->GetAddress (i, 0);
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   303
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   304
      canRunOlsr = true;
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   305
    }
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
   306
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   307
  if(canRunOlsr)
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   308
   {
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   309
      HelloTimerExpire ();
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   310
      TcTimerExpire ();
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   311
      MidTimerExpire ();
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   312
      HnaTimerExpire ();      
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   313
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   314
      NS_LOG_DEBUG ("OLSR on node " << m_mainAddress << " started");
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   315
   }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   316
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   317
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   318
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
   319
{
4375
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4218
diff changeset
   320
  m_mainAddress = m_ipv4->GetAddress (interface, 0).GetLocal ();
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   321
}
9757633a85da Add OLSR routing support, (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
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   323
void RoutingProtocol::SetInterfaceExclusions (std::set<uint32_t> exceptions)
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   324
{
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   325
  m_interfaceExclusions = exceptions;
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   326
}
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   327
9757633a85da Add OLSR routing support, (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
//
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   329
// \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
   330
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   331
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
   332
{
3098
d384d52f8f6e Cut over UDP applications to use the new receive API
Tom Henderson <tomh@tomh.org>
parents: 2972
diff changeset
   333
  Ptr<Packet> receivedPacket;
3270
e01d2843b3a0 Change OLSR to use RecvFrom
Tom Henderson <tomh@tomh.org>
parents: 3269
diff changeset
   334
  Address sourceAddress;
e01d2843b3a0 Change OLSR to use RecvFrom
Tom Henderson <tomh@tomh.org>
parents: 3269
diff changeset
   335
  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
   336
1740
3d3168e8fef6 Update OLSR code to NS-3 API changes.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1732
diff changeset
   337
  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
   338
  Ipv4Address senderIfaceAddr = inetSourceAddr.GetIpv4 ();
5761
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
   339
  Ipv4Address receiverIfaceAddr = m_socketAddresses[socket].GetLocal ();
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   340
  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
   341
  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
   342
                << 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
   343
  
1716
9757633a85da Add OLSR routing support, (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
  // 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
   345
  // 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
   346
  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
   347
  
1868
06027fd6a68c olsr gets new packet
Craig Dowell <craigdo@ee.washington.edu>
parents: 1803
diff changeset
   348
  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
   349
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
   350
  olsr::PacketHeader olsrPacketHeader;
1868
06027fd6a68c olsr gets new packet
Craig Dowell <craigdo@ee.washington.edu>
parents: 1803
diff changeset
   351
  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
   352
  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
   353
  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
   354
4078e5efdfc6 Add OLSR message tracing, as discussed on ns-developers list.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1801
diff changeset
   355
  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
   356
  
9757633a85da Add OLSR routing support, (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
  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
   358
    {
1803
4078e5efdfc6 Add OLSR message tracing, as discussed on ns-developers list.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1801
diff changeset
   359
      MessageHeader messageHeader;
1868
06027fd6a68c olsr gets new packet
Craig Dowell <craigdo@ee.washington.edu>
parents: 1803
diff changeset
   360
      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
   361
        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
   362
      
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
   363
      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
   364
1804
9c11e776f501 bug 96: debug.h duplicates functionality from log.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1803
diff changeset
   365
      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
   366
                << 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
   367
                << " 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
   368
                << " 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
   369
      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
   370
    }
1716
9757633a85da Add OLSR routing support, (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
1803
4078e5efdfc6 Add OLSR message tracing, as discussed on ns-developers list.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1801
diff changeset
   372
  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
   373
4078e5efdfc6 Add OLSR message tracing, as discussed on ns-developers list.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1801
diff changeset
   374
  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
   375
       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
   376
    {
4078e5efdfc6 Add OLSR message tracing, as discussed on ns-developers list.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1801
diff changeset
   377
      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
   378
      // 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
   379
      // 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
   380
      // 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
   381
      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
   382
          || 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
   383
        {
1868
06027fd6a68c olsr gets new packet
Craig Dowell <craigdo@ee.washington.edu>
parents: 1803
diff changeset
   384
          packet->RemoveAtStart (messageHeader.GetSerializedSize ()
06027fd6a68c olsr gets new packet
Craig Dowell <craigdo@ee.washington.edu>
parents: 1803
diff changeset
   385
                                 - 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
   386
          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
   387
        }
9757633a85da Add OLSR routing support, (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
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   389
      // 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
   390
      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
   391
      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
   392
        (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
   393
         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
   394
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
   395
      // 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
   396
//       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
   397
//       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
   398
//       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
   399
//         {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   400
//           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
   401
//         }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   402
//       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
   403
//         {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   404
//           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
   405
//         }
1716
9757633a85da Add OLSR routing support, (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
      
9757633a85da Add OLSR routing support, (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
      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
   408
        {
9757633a85da Add OLSR routing support, (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
          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
   410
            {
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
   411
            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
   412
              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
   413
                            << "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
   414
                            << " 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
   415
              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
   416
              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
   417
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
   418
            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
   419
              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
   420
                            << "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
   421
                            << " 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
   422
              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
   423
              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
   424
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
   425
            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
   426
              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
   427
                            << "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
   428
                            <<  " 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
   429
              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
   430
              break;
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   431
            case olsr::MessageHeader::HNA_MESSAGE:
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   432
              NS_LOG_DEBUG (Simulator::Now ().GetSeconds ()
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   433
                            << "s OLSR node " << m_mainAddress
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   434
                            <<  " received HNA message of size " << messageHeader.GetSerializedSize ());
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   435
              ProcessHna (messageHeader, senderIfaceAddr);
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
   436
              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
   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
            default:
1804
9c11e776f501 bug 96: debug.h duplicates functionality from log.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1803
diff changeset
   439
              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
   440
                        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
   441
                        " 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
   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
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   444
      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
   445
        {
1804
9c11e776f501 bug 96: debug.h duplicates functionality from log.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1803
diff changeset
   446
          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
   447
      
9757633a85da Add OLSR routing support, (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
          // 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
   449
          // 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
   450
          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
   451
               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
   452
            {
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
   453
              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
   454
                {
9757633a85da Add OLSR routing support, (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
                  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
   456
                  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
   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
        }
9757633a85da Add OLSR routing support, (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
      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
   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
          // 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
   464
          // 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
   465
          // 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
   466
          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
   467
            {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   468
              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
   469
                              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
   470
            }
1716
9757633a85da Add OLSR routing support, (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
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   472
	
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   473
    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   474
9757633a85da Add OLSR routing support, (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
  // 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
   476
  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
   477
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   478
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   479
///
9757633a85da Add OLSR routing support, (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
/// \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
   481
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   482
/// \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
   483
/// \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
   484
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   485
int
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   486
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
   487
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   488
  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
   489
  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
   490
       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
   491
    {
9757633a85da Add OLSR routing support, (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
      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
   493
      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
   494
        {
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   495
          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
   496
            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
   497
          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
   498
            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
   499
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   500
    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   501
  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
   502
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   503
5756
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   504
namespace {
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   505
///
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   506
/// \brief Remove all covered 2-hop neighbors from N2 set. This is a helper function used by MprComputation algorithm.
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   507
///
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   508
void 
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   509
CoverTwoHopNeighbors (Ipv4Address neighborMainAddr, TwoHopNeighborSet & N2)
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   510
{
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   511
  // first gather all 2-hop neighbors to be removed
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   512
  std::set<Ipv4Address> toRemove;
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   513
  for (TwoHopNeighborSet::iterator twoHopNeigh = N2.begin (); twoHopNeigh != N2.end (); twoHopNeigh ++)
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   514
    {
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   515
      if (twoHopNeigh->neighborMainAddr == neighborMainAddr)
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   516
        {
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   517
          toRemove.insert (twoHopNeigh->twoHopNeighborAddr);
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   518
        }
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   519
    }
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   520
  // Now remove all matching records from N2
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   521
  for (TwoHopNeighborSet::iterator twoHopNeigh = N2.begin (); twoHopNeigh != N2.end (); )
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   522
    {
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   523
      if (toRemove.find (twoHopNeigh->twoHopNeighborAddr) != toRemove.end ())
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   524
        {
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   525
          twoHopNeigh = N2.erase (twoHopNeigh);
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   526
        }
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   527
      else
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   528
        {
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   529
          twoHopNeigh ++;
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   530
        }
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   531
    }
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   532
}
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   533
} // anonymous namespace
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   534
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   535
///
9757633a85da Add OLSR routing support, (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
/// \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
   537
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   538
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   539
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
   540
{
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   541
  NS_LOG_FUNCTION (this);
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   542
  
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   543
  // 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
   544
  // (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
   545
  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
   546
	
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   547
  
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   548
  // 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
   549
  // 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
   550
  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
   551
  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
   552
       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
   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->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
   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
          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
   557
        }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   558
    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   559
	
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   560
  // 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
   561
  // 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
   562
  // (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
   563
  // (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
   564
  // (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
   565
  //       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
   566
  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
   567
  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
   568
       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
   569
    {
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
   570
      // 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
   571
      // (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
   572
      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
   573
        {
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
   574
          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
   575
        }
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
   576
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
   577
      //  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
   578
      // (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
   579
      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
   580
      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
   581
           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
   582
        {
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
   583
          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
   584
            {
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
              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
   586
                {
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
                  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
   588
                  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
   589
                }
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
   590
              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
   591
                {
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
   592
                  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
   593
                  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
   594
                }
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
            }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   596
        }
2361
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   597
      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
   598
        {
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
   599
          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
   600
        }
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
      // 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
   603
      // (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
   604
      //       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
   605
      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
   606
           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
   607
        {
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
   608
          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
   609
            {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   610
              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
   611
              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
   612
            }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   613
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   614
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   615
      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
   616
        {
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   617
          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
   618
        }
1716
9757633a85da Add OLSR routing support, (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
    }
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
   620
5471
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   621
#ifdef NS3_LOG_ENABLE
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   622
  {
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   623
    std::ostringstream os;
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   624
    os << "[";
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   625
    for (TwoHopNeighborSet::const_iterator iter = N2.begin ();
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   626
         iter != N2.end (); iter++)
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   627
      {
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   628
        TwoHopNeighborSet::const_iterator next = iter;
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   629
        next++;
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   630
        os << iter->neighborMainAddr << "->" << iter->twoHopNeighborAddr;
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   631
        if (next != N2.end ())
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   632
          os << ", ";
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   633
      }
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   634
    os << "]";
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   635
    NS_LOG_DEBUG ("N2: " << os.str ());
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   636
  }
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   637
#endif  //NS3_LOG_ENABLE
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   638
1716
9757633a85da Add OLSR routing support, (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
  // 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
   640
  // 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
   641
  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
   642
    {
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
   643
      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
   644
        {
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
   645
          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
   646
          // (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
   647
          // neighbors reachable by the MPR from N2)
5756
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   648
          CoverTwoHopNeighbors (neighbor->neighborMainAddr, N2);
2361
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   649
        }
1716
9757633a85da Add OLSR routing support, (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
    }
9757633a85da Add OLSR routing support, (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
  
9757633a85da Add OLSR routing support, (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
  // 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
   653
  // (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
   654
	
9757633a85da Add OLSR routing support, (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
  // 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
   656
  // 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
   657
  std::set<Ipv4Address> coveredTwoHopNeighbors;
5471
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   658
  for (TwoHopNeighborSet::const_iterator twoHopNeigh = N2.begin (); twoHopNeigh != N2.end (); twoHopNeigh++)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   659
    {
5471
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   660
      bool onlyOne = true;
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   661
      // try to find another neighbor that can reach twoHopNeigh->twoHopNeighborAddr
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   662
      for (TwoHopNeighborSet::const_iterator otherTwoHopNeigh = N2.begin (); otherTwoHopNeigh != N2.end (); otherTwoHopNeigh++)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   663
        {
5471
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   664
          if (otherTwoHopNeigh->twoHopNeighborAddr == twoHopNeigh->twoHopNeighborAddr
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   665
              && otherTwoHopNeigh->neighborMainAddr != twoHopNeigh->neighborMainAddr)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   666
            {
5471
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   667
              onlyOne = false;
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   668
              break;
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   669
            }
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   670
        }
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   671
      if (onlyOne)
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   672
        {
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   673
          NS_LOG_LOGIC ("Neighbor " << twoHopNeigh->neighborMainAddr
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   674
                        << " is the only that can reach 2-hop neigh. "
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   675
                        << twoHopNeigh->twoHopNeighborAddr
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   676
                        << " => select as MPR.");
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   677
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   678
          mprSet.insert (twoHopNeigh->neighborMainAddr);
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   679
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   680
          // take note of all the 2-hop neighbors reachable by the newly elected MPR
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   681
          for (TwoHopNeighborSet::const_iterator otherTwoHopNeigh = N2.begin ();
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   682
               otherTwoHopNeigh != N2.end (); otherTwoHopNeigh++)
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   683
            {
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   684
              if (otherTwoHopNeigh->neighborMainAddr == twoHopNeigh->neighborMainAddr)
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   685
                {
5471
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   686
                  coveredTwoHopNeighbors.insert (otherTwoHopNeigh->twoHopNeighborAddr);
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   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
        }
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
   690
    }
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
  // 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
   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 (); )
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
   694
    {
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 (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
   696
        {
5756
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   697
          // This works correctly only because it is known that twoHopNeigh is reachable by exactly one neighbor, 
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   698
          // so only one record in N2 exists for each of them. This record is erased here.
5471
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   699
          NS_LOG_LOGIC ("2-hop neigh. " << twoHopNeigh->twoHopNeighborAddr << " is already covered by an MPR.");
2361
743e0e351379 OLSR: fix default willingness value, cleanup and fix the MPR computation algorithm.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2359
diff changeset
   700
          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
   701
        }
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
   702
      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
   703
        {
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
   704
          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
   705
        }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   706
    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   707
	
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   708
  // 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
   709
  // 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
   710
  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
   711
    {
5471
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   712
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   713
#ifdef NS3_LOG_ENABLE
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   714
      {
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   715
        std::ostringstream os;
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   716
        os << "[";
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   717
        for (TwoHopNeighborSet::const_iterator iter = N2.begin ();
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   718
             iter != N2.end (); iter++)
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   719
          {
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   720
            TwoHopNeighborSet::const_iterator next = iter;
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   721
            next++;
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   722
            os << iter->neighborMainAddr << "->" << iter->twoHopNeighborAddr;
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   723
            if (next != N2.end ())
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   724
              os << ", ";
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   725
          }
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   726
        os << "]";
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   727
        NS_LOG_DEBUG ("Step 4 iteration: N2=" << os.str ());
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   728
      }
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   729
#endif  //NS3_LOG_ENABLE
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   730
61831e265e20 Bug 733: OLSR MPR Computation give incorrect result
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   731
1716
9757633a85da Add OLSR routing support, (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
      // 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
   733
      // 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
   734
      // 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
   735
      // 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
   736
      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
   737
      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
   738
      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
   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
          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
   741
          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
   742
          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
   743
            {
9757633a85da Add OLSR routing support, (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
              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
   745
              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
   746
                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
   747
            }
9757633a85da Add OLSR routing support, (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
          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
   749
          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
   750
        }
9757633a85da Add OLSR routing support, (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
      
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   752
      // 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
   753
      // 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
   754
      // 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
   755
      // 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
   756
      // 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
   757
      // 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
   758
      // 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
   759
      // 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
   760
      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
   761
      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
   762
      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
   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
          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
   765
          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
   766
            {
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
   767
              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
   768
            }
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
   769
          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
   770
               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
   771
            {
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
   772
              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
   773
              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
   774
                {
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
   775
                  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
   776
                  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
   777
                }
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
   778
              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
   779
                {
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
   780
                  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
   781
                    {
9757633a85da Add OLSR routing support, (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
                      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
   783
                      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
   784
                    }
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
   785
                  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
   786
                    {
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
   787
                      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
   788
                        {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   789
                          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
   790
                          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
   791
                        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   792
                    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   793
                }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   794
            }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   795
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   796
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   797
      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
   798
        {
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
   799
          mprSet.insert (max->neighborMainAddr);
5756
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   800
          CoverTwoHopNeighbors (max->neighborMainAddr, N2);
31623ed9b682 [olsr] Bug 740 fixed
Pavel Boyko <boyko@iitp.ru>
parents: 5524
diff changeset
   801
          NS_LOG_LOGIC (N2.size () << " 2-hop neighbors left to cover!");           
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   802
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   803
    }
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
   804
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   805
#ifdef NS3_LOG_ENABLE
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   806
  {
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   807
    std::ostringstream os;
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   808
    os << "[";
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   809
    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
   810
         iter != mprSet.end (); iter++)
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   811
      {
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   812
        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
   813
        next++;
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   814
        os << *iter;
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   815
        if (next != mprSet.end ())
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   816
          os << ", ";
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   817
      }
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   818
    os << "]";
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   819
    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
   820
  }
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
   821
#endif  //NS3_LOG_ENABLE
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
   822
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
   823
  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
   824
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   825
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   826
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   827
/// \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
   828
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   829
/// \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
   830
/// \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
   831
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   832
Ipv4Address
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   833
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
   834
{
1798
7bb07f0d0e9f Make OlsrAgentImpl::GetMainAddress const
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1779
diff changeset
   835
  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
   836
    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
   837
  
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   838
  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
   839
    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
   840
  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
   841
    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
   842
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   843
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   844
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   845
/// \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
   846
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   847
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
   848
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
   849
{
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
   850
  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
   851
                << ": 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
   852
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   853
  // 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
   854
  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
   855
	
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   856
  // 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
   857
  // 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
   858
  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
   859
  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
   860
       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
   861
    {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   862
      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
   863
      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
   864
      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
   865
        {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   866
          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
   867
          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
   868
          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
   869
          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
   870
               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
   871
            {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   872
              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
   873
              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
   874
                            << (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
   875
              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
   876
                  && 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
   877
                {
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
   878
                  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
   879
                                << " => 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
   880
                  lt = &link_tuple;
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
   881
                  AddEntry (link_tuple.neighborIfaceAddr,
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
   882
                            link_tuple.neighborIfaceAddr,
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
   883
                            link_tuple.localIfaceAddr,
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
   884
                            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
   885
                  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
   886
                    {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   887
                      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
   888
                    }
caa15068fb3b OLSR: code cleanup, more 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
                }
caa15068fb3b OLSR: code cleanup, more 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
              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
   891
                {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   892
                  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
   893
                                << "; 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
   894
                                << "; 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
   895
                                << " => 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
   896
                }
9757633a85da Add OLSR routing support, (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
            }
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   898
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   899
          // 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
   900
          // 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
   901
          // 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
   902
          //      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
   903
          //      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
   904
          //                     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
   905
          //      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
   906
          //      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
   907
          //                     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
   908
          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
   909
            {
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
              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
   911
                            "=> adding additional routing entry");
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
   912
              AddEntry(nb_tuple.neighborMainAddr,
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
   913
                       lt->neighborIfaceAddr,
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
   914
                       lt->localIfaceAddr,
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
   915
                       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
   916
            }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   917
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   918
    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   919
  
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
  //  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
   921
  //  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
   922
  //  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
   923
  //  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
   924
  //  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
   925
  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
   926
  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
   927
       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
   928
    {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   929
      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
   930
caa15068fb3b OLSR: code cleanup, more 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
      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
   932
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   933
      // a 2-hop neighbor which is not a neighbor node or the node itself
5867
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
   934
      if (m_state.FindSymNeighborTuple (nb2hop_tuple.twoHopNeighborAddr))
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   935
        {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   936
          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
   937
          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
   938
        }
caa15068fb3b OLSR: code cleanup, more 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
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   940
      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
   941
        {
caa15068fb3b OLSR: code cleanup, more 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
          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
   943
          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
   944
        }
caa15068fb3b OLSR: code cleanup, more 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
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   946
      // ...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
   947
      // 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
   948
      // 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
   949
      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
   950
      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
   951
           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
   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
          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
   954
              && 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
   955
            {
caa15068fb3b OLSR: code cleanup, more 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
              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
   957
              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
   958
            }
caa15068fb3b OLSR: code cleanup, more 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
        }
caa15068fb3b OLSR: code cleanup, more 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
      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
   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
          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
   963
                        << 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
   964
                        << " 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
   965
                        << ", 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
   966
          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
   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
      
caa15068fb3b OLSR: code cleanup, more 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
      // 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
   970
      //                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
   971
      //                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
   972
      //                               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
   973
      //                                   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
   974
      //                                                  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
   975
      //                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
   976
      //                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
   977
      //                               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
   978
      //                                   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
   979
      //                                                  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
   980
      RoutingTableEntry entry;
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
   981
      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
   982
      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
   983
        {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   984
          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
   985
          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
   986
                                    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
   987
                                    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
   988
                                    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
   989
        }
1716
9757633a85da Add OLSR routing support, (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
      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
   991
        {
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
   992
          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
   993
                        << nb2hop_tuple.twoHopNeighborAddr
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
   994
                        << " 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
   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
    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   997
  
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   998
  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
   999
    {
9757633a85da Add OLSR routing support, (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
      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
  1001
		
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
      // 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
  1003
      // 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
  1004
      // 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
  1005
      // 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
  1006
      // 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
  1007
      // 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
  1008
      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
  1009
      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
  1010
           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
  1011
        {
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1012
          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
  1013
          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
  1014
caa15068fb3b OLSR: code cleanup, more 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
          RoutingTableEntry destAddrEntry, lastAddrEntry;
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  1016
          bool have_destAddrEntry = Lookup (topology_tuple.destAddr, destAddrEntry);
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  1017
          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
  1018
          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
  1019
            {
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
  1020
              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
  1021
              // 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
  1022
              //                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
  1023
              //                     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
  1024
              //                     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
  1025
              //                                    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
  1026
              //                                    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
  1027
              //                     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
  1028
              //                     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
  1029
              //                                    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
  1030
              //                                       R_dest_addr == T_last_addr.
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  1031
              AddEntry (topology_tuple.destAddr,
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  1032
                        lastAddrEntry.nextAddr,
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  1033
                        lastAddrEntry.interface,
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  1034
                        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
  1035
              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
  1036
            }
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
  1037
          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
  1038
            {
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
  1039
              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
  1040
                            "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
  1041
                            << " 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
  1042
                            << " 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
  1043
                            << " (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
  1044
            }
9757633a85da Add OLSR routing support, (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
        }
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
  1046
      
1716
9757633a85da Add OLSR routing support, (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
      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
  1048
        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
  1049
    }
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1050
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1051
  // 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
  1052
  // 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
  1053
  //	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
  1054
  // 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
  1055
  //	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
  1056
  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
  1057
  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
  1058
       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
  1059
    {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1060
      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
  1061
      RoutingTableEntry entry1, entry2;
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  1062
      bool have_entry1 = Lookup (tuple.mainAddr, entry1);
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  1063
      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
  1064
      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
  1065
        {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1066
          // 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
  1067
          //       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
  1068
          //                                     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
  1069
          //       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
  1070
          //       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
  1071
          //       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
  1072
          AddEntry (tuple.ifaceAddr,
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  1073
                    entry1.nextAddr,
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  1074
                    entry1.interface,
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  1075
                    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
  1076
        }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1077
    }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1078
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1079
  // 5. For each tuple in the association set,
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1080
  //    If there is no entry in the routing table with:
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1081
  //        R_dest_addr     == A_network_addr/A_netmask
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1082
  //   then a new routing entry is created.
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1083
  const AssociationSet &associationSet = m_state.GetAssociationSet ();
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1084
  for (AssociationSet::const_iterator it = associationSet.begin ();
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1085
       it != associationSet.end (); it++)
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1086
    {
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1087
      AssociationTuple const &tuple = *it;
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1088
      RoutingTableEntry gatewayEntry;
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1089
      
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1090
      bool gatewayEntryExists = Lookup (tuple.gatewayAddr, gatewayEntry);
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1091
      bool addRoute = false;
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1092
      
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1093
      uint32_t routeIndex = 0;
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1094
      
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1095
      for (routeIndex = 0; routeIndex < m_hnaRoutingTable->GetNRoutes (); routeIndex++)
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1096
        {
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1097
          Ipv4RoutingTableEntry route = m_hnaRoutingTable->GetRoute (routeIndex);
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1098
          if (route.GetDestNetwork () == tuple.networkAddr &&
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1099
              route.GetDestNetworkMask () == tuple.netmask)
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1100
            {
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1101
              break;
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1102
            }
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1103
        }
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1104
    
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1105
      if (routeIndex == m_hnaRoutingTable->GetNRoutes ())
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1106
        {
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1107
          addRoute = true;
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1108
        }
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1109
      else if(gatewayEntryExists && m_hnaRoutingTable->GetMetric (routeIndex) > gatewayEntry.distance)
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1110
        {
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1111
          m_hnaRoutingTable->RemoveRoute(routeIndex);
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1112
          addRoute = true;
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1113
        }
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1114
        
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1115
      if(addRoute && gatewayEntryExists)
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1116
        {
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1117
          m_hnaRoutingTable->AddNetworkRouteTo (tuple.networkAddr,
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1118
                                                tuple.netmask,
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1119
                                                gatewayEntry.nextAddr,
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1120
                                                gatewayEntry.interface,
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1121
                                                gatewayEntry.distance);
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1122
                                             
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1123
        }
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1124
    }
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1125
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
  1126
  NS_LOG_DEBUG ("Node " << m_mainAddress << ": RoutingTableComputation end.");
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  1127
  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
  1128
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1129
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1130
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1131
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1132
/// \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
  1133
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1134
/// 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
  1135
/// 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
  1136
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1137
/// \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
  1138
/// \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
  1139
/// \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
  1140
///
9757633a85da Add OLSR routing support, (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
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1142
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
  1143
                         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
  1144
                         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
  1145
{
6438
96f612b05035 Fix OLSR socket usage: use the new SetAllowBroadcast socket option; Bind to interface bcast address instead of local address, use SendTo instead of Send. This is how things have to work with real world sockets.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6324
diff changeset
  1146
  NS_LOG_FUNCTION (msg << receiverIface << senderIface);
96f612b05035 Fix OLSR socket usage: use the new SetAllowBroadcast socket option; Bind to interface bcast address instead of local address, use SendTo instead of Send. This is how things have to work with real world sockets.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6324
diff changeset
  1147
  
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
  1148
  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
  1149
1716
9757633a85da Add OLSR routing support, (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
  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
  1151
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1152
#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
  1153
  {
caa15068fb3b OLSR: code cleanup, more 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 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
  1155
    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
  1156
                  << "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
  1157
    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
  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(*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
  1160
      }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1161
    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
  1162
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1163
    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
  1164
    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
  1165
                  << "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
  1166
    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
  1167
      {
caa15068fb3b OLSR: code cleanup, more 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
        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
  1169
      }
caa15068fb3b OLSR: code cleanup, more 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
    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
  1171
  }
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  1172
#endif // NS3_LOG_ENABLE
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1173
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1174
  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
  1175
  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
  1176
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1177
#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
  1178
  {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1179
    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
  1180
    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
  1181
                  << "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
  1182
    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
  1183
         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
  1184
      {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1185
        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
  1186
      }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1187
    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
  1188
  }
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  1189
#endif // NS3_LOG_ENABLE
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1190
1716
9757633a85da Add OLSR routing support, (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
  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
  1192
  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
  1193
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1194
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1195
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1196
/// \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
  1197
///
9757633a85da Add OLSR routing support, (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
/// 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
  1199
/// 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
  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
/// \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
  1202
/// \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
  1203
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1204
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1205
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
  1206
                      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
  1207
{
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
  1208
  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
  1209
  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
  1210
	
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1211
  // 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
  1212
  // 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
  1213
  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
  1214
  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
  1215
    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
  1216
	
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1217
  // 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
  1218
  // 	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
  1219
  // 	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
  1220
  // 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
  1221
  // performed.
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  1222
  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
  1223
    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
  1224
  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
  1225
    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
  1226
	
9757633a85da Add OLSR routing support, (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
  // 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
  1228
  //	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
  1229
  //	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
  1230
  // 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
  1231
  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
  1232
9757633a85da Add OLSR routing support, (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
  // 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
  1234
  // 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
  1235
  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
  1236
       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
  1237
    {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1238
      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
  1239
      // 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
  1240
      // 	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
  1241
      // 	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
  1242
      // 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
  1243
      // 	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
  1244
      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
  1245
        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
  1246
9757633a85da Add OLSR routing support, (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
      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
  1248
        {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1249
          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
  1250
        }
9757633a85da Add OLSR routing support, (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
      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
  1252
        {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1253
          // 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
  1254
          // 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
  1255
          //	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
  1256
          //	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
  1257
          //	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
  1258
          //	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
  1259
          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
  1260
          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
  1261
          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
  1262
          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
  1263
          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
  1264
          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
  1265
9757633a85da Add OLSR routing support, (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
          // 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
  1267
          m_events.Track (Simulator::Schedule (DELAY (topologyTuple.expirationTime),
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1268
                                               &RoutingProtocol::TopologyTupleTimerExpire,
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  1269
                                               this,
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  1270
                                               topologyTuple.destAddr,
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  1271
                                               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
  1272
        }
9757633a85da Add OLSR routing support, (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
    }
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
  1274
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1275
#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
  1276
  {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1277
    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
  1278
    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
  1279
                  << "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
  1280
    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
  1281
         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
  1282
      {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1283
        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
  1284
      }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1285
    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
  1286
  }
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  1287
#endif // NS3_LOG_ENABLE
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1288
}
9757633a85da Add OLSR routing support, (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
9757633a85da Add OLSR routing support, (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
///
9757633a85da Add OLSR routing support, (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
/// \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
  1292
///
9757633a85da Add OLSR routing support, (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
/// 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
  1294
/// 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
  1295
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1296
/// \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
  1297
/// \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
  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
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1300
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
  1301
                       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
  1302
{
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
  1303
  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
  1304
  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
  1305
  
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1306
  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
  1307
  // 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
  1308
  // 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
  1309
  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
  1310
  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
  1311
    {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1312
      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
  1313
                    ": 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
  1314
                    "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
  1315
                    " 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
  1316
      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
  1317
    }
1716
9757633a85da Add OLSR routing support, (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
  // 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
  1320
  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
  1321
       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
  1322
    {
9757633a85da Add OLSR routing support, (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
      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
  1324
      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
  1325
      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
  1326
           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
  1327
        {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1328
          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
  1329
              && 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
  1330
            {
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
  1331
              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
  1332
              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
  1333
              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
  1334
            }
9757633a85da Add OLSR routing support, (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
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1336
      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
  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
          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
  1339
          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
  1340
          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
  1341
          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
  1342
          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
  1343
          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
  1344
          // 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
  1345
          Simulator::Schedule (DELAY (tuple.time),
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1346
                               &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
  1347
        }
9757633a85da Add OLSR routing support, (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
    }
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
  1349
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1350
  // 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
  1351
  // 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
  1352
  // 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
  1353
  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
  1354
  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
  1355
    {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1356
      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
  1357
    }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1358
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1359
  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
  1360
  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
  1361
       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
  1362
    {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1363
      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
  1364
      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
  1365
    }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1366
  NS_LOG_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
  1367
}
9757633a85da Add OLSR routing support, (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
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1369
///
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1370
/// \brief Processes a HNA message following RFC 3626 specification.
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1371
///
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1372
/// The Host Network Association Set is updated (if needed) with the information
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1373
/// of the received HNA message.
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1374
///
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1375
/// \param msg the %OLSR message which contains the HNA message.
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1376
/// \param sender_iface the address of the interface where the message was sent from.
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1377
///
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1378
void
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1379
RoutingProtocol::ProcessHna (const olsr::MessageHeader &msg,
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1380
                       const Ipv4Address &senderIface)
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1381
{
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1382
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1383
  const olsr::MessageHeader::Hna &hna = msg.GetHna ();
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1384
  Time now = Simulator::Now ();
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1385
  
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1386
  // 1. If the sender interface of this message is not in the symmetric
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1387
  // 1-hop neighborhood of this node, the message MUST be discarded.
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1388
  const LinkTuple *link_tuple = m_state.FindSymLinkTuple (senderIface, now);
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1389
  if (link_tuple == NULL)
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1390
    return;
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1391
  
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1392
  // 2. Otherwise, for each (network address, netmask) pair in the
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1393
  // message:
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1394
  
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1395
  for (std::vector<olsr::MessageHeader::Hna::Association>::const_iterator it = hna.associations.begin();
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1396
       it != hna.associations.end() ; it++)
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1397
    {
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1398
      AssociationTuple *tuple = m_state.FindAssociationTuple(msg.GetOriginatorAddress(),it->address,it->mask);
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1399
  
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1400
      // 2.1  if an entry in the association set already exists, where:
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1401
      //          A_gateway_addr == originator address
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1402
      //          A_network_addr == network address
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1403
      //          A_netmask      == netmask
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1404
      //      then the holding time for that tuple MUST be set to:
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1405
      //          A_time         =  current time + validity time
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1406
      if(tuple != NULL)
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1407
        {
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1408
          tuple->expirationTime = now + msg.GetVTime ();
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1409
        }
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1410
        
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1411
      // 2.2 otherwise, a new tuple MUST be recorded with:
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1412
      //          A_gateway_addr =  originator address
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1413
      //          A_network_addr =  network address
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1414
      //          A_netmask      =  netmask
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1415
      //          A_time         =  current time + validity time
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1416
      else
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1417
        {
6143
ad316b5cfb5a Fix compilation error: ISO C++ forbids use of initializer list to initialize reference assocTuple
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6142
diff changeset
  1418
          AssociationTuple assocTuple = {
ad316b5cfb5a Fix compilation error: ISO C++ forbids use of initializer list to initialize reference assocTuple
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6142
diff changeset
  1419
            msg.GetOriginatorAddress(),
ad316b5cfb5a Fix compilation error: ISO C++ forbids use of initializer list to initialize reference assocTuple
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6142
diff changeset
  1420
            it->address,
ad316b5cfb5a Fix compilation error: ISO C++ forbids use of initializer list to initialize reference assocTuple
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6142
diff changeset
  1421
            it->mask,
ad316b5cfb5a Fix compilation error: ISO C++ forbids use of initializer list to initialize reference assocTuple
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6142
diff changeset
  1422
            now + msg.GetVTime ()
ad316b5cfb5a Fix compilation error: ISO C++ forbids use of initializer list to initialize reference assocTuple
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6142
diff changeset
  1423
          };
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1424
          AddAssociationTuple (assocTuple);
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1425
          
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1426
          //Schedule Association Tuple deletion
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1427
          Simulator::Schedule (DELAY (assocTuple.expirationTime),
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1428
                               &RoutingProtocol::AssociationTupleTimerExpire, this,
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1429
                               assocTuple.gatewayAddr,assocTuple.networkAddr,assocTuple.netmask);
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1430
        }
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1431
        
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1432
    }
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1433
}
1716
9757633a85da Add OLSR routing support, (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
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1435
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1436
/// \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
  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
/// 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
  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
/// \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
  1441
/// \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
  1442
/// \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
  1443
/// 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
  1444
/// \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
  1445
///
9757633a85da Add OLSR routing support, (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
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1447
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
  1448
                               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
  1449
                               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
  1450
                               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
  1451
{
9757633a85da Add OLSR routing support, (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
  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
  1453
  
9757633a85da Add OLSR routing support, (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
  // 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
  1455
  // 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
  1456
  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
  1457
  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
  1458
    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
  1459
9757633a85da Add OLSR routing support, (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
  // 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
  1461
  // 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
  1462
  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
  1463
    {
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
  1464
      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
  1465
                    " 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
  1466
      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
  1467
    }
9757633a85da Add OLSR routing support, (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
	
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1469
  // 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
  1470
  // 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
  1471
  // 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
  1472
  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
  1473
  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
  1474
    {
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  1475
      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
  1476
        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
  1477
      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
  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
          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
  1480
          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
  1481
          // 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
  1482
          // 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
  1483
          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
  1484
          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
  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
    }
9757633a85da Add OLSR routing support, (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
	
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1488
  // 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
  1489
  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
  1490
    {
9757633a85da Add OLSR routing support, (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
      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
  1492
      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
  1493
      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
  1494
    }
9757633a85da Add OLSR routing support, (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
  // ...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
  1496
  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
  1497
    {
9757633a85da Add OLSR routing support, (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
      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
  1499
      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
  1500
      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
  1501
      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
  1502
      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
  1503
      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
  1504
      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
  1505
      // 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
  1506
      Simulator::Schedule (OLSR_DUP_HOLD_TIME,
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1507
                           &RoutingProtocol::DupTupleTimerExpire, this,
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  1508
                           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
  1509
    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1510
}
9757633a85da Add OLSR routing support, (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
9757633a85da Add OLSR routing support, (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
///
9757633a85da Add OLSR routing support, (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
/// \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
  1514
///
9757633a85da Add OLSR routing support, (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
/// 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
  1516
/// 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
  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
/// \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
  1519
/// \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
  1520
///
9757633a85da Add OLSR routing support, (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
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1522
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
  1523
{
9757633a85da Add OLSR routing support, (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
  m_queuedMessages.push_back (message);
1730
163aab5f1129 solve some merge problems
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1723
diff changeset
  1525
  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
  1526
    {
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
  1527
      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
  1528
      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
  1529
    }
9757633a85da Add OLSR routing support, (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
}
9757633a85da Add OLSR routing support, (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
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1533
RoutingProtocol::SendPacket (Ptr<Packet> packet, 
1868
06027fd6a68c olsr gets new packet
Craig Dowell <craigdo@ee.washington.edu>
parents: 1803
diff changeset
  1534
                       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
  1535
{
1804
9c11e776f501 bug 96: debug.h duplicates functionality from log.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1803
diff changeset
  1536
  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
  1537
1716
9757633a85da Add OLSR routing support, (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
  // 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
  1539
  olsr::PacketHeader header;
1868
06027fd6a68c olsr gets new packet
Craig Dowell <craigdo@ee.washington.edu>
parents: 1803
diff changeset
  1540
  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
  1541
  header.SetPacketSequenceNumber (GetPacketSequenceNumber ());
1868
06027fd6a68c olsr gets new packet
Craig Dowell <craigdo@ee.washington.edu>
parents: 1803
diff changeset
  1542
  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
  1543
4078e5efdfc6 Add OLSR message tracing, as discussed on ns-developers list.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1801
diff changeset
  1544
  // 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
  1545
  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
  1546
1716
9757633a85da Add OLSR routing support, (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
  // Send it
6303
4ef0052694b9 Bug Fix: OLSR messages generated on non-OLSR interfaces
Lalith Suresh
parents: 6143
diff changeset
  1548
  for (std::map<Ptr<Socket> , Ipv4InterfaceAddress>::const_iterator i =
4ef0052694b9 Bug Fix: OLSR messages generated on non-OLSR interfaces
Lalith Suresh
parents: 6143
diff changeset
  1549
      m_socketAddresses.begin (); i != m_socketAddresses.end (); i++)
4ef0052694b9 Bug Fix: OLSR messages generated on non-OLSR interfaces
Lalith Suresh
parents: 6143
diff changeset
  1550
    {
6438
96f612b05035 Fix OLSR socket usage: use the new SetAllowBroadcast socket option; Bind to interface bcast address instead of local address, use SendTo instead of Send. This is how things have to work with real world sockets.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6324
diff changeset
  1551
      Ipv4Address bcast = i->second.GetLocal ().GetSubnetDirectedBroadcast (i->second.GetMask ());
96f612b05035 Fix OLSR socket usage: use the new SetAllowBroadcast socket option; Bind to interface bcast address instead of local address, use SendTo instead of Send. This is how things have to work with real world sockets.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6324
diff changeset
  1552
      i->first->SendTo (packet, 0, InetSocketAddress (bcast, OLSR_PORT_NUMBER));
6303
4ef0052694b9 Bug Fix: OLSR messages generated on non-OLSR interfaces
Lalith Suresh
parents: 6143
diff changeset
  1553
    }
1716
9757633a85da Add OLSR routing support, (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
}
9757633a85da Add OLSR routing support, (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
9757633a85da Add OLSR routing support, (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
///
9757633a85da Add OLSR routing support, (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
/// \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
  1558
/// %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
  1559
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1560
/// 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
  1561
/// 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
  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
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1564
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
  1565
{
1868
06027fd6a68c olsr gets new packet
Craig Dowell <craigdo@ee.washington.edu>
parents: 1803
diff changeset
  1566
  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
  1567
  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
  1568
1804
9c11e776f501 bug 96: debug.h duplicates functionality from log.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1803
diff changeset
  1569
  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
  1570
1803
4078e5efdfc6 Add OLSR message tracing, as discussed on ns-developers list.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1801
diff changeset
  1571
  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
  1572
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
  1573
  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
  1574
       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
  1575
       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
  1576
    {
1868
06027fd6a68c olsr gets new packet
Craig Dowell <craigdo@ee.washington.edu>
parents: 1803
diff changeset
  1577
      Ptr<Packet> p = Create<Packet> ();
06027fd6a68c olsr gets new packet
Craig Dowell <craigdo@ee.washington.edu>
parents: 1803
diff changeset
  1578
      p->AddHeader (*message);
06027fd6a68c olsr gets new packet
Craig Dowell <craigdo@ee.washington.edu>
parents: 1803
diff changeset
  1579
      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
  1580
      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
  1581
      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
  1582
        {
1803
4078e5efdfc6 Add OLSR message tracing, as discussed on ns-developers list.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1801
diff changeset
  1583
          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
  1584
          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
  1585
          // 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
  1586
          numMessages = 0;
1868
06027fd6a68c olsr gets new packet
Craig Dowell <craigdo@ee.washington.edu>
parents: 1803
diff changeset
  1587
          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
  1588
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1589
    }
9757633a85da Add OLSR routing support, (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
1868
06027fd6a68c olsr gets new packet
Craig Dowell <craigdo@ee.washington.edu>
parents: 1803
diff changeset
  1591
  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
  1592
    {
1803
4078e5efdfc6 Add OLSR message tracing, as discussed on ns-developers list.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1801
diff changeset
  1593
      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
  1594
    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1595
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1596
  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
  1597
}
9757633a85da Add OLSR routing support, (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
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1600
/// \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
  1601
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1602
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1603
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
  1604
{
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  1605
  NS_LOG_FUNCTION (this);
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1606
    
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
  1607
  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
  1608
  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
  1609
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1610
  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
  1611
  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
  1612
  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
  1613
  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
  1614
  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
  1615
  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
  1616
5772
a8245e39c546 Bug 739 - OLSR: Strange HTime value in HELLO messages (thanks to Pavel Boyko)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5761
diff changeset
  1617
  hello.SetHTime (m_helloInterval);
1755
262febe2f1c9 Make the OLSR headers usable from the AciiTracing point of view
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1752
diff changeset
  1618
  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
  1619
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
  1620
  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
  1621
    &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
  1622
	
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
  1623
  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
  1624
  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
  1625
       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
  1626
    {
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
  1627
      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
  1628
            && 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
  1629
        {
caa15068fb3b OLSR: code cleanup, more 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
          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
  1631
        }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1632
1762
6410d2be8cbf Fix a couple more warnings in OLSR
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1755
diff changeset
  1633
      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
  1634
			
9757633a85da Add OLSR routing support, (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
      // 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
  1636
      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
  1637
        {
9757633a85da Add OLSR routing support, (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
          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
  1639
        }
9757633a85da Add OLSR routing support, (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
      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
  1641
        {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1642
          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
  1643
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1644
      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
  1645
        {
9757633a85da Add OLSR routing support, (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
          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
  1647
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1648
      // 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
  1649
      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
  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
          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
  1652
          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
  1653
                        << " 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
  1654
        }
9757633a85da Add OLSR routing support, (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
      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
  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
          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
  1658
          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
  1659
               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
  1660
               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
  1661
            {
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
  1662
              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
  1663
                {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1664
                  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
  1665
                    {
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  1666
                      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
  1667
                                    << " 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
  1668
                      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
  1669
                    }
9757633a85da Add OLSR routing support, (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
                  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
  1671
                    {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1672
                      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
  1673
                      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
  1674
                                    << " 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
  1675
                    }
9757633a85da Add OLSR routing support, (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
                  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
  1677
                    {
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
  1678
                      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
  1679
                    }
9757633a85da Add OLSR routing support, (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
                  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
  1681
                  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
  1682
                }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1683
            }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1684
          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
  1685
            {
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  1686
              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
  1687
              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
  1688
            }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1689
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1690
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
  1691
      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
  1692
      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
  1693
      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
  1694
        (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
  1695
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1696
      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
  1697
        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
  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
      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
  1700
        (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
  1701
         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
  1702
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1703
      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
  1704
    }
1804
9c11e776f501 bug 96: debug.h duplicates functionality from log.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1803
diff changeset
  1705
  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
  1706
                << " (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
  1707
  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
  1708
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1709
9757633a85da Add OLSR routing support, (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
/// \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
  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
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1714
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
  1715
{
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  1716
  NS_LOG_FUNCTION (this);
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  1717
  
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
  1718
  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
  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
  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
  1721
  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
  1722
  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
  1723
  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
  1724
  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
  1725
  
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
  1726
  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
  1727
  tc.ansn = m_ansn;
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1728
      
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1729
  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
  1730
       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
  1731
    {
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
  1732
      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
  1733
    }
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
  1734
  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
  1735
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1736
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1737
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1738
/// \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
  1739
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1740
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1741
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
  1742
{
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
  1743
  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
  1744
  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
  1745
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1746
  // 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
  1747
  // 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
  1748
  // 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
  1749
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1750
  // 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
  1751
  // 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
  1752
  // 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
  1753
  // 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
  1754
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1755
  // 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
  1756
  // 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
  1757
  // 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
  1758
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1759
  // [ 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
  1760
  // 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
  1761
9757633a85da Add OLSR routing support, (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
  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
  1763
  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
  1764
    {
4375
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4218
diff changeset
  1765
      Ipv4Address addr = m_ipv4->GetAddress (i, 0).GetLocal ();
6142
c5b36fbaa9c8 Bug 407 postfix: filter out non-OLSR interfaces when generating MID messages
Lalith Suresh <suresh.lalith@gmail.com>
parents: 6140
diff changeset
  1766
      if (addr != m_mainAddress && addr != loopback && m_interfaceExclusions.find (i) == m_interfaceExclusions.end ())
1755
262febe2f1c9 Make the OLSR headers usable from the AciiTracing point of view
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1752
diff changeset
  1767
        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
  1768
    }
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
  1769
  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
  1770
    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
  1771
  
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1772
  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
  1773
  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
  1774
  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
  1775
  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
  1776
  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
  1777
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
  1778
  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
  1779
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1780
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1781
///
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1782
/// \brief Creates a new %OLSR HNA message which is buffered for being sent later on.
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1783
///
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1784
void
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1785
RoutingProtocol::SendHna ()
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1786
{
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1787
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1788
  olsr::MessageHeader msg;
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1789
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1790
  msg.SetVTime (OLSR_HNA_HOLD_TIME);
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1791
  msg.SetOriginatorAddress (m_mainAddress);
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1792
  msg.SetTimeToLive (255);
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1793
  msg.SetHopCount (0);
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1794
  msg.SetMessageSequenceNumber (GetMessageSequenceNumber ());
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1795
  olsr::MessageHeader::Hna &hna = msg.GetHna ();
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1796
  
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1797
  std::vector<olsr::MessageHeader::Hna::Association>
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1798
    &associations = hna.associations;
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1799
      
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1800
  if (m_routingTableAssociation != 0)
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1801
    {
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1802
      // Add (NetworkAddr, Netmask) entries from Associated Routing Table to HNA message.
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1803
      for (uint32_t i = 0; i < m_routingTableAssociation->GetNRoutes (); i++)
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1804
        {
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1805
          Ipv4RoutingTableEntry route = m_routingTableAssociation->GetRoute (i);
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1806
          
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1807
          std::set<uint32_t>::const_iterator ci = m_interfaceExclusions.find (route.GetInterface ());
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1808
                  
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1809
          if (ci != m_interfaceExclusions.end ())
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1810
            {
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1811
              olsr::MessageHeader::Hna::Association assoc = {route.GetDestNetwork (), route.GetDestNetworkMask ()};
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1812
              associations.push_back(assoc);
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1813
            }
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1814
        }
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1815
    }
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1816
    
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1817
  int size = associations.size ();
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1818
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1819
  // Add (NetworkAddr, Netmask) entries specified using AddHostNetworkAssociation () to HNA message.
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1820
  for (Associations::const_iterator it = m_state.GetAssociations ().begin ();
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1821
        it != m_state.GetAssociations ().end (); it++)
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1822
    {
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1823
      // Check if the entry has already been added from the Associated Routing Table
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1824
      std::vector<olsr::MessageHeader::Hna::Association>::const_iterator ci = associations.begin ();
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1825
      bool found = false;
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1826
      for (int i = 0; i < size; i++)
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1827
        {
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1828
          if (it->networkAddr == ci->address && it->netmask == ci->mask)
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1829
            {
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1830
              found = true;
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1831
              break;
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1832
            }
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1833
          ci++;
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1834
        }
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1835
      
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1836
      if(!found)
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1837
        {
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1838
          olsr::MessageHeader::Hna::Association assoc = {it->networkAddr,it->netmask};
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1839
          associations.push_back(assoc);
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1840
        }
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1841
    }
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1842
    
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1843
  if(associations.size () == 0)
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1844
    return;
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1845
  
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1846
  QueueMessage (msg, JITTER);
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1847
}
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1848
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1849
///
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1850
/// \brief Injects a (networkAddr, netmask) tuple for which the node
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1851
///        can generate an HNA message for
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1852
///
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1853
void
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1854
RoutingProtocol::AddHostNetworkAssociation (Ipv4Address networkAddr, Ipv4Mask netmask)
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1855
{
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1856
  m_state.InsertAssociation ((Association) {networkAddr, netmask});
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1857
}
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1858
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1859
///
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1860
/// \brief Adds an Ipv4StaticRouting protocol Association
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1861
///        can generate an HNA message for
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1862
///
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1863
void
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1864
RoutingProtocol::SetRoutingTableAssociation (Ptr<Ipv4StaticRouting> routingTable)
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1865
{
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1866
  m_routingTableAssociation = routingTable;
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1867
}
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1868
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  1869
///
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1870
/// \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
  1871
///		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
  1872
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  1873
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
  1874
                        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
  1875
                        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
  1876
                        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
  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
  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
  1879
  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
  1880
  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
  1881
  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
  1882
                << ": 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
  1883
                << ", 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
  1884
	
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
  1885
  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
  1886
  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
  1887
  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
  1888
    {
9757633a85da Add OLSR routing support, (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
      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
  1890
      // 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
  1891
      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
  1892
      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
  1893
      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
  1894
      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
  1895
      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
  1896
      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
  1897
      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
  1898
    }
9757633a85da Add OLSR routing support, (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
  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
  1900
    {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1901
      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
  1902
      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
  1903
    }
1716
9757633a85da Add OLSR routing support, (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
	
9757633a85da Add OLSR routing support, (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
  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
  1906
  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
  1907
         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
  1908
       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
  1909
       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
  1910
    {
9757633a85da Add OLSR routing support, (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
      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
  1912
      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
  1913
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1914
#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
  1915
      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
  1916
      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
  1917
        {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1918
        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
  1919
        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
  1920
        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
  1921
        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
  1922
        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
  1923
        }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1924
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1925
      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
  1926
      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
  1927
        {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1928
        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
  1929
        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
  1930
        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
  1931
        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
  1932
        }
caa15068fb3b OLSR: code cleanup, more 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
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1934
      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
  1935
                    << 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
  1936
                    << ") 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
  1937
                    << " (" << neighborTypeName << ")");
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  1938
#endif // NS3_LOG_ENABLE
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1939
1716
9757633a85da Add OLSR routing support, (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
      // 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
  1941
      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
  1942
          (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
  1943
           && 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
  1944
        {
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
  1945
          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
  1946
          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
  1947
        }
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
  1948
      
1716
9757633a85da Add OLSR routing support, (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
      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
  1950
             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
  1951
           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
  1952
           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
  1953
        {
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
  1954
          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
  1955
          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
  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
              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
  1958
                {
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
  1959
                  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
  1960
                  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
  1961
                  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
  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
              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
  1964
                {
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
  1965
                  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
  1966
                                " (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
  1967
                  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
  1968
                  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
  1969
                  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
  1970
                }
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
  1971
              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
  1972
                {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1973
                  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
  1974
                }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1975
              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
  1976
            }
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
  1977
          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
  1978
            {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  1979
              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
  1980
                            << " != 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
  1981
            }
1716
9757633a85da Add OLSR routing support, (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
        }
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
      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
  1984
    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1985
  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
  1986
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  1987
  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
  1988
    {
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  1989
      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
  1990
    }
1716
9757633a85da Add OLSR routing support, (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
9757633a85da Add OLSR routing support, (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
  // 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
  1993
  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
  1994
    {
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
  1995
      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
  1996
      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
  1997
                                           &RoutingProtocol::LinkTupleTimerExpire, this,
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  1998
                                           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
  1999
    }
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
  2000
  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
  2001
                << ": 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
  2002
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2003
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2004
///
9757633a85da Add OLSR routing support, (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
/// \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
  2006
///		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
  2007
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2008
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
  2009
                                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
  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
  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
  2012
  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
  2013
    {
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2014
      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
  2015
    }
1716
9757633a85da Add OLSR routing support, (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
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2018
9757633a85da Add OLSR routing support, (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
/// \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
  2021
///		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
  2022
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2023
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
  2024
                                      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
  2025
{
9757633a85da Add OLSR routing support, (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
  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
  2027
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2028
  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
  2029
	
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2030
  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
  2031
       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
  2032
    {
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
  2033
      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
  2034
      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
  2035
        {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2036
          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
  2037
                        "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
  2038
          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
  2039
                        << 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
  2040
                        << "; 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
  2041
          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
  2042
        }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2043
caa15068fb3b OLSR: code cleanup, more 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
      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
  2045
        {
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
  2046
          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
  2047
          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
  2048
        }
caa15068fb3b OLSR: code cleanup, more 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
caa15068fb3b OLSR: code cleanup, more 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
      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
  2051
      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
  2052
           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
  2053
        {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2054
          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
  2055
#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
  2056
          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
  2057
          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
  2058
                                          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
  2059
                                          : "(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
  2060
          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
  2061
                        << neighborType << " (" << neighborTypeName << ")");
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  2062
#endif // NS3_LOG_ENABLE
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2063
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2064
          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
  2065
                 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
  2066
               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
  2067
               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
  2068
            {
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
  2069
              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
  2070
              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
  2071
                            << *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
  2072
                            << " (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
  2073
              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
  2074
                {
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
  2075
                  // 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
  2076
                  // 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
  2077
                  // 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
  2078
                  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
  2079
                    {
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2080
                      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
  2081
                      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
  2082
                    }
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
  2083
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2084
                  // 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
  2085
                  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
  2086
                    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
  2087
                  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
  2088
                                << (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
  2089
                  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
  2090
                    {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2091
                      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
  2092
                      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
  2093
                      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
  2094
                      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
  2095
                      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
  2096
                      // 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
  2097
                      m_events.Track (Simulator::Schedule (DELAY (new_nb2hop_tuple.expirationTime),
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2098
                                                           &RoutingProtocol::Nb2hopTupleTimerExpire, this,
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  2099
                                                           new_nb2hop_tuple.neighborMainAddr,
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  2100
                                                           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
  2101
                    }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2102
                  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
  2103
                    {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2104
                      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
  2105
                    }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2106
                }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2107
              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
  2108
                {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2109
                  // 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
  2110
                  // 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
  2111
                  // 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
  2112
                  // 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
  2113
                  // 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
  2114
                  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
  2115
                  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
  2116
                }
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2117
              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
  2118
                {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2119
                  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
  2120
                                " 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
  2121
                }
9757633a85da Add OLSR routing support, (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
            }
9757633a85da Add OLSR routing support, (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
        }
9757633a85da Add OLSR routing support, (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
    }
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
  2125
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2126
  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
  2127
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2128
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2129
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2130
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2131
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2132
/// \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
  2133
///		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
  2134
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2135
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
  2136
                                       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
  2137
{
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2138
  NS_LOG_FUNCTION (this);
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2139
  
1716
9757633a85da Add OLSR routing support, (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
  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
  2141
	
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
  2142
  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
  2143
  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
  2144
       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
  2145
       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
  2146
    {
9757633a85da Add OLSR routing support, (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
      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
  2148
      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
  2149
        {
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2150
          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
  2151
          
1716
9757633a85da Add OLSR routing support, (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
          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
  2153
                 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
  2154
               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
  2155
               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
  2156
            {
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
  2157
              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
  2158
                {
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2159
                  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
  2160
                  
1716
9757633a85da Add OLSR routing support, (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
                  // 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
  2162
                  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
  2163
                    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
  2164
                  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
  2165
                    {
9757633a85da Add OLSR routing support, (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
                      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
  2167
9757633a85da Add OLSR routing support, (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
                      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
  2169
                      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
  2170
                      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
  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
                      // 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
  2173
                      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
  2174
                                      (DELAY (mprsel_tuple.expirationTime),
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2175
                                       &RoutingProtocol::MprSelTupleTimerExpire, this,
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  2176
                                       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
  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
                  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
  2179
                    {
9757633a85da Add OLSR routing support, (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
                      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
  2181
                    }
9757633a85da Add OLSR routing support, (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
                }
9757633a85da Add OLSR routing support, (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
            }
9757633a85da Add OLSR routing support, (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
        }
9757633a85da Add OLSR routing support, (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
    }
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2186
  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
  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
9757633a85da Add OLSR routing support, (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
#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
  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	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
  2193
///		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
  2194
///		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
  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
/// \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
  2197
///
9757633a85da Add OLSR routing support, (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
void
1868
06027fd6a68c olsr gets new packet
Craig Dowell <craigdo@ee.washington.edu>
parents: 1803
diff changeset
  2199
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
  2200
	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
  2201
	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
  2202
	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
  2203
	
9757633a85da Add OLSR routing support, (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
	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
  2205
		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
  2206
		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
  2207
		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
  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
	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
  2210
		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
  2211
		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
  2212
	}
9757633a85da Add OLSR routing support, (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
	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
  2215
	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
  2216
		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
  2217
		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
  2218
		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
  2219
	}
9757633a85da Add OLSR routing support, (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
	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
  2221
}
9757633a85da Add OLSR routing support, (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
#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
  2223
9757633a85da Add OLSR routing support, (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
///
9757633a85da Add OLSR routing support, (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
/// \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
  2229
///
9757633a85da Add OLSR routing support, (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
/// 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
  2231
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2232
/// \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
  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
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2235
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
  2236
{
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
  2237
  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
  2238
                << "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
  2239
                << " 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
  2240
  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
  2241
  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
  2242
  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
  2243
  
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
  2244
  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
  2245
  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
  2246
}
9757633a85da Add OLSR routing support, (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
9757633a85da Add OLSR routing support, (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
/// \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
  2250
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2251
/// \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
  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
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2254
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
  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
	/*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
  2257
		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
  2258
		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
  2259
		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
  2260
		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
  2261
  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
  2262
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2263
9757633a85da Add OLSR routing support, (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
/// \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
  2266
///
9757633a85da Add OLSR routing support, (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
/// \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
  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
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2270
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
  2271
{
9757633a85da Add OLSR routing support, (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
  /*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
  2273
    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
  2274
    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
  2275
    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
  2276
    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
  2277
  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
  2278
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2279
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
  2280
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2281
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
  2282
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2283
  // 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
  2284
  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
  2285
  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
  2286
  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
  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
  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
  2289
    {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2290
      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
  2291
    }
1716
9757633a85da Add OLSR routing support, (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
  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
  2293
    {
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2294
      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
  2295
    }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2296
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2297
  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
  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
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2300
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2301
/// \brief 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
  2302
///
9757633a85da Add OLSR routing support, (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
/// \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
  2304
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2305
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2306
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
  2307
{
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
  2308
  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
  2309
                << "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
  2310
                << " 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
  2311
9757633a85da Add OLSR routing support, (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
  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
  2313
  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
  2314
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2315
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2316
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2317
///
9757633a85da Add OLSR routing support, (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
/// \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
  2319
///		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
  2320
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2321
/// \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
  2322
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2323
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2324
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
  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
  // 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
  2327
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2328
  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
  2329
                << "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
  2330
                << " 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
  2331
1716
9757633a85da Add OLSR routing support, (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
  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
  2333
    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
  2334
  
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2335
  if (nb_tuple == NULL)
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2336
    {
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2337
      LinkTupleAdded (tuple, willingness);
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2338
      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
  2339
    }
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
  2340
1716
9757633a85da Add OLSR routing support, (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
  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
  2342
    {
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
  2343
#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
  2344
      int statusBefore = nb_tuple->status;
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  2345
#endif // NS3_LOG_ENABLE
2328
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2346
      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
  2347
        {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2348
          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
  2349
          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
  2350
                        << 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
  2351
        }
9757633a85da Add OLSR routing support, (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
      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
  2353
        {
9757633a85da Add OLSR routing support, (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
          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
  2355
          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
  2356
                        << 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
  2357
        }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2358
    }
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2359
  else
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2360
    {
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2361
      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
  2362
    }
1716
9757633a85da Add OLSR routing support, (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
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2365
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2366
/// \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
  2367
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2368
/// \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
  2369
///
9757633a85da Add OLSR routing support, (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
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2371
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
  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
//   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
  2374
//         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
  2375
//         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
  2376
//         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
  2377
//         ((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
  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
  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
  2380
  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
  2381
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2382
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2383
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2384
/// \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
  2385
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2386
/// \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
  2387
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2388
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2389
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
  2390
{
9757633a85da Add OLSR routing support, (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
//   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
  2392
//         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
  2393
//         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
  2394
//         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
  2395
//         ((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
  2396
	
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2397
  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
  2398
  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
  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
///
9757633a85da Add OLSR routing support, (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
/// \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
  2403
///
9757633a85da Add OLSR routing support, (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
/// \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
  2405
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2406
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2407
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
  2408
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2409
//   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
  2410
//         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
  2411
//         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
  2412
//         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
  2413
//         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
  2414
  
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2415
  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
  2416
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2417
9757633a85da Add OLSR routing support, (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
/// \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
  2420
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2421
/// \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
  2422
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2423
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2424
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
  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
//   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
  2427
//         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
  2428
//         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
  2429
//         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
  2430
//         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
  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
  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
  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
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
  2435
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2436
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
  2437
{
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2438
  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
  2439
}
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2440
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2441
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2442
/// \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
  2443
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2444
/// 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
  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
/// \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
  2447
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2448
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2449
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
  2450
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2451
//   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
  2452
//         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
  2453
//         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
  2454
//         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
  2455
  
9757633a85da Add OLSR routing support, (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
  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
  2457
  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
  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
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2460
///
9757633a85da Add OLSR routing support, (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
/// \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
  2462
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2463
/// 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
  2464
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2465
/// \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
  2466
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2467
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2468
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
  2469
{
9757633a85da Add OLSR routing support, (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
//   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
  2471
//         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
  2472
//         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
  2473
//         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
  2474
  
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2475
  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
  2476
  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
  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
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2479
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2480
/// \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
  2481
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2482
/// \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
  2483
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2484
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2485
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
  2486
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2487
//   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
  2488
//         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
  2489
//         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
  2490
//         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
  2491
//         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
  2492
//         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
  2493
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2494
  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
  2495
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2496
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2497
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2498
/// \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
  2499
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2500
/// \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
  2501
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2502
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2503
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
  2504
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2505
//   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
  2506
//         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
  2507
//         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
  2508
//         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
  2509
//         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
  2510
//         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
  2511
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2512
  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
  2513
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2514
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2515
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2516
/// \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
  2517
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2518
/// \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
  2519
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2520
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2521
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
  2522
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2523
//   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
  2524
//         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
  2525
//         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
  2526
//         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
  2527
//         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
  2528
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2529
  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
  2530
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2531
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2532
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2533
/// \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
  2534
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2535
/// \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
  2536
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2537
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2538
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
  2539
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2540
//   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
  2541
//         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
  2542
//         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
  2543
//         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
  2544
//         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
  2545
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2546
  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
  2547
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2548
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2549
///
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2550
/// \brief Adds a host network association tuple to the Association Set.
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2551
///
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2552
/// \param tuple the host network association tuple to be added.
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2553
///
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2554
void
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2555
RoutingProtocol::AddAssociationTuple (const AssociationTuple &tuple)
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2556
{
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2557
  m_state.InsertAssociationTuple (tuple);
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2558
}
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2559
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2560
///
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2561
/// \brief Removes a host network association tuple from the Association Set.
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2562
///
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2563
/// \param tuple the host network association tuple to be removed.
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2564
///
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2565
void
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2566
RoutingProtocol::RemoveAssociationTuple (const AssociationTuple &tuple)
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2567
{
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2568
  m_state.EraseAssociationTuple (tuple);
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2569
}
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2570
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2571
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2572
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2573
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
  2574
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2575
  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
  2576
  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
  2577
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2578
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2579
/// Increments message sequence number and returns the new value.
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2580
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
  2581
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2582
  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
  2583
  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
  2584
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2585
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2586
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2587
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2588
/// \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
  2589
/// \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
  2590
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2591
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2592
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
  2593
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2594
  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
  2595
  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
  2596
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2597
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2598
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2599
/// \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
  2600
/// \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
  2601
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2602
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2603
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
  2604
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2605
  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
  2606
    {
763f8d1bb058 Adapt the OLSR agent code to use the new Timer class.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1763
diff changeset
  2607
      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
  2608
    }
3970
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2609
  else
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2610
    {
8658841e4782 Fix a couple of OLSR bugs (#415)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3853
diff changeset
  2611
      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
  2612
    }
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
  2613
  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
  2614
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2615
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2616
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2617
/// \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
  2618
/// \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
  2619
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2620
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2621
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
  2622
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2623
  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
  2624
  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
  2625
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2626
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2627
///
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2628
/// \brief Sends an HNA message (if the node has associated hosts/networks) and reschedules the HNA timer.
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2629
/// \param e The event which has expired.
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2630
///
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2631
void
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2632
RoutingProtocol::HnaTimerExpire ()
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2633
{
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2634
  if (m_state.GetAssociations ().size () > 0 || m_routingTableAssociation !=0)
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2635
    {
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2636
      SendHna ();
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2637
    }
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2638
  else
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2639
    {
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2640
      NS_LOG_DEBUG ("Not sending any HNA, no associations to advertise.");
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2641
    }
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2642
  m_hnaTimer.Schedule (m_hnaInterval);
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2643
}
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2644
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2645
///
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
  2646
/// \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
  2647
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2648
/// 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
  2649
///
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
  2650
/// \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
  2651
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2652
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2653
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
  2654
{
2329
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2655
  DuplicateTuple *tuple =
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  2656
    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
  2657
  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
  2658
    {
2329
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2659
      return;
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2660
    }
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2661
  if (tuple->expirationTime < Simulator::Now ())
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2662
    {
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2663
      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
  2664
    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2665
  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
  2666
    {
2329
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2667
      m_events.Track (Simulator::Schedule (DELAY (tuple->expirationTime),
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2668
                                           &RoutingProtocol::DupTupleTimerExpire, this,
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  2669
                                           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
  2670
    }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2671
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2672
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2673
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2674
/// \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
  2675
/// 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
  2676
/// 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
  2677
/// 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
  2678
/// 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
  2679
///
9757633a85da Add OLSR routing support, (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
/// 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
  2681
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2682
/// \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
  2683
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2684
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2685
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
  2686
{
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2687
  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
  2688
caa15068fb3b OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2308
diff changeset
  2689
  // 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
  2690
  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
  2691
  if (tuple == NULL)
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2692
    {
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2693
      return;
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2694
    }
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2695
  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
  2696
    {
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
  2697
      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
  2698
    }
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
  2699
  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
  2700
    {
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2701
      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
  2702
        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
  2703
      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
  2704
        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
  2705
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
  2706
      m_events.Track (Simulator::Schedule (DELAY (tuple->time),
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2707
                                           &RoutingProtocol::LinkTupleTimerExpire, this,
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  2708
                                           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
  2709
    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2710
  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
  2711
    {
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
  2712
      m_events.Track (Simulator::Schedule (DELAY (std::min (tuple->time, tuple->symTime)),
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2713
                                           &RoutingProtocol::LinkTupleTimerExpire, this,
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  2714
                                           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
  2715
    }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2716
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2717
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2718
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2719
/// \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
  2720
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2721
/// 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
  2722
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2723
/// \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
  2724
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2725
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2726
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
  2727
{
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
  2728
  TwoHopNeighborTuple *tuple;
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  2729
  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
  2730
  if (tuple == NULL)
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2731
    {
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2732
      return;
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2733
    }
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2734
  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
  2735
    {
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
  2736
      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
  2737
    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2738
  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
  2739
    {
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
  2740
      m_events.Track (Simulator::Schedule (DELAY (tuple->expirationTime),
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2741
                                           &RoutingProtocol::Nb2hopTupleTimerExpire,
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  2742
                                           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
  2743
    }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2744
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2745
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2746
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2747
/// \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
  2748
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2749
/// 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
  2750
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2751
/// \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
  2752
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2753
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2754
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
  2755
{
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  2756
  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
  2757
  if (tuple == NULL)
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2758
    {
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2759
      return;
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2760
    }
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2761
  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
  2762
    {
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
  2763
      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
  2764
    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2765
  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
  2766
    {
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
  2767
      m_events.Track (Simulator::Schedule (DELAY (tuple->expirationTime),
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2768
                                           &RoutingProtocol::MprSelTupleTimerExpire,
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  2769
                                           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
  2770
    }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2771
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2772
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2773
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2774
/// \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
  2775
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2776
/// 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
  2777
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2778
/// \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
  2779
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2780
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2781
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
  2782
{
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  2783
  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
  2784
  if (tuple == NULL)
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2785
    {
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2786
      return;
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2787
    }
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2788
  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
  2789
    {
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
  2790
      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
  2791
    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2792
  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
  2793
    {
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
  2794
      m_events.Track (Simulator::Schedule (DELAY (tuple->expirationTime),
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2795
                                           &RoutingProtocol::TopologyTupleTimerExpire,
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  2796
                                           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
  2797
    }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2798
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2799
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2800
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2801
/// \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
  2802
/// \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
  2803
///
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2804
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2805
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
  2806
{
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  2807
  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
  2808
  if (tuple == NULL)
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2809
    {
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2810
      return;
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2811
    }
eadca3b1de1a A couple more OLSR bug fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2328
diff changeset
  2812
  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
  2813
    {
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
  2814
      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
  2815
    }
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2816
  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
  2817
    {
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
  2818
      m_events.Track (Simulator::Schedule (DELAY (tuple->time),
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2819
                                           &RoutingProtocol::IfaceAssocTupleTimerExpire,
2358
bf0230eba16e Small OLSR memory optimisation.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2334
diff changeset
  2820
                                           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
  2821
    }
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2822
}
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  2823
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2824
/// \brief Removes tuple_ if expired. Else timer is rescheduled to expire at tuple_->time().
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2825
/// \param e The event which has expired.
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2826
///
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2827
void
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2828
RoutingProtocol::AssociationTupleTimerExpire (Ipv4Address gatewayAddr, Ipv4Address networkAddr, Ipv4Mask netmask)
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2829
{
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2830
  AssociationTuple *tuple = m_state.FindAssociationTuple (gatewayAddr, networkAddr, netmask);
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2831
  if (tuple == NULL)
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2832
    {
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2833
      return;
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2834
    }
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2835
  if (tuple->expirationTime < Simulator::Now ())
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2836
    {
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2837
      RemoveAssociationTuple (*tuple);
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2838
    }
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2839
  else
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2840
    {
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2841
      m_events.Track (Simulator::Schedule (DELAY (tuple->expirationTime),
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2842
                                           &RoutingProtocol::AssociationTupleTimerExpire,
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2843
                                           this, gatewayAddr, networkAddr, netmask));
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2844
    }
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2845
}
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2846
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2847
///
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2848
/// \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
  2849
///
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2850
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2851
RoutingProtocol::Clear ()
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2852
{
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2853
  NS_LOG_FUNCTION_NOARGS ();
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2854
  m_table.clear ();
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2855
}
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2856
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2857
///
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2858
/// \brief Deletes the entry whose destination address is given.
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2859
/// \param dest	address of the destination node.
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2860
///
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2861
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2862
RoutingProtocol::RemoveEntry (Ipv4Address const &dest)
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2863
{
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2864
  m_table.erase (dest);
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2865
}
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2866
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2867
///
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2868
/// \brief Looks up an entry for the specified destination address.
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2869
/// \param dest	destination address.
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2870
/// \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
  2871
/// \return	true if found, false if not found
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2872
///
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2873
bool
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2874
RoutingProtocol::Lookup (Ipv4Address const &dest,
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2875
                      RoutingTableEntry &outEntry) const
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2876
{
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2877
  // Get the iterator at "dest" position
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2878
  std::map<Ipv4Address, RoutingTableEntry>::const_iterator it =
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2879
    m_table.find (dest);
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2880
  // If there is no route to "dest", return NULL
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2881
  if (it == m_table.end ())
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2882
    return false;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2883
  outEntry = it->second;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2884
  return true;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2885
}
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2886
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2887
///
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2888
/// \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
  2889
///		a data packet to a next hop (given a destination).
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2890
///
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2891
/// 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
  2892
/// 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
  2893
/// [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
  2894
/// 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
  2895
/// 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
  2896
///
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2897
/// \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
  2898
///			we are interested in.
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2899
/// \return		the appropiate routing table entry which indicates the next
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2900
///			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
  2901
///			if there is no such entry.
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2902
///
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2903
bool
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  2904
RoutingProtocol::FindSendEntry (RoutingTableEntry const &entry,
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2905
                             RoutingTableEntry &outEntry) const
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2906
{
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2907
  outEntry = entry;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2908
  while (outEntry.destAddr != outEntry.nextAddr)
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2909
    {
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2910
      if (not Lookup(outEntry.nextAddr, outEntry))
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2911
        return false;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2912
    }
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2913
  return true;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2914
}
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2915
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  2916
Ptr<Ipv4Route>
5856
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 5772
diff changeset
  2917
RoutingProtocol::RouteOutput (Ptr<Packet> p, const Ipv4Header &header, Ptr<NetDevice> oif, Socket::SocketErrno &sockerr)
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  2918
{  
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  2919
  NS_LOG_FUNCTION (this << " " << m_ipv4->GetObject<Node> ()->GetId() << " " << header.GetDestination () << " " << oif);
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  2920
  Ptr<Ipv4Route> rtentry;
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2921
  RoutingTableEntry entry1, entry2;
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2922
  bool found = false;
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2923
  
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  2924
  if (Lookup (header.GetDestination (), entry1) != 0)
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2925
    {
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2926
      bool foundSendEntry = FindSendEntry (entry1, entry2);
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2927
      if (!foundSendEntry)
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  2928
        {
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  2929
          NS_FATAL_ERROR ("FindSendEntry failure");
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  2930
        }
5946
4fef76630d66 Bug 778 - OLSR ignores specified outgoing interface in RouteOutput()
Tom Henderson <tomh@tomh.org>
parents: 5932
diff changeset
  2931
      uint32_t interfaceIdx = entry2.interface;
4fef76630d66 Bug 778 - OLSR ignores specified outgoing interface in RouteOutput()
Tom Henderson <tomh@tomh.org>
parents: 5932
diff changeset
  2932
      if (oif && m_ipv4->GetInterfaceForDevice (oif) != static_cast<int> (interfaceIdx))
4fef76630d66 Bug 778 - OLSR ignores specified outgoing interface in RouteOutput()
Tom Henderson <tomh@tomh.org>
parents: 5932
diff changeset
  2933
        {
4fef76630d66 Bug 778 - OLSR ignores specified outgoing interface in RouteOutput()
Tom Henderson <tomh@tomh.org>
parents: 5932
diff changeset
  2934
          // We do not attempt to perform a constrained routing search
4fef76630d66 Bug 778 - OLSR ignores specified outgoing interface in RouteOutput()
Tom Henderson <tomh@tomh.org>
parents: 5932
diff changeset
  2935
          // if the caller specifies the oif; we just enforce that 
4fef76630d66 Bug 778 - OLSR ignores specified outgoing interface in RouteOutput()
Tom Henderson <tomh@tomh.org>
parents: 5932
diff changeset
  2936
          // that the found route matches the requested outbound interface 
4fef76630d66 Bug 778 - OLSR ignores specified outgoing interface in RouteOutput()
Tom Henderson <tomh@tomh.org>
parents: 5932
diff changeset
  2937
          NS_LOG_DEBUG ("Olsr node " << m_mainAddress 
4fef76630d66 Bug 778 - OLSR ignores specified outgoing interface in RouteOutput()
Tom Henderson <tomh@tomh.org>
parents: 5932
diff changeset
  2938
                        << ": RouteOutput for dest=" << header.GetDestination ()
4fef76630d66 Bug 778 - OLSR ignores specified outgoing interface in RouteOutput()
Tom Henderson <tomh@tomh.org>
parents: 5932
diff changeset
  2939
                        << " Route interface " << interfaceIdx 
4fef76630d66 Bug 778 - OLSR ignores specified outgoing interface in RouteOutput()
Tom Henderson <tomh@tomh.org>
parents: 5932
diff changeset
  2940
                        << " does not match requested output interface "
4fef76630d66 Bug 778 - OLSR ignores specified outgoing interface in RouteOutput()
Tom Henderson <tomh@tomh.org>
parents: 5932
diff changeset
  2941
                        << m_ipv4->GetInterfaceForDevice (oif));
4fef76630d66 Bug 778 - OLSR ignores specified outgoing interface in RouteOutput()
Tom Henderson <tomh@tomh.org>
parents: 5932
diff changeset
  2942
          sockerr = Socket::ERROR_NOROUTETOHOST;
4fef76630d66 Bug 778 - OLSR ignores specified outgoing interface in RouteOutput()
Tom Henderson <tomh@tomh.org>
parents: 5932
diff changeset
  2943
          return rtentry;
4fef76630d66 Bug 778 - OLSR ignores specified outgoing interface in RouteOutput()
Tom Henderson <tomh@tomh.org>
parents: 5932
diff changeset
  2944
        }
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  2945
      rtentry = Create<Ipv4Route> ();
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  2946
      rtentry->SetDestination (header.GetDestination ());
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  2947
      // the source address is the interface address that matches
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  2948
      // the destination address (when multiple are present on the 
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  2949
      // outgoing interface, one is selected via scoping rules)
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  2950
      NS_ASSERT (m_ipv4);  
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  2951
      uint32_t numOifAddresses = m_ipv4->GetNAddresses (interfaceIdx);
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  2952
      NS_ASSERT (numOifAddresses > 0);
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  2953
      Ipv4InterfaceAddress ifAddr;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  2954
      if (numOifAddresses == 1) {
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  2955
        ifAddr = m_ipv4->GetAddress (interfaceIdx, 0);
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  2956
      } else {
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  2957
        NS_FATAL_ERROR ("XXX Not implemented yet:  IP aliasing and OLSR");
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  2958
      }
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  2959
      rtentry->SetSource (ifAddr.GetLocal ());
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  2960
      rtentry->SetGateway (entry2.nextAddr);
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  2961
      rtentry->SetOutputDevice (m_ipv4->GetNetDevice (interfaceIdx));
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  2962
      sockerr = Socket::ERROR_NOTERROR;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  2963
      NS_LOG_DEBUG ("Olsr node " << m_mainAddress 
5867
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  2964
                    << ": RouteOutput for dest=" << header.GetDestination ()
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  2965
                    << " --> nextHop=" << entry2.nextAddr
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2966
                    << " interface=" << entry2.interface);
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2967
      NS_LOG_DEBUG ("Found route to " << rtentry->GetDestination () << " via nh " << rtentry->GetGateway () << " with source addr " << rtentry->GetSource () << " and output dev " << rtentry->GetOutputDevice());
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2968
      found = true;
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  2969
    }
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  2970
  else
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  2971
    { 
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2972
      rtentry = m_hnaRoutingTable->RouteOutput (p, header, oif, sockerr);
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2973
      
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2974
      if (rtentry)
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2975
        {
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2976
          found = true;
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2977
          NS_LOG_DEBUG ("Found route to " << rtentry->GetDestination () << " via nh " << rtentry->GetGateway () << " with source addr " << rtentry->GetSource () << " and output dev " << rtentry->GetOutputDevice());
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2978
        }
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2979
    }
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2980
    
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2981
  if (!found)
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  2982
    {
5867
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  2983
      NS_LOG_DEBUG ("Olsr node " << m_mainAddress 
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  2984
                    << ": RouteOutput for dest=" << header.GetDestination ()
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  2985
                    << " No route to host");
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  2986
      sockerr = Socket::ERROR_NOROUTETOHOST;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  2987
    }
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  2988
  return rtentry;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  2989
}
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  2990
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  2991
bool RoutingProtocol::RouteInput  (Ptr<const Packet> p, 
5761
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  2992
  const Ipv4Header &header, Ptr<const NetDevice> idev,                            
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  2993
  UnicastForwardCallback ucb, MulticastForwardCallback mcb,             
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  2994
  LocalDeliverCallback lcb, ErrorCallback ecb)
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  2995
{   
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  2996
  NS_LOG_FUNCTION (this << " " << m_ipv4->GetObject<Node> ()->GetId() << " " << header.GetDestination ());
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  2997
  
5761
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  2998
  Ipv4Address dst = header.GetDestination ();
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  2999
  Ipv4Address origin = header.GetSource ();
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3000
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3001
  // Consume self-originated packets
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3002
  if (IsMyOwnAddress (origin) == true)
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3003
    {
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3004
      return true; 
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3005
    }
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3006
  
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3007
  // Local delivery
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3008
  NS_ASSERT (m_ipv4->GetInterfaceForDevice (idev) >= 0);
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3009
  uint32_t iif = m_ipv4->GetInterfaceForDevice (idev);
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3010
  if (m_ipv4->IsDestinationAddress (dst, iif))
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3011
    {
6324
e56ec0532fec Bug 926 - olsr handling of multicast packets
Ken Renard <kenneth.renard@arl.army.mil>
parents: 6303
diff changeset
  3012
      if (!lcb.IsNull ())
e56ec0532fec Bug 926 - olsr handling of multicast packets
Ken Renard <kenneth.renard@arl.army.mil>
parents: 6303
diff changeset
  3013
        {
e56ec0532fec Bug 926 - olsr handling of multicast packets
Ken Renard <kenneth.renard@arl.army.mil>
parents: 6303
diff changeset
  3014
          NS_LOG_LOGIC ("Local delivery to " << dst);
e56ec0532fec Bug 926 - olsr handling of multicast packets
Ken Renard <kenneth.renard@arl.army.mil>
parents: 6303
diff changeset
  3015
          lcb (p, header, iif);
e56ec0532fec Bug 926 - olsr handling of multicast packets
Ken Renard <kenneth.renard@arl.army.mil>
parents: 6303
diff changeset
  3016
          return true;
e56ec0532fec Bug 926 - olsr handling of multicast packets
Ken Renard <kenneth.renard@arl.army.mil>
parents: 6303
diff changeset
  3017
        }
e56ec0532fec Bug 926 - olsr handling of multicast packets
Ken Renard <kenneth.renard@arl.army.mil>
parents: 6303
diff changeset
  3018
      else
e56ec0532fec Bug 926 - olsr handling of multicast packets
Ken Renard <kenneth.renard@arl.army.mil>
parents: 6303
diff changeset
  3019
        {
e56ec0532fec Bug 926 - olsr handling of multicast packets
Ken Renard <kenneth.renard@arl.army.mil>
parents: 6303
diff changeset
  3020
          // The local delivery callback is null.  This may be a multicast
e56ec0532fec Bug 926 - olsr handling of multicast packets
Ken Renard <kenneth.renard@arl.army.mil>
parents: 6303
diff changeset
  3021
          // or broadcast packet, so return false so that another 
e56ec0532fec Bug 926 - olsr handling of multicast packets
Ken Renard <kenneth.renard@arl.army.mil>
parents: 6303
diff changeset
  3022
          // multicast routing protocol can handle it.  It should be possible
e56ec0532fec Bug 926 - olsr handling of multicast packets
Ken Renard <kenneth.renard@arl.army.mil>
parents: 6303
diff changeset
  3023
          // to extend this to explicitly check whether it is a unicast
e56ec0532fec Bug 926 - olsr handling of multicast packets
Ken Renard <kenneth.renard@arl.army.mil>
parents: 6303
diff changeset
  3024
          // packet, and invoke the error callback if so
e56ec0532fec Bug 926 - olsr handling of multicast packets
Ken Renard <kenneth.renard@arl.army.mil>
parents: 6303
diff changeset
  3025
          return false;
e56ec0532fec Bug 926 - olsr handling of multicast packets
Ken Renard <kenneth.renard@arl.army.mil>
parents: 6303
diff changeset
  3026
        }
5761
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3027
    }
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3028
  
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3029
  // Forwarding
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3030
  Ptr<Ipv4Route> rtentry;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3031
  RoutingTableEntry entry1, entry2; 
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3032
  if (Lookup (header.GetDestination (), entry1))
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3033
    { 
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3034
      bool foundSendEntry = FindSendEntry (entry1, entry2);
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3035
      if (!foundSendEntry)
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3036
        NS_FATAL_ERROR ("FindSendEntry failure");
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3037
      rtentry = Create<Ipv4Route> ();
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3038
      rtentry->SetDestination (header.GetDestination ());
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3039
      uint32_t interfaceIdx = entry2.interface;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3040
      // the source address is the interface address that matches
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3041
      // the destination address (when multiple are present on the
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3042
      // outgoing interface, one is selected via scoping rules)
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3043
      NS_ASSERT (m_ipv4);
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3044
      uint32_t numOifAddresses = m_ipv4->GetNAddresses (interfaceIdx);
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3045
      NS_ASSERT (numOifAddresses > 0);
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3046
      Ipv4InterfaceAddress ifAddr;
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3047
      if (numOifAddresses == 1) {
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3048
        ifAddr = m_ipv4->GetAddress (interfaceIdx, 0);
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3049
      } else {
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3050
        NS_FATAL_ERROR ("XXX Not implemented yet:  IP aliasing and OLSR");
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3051
      }
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3052
      rtentry->SetSource (ifAddr.GetLocal ());
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3053
      rtentry->SetGateway (entry2.nextAddr);
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3054
      rtentry->SetOutputDevice (m_ipv4->GetNetDevice (interfaceIdx));
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3055
      
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3056
      NS_LOG_DEBUG ("Olsr node " << m_mainAddress
5867
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3057
                    << ": RouteInput for dest=" << header.GetDestination ()
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3058
                    << " --> nextHop=" << entry2.nextAddr
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3059
                    << " interface=" << entry2.interface);
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3060
      
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4452
diff changeset
  3061
      ucb (rtentry, p, header);
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3062
      return true;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3063
    }
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3064
  else
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3065
    {
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  3066
      if(m_hnaRoutingTable->RouteInput (p, header, idev, ucb, mcb, lcb, ecb))
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  3067
        {
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  3068
          return true;
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  3069
        }
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  3070
      else
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  3071
        {
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  3072
        
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3073
#ifdef NS3_LOG_ENABLE
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  3074
          NS_LOG_DEBUG ("Olsr node " << m_mainAddress 
5867
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3075
                    << ": RouteInput for dest=" << header.GetDestination ()
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  3076
                    << " --> NOT FOUND; ** Dumping routing table...");      
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  3077
                    
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  3078
          for (std::map<Ipv4Address, RoutingTableEntry>::const_iterator iter = m_table.begin ();
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  3079
             iter != m_table.end (); iter++)
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  3080
          { 
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  3081
            NS_LOG_DEBUG ("dest=" << iter->first << " --> next=" << iter->second.nextAddr                 
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3082
                        << " via interface " << iter->second.interface);
6140
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  3083
          }
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  3084
      
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  3085
          NS_LOG_DEBUG ("** Routing table dump end.");
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  3086
#endif // NS3_LOG_ENABLE
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  3087
12bb87242796 Bug 407 - OLSR is missing HNA support
Lalith Suresh <suresh.lalith@gmail.com>
parents: 5985
diff changeset
  3088
          return false;
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3089
        }
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3090
    }
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
  3091
}
4560
2f106fd728ab Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4472
diff changeset
  3092
void 
2f106fd728ab Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4472
diff changeset
  3093
RoutingProtocol::NotifyInterfaceUp (uint32_t i)
2f106fd728ab Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4472
diff changeset
  3094
{}
2f106fd728ab Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4472
diff changeset
  3095
void 
2f106fd728ab Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4472
diff changeset
  3096
RoutingProtocol::NotifyInterfaceDown (uint32_t i)
2f106fd728ab Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4472
diff changeset
  3097
{}
2f106fd728ab Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4472
diff changeset
  3098
void 
2f106fd728ab Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4472
diff changeset
  3099
RoutingProtocol::NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress address)
2f106fd728ab Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4472
diff changeset
  3100
{}
2f106fd728ab Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4472
diff changeset
  3101
void 
2f106fd728ab Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4472
diff changeset
  3102
RoutingProtocol::NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress address)
2f106fd728ab Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4472
diff changeset
  3103
{}
1716
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  3104
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3105
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3106
///
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3107
/// \brief Adds a new entry into the routing table.
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3108
///
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3109
/// 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
  3110
///
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3111
/// \param dest		address of the destination node.
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3112
/// \param next		address of the next hop node.
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3113
/// \param iface	address of the local interface.
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3114
/// \param dist		distance to the destination node.
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3115
///
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3116
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  3117
RoutingProtocol::AddEntry (Ipv4Address const &dest,
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3118
                        Ipv4Address const &next,
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3119
                        uint32_t interface,
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3120
                        uint32_t distance)
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3121
{
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3122
  NS_LOG_FUNCTION (this << dest << next << interface << distance << m_mainAddress);
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3123
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3124
  NS_ASSERT (distance > 0);
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3125
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3126
  // Creates a new rt entry with specified values
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3127
  RoutingTableEntry &entry = m_table[dest];
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3128
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3129
  entry.destAddr = dest;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3130
  entry.nextAddr = next;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3131
  entry.interface = interface;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3132
  entry.distance = distance;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3133
}
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3134
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3135
void
4364
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4362
diff changeset
  3136
RoutingProtocol::AddEntry (Ipv4Address const &dest,
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3137
                        Ipv4Address const &next,
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3138
                        Ipv4Address const &interfaceAddress,
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3139
                        uint32_t distance)
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3140
{
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3141
  NS_LOG_FUNCTION (this << dest << next << interfaceAddress << distance << m_mainAddress);
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3142
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3143
  NS_ASSERT (distance > 0);
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3144
  NS_ASSERT (m_ipv4);
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3145
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3146
  RoutingTableEntry entry;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3147
  for (uint32_t i = 0; i < m_ipv4->GetNInterfaces (); i++)
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3148
    {
4380
bbbc2e622f50 fix merge issues
Tom Henderson <tomh@tomh.org>
parents: 4379
diff changeset
  3149
      for (uint32_t j = 0; j < m_ipv4->GetNAddresses (i); j++)
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3150
        {
4380
bbbc2e622f50 fix merge issues
Tom Henderson <tomh@tomh.org>
parents: 4379
diff changeset
  3151
          if (m_ipv4->GetAddress (i,j).GetLocal () == interfaceAddress)
bbbc2e622f50 fix merge issues
Tom Henderson <tomh@tomh.org>
parents: 4379
diff changeset
  3152
            {
bbbc2e622f50 fix merge issues
Tom Henderson <tomh@tomh.org>
parents: 4379
diff changeset
  3153
              AddEntry (dest, next, i, distance);
bbbc2e622f50 fix merge issues
Tom Henderson <tomh@tomh.org>
parents: 4379
diff changeset
  3154
              return;
bbbc2e622f50 fix merge issues
Tom Henderson <tomh@tomh.org>
parents: 4379
diff changeset
  3155
            }
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3156
        }
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3157
    }
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3158
  NS_ASSERT (false); // should not be reached
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3159
  AddEntry (dest, next, 0, distance);
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3160
}
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3161
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3162
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3163
std::vector<RoutingTableEntry>
5985
42d6f24bd0f4 New API olsr::RoutingProtocol::GetRoutingTableEntries ()
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5946
diff changeset
  3164
RoutingProtocol::GetRoutingTableEntries () const
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3165
{
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3166
  std::vector<RoutingTableEntry> retval;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3167
  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
  3168
       iter != m_table.end (); iter++)
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3169
    {
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3170
      retval.push_back (iter->second);
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3171
    }
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3172
  return retval;
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3173
}
5509
33d52e78605a [Bug 740] OLSR MprCompute () works wrong: fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5471
diff changeset
  3174
OlsrMprTestCase::OlsrMprTestCase ()
33d52e78605a [Bug 740] OLSR MprCompute () works wrong: fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5471
diff changeset
  3175
  : TestCase ("Check OLSR MPR computing mechanism")
33d52e78605a [Bug 740] OLSR MprCompute () works wrong: fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5471
diff changeset
  3176
{
33d52e78605a [Bug 740] OLSR MprCompute () works wrong: fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5471
diff changeset
  3177
}
33d52e78605a [Bug 740] OLSR MprCompute () works wrong: fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5471
diff changeset
  3178
OlsrMprTestCase::~OlsrMprTestCase ()
33d52e78605a [Bug 740] OLSR MprCompute () works wrong: fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5471
diff changeset
  3179
{
33d52e78605a [Bug 740] OLSR MprCompute () works wrong: fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5471
diff changeset
  3180
}
33d52e78605a [Bug 740] OLSR MprCompute () works wrong: fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5471
diff changeset
  3181
bool
33d52e78605a [Bug 740] OLSR MprCompute () works wrong: fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5471
diff changeset
  3182
OlsrMprTestCase::DoRun ()
33d52e78605a [Bug 740] OLSR MprCompute () works wrong: fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5471
diff changeset
  3183
{
5757
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3184
  Ptr<RoutingProtocol> protocol = CreateObject<RoutingProtocol> ();
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3185
  protocol->m_mainAddress = Ipv4Address ("10.0.0.1");
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3186
  OlsrState & state = protocol->m_state; 
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3187
 
5509
33d52e78605a [Bug 740] OLSR MprCompute () works wrong: fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5471
diff changeset
  3188
  /*
5757
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3189
   *  1 -- 2 
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3190
   *  |    |
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3191
   *  3 -- 4
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3192
   *
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3193
   * Node 1 must select only one MPR (2 or 3, doesn't matter)
5510
ff4cb6dfdad5 cosmetics
Pavel Boyko <boyko@iitp.ru>
parents: 5509
diff changeset
  3194
   */
5509
33d52e78605a [Bug 740] OLSR MprCompute () works wrong: fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5471
diff changeset
  3195
  NeighborTuple neigbor;
33d52e78605a [Bug 740] OLSR MprCompute () works wrong: fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5471
diff changeset
  3196
  neigbor.status = NeighborTuple::STATUS_SYM;
33d52e78605a [Bug 740] OLSR MprCompute () works wrong: fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5471
diff changeset
  3197
  neigbor.willingness = OLSR_WILL_DEFAULT;
5757
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3198
  neigbor.neighborMainAddr = Ipv4Address ("10.0.0.2");
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3199
  protocol->m_state.InsertNeighborTuple (neigbor);
5509
33d52e78605a [Bug 740] OLSR MprCompute () works wrong: fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5471
diff changeset
  3200
  neigbor.neighborMainAddr = Ipv4Address ("10.0.0.3");
5757
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3201
  protocol->m_state.InsertNeighborTuple (neigbor); 
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3202
  TwoHopNeighborTuple tuple;
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3203
  tuple.expirationTime = Seconds (3600);
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3204
  tuple.neighborMainAddr = Ipv4Address ("10.0.0.2");
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3205
  tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.4");
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3206
  protocol->m_state.InsertTwoHopNeighborTuple (tuple);
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3207
  tuple.neighborMainAddr = Ipv4Address ("10.0.0.3");
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3208
  tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.4");
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3209
  protocol->m_state.InsertTwoHopNeighborTuple (tuple);
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3210
  
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3211
  protocol->MprComputation ();
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3212
  NS_TEST_EXPECT_MSG_EQ (state.GetMprSet ().size (), 1 , "An only address must be chosen.");
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3213
  /*
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3214
   *  1 -- 2 -- 5 
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3215
   *  |    |
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3216
   *  3 -- 4
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3217
   *
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3218
   * Node 1 must select node 2 as MPR.
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3219
   */
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3220
  tuple.neighborMainAddr = Ipv4Address ("10.0.0.2");
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3221
  tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.5");
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3222
  protocol->m_state.InsertTwoHopNeighborTuple (tuple);
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3223
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3224
  protocol->MprComputation ();
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3225
  MprSet mpr = state.GetMprSet ();
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3226
  NS_TEST_EXPECT_MSG_EQ (mpr.size (), 1 , "An only address must be chosen.");
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3227
  NS_TEST_EXPECT_MSG_EQ ((mpr.find ("10.0.0.2") != mpr.end ()), true, "Node 1 must select node 2 as MPR");
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3228
  /*
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3229
   *  1 -- 2 -- 5 
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3230
   *  |    |
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3231
   *  3 -- 4
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3232
   *  |
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3233
   *  6
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3234
   *
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3235
   * Node 1 must select nodes 2 and 3 as MPRs.
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3236
   */
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3237
  tuple.neighborMainAddr = Ipv4Address ("10.0.0.3");
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3238
  tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.6");
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3239
  protocol->m_state.InsertTwoHopNeighborTuple (tuple);
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3240
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3241
  protocol->MprComputation ();
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3242
  mpr = state.GetMprSet ();
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3243
  NS_TEST_EXPECT_MSG_EQ (mpr.size (), 2 , "An only address must be chosen.");
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3244
  NS_TEST_EXPECT_MSG_EQ ((mpr.find ("10.0.0.2") != mpr.end ()), true, "Node 1 must select node 2 as MPR");
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3245
  NS_TEST_EXPECT_MSG_EQ ((mpr.find ("10.0.0.3") != mpr.end ()), true, "Node 1 must select node 3 as MPR");
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3246
  /*
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3247
   *  7 (OLSR_WILL_ALWAYS)
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3248
   *  |
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3249
   *  1 -- 2 -- 5 
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3250
   *  |    |
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3251
   *  3 -- 4
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3252
   *  |
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3253
   *  6
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3254
   *
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3255
   * Node 1 must select nodes 2, 3 and 7 (since it is WILL_ALWAYS) as MPRs.
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3256
   */
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3257
  neigbor.willingness = OLSR_WILL_ALWAYS;
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3258
  neigbor.neighborMainAddr = Ipv4Address ("10.0.0.7");
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3259
  protocol->m_state.InsertNeighborTuple (neigbor);
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3260
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3261
  protocol->MprComputation ();
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3262
  mpr = state.GetMprSet ();
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3263
  NS_TEST_EXPECT_MSG_EQ (mpr.size (), 3 , "An only address must be chosen.");
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3264
  NS_TEST_EXPECT_MSG_EQ ((mpr.find ("10.0.0.7") != mpr.end ()), true, "Node 1 must select node 7 as MPR");
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3265
  /*
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3266
   *                7 <- WILL_ALWAYS
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3267
   *                |
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3268
   *      9 -- 8 -- 1 -- 2 -- 5 
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3269
   *                |    |
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3270
   *           ^    3 -- 4
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3271
   *           |    |
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3272
   *   WILL_NEVER   6
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3273
   *
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3274
   * Node 1 must select nodes 2, 3 and 7 (since it is WILL_ALWAYS) as MPRs.
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3275
   * Node 1 must NOT select node 8 as MPR since it is WILL_NEVER
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3276
   */
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3277
  neigbor.willingness = OLSR_WILL_NEVER;
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3278
  neigbor.neighborMainAddr = Ipv4Address ("10.0.0.8");
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3279
  protocol->m_state.InsertNeighborTuple (neigbor);
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3280
  tuple.neighborMainAddr = Ipv4Address ("10.0.0.8");
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3281
  tuple.twoHopNeighborAddr = Ipv4Address ("10.0.0.9");
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3282
  protocol->m_state.InsertTwoHopNeighborTuple (tuple);
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3283
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3284
  protocol->MprComputation ();
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3285
  mpr = state.GetMprSet ();
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3286
  NS_TEST_EXPECT_MSG_EQ (mpr.size (), 3 , "An only address must be chosen.");
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3287
  NS_TEST_EXPECT_MSG_EQ ((mpr.find ("10.0.0.9") == mpr.end ()), true, "Node 1 must NOT select node 8 as MPR");
c2dc9d69d547 [olsr] MPR selection unit tests updated
Pavel Boyko <boyko@iitp.ru>
parents: 5756
diff changeset
  3288
5509
33d52e78605a [Bug 740] OLSR MprCompute () works wrong: fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5471
diff changeset
  3289
  return false;
33d52e78605a [Bug 740] OLSR MprCompute () works wrong: fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5471
diff changeset
  3290
}
33d52e78605a [Bug 740] OLSR MprCompute () works wrong: fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5471
diff changeset
  3291
33d52e78605a [Bug 740] OLSR MprCompute () works wrong: fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5471
diff changeset
  3292
static class OlsrProtocolTestSuite : public TestSuite
33d52e78605a [Bug 740] OLSR MprCompute () works wrong: fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5471
diff changeset
  3293
{
33d52e78605a [Bug 740] OLSR MprCompute () works wrong: fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5471
diff changeset
  3294
public:
33d52e78605a [Bug 740] OLSR MprCompute () works wrong: fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5471
diff changeset
  3295
  OlsrProtocolTestSuite ();
33d52e78605a [Bug 740] OLSR MprCompute () works wrong: fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5471
diff changeset
  3296
} g_olsrProtocolTestSuite;
33d52e78605a [Bug 740] OLSR MprCompute () works wrong: fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5471
diff changeset
  3297
33d52e78605a [Bug 740] OLSR MprCompute () works wrong: fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5471
diff changeset
  3298
OlsrProtocolTestSuite::OlsrProtocolTestSuite()
5510
ff4cb6dfdad5 cosmetics
Pavel Boyko <boyko@iitp.ru>
parents: 5509
diff changeset
  3299
  : TestSuite("routing-olsr", UNIT)
5509
33d52e78605a [Bug 740] OLSR MprCompute () works wrong: fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5471
diff changeset
  3300
{
33d52e78605a [Bug 740] OLSR MprCompute () works wrong: fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5471
diff changeset
  3301
  AddTestCase (new OlsrMprTestCase ());
33d52e78605a [Bug 740] OLSR MprCompute () works wrong: fixed
Kirill Andreev <andreev@iitp.ru>
parents: 5471
diff changeset
  3302
}
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3303
5761
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3304
bool
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3305
RoutingProtocol::IsMyOwnAddress (const Ipv4Address & a) const
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3306
{
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3307
  for (std::map<Ptr<Socket> , Ipv4InterfaceAddress>::const_iterator j =
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3308
      m_socketAddresses.begin (); j != m_socketAddresses.end (); ++j)
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3309
    {
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3310
      Ipv4InterfaceAddress iface = j->second;
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3311
      if (a == iface.GetLocal ())
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3312
        {
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3313
          return true;
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3314
        }
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3315
    }
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3316
  return false;
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3317
}
55f21c521021 (Bug 735) Update Olsr for local delivery
Tom Henderson <tomh@tomh.org>
parents: 5757
diff changeset
  3318
5867
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3319
void
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3320
RoutingProtocol::Dump (void)
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3321
{
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3322
  Time now = Simulator::Now ();
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3323
  
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3324
#ifdef NS3_LOG_ENABLE
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3325
  NS_LOG_DEBUG ("Dumping for node with main address " << m_mainAddress);
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3326
  NS_LOG_DEBUG (" Neighbor set");
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3327
  for (NeighborSet::const_iterator iter = m_state.GetNeighbors ().begin ();
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3328
         iter != m_state.GetNeighbors ().end (); iter++)
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3329
    {
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3330
      NS_LOG_DEBUG ("  " << *iter);
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3331
    }
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3332
  NS_LOG_DEBUG (" Two-hop neighbor set");
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3333
  for (TwoHopNeighborSet::const_iterator iter = m_state.GetTwoHopNeighbors ().begin ();
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3334
         iter != m_state.GetTwoHopNeighbors ().end (); iter++)
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3335
    {
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3336
      if (now < iter->expirationTime)
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3337
        { 
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3338
          NS_LOG_DEBUG ("  " << *iter);
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3339
        }
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3340
    }
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3341
  NS_LOG_DEBUG (" Routing table");
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3342
  for (std::map<Ipv4Address, RoutingTableEntry>::const_iterator iter = m_table.begin (); iter != m_table.end (); iter++)
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3343
    {
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3344
      NS_LOG_DEBUG ("  dest=" << iter->first << " --> next=" << iter->second.nextAddr << " via interface " << iter->second.interface);
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3345
    }
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3346
  NS_LOG_DEBUG ("");
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3347
#endif  //NS3_LOG_ENABLE
8c65da328ae9 Fix Bug 780 (problem in RoutingTableComputation with asymetric links), while adding debugging methods to OLSR. Thanks Abdul Jabbar, Pavel Boyko, and Tom Henderson for test case and debug code.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5856
diff changeset
  3348
}
4358
e63305078fe5 rework olsr
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4218
diff changeset
  3349
1801
522029e3b8a6 Put everything OLSR into the 'olsr' C++ namespace, for consistency.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1799
diff changeset
  3350
}} // 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
  3351
9757633a85da Add OLSR routing support, (loosely) based on Francisco J. Ros's NS-2 code (University of Murcia).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
  3352