View | Details | Raw Unified | Return to bug 938
Collapse All | Expand All

(-)a/src/internet/model/ipv4-global-routing.cc (-44 / +16 lines)
 Lines 489-541    Link Here 
489
  NS_ASSERT (m_ipv4->GetInterfaceForDevice (idev) >= 0);
489
  NS_ASSERT (m_ipv4->GetInterfaceForDevice (idev) >= 0);
490
  uint32_t iif = m_ipv4->GetInterfaceForDevice (idev);
490
  uint32_t iif = m_ipv4->GetInterfaceForDevice (idev);
491
491
492
  if (header.GetDestination ().IsMulticast ())
492
  if (m_ipv4->IsDestinationAddress (header.GetDestination (), iif))
493
    {
493
    {
494
      NS_LOG_LOGIC ("Multicast destination-- returning false");
494
      if (!lcb.IsNull ())
495
      return false; // Let other routing protocols try to handle this
495
        {
496
          NS_LOG_LOGIC ("Local delivery to " << header.GetDestination ());
497
          lcb (p, header, iif);
498
          return true;
499
        }
500
      else
501
        {
502
          // The local delivery callback is null.  This may be a multicast
503
          // or broadcast packet, so return false so that another
504
          // multicast routing protocol can handle it.  It should be possible
505
          // to extend this to explicitly check whether it is a unicast
506
          // packet, and invoke the error callback if so
507
          return false;
508
        }
496
    }
509
    }
497
510
498
  if (header.GetDestination ().IsBroadcast ())
499
    {
500
      NS_LOG_LOGIC ("For me (Ipv4Addr broadcast address)");
501
      /// \todo  Local Deliver for broadcast
502
      /// \todo  Forward broadcast
503
    }
504
505
  /// \todo  Configurable option to enable \RFC{1222} Strong End System Model
506
  // Right now, we will be permissive and allow a source to send us
507
  // a packet to one of our other interface addresses; that is, the
508
  // destination unicast address does not match one of the iif addresses,
509
  // but we check our other interfaces.  This could be an option
510
  // (to remove the outer loop immediately below and just check iif).
511
  for (uint32_t j = 0; j < m_ipv4->GetNInterfaces (); j++)
512
    {
513
      for (uint32_t i = 0; i < m_ipv4->GetNAddresses (j); i++)
514
        {
515
          Ipv4InterfaceAddress iaddr = m_ipv4->GetAddress (j, i);
516
          Ipv4Address addr = iaddr.GetLocal ();
517
          if (addr.IsEqual (header.GetDestination ()))
518
            {
519
              if (j == iif)
520
                {
521
                  NS_LOG_LOGIC ("For me (destination " << addr << " match)");
522
                }
523
              else
524
                {
525
                  NS_LOG_LOGIC ("For me (destination " << addr << " match) on another interface " << header.GetDestination ());
526
                }
527
              lcb (p, header, iif);
528
              return true;
529
            }
530
          if (header.GetDestination ().IsEqual (iaddr.GetBroadcast ()))
531
            {
532
              NS_LOG_LOGIC ("For me (interface broadcast address)");
533
              lcb (p, header, iif);
534
              return true;
535
            }
536
          NS_LOG_LOGIC ("Address "<< addr << " not a match");
537
        }
538
    }
539
  // Check if input device supports IP forwarding
511
  // Check if input device supports IP forwarding
540
  if (m_ipv4->IsForwarding (iif) == false)
512
  if (m_ipv4->IsForwarding (iif) == false)
541
    {
513
    {
(-)a/src/internet/model/ipv4-static-routing.cc (-40 / +18 lines)
 Lines 495-501    Link Here 
495
  uint32_t iif = m_ipv4->GetInterfaceForDevice (idev); 
495
  uint32_t iif = m_ipv4->GetInterfaceForDevice (idev); 
496
496
497
  // Multicast recognition; handle local delivery here
497
  // Multicast recognition; handle local delivery here
498
  //
498
499
  if (ipHeader.GetDestination ().IsMulticast ())
499
  if (ipHeader.GetDestination ().IsMulticast ())
500
    {
500
    {
501
      NS_LOG_LOGIC ("Multicast destination");
501
      NS_LOG_LOGIC ("Multicast destination");
 Lines 514-561    Link Here 
514
          return false; // Let other routing protocols try to handle this
514
          return false; // Let other routing protocols try to handle this
515
        }
515
        }
516
    }
516
    }
517
  if (ipHeader.GetDestination ().IsBroadcast ())
517
518
  if (m_ipv4->IsDestinationAddress (ipHeader.GetDestination (), iif))
518
    {
519
    {
519
      NS_LOG_LOGIC ("For me (Ipv4Addr broadcast address)");
520
      if (!lcb.IsNull ())
520
      /// \todo Local Deliver for broadcast
521
        {
521
      /// \todo Forward broadcast
522
          NS_LOG_LOGIC ("Local delivery to " << ipHeader.GetDestination ());
523
          lcb (p, ipHeader, iif);
524
          return true;
525
        }
526
      else
527
        {
528
          // The local delivery callback is null.  This may be a multicast
529
          // or broadcast packet, so return false so that another
530
          // multicast routing protocol can handle it.  It should be possible
531
          // to extend this to explicitly check whether it is a unicast
532
          // packet, and invoke the error callback if so
533
          return false;
534
        }
522
    }
535
    }
523
536
524
  NS_LOG_LOGIC ("Unicast destination");
525
  /// \todo Configurable option to enable \RFC{1222} Strong End System Model
526
  // Right now, we will be permissive and allow a source to send us
527
  // a packet to one of our other interface addresses; that is, the
528
  // destination unicast address does not match one of the iif addresses,
529
  // but we check our other interfaces.  This could be an option
530
  // (to remove the outer loop immediately below and just check iif).
531
  for (uint32_t j = 0; j < m_ipv4->GetNInterfaces (); j++)
532
    {
533
      for (uint32_t i = 0; i < m_ipv4->GetNAddresses (j); i++)
534
        {
535
          Ipv4InterfaceAddress iaddr = m_ipv4->GetAddress (j, i);
536
          Ipv4Address addr = iaddr.GetLocal ();
537
          if (addr.IsEqual (ipHeader.GetDestination ()))
538
            {
539
              if (j == iif)
540
                {
541
                  NS_LOG_LOGIC ("For me (destination " << addr << " match)");
542
                }
543
              else
544
                {
545
                  NS_LOG_LOGIC ("For me (destination " << addr << " match) on another interface " << ipHeader.GetDestination ());
546
                }
547
              lcb (p, ipHeader, iif);
548
              return true;
549
            }
550
          if (ipHeader.GetDestination ().IsEqual (iaddr.GetBroadcast ()))
551
            {
552
              NS_LOG_LOGIC ("For me (interface broadcast address)");
553
              lcb (p, ipHeader, iif);
554
              return true;
555
            }
556
          NS_LOG_LOGIC ("Address "<< addr << " not a match");
557
        }
558
    }
559
  // Check if input device supports IP forwarding
537
  // Check if input device supports IP forwarding
560
  if (m_ipv4->IsForwarding (iif) == false)
538
  if (m_ipv4->IsForwarding (iif) == false)
561
    {
539
    {
(-)a/src/olsr/doc/olsr.rst (-11 / +32 lines)
 Lines 9-21    Link Here 
9
University of Murcia (Spain) by Francisco J. Ros for NS-2, and was
9
University of Murcia (Spain) by Francisco J. Ros for NS-2, and was
10
ported to NS-3 by Gustavo Carneiro at INESC Porto (Portugal).
10
ported to NS-3 by Gustavo Carneiro at INESC Porto (Portugal).
11
11
12
The implementation is based on OLSR Version 1 (:rfc:`3626`) and
13
it is *not* compliant with OLSR Version 2 (:rfc:`7181`) or any 
14
of the Version 2 extensions.
15
 
12
Model Description
16
Model Description
13
*****************
17
*****************
14
18
15
The source code for the OLSR model lives in the directory `src/olsr`.
19
The source code for the OLSR model lives in the directory `src/olsr`.
16
20
As stated before, the model is based on :rfc:`3626`. Moreover, many
17
Design
21
design choices are based on the previous ns2 model.
18
++++++
19
22
20
Scope and Limitations
23
Scope and Limitations
21
+++++++++++++++++++++
24
+++++++++++++++++++++
 Lines 35-47    Link Here 
35
++++++++++
38
++++++++++
36
39
37
.. [rfc3626] :rfc:`3626` *Optimized Link State Routing*
40
.. [rfc3626] :rfc:`3626` *Optimized Link State Routing*
41
.. [rfc7181] :rfc:`7181` *The Optimized Link State Routing Protocol Version 2*
38
42
39
Usage
43
Usage
40
*****
44
*****
41
45
46
The usage pattern is the one of all the Internet routing protocols.
47
Since OLSR is not installed by default in the Internet stack, it is necessary to
48
set it in the Internet Stack helper by using ``InternetStackHelper::SetRoutingHelper``
49
42
Examples
50
Examples
43
++++++++
51
++++++++
44
52
53
The examples are in the ``src/olsr/examples/`` directory. However, many other examples esists in the
54
general examples directory, e.g., ``examples/routing/manet-routing-compare.cc``.
55
56
For specific examples of the HNA feature, see the examples in ``src/olsr/examples/``.
57
45
Helpers
58
Helpers
46
+++++++
59
+++++++
47
60
 Lines 61-81    Link Here 
61
MidInterval, Willingness.  Other parameters are defined as macros
74
MidInterval, Willingness.  Other parameters are defined as macros
62
in ``olsr-routing-protocol.cc``.
75
in ``olsr-routing-protocol.cc``.
63
76
77
The list of configurabel attributes is:
78
79
* HelloInterval (time, default 2s), HELLO messages emission interval.
80
* TcInterval (time, default 5s), TC messages emission interval.
81
* MidInterval (time, default 5s), MID messages emission interval.
82
* HnaInterval (time, default 5s), HNA messages emission interval.
83
* Willingness (enum, default OLSR_WILL_DEFAULT), Willingness of a node to carry and forward traffic for other nodes.
84
64
Tracing
85
Tracing
65
+++++++
86
+++++++
66
87
67
Logging
88
The available traces are:
68
+++++++
89
90
* Rx: Receive OLSR packet.
91
* Tx: Send OLSR packet.
92
* RoutingTableChanged: The OLSR routing table has changed.
69
93
70
Caveats
94
Caveats
71
+++++++
95
+++++++
72
96
97
The code does not present any known issue.
98
73
Validation
99
Validation
74
**********
100
**********
75
101
76
Unit tests
102
The code validationhas been done through Wireshark message compliance and unit testings.
77
++++++++++
78
79
Larger-scale performance tests
80
++++++++++++++++++++++++++++++
81
(-)a/src/olsr/helper/olsr-helper.h (+2 lines)
 Lines 30-35    Link Here 
30
namespace ns3 {
30
namespace ns3 {
31
31
32
/**
32
/**
33
 * \ingroup olsr
34
 *
33
 * \brief Helper class that adds OLSR routing to nodes.
35
 * \brief Helper class that adds OLSR routing to nodes.
34
 *
36
 *
35
 * This class is expected to be used in conjunction with 
37
 * This class is expected to be used in conjunction with 
(-)a/src/olsr/model/olsr-header.h (-155 / +401 lines)
 Lines 34-100    Link Here 
34
double EmfToSeconds (uint8_t emf);
34
double EmfToSeconds (uint8_t emf);
35
uint8_t SecondsToEmf (double seconds);
35
uint8_t SecondsToEmf (double seconds);
36
36
37
// 3.3.  Packet Format
37
/**
38
//
38
 * \ingroup olsr
39
//    The basic layout of any packet in OLSR is as follows (omitting IP and
39
 *
40
//    UDP headers):
40
 * The basic layout of any packet in OLSR is as follows (omitting IP and
41
//
41
 * UDP headers):
42
//        0                   1                   2                   3
42
  \verbatim
43
//        0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
43
    0                   1                   2                   3
44
//       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
44
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
45
//       |         Packet Length         |    Packet Sequence Number     |
45
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
46
//       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
46
   |         Packet Length         |    Packet Sequence Number     |
47
//       |  Message Type |     Vtime     |         Message Size          |
47
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
48
//       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
48
   |  Message Type |     Vtime     |         Message Size          |
49
//       |                      Originator Address                       |
49
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
50
//       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
50
   |                      Originator Address                       |
51
//       |  Time To Live |   Hop Count   |    Message Sequence Number    |
51
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
52
//       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
52
   |  Time To Live |   Hop Count   |    Message Sequence Number    |
53
//       |                                                               |
53
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
54
//       :                            MESSAGE                            :
54
   |                                                               |
55
//       |                                                               |
55
   :                            MESSAGE                            :
56
//       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
56
   |                                                               |
57
//       |  Message Type |     Vtime     |         Message Size          |
57
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
58
//       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
58
   |  Message Type |     Vtime     |         Message Size          |
59
//       |                      Originator Address                       |
59
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
60
//       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
60
   |                      Originator Address                       |
61
//       |  Time To Live |   Hop Count   |    Message Sequence Number    |
61
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
62
//       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
62
   |  Time To Live |   Hop Count   |    Message Sequence Number    |
63
//       |                                                               |
63
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
64
//       :                            MESSAGE                            :
64
   |                                                               |
65
//       |                                                               |
65
   :                            MESSAGE                            :
66
//       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
66
   |                                                               |
67
//       :                                                               :
67
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
68
//                (etc.)
68
   :                                                               :
69
            (etc.)
70
  \endverbatim
71
  *
72
  * This header only holds the common part of a message group, i.e.,
73
  * the first 4 bytes.
74
  */
69
class PacketHeader : public Header
75
class PacketHeader : public Header
70
{
76
{
71
public:
77
public:
72
  PacketHeader ();
78
  PacketHeader ();
73
  virtual ~PacketHeader ();
79
  virtual ~PacketHeader ();
74
80
81
  /**
82
   * Set the packet total length.
83
   * \param length The packet length.
84
   */
75
  void SetPacketLength (uint16_t length)
85
  void SetPacketLength (uint16_t length)
76
  {
86
  {
77
    m_packetLength = length;
87
    m_packetLength = length;
78
  }
88
  }
89
90
  /**
91
   * Get the packet total length.
92
   * \return The packet length.
93
   */
79
  uint16_t GetPacketLength () const
94
  uint16_t GetPacketLength () const
80
  {
95
  {
81
    return m_packetLength;
96
    return m_packetLength;
82
  }
97
  }
83
98
99
  /**
100
   * Set the packet sequence number.
101
   * \param seqnum The packet sequence number.
102
   */
84
  void SetPacketSequenceNumber (uint16_t seqnum)
103
  void SetPacketSequenceNumber (uint16_t seqnum)
85
  {
104
  {
86
    m_packetSequenceNumber = seqnum;
105
    m_packetSequenceNumber = seqnum;
87
  }
106
  }
107
108
  /**
109
   * Get the packet sequence number.
110
   * \returns The packet sequence number.
111
   */
88
  uint16_t GetPacketSequenceNumber () const
112
  uint16_t GetPacketSequenceNumber () const
89
  {
113
  {
90
    return m_packetSequenceNumber;
114
    return m_packetSequenceNumber;
91
  }
115
  }
92
116
93
private:
117
private:
94
  uint16_t m_packetLength;
118
  uint16_t m_packetLength;          //!< The packet length.
95
  uint16_t m_packetSequenceNumber;
119
  uint16_t m_packetSequenceNumber;  //!< The packet sequence number.
96
120
97
public:
121
public:
122
  /**
123
   * \brief Get the type ID.
124
   * \return The object TypeId.
125
   */
98
  static TypeId GetTypeId (void);
126
  static TypeId GetTypeId (void);
99
  virtual TypeId GetInstanceTypeId (void) const;
127
  virtual TypeId GetInstanceTypeId (void) const;
100
  virtual void Print (std::ostream &os) const;
128
  virtual void Print (std::ostream &os) const;
 Lines 103-122    Link Here 
103
  virtual uint32_t Deserialize (Buffer::Iterator start);
131
  virtual uint32_t Deserialize (Buffer::Iterator start);
104
};
132
};
105
133
106
134
/**
107
//        0                   1                   2                   3
135
 * \ingroup olsr
108
//        0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
136
 *
109
//       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
137
 * This header can store HELP, TC, MID and HNA messages.
110
//       |  Message Type |     Vtime     |         Message Size          |
138
 * The header size is variable, and depends on the
111
//       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
139
 * actual message type.
112
//       |                      Originator Address                       |
140
 *
113
//       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
141
  \verbatim
114
//       |  Time To Live |   Hop Count   |    Message Sequence Number    |
142
    0                   1                   2                   3
115
//       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
143
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
144
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
145
   |  Message Type |     Vtime     |         Message Size          |
146
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
147
   |                      Originator Address                       |
148
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
149
   |  Time To Live |   Hop Count   |    Message Sequence Number    |
150
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
151
   |                                                               |
152
   :                            MESSAGE                            :
153
   |                                                               |
154
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
155
  \endverbatim
156
 */
116
class MessageHeader : public Header
157
class MessageHeader : public Header
117
{
158
{
118
public:
159
public:
119
160
161
  /**
162
   * Message type
163
   */
120
  enum MessageType {
164
  enum MessageType {
121
    HELLO_MESSAGE = 1,
165
    HELLO_MESSAGE = 1,
122
    TC_MESSAGE    = 2,
166
    TC_MESSAGE    = 2,
 Lines 127-205    Link Here 
127
  MessageHeader ();
171
  MessageHeader ();
128
  virtual ~MessageHeader ();
172
  virtual ~MessageHeader ();
129
173
174
  /**
175
   * Set the message type.
176
   * \param messageType The message type.
177
   */
130
  void SetMessageType (MessageType messageType)
178
  void SetMessageType (MessageType messageType)
131
  {
179
  {
132
    m_messageType = messageType;
180
    m_messageType = messageType;
133
  }
181
  }
182
  /**
183
   * Get the message type.
184
   * \return The message type.
185
   */
134
  MessageType GetMessageType () const
186
  MessageType GetMessageType () const
135
  {
187
  {
136
    return m_messageType;
188
    return m_messageType;
137
  }
189
  }
138
190
191
  /**
192
   * Set the validity time.
193
   * \param time The validity time.
194
   */
139
  void SetVTime (Time time)
195
  void SetVTime (Time time)
140
  {
196
  {
141
    m_vTime = SecondsToEmf (time.GetSeconds ());
197
    m_vTime = SecondsToEmf (time.GetSeconds ());
142
  }
198
  }
199
  /**
200
   * Get the validity time.
201
   * \return The validity time.
202
   */
143
  Time GetVTime () const
203
  Time GetVTime () const
144
  {
204
  {
145
    return Seconds (EmfToSeconds (m_vTime));
205
    return Seconds (EmfToSeconds (m_vTime));
146
  }
206
  }
147
207
208
  /**
209
   * Set the originator address.
210
   * \param originatorAddress The originator address.
211
   */
148
  void SetOriginatorAddress (Ipv4Address originatorAddress)
212
  void SetOriginatorAddress (Ipv4Address originatorAddress)
149
  {
213
  {
150
    m_originatorAddress = originatorAddress;
214
    m_originatorAddress = originatorAddress;
151
  }
215
  }
216
  /**
217
   * Get the originator address.
218
   * \return The originator address.
219
   */
152
  Ipv4Address GetOriginatorAddress () const
220
  Ipv4Address GetOriginatorAddress () const
153
  {
221
  {
154
    return m_originatorAddress;
222
    return m_originatorAddress;
155
  }
223
  }
156
224
225
  /**
226
   * Set the time to live.
227
   * \param timeToLive The time to live.
228
   */
157
  void SetTimeToLive (uint8_t timeToLive)
229
  void SetTimeToLive (uint8_t timeToLive)
158
  {
230
  {
159
    m_timeToLive = timeToLive;
231
    m_timeToLive = timeToLive;
160
  }
232
  }
233
  /**
234
   * Get the time to live.
235
   * \return The time to live.
236
   */
161
  uint8_t GetTimeToLive () const
237
  uint8_t GetTimeToLive () const
162
  {
238
  {
163
    return m_timeToLive;
239
    return m_timeToLive;
164
  }
240
  }
165
241
242
  /**
243
   * Set the hop count.
244
   * \param hopCount The hop count.
245
   */
166
  void SetHopCount (uint8_t hopCount)
246
  void SetHopCount (uint8_t hopCount)
167
  {
247
  {
168
    m_hopCount = hopCount;
248
    m_hopCount = hopCount;
169
  }
249
  }
250
  /**
251
   * Get the hop count.
252
   * \return The hop count.
253
   */
170
  uint8_t GetHopCount () const
254
  uint8_t GetHopCount () const
171
  {
255
  {
172
    return m_hopCount;
256
    return m_hopCount;
173
  }
257
  }
174
258
259
  /**
260
   * Set the message sequence number.
261
   * \param messageSequenceNumber The message sequence number.
262
   */
175
  void SetMessageSequenceNumber (uint16_t messageSequenceNumber)
263
  void SetMessageSequenceNumber (uint16_t messageSequenceNumber)
176
  {
264
  {
177
    m_messageSequenceNumber = messageSequenceNumber;
265
    m_messageSequenceNumber = messageSequenceNumber;
178
  }
266
  }
267
  /**
268
   * Get the message sequence number.
269
   * \return The message sequence number.
270
   */
179
  uint16_t GetMessageSequenceNumber () const
271
  uint16_t GetMessageSequenceNumber () const
180
  {
272
  {
181
    return m_messageSequenceNumber;
273
    return m_messageSequenceNumber;
182
  }
274
  }
183
275
184
//   void SetMessageSize (uint16_t messageSize)
185
//   {
186
//     m_messageSize = messageSize;
187
//   }
188
//   uint16_t GetMessageSize () const
189
//   {
190
//     return m_messageSize;
191
//   }
192
193
private:
276
private:
194
  MessageType m_messageType;
277
  MessageType m_messageType;        //!< The message type
195
  uint8_t m_vTime;
278
  uint8_t m_vTime;                  //!< The validity time.
196
  Ipv4Address m_originatorAddress;
279
  Ipv4Address m_originatorAddress;  //!< The originator address.
197
  uint8_t m_timeToLive;
280
  uint8_t m_timeToLive;             //!< The time to live.
198
  uint8_t m_hopCount;
281
  uint8_t m_hopCount;               //!< The hop count.
199
  uint16_t m_messageSequenceNumber;
282
  uint16_t m_messageSequenceNumber; //!< The message sequence number.
200
  uint16_t m_messageSize;
283
  uint16_t m_messageSize;           //!< The message size.
201
284
202
public:
285
public:
286
  /**
287
   * \brief Get the type ID.
288
   * \return The object TypeId.
289
   */
203
  static TypeId GetTypeId (void);
290
  static TypeId GetTypeId (void);
204
  virtual TypeId GetInstanceTypeId (void) const;
291
  virtual TypeId GetInstanceTypeId (void) const;
205
  virtual void Print (std::ostream &os) const;
292
  virtual void Print (std::ostream &os) const;
 Lines 207-359    Link Here 
207
  virtual void Serialize (Buffer::Iterator start) const;
294
  virtual void Serialize (Buffer::Iterator start) const;
208
  virtual uint32_t Deserialize (Buffer::Iterator start);
295
  virtual uint32_t Deserialize (Buffer::Iterator start);
209
296
210
  // 5.1.  MID Message Format
297
  /**
211
  //
298
   * \ingroup olsr
212
  //    The proposed format of a MID message is as follows:
299
   * MID Message Format
213
  //
300
   *
214
  //        0                   1                   2                   3
301
  \verbatim
215
  //        0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
302
    0                   1                   2                   3
216
  //       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
303
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
217
  //       |                    OLSR Interface Address                     |
304
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
218
  //       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
305
   |                    OLSR Interface Address                     |
219
  //       |                    OLSR Interface Address                     |
306
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
220
  //       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
307
   |                    OLSR Interface Address                     |
221
  //       |                              ...                              |
308
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
222
  //       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
309
   |                              ...                              |
310
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
311
  \endverbatim
312
  */
223
  struct Mid
313
  struct Mid
224
  {
314
  {
225
    std::vector<Ipv4Address> interfaceAddresses;
315
    std::vector<Ipv4Address> interfaceAddresses;  //!< Interface Address container.
316
    /**
317
     * This method is used to print the content of a MID message.
318
     * \param os output stream
319
     */
226
    void Print (std::ostream &os) const;
320
    void Print (std::ostream &os) const;
321
    /**
322
     * Returns the expected size of the header.
323
     * \returns the expected size of the header.
324
     */
227
    uint32_t GetSerializedSize (void) const;
325
    uint32_t GetSerializedSize (void) const;
326
    /**
327
     * This method is used by Packet::AddHeader to
328
     * store a header into the byte buffer of a packet.
329
     *
330
     * \param start an iterator which points to where the header should
331
     *        be written.
332
     */
228
    void Serialize (Buffer::Iterator start) const;
333
    void Serialize (Buffer::Iterator start) const;
229
    uint32_t Deserialize (Buffer::Iterator start, uint32_t messageSize);
334
    /**
335
     * This method is used by Packet::RemoveHeader to
336
     * re-create a header from the byte buffer of a packet.
337
     *
338
     * \param start an iterator which points to where the header should
339
     *        read from.
340
     * \param messageSize the message size.
341
     * \returns the number of bytes read.
342
     */
343
   uint32_t Deserialize (Buffer::Iterator start, uint32_t messageSize);
230
  };
344
  };
231
345
232
  // 6.1.  HELLO Message Format
346
  /**
233
  //
347
   * \ingroup olsr
234
  //        0                   1                   2                   3
348
   * HELLO Message Format
235
  //        0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
349
   *
236
  //
350
  \verbatim
237
  //       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
351
    0                   1                   2                   3
238
  //       |          Reserved             |     Htime     |  Willingness  |
352
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
239
  //       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
353
240
  //       |   Link Code   |   Reserved    |       Link Message Size       |
354
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
241
  //       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
355
   |          Reserved             |     Htime     |  Willingness  |
242
  //       |                  Neighbor Interface Address                   |
356
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
243
  //       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
357
   |   Link Code   |   Reserved    |       Link Message Size       |
244
  //       |                  Neighbor Interface Address                   |
358
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
245
  //       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
359
   |                  Neighbor Interface Address                   |
246
  //       :                             .  .  .                           :
360
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
247
  //       :                                                               :
361
   |                  Neighbor Interface Address                   |
248
  //       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
362
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
249
  //       |   Link Code   |   Reserved    |       Link Message Size       |
363
   :                             .  .  .                           :
250
  //       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
364
   :                                                               :
251
  //       |                  Neighbor Interface Address                   |
365
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
252
  //       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
366
   |   Link Code   |   Reserved    |       Link Message Size       |
253
  //       |                  Neighbor Interface Address                   |
367
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
254
  //       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
368
   |                  Neighbor Interface Address                   |
255
  //       :                                                               :
369
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
256
  //       :                                       :
370
   |                  Neighbor Interface Address                   |
257
  //    (etc.)
371
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
258
  struct Hello
372
   :                                                               :
373
     (etc.)
374
  \endverbatim
375
  */
376
 struct Hello
259
  {
377
  {
378
    /**
379
     * Link message item
380
     */
260
    struct LinkMessage {
381
    struct LinkMessage {
261
      uint8_t linkCode;
382
      uint8_t linkCode;       //!< Link code
262
      std::vector<Ipv4Address> neighborInterfaceAddresses;
383
      std::vector<Ipv4Address> neighborInterfaceAddresses;  //!< Neighbor interface address container.
263
    };
384
    };
264
385
265
    uint8_t hTime;
386
    uint8_t hTime;  //!< HELLO emission interval (coded)
387
388
    /**
389
     * Set the HELLO emission interval.
390
     * \param time The HELLO emission interval.
391
     */
266
    void SetHTime (Time time)
392
    void SetHTime (Time time)
267
    {
393
    {
268
      this->hTime = SecondsToEmf (time.GetSeconds ());
394
      this->hTime = SecondsToEmf (time.GetSeconds ());
269
    }
395
    }
396
397
    /**
398
     * Get the HELLO emission interval.
399
     * \return The HELLO emission interval.
400
     */
270
    Time GetHTime () const
401
    Time GetHTime () const
271
    {
402
    {
272
      return Seconds (EmfToSeconds (this->hTime));
403
      return Seconds (EmfToSeconds (this->hTime));
273
    }
404
    }
274
405
275
    uint8_t willingness;
406
    uint8_t willingness; //!< The willingness of a node to carry and forward traffic for other nodes.
276
    std::vector<LinkMessage> linkMessages;
407
    std::vector<LinkMessage> linkMessages; //!< Link messages container.
277
408
409
    /**
410
     * This method is used to print the content of a MID message.
411
     * \param os output stream
412
     */
278
    void Print (std::ostream &os) const;
413
    void Print (std::ostream &os) const;
414
    /**
415
     * Returns the expected size of the header.
416
     * \returns the expected size of the header.
417
     */
279
    uint32_t GetSerializedSize (void) const;
418
    uint32_t GetSerializedSize (void) const;
419
    /**
420
     * This method is used by Packet::AddHeader to
421
     * store a header into the byte buffer of a packet.
422
     *
423
     * \param start an iterator which points to where the header should
424
     *        be written.
425
     */
280
    void Serialize (Buffer::Iterator start) const;
426
    void Serialize (Buffer::Iterator start) const;
427
    /**
428
     * This method is used by Packet::RemoveHeader to
429
     * re-create a header from the byte buffer of a packet.
430
     *
431
     * \param start an iterator which points to where the header should
432
     *        read from.
433
     * \param messageSize the message size.
434
     * \returns the number of bytes read.
435
     */
281
    uint32_t Deserialize (Buffer::Iterator start, uint32_t messageSize);
436
    uint32_t Deserialize (Buffer::Iterator start, uint32_t messageSize);
282
  };
437
  };
283
438
284
  // 9.1.  TC Message Format
439
 /**
285
  //
440
  * \ingroup olsr
286
  //    The proposed format of a TC message is as follows:
441
  * TC Message Format
287
  //
442
  *
288
  //        0                   1                   2                   3
443
  \verbatim
289
  //        0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
444
    0                   1                   2                   3
290
  //       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
445
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
291
  //       |              ANSN             |           Reserved            |
446
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
292
  //       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
447
   |              ANSN             |           Reserved            |
293
  //       |               Advertised Neighbor Main Address                |
448
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
294
  //       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
449
   |               Advertised Neighbor Main Address                |
295
  //       |               Advertised Neighbor Main Address                |
450
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
296
  //       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
451
   |               Advertised Neighbor Main Address                |
297
  //       |                              ...                              |
452
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
298
  //       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
453
   |                              ...                              |
454
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
455
  \endverbatim
456
  */
457
 struct Tc
458
  {
459
    std::vector<Ipv4Address> neighborAddresses; //!< Neighbor address container.
460
    uint16_t ansn;  //!< Advertised Neighbor Sequence Number.
299
461
300
  struct Tc
462
    /**
301
  {
463
     * This method is used to print the content of a MID message.
302
    std::vector<Ipv4Address> neighborAddresses;
464
     * \param os output stream
303
    uint16_t ansn;
465
     */
304
305
    void Print (std::ostream &os) const;
466
    void Print (std::ostream &os) const;
467
    /**
468
     * Returns the expected size of the header.
469
     * \returns the expected size of the header.
470
     */
306
    uint32_t GetSerializedSize (void) const;
471
    uint32_t GetSerializedSize (void) const;
472
    /**
473
     * This method is used by Packet::AddHeader to
474
     * store a header into the byte buffer of a packet.
475
     *
476
     * \param start an iterator which points to where the header should
477
     *        be written.
478
     */
307
    void Serialize (Buffer::Iterator start) const;
479
    void Serialize (Buffer::Iterator start) const;
308
    uint32_t Deserialize (Buffer::Iterator start, uint32_t messageSize);
480
    /**
481
     * This method is used by Packet::RemoveHeader to
482
     * re-create a header from the byte buffer of a packet.
483
     *
484
     * \param start an iterator which points to where the header should
485
     *        read from.
486
     * \param messageSize the message size.
487
     * \returns the number of bytes read.
488
     */
489
   uint32_t Deserialize (Buffer::Iterator start, uint32_t messageSize);
309
  };
490
  };
310
491
311
492
312
  // 12.1.  HNA Message Format
493
 /**
313
  //
494
  * \ingroup olsr
314
  //    The proposed format of an HNA-message is:
495
  * HNA (Host Network Association) Message Format
315
  //
496
  *
316
  //        0                   1                   2                   3
497
  \verbatim
317
  //        0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
498
    0                   1                   2                   3
318
  //       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
499
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
319
  //       |                         Network Address                       |
500
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
320
  //       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
501
   |                         Network Address                       |
321
  //       |                             Netmask                           |
502
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
322
  //       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
503
   |                             Netmask                           |
323
  //       |                         Network Address                       |
504
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
324
  //       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
505
   |                         Network Address                       |
325
  //       |                             Netmask                           |
506
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
326
  //       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
507
   |                             Netmask                           |
327
  //       |                              ...                              |
508
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
328
  //       +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
509
   |                              ...                              |
329
510
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
330
  // Note: HNA stands for Host Network Association
511
  \endverbatim
512
  */
331
  struct Hna
513
  struct Hna
332
  {
514
  {
515
   /**
516
    * Association item structure.
517
    */
333
    struct Association
518
    struct Association
334
    {
519
    {
335
      Ipv4Address address;
520
      Ipv4Address address; //!< IPv4 Address.
336
      Ipv4Mask mask;
521
      Ipv4Mask mask;       //!< IPv4 netmask.
337
    };
522
    };
338
    std::vector<Association> associations;
339
523
524
    std::vector<Association> associations; //!< Association container.
525
526
    /**
527
     * This method is used to print the content of a MID message.
528
     * \param os output stream
529
     */
340
    void Print (std::ostream &os) const;
530
    void Print (std::ostream &os) const;
531
    /**
532
     * Returns the expected size of the header.
533
     * \returns the expected size of the header.
534
     */
341
    uint32_t GetSerializedSize (void) const;
535
    uint32_t GetSerializedSize (void) const;
536
    /**
537
     * This method is used by Packet::AddHeader to
538
     * store a header into the byte buffer of a packet.
539
     *
540
     * \param start an iterator which points to where the header should
541
     *        be written.
542
     */
342
    void Serialize (Buffer::Iterator start) const;
543
    void Serialize (Buffer::Iterator start) const;
544
    /**
545
     * This method is used by Packet::RemoveHeader to
546
     * re-create a header from the byte buffer of a packet.
547
     *
548
     * \param start an iterator which points to where the header should
549
     *        read from.
550
     * \param messageSize the message size.
551
     * \returns the number of bytes read.
552
     */
343
    uint32_t Deserialize (Buffer::Iterator start, uint32_t messageSize);
553
    uint32_t Deserialize (Buffer::Iterator start, uint32_t messageSize);
344
  };
554
  };
345
555
346
private:
556
private:
557
558
  /**
559
   * Structure holding the message content.
560
   */
347
  struct
561
  struct
348
  {
562
  {
349
    Mid mid;
563
    Mid mid;      //!< MID message (optional).
350
    Hello hello;
564
    Hello hello;  //!< HELLO message (optional).
351
    Tc tc;
565
    Tc tc;        //!< TC message (optional).
352
    Hna hna;
566
    Hna hna;      //!< HNA message (optional).
353
  } m_message; // union not allowed
567
  } m_message; //!< The actual message being carried.
354
568
355
public:
569
public:
356
570
571
  /**
572
   * Set the message type to MID and return the message content.
573
   * \returns The MID message.
574
   */
357
  Mid& GetMid ()
575
  Mid& GetMid ()
358
  {
576
  {
359
    if (m_messageType == 0)
577
    if (m_messageType == 0)
 Lines 367-372    Link Here 
367
    return m_message.mid;
585
    return m_message.mid;
368
  }
586
  }
369
587
588
  /**
589
   * Set the message type to HELLO and return the message content.
590
   * \returns The HELLO message.
591
   */
370
  Hello& GetHello ()
592
  Hello& GetHello ()
371
  {
593
  {
372
    if (m_messageType == 0)
594
    if (m_messageType == 0)
 Lines 380-385    Link Here 
380
    return m_message.hello;
602
    return m_message.hello;
381
  }
603
  }
382
604
605
  /**
606
   * Set the message type to TC and return the message content.
607
   * \returns The TC message.
608
   */
383
  Tc& GetTc ()
609
  Tc& GetTc ()
384
  {
610
  {
385
    if (m_messageType == 0)
611
    if (m_messageType == 0)
 Lines 393-398    Link Here 
393
    return m_message.tc;
619
    return m_message.tc;
394
  }
620
  }
395
621
622
  /**
623
   * Set the message type to HNA and return the message content.
624
   * \returns The HNA message.
625
   */
396
  Hna& GetHna ()
626
  Hna& GetHna ()
397
  {
627
  {
398
    if (m_messageType == 0)
628
    if (m_messageType == 0)
 Lines 407-430    Link Here 
407
  }
637
  }
408
638
409
639
640
  /**
641
   * Get the MID message.
642
   * \returns The MID message.
643
   */
410
  const Mid& GetMid () const
644
  const Mid& GetMid () const
411
  {
645
  {
412
    NS_ASSERT (m_messageType == MID_MESSAGE);
646
    NS_ASSERT (m_messageType == MID_MESSAGE);
413
    return m_message.mid;
647
    return m_message.mid;
414
  }
648
  }
415
649
650
  /**
651
   * Get the HELLO message.
652
   * \returns The HELLO message.
653
   */
416
  const Hello& GetHello () const
654
  const Hello& GetHello () const
417
  {
655
  {
418
    NS_ASSERT (m_messageType == HELLO_MESSAGE);
656
    NS_ASSERT (m_messageType == HELLO_MESSAGE);
419
    return m_message.hello;
657
    return m_message.hello;
420
  }
658
  }
421
659
660
  /**
661
   * Get the TC message.
662
   * \returns The TC message.
663
   */
422
  const Tc& GetTc () const
664
  const Tc& GetTc () const
423
  {
665
  {
424
    NS_ASSERT (m_messageType == TC_MESSAGE);
666
    NS_ASSERT (m_messageType == TC_MESSAGE);
425
    return m_message.tc;
667
    return m_message.tc;
426
  }
668
  }
427
669
670
  /**
671
   * Get the HNA message.
672
   * \returns The HNA message.
673
   */
428
  const Hna& GetHna () const
674
  const Hna& GetHna () const
429
  {
675
  {
430
    NS_ASSERT (m_messageType == HNA_MESSAGE);
676
    NS_ASSERT (m_messageType == HNA_MESSAGE);
(-)a/src/olsr/model/olsr-repositories.h (-228 / +236 lines)
 Lines 36-303    Link Here 
36
namespace ns3 { namespace olsr {
36
namespace ns3 { namespace olsr {
37
37
38
38
39
/// \ingroup olsr
40
/// An Interface Association Tuple.
41
struct IfaceAssocTuple
42
{
43
  /// Interface address of a node.
44
  Ipv4Address ifaceAddr;
45
  /// Main address of the node.
46
  Ipv4Address mainAddr;
47
  /// Time at which this tuple expires and must be removed.
48
  Time time;
49
};
39
50
40
/// An Interface Association Tuple.
51
static inline bool
41
                struct IfaceAssocTuple
52
operator == (const IfaceAssocTuple &a, const IfaceAssocTuple &b)
42
                {
53
{
43
                  /// Interface address of a node.
54
  return (a.ifaceAddr == b.ifaceAddr
44
                  Ipv4Address ifaceAddr;
55
      && a.mainAddr == b.mainAddr);
45
                  /// Main address of the node.
56
}
46
                  Ipv4Address mainAddr;
47
                  /// Time at which this tuple expires and must be removed.
48
                  Time time;
49
                };
50
57
51
                static inline bool
58
static inline std::ostream&
52
                operator == (const IfaceAssocTuple &a, const IfaceAssocTuple &b)
59
operator << (std::ostream &os, const IfaceAssocTuple &tuple)
53
                {
60
{
54
                  return (a.ifaceAddr == b.ifaceAddr
61
  os << "IfaceAssocTuple(ifaceAddr=" << tuple.ifaceAddr
55
                          && a.mainAddr == b.mainAddr);
62
                         << ", mainAddr=" << tuple.mainAddr
56
                }
63
                         << ", time=" << tuple.time << ")";
64
  return os;
65
}
57
66
58
                static inline std::ostream&
67
/// \ingroup olsr
59
                operator << (std::ostream &os, const IfaceAssocTuple &tuple)
68
/// A Link Tuple.
60
                {
69
struct LinkTuple
61
                  os << "IfaceAssocTuple(ifaceAddr=" << tuple.ifaceAddr
70
{
62
                  << ", mainAddr=" << tuple.mainAddr
71
  /// Interface address of the local node.
63
                  << ", time=" << tuple.time << ")";
72
  Ipv4Address localIfaceAddr;
64
                  return os;
73
  /// Interface address of the neighbor node.
65
                }
74
  Ipv4Address neighborIfaceAddr;
75
  /// The link is considered bidirectional until this time.
76
  Time symTime;
77
  /// The link is considered unidirectional until this time.
78
  Time asymTime;
79
  /// Time at which this tuple expires and must be removed.
80
  Time time;
81
};
66
82
67
/// A Link Tuple.
83
static inline bool
68
                struct LinkTuple
84
operator == (const LinkTuple &a, const LinkTuple &b)
69
                {
85
{
70
                  /// Interface address of the local node.
86
  return (a.localIfaceAddr == b.localIfaceAddr
71
                  Ipv4Address localIfaceAddr;
87
      && a.neighborIfaceAddr == b.neighborIfaceAddr);
72
                  /// Interface address of the neighbor node.
88
}
73
                  Ipv4Address neighborIfaceAddr;
74
                  /// The link is considered bidirectional until this time.
75
                  Time symTime;
76
                  /// The link is considered unidirectional until this time.
77
                  Time asymTime;
78
                  /// Time at which this tuple expires and must be removed.
79
                  Time time;
80
                };
81
89
82
                static inline bool
90
static inline std::ostream&
83
                operator == (const LinkTuple &a, const LinkTuple &b)
91
operator << (std::ostream &os, const LinkTuple &tuple)
84
                {
92
{
85
                  return (a.localIfaceAddr == b.localIfaceAddr
93
  os << "LinkTuple(localIfaceAddr=" << tuple.localIfaceAddr
86
                          && a.neighborIfaceAddr == b.neighborIfaceAddr);
94
                   << ", neighborIfaceAddr=" << tuple.neighborIfaceAddr
87
                }
95
                   << ", symTime=" << tuple.symTime
96
                   << ", asymTime=" << tuple.asymTime
97
                   << ", expTime=" << tuple.time
98
                   << ")";
99
  return os;
100
}
88
101
89
                static inline std::ostream&
102
/// \ingroup olsr
90
                operator << (std::ostream &os, const LinkTuple &tuple)
103
/// A Neighbor Tuple.
91
                {
104
struct NeighborTuple
92
                  os << "LinkTuple(localIfaceAddr=" << tuple.localIfaceAddr
105
{
93
                  << ", neighborIfaceAddr=" << tuple.neighborIfaceAddr
106
  /// Main address of a neighbor node.
94
                  << ", symTime=" << tuple.symTime
107
  Ipv4Address neighborMainAddr;
95
                  << ", asymTime=" << tuple.asymTime
108
  /// Status of the link (Symmetric or not Symmetric).
96
                  << ", expTime=" << tuple.time
109
  enum Status {
97
                  << ")";
110
    STATUS_NOT_SYM = 0, // "not symmetric"
98
                  return os;
111
    STATUS_SYM = 1, // "symmetric"
99
                }
112
  } status; //!< Status of the link.
113
  /// A value between 0 and 7 specifying the node's willingness to carry traffic on behalf of other nodes.
114
  uint8_t willingness;
115
};
100
116
101
/// A Neighbor Tuple.
117
static inline bool
102
                struct NeighborTuple
118
operator == (const NeighborTuple &a, const NeighborTuple &b)
103
                {
119
{
104
                  /// Main address of a neighbor node.
120
  return (a.neighborMainAddr == b.neighborMainAddr
105
                  Ipv4Address neighborMainAddr;
121
      && a.status == b.status
106
                  /// Neighbor Type and Link Type at the four less significative digits.
122
      && a.willingness == b.willingness);
107
                  enum Status {
123
}
108
                    STATUS_NOT_SYM = 0, // "not symmetric"
109
                    STATUS_SYM = 1, // "symmetric"
110
                  } status;
111
                  /// A value between 0 and 7 specifying the node's willingness to carry traffic on behalf of other nodes.
112
                  uint8_t willingness;
113
                };
114
124
115
                static inline bool
125
static inline std::ostream&
116
                operator == (const NeighborTuple &a, const NeighborTuple &b)
126
operator << (std::ostream &os, const NeighborTuple &tuple)
117
                {
127
{
118
                  return (a.neighborMainAddr == b.neighborMainAddr
128
  os << "NeighborTuple(neighborMainAddr=" << tuple.neighborMainAddr
119
                          && a.status == b.status
129
                       << ", status=" << (tuple.status == NeighborTuple::STATUS_SYM ? "SYM" : "NOT_SYM")
120
                          && a.willingness == b.willingness);
130
                       << ", willingness=" << (int) tuple.willingness << ")";
121
                }
131
  return os;
132
}
122
133
123
                static inline std::ostream&
134
/// \ingroup olsr
124
                operator << (std::ostream &os, const NeighborTuple &tuple)
135
/// A 2-hop Tuple.
125
                {
136
struct TwoHopNeighborTuple
126
                  os << "NeighborTuple(neighborMainAddr=" << tuple.neighborMainAddr
137
{
127
                  << ", status=" << (tuple.status == NeighborTuple::STATUS_SYM ? "SYM" : "NOT_SYM")
138
  /// Main address of a neighbor.
128
                  << ", willingness=" << (int) tuple.willingness << ")";
139
  Ipv4Address neighborMainAddr;
129
                  return os;
140
  /// Main address of a 2-hop neighbor with a symmetric link to nb_main_addr.
130
                }
141
  Ipv4Address twoHopNeighborAddr;
142
  /// Time at which this tuple expires and must be removed.
143
  Time expirationTime; // previously called 'time_'
144
};
131
145
132
/// A 2-hop Tuple.
146
static inline std::ostream&
133
                struct TwoHopNeighborTuple
147
operator << (std::ostream &os, const TwoHopNeighborTuple &tuple)
134
                {
148
{
135
                  /// Main address of a neighbor.
149
  os << "TwoHopNeighborTuple(neighborMainAddr=" << tuple.neighborMainAddr
136
                  Ipv4Address neighborMainAddr;
150
      << ", twoHopNeighborAddr=" << tuple.twoHopNeighborAddr
137
                  /// Main address of a 2-hop neighbor with a symmetric link to nb_main_addr.
151
      << ", expirationTime=" << tuple.expirationTime
138
                  Ipv4Address twoHopNeighborAddr;
152
      << ")";
139
                  /// Time at which this tuple expires and must be removed.
153
  return os;
140
                  Time expirationTime; // previously called 'time_'
154
}
141
                };
142
155
143
                static inline std::ostream&
156
static inline bool
144
                operator << (std::ostream &os, const TwoHopNeighborTuple &tuple)
157
operator == (const TwoHopNeighborTuple &a, const TwoHopNeighborTuple &b)
145
                {
158
{
146
                  os << "TwoHopNeighborTuple(neighborMainAddr=" << tuple.neighborMainAddr
159
  return (a.neighborMainAddr == b.neighborMainAddr
147
                  << ", twoHopNeighborAddr=" << tuple.twoHopNeighborAddr
160
      && a.twoHopNeighborAddr == b.twoHopNeighborAddr);
148
                  << ", expirationTime=" << tuple.expirationTime
161
}
149
                  << ")";
150
                  return os;
151
                }
152
162
153
                static inline bool
163
/// \ingroup olsr
154
                operator == (const TwoHopNeighborTuple &a, const TwoHopNeighborTuple &b)
164
/// An MPR-Selector Tuple.
155
                {
165
struct MprSelectorTuple
156
                  return (a.neighborMainAddr == b.neighborMainAddr
166
{
157
                          && a.twoHopNeighborAddr == b.twoHopNeighborAddr);
167
  /// Main address of a node which have selected this node as a MPR.
158
                }
168
  Ipv4Address mainAddr;
169
  /// Time at which this tuple expires and must be removed.
170
  Time expirationTime; // previously called 'time_'
171
};
159
172
160
/// An MPR-Selector Tuple.
173
static inline bool
161
                struct MprSelectorTuple
174
operator == (const MprSelectorTuple &a, const MprSelectorTuple &b)
162
                {
175
{
163
                  /// Main address of a node which have selected this node as a MPR.
176
  return (a.mainAddr == b.mainAddr);
164
                  Ipv4Address mainAddr;
177
}
165
                  /// Time at which this tuple expires and must be removed.
166
                  Time expirationTime; // previously called 'time_'
167
                };
168
178
169
                static inline bool
170
                operator == (const MprSelectorTuple &a, const MprSelectorTuple &b)
171
                {
172
                  return (a.mainAddr == b.mainAddr);
173
                }
174
179
175
180
// The type "list of interface addresses"
176
/// The type "list of interface addresses"
177
//typedef std::vector<nsaddr_t> addr_list_t;
181
//typedef std::vector<nsaddr_t> addr_list_t;
178
182
183
/// \ingroup olsr
179
/// A Duplicate Tuple
184
/// A Duplicate Tuple
180
                struct DuplicateTuple
185
struct DuplicateTuple
181
                {
186
{
182
                  /// Originator address of the message.
187
  /// Originator address of the message.
183
                  Ipv4Address address;
188
  Ipv4Address address;
184
                  /// Message sequence number.
189
  /// Message sequence number.
185
                  uint16_t sequenceNumber;
190
  uint16_t sequenceNumber;
186
                  /// Indicates whether the message has been retransmitted or not.
191
  /// Indicates whether the message has been retransmitted or not.
187
                  bool retransmitted;
192
  bool retransmitted;
188
                  /// List of interfaces which the message has been received on.
193
  /// List of interfaces which the message has been received on.
189
                  std::vector<Ipv4Address> ifaceList;
194
  std::vector<Ipv4Address> ifaceList;
190
                  /// Time at which this tuple expires and must be removed.
195
  /// Time at which this tuple expires and must be removed.
191
                  Time expirationTime;
196
  Time expirationTime;
192
                };
197
};
193
198
194
                static inline bool
199
static inline bool
195
                operator == (const DuplicateTuple &a, const DuplicateTuple &b)
200
operator == (const DuplicateTuple &a, const DuplicateTuple &b)
196
                {
201
{
197
                  return (a.address == b.address
202
  return (a.address == b.address
198
                          && a.sequenceNumber == b.sequenceNumber);
203
      && a.sequenceNumber == b.sequenceNumber);
199
                }
204
}
200
205
206
/// \ingroup olsr
201
/// A Topology Tuple
207
/// A Topology Tuple
202
                struct TopologyTuple
208
struct TopologyTuple
203
                {
209
{
204
                  /// Main address of the destination.
210
  /// Main address of the destination.
205
                  Ipv4Address destAddr;
211
  Ipv4Address destAddr;
206
                  /// Main address of a node which is a neighbor of the destination.
212
  /// Main address of a node which is a neighbor of the destination.
207
                  Ipv4Address lastAddr;
213
  Ipv4Address lastAddr;
208
                  /// Sequence number.
214
  /// Sequence number.
209
                  uint16_t sequenceNumber;
215
  uint16_t sequenceNumber;
210
                  /// Time at which this tuple expires and must be removed.
216
  /// Time at which this tuple expires and must be removed.
211
                  Time expirationTime;
217
  Time expirationTime;
212
                };
218
};
213
219
214
                static inline bool
220
static inline bool
215
                operator == (const TopologyTuple &a, const TopologyTuple &b)
221
operator == (const TopologyTuple &a, const TopologyTuple &b)
216
                {
222
{
217
                  return (a.destAddr == b.destAddr
223
  return (a.destAddr == b.destAddr
218
                          && a.lastAddr == b.lastAddr
224
      && a.lastAddr == b.lastAddr
219
                          && a.sequenceNumber == b.sequenceNumber);
225
      && a.sequenceNumber == b.sequenceNumber);
220
                }
226
}
221
227
222
                static inline std::ostream&
228
static inline std::ostream&
223
                operator << (std::ostream &os, const TopologyTuple &tuple)
229
operator << (std::ostream &os, const TopologyTuple &tuple)
224
                {
230
{
225
                  os << "TopologyTuple(destAddr=" << tuple.destAddr
231
  os << "TopologyTuple(destAddr=" << tuple.destAddr
226
                  << ", lastAddr=" << tuple.lastAddr
232
                       << ", lastAddr=" << tuple.lastAddr
227
                  << ", sequenceNumber=" << (int) tuple.sequenceNumber
233
                       << ", sequenceNumber=" << (int) tuple.sequenceNumber
228
                  << ", expirationTime=" << tuple.expirationTime
234
                       << ", expirationTime=" << tuple.expirationTime
229
                  << ")";
235
                       << ")";
230
                  return os;
236
  return os;
231
                }
237
}
232
238
239
/// \ingroup olsr
233
/// Association
240
/// Association
234
                struct Association
241
struct Association
235
                {
242
{
236
                  Ipv4Address networkAddr;
243
  Ipv4Address networkAddr; //!< IPv4 Network address.
237
                  Ipv4Mask netmask;
244
  Ipv4Mask netmask;        //!< IPv4 Network mask.
238
                };
245
};
239
246
240
                static inline bool
247
static inline bool
241
                operator == (const Association &a, const Association &b)
248
operator == (const Association &a, const Association &b)
242
                {
249
{
243
                  return (a.networkAddr == b.networkAddr
250
  return (a.networkAddr == b.networkAddr
244
                          && a.netmask == b.netmask);
251
      && a.netmask == b.netmask);
245
                }
252
}
246
253
247
                static inline std::ostream&
254
static inline std::ostream&
248
                operator << (std::ostream &os, const Association &tuple)
255
operator << (std::ostream &os, const Association &tuple)
249
                {
256
{
250
                  os << "Association(networkAddr=" << tuple.networkAddr
257
  os << "Association(networkAddr=" << tuple.networkAddr
251
                  << ", netmask=" << tuple.netmask
258
                     << ", netmask=" << tuple.netmask
252
                  << ")";
259
                     << ")";
253
                  return os;
260
  return os;
254
                }
261
}
255
262
263
/// \ingroup olsr
256
/// An Association Tuple
264
/// An Association Tuple
257
                struct AssociationTuple
265
struct AssociationTuple
258
                {
266
{
259
                  /// Main address of the gateway.
267
  /// Main address of the gateway.
260
                  Ipv4Address gatewayAddr;
268
  Ipv4Address gatewayAddr;
261
                  /// Network Address of network reachable through gatewayAddr
269
  /// Network Address of network reachable through gatewayAddr
262
                  Ipv4Address networkAddr;
270
  Ipv4Address networkAddr;
263
                  /// Netmask of network reachable through gatewayAddr
271
  /// Netmask of network reachable through gatewayAddr
264
                  Ipv4Mask netmask;
272
  Ipv4Mask netmask;
265
                  /// Time at which this tuple expires and must be removed
273
  /// Time at which this tuple expires and must be removed
266
                  Time expirationTime;
274
  Time expirationTime;
267
                };
275
};
268
276
269
                static inline bool
277
static inline bool
270
                operator == (const AssociationTuple &a, const AssociationTuple &b)
278
operator == (const AssociationTuple &a, const AssociationTuple &b)
271
                {
279
{
272
                  return (a.gatewayAddr == b.gatewayAddr
280
  return (a.gatewayAddr == b.gatewayAddr
273
                          && a.networkAddr == b.networkAddr
281
      && a.networkAddr == b.networkAddr
274
                          && a.netmask == b.netmask);
282
      && a.netmask == b.netmask);
275
                }
283
}
276
284
277
                static inline std::ostream&
285
static inline std::ostream&
278
                operator << (std::ostream &os, const AssociationTuple &tuple)
286
operator << (std::ostream &os, const AssociationTuple &tuple)
279
                {
287
{
280
                  os << "AssociationTuple(gatewayAddr=" << tuple.gatewayAddr
288
  os << "AssociationTuple(gatewayAddr=" << tuple.gatewayAddr
281
                  << ", networkAddr=" << tuple.networkAddr
289
                          << ", networkAddr=" << tuple.networkAddr
282
                  << ", netmask=" << tuple.netmask
290
                          << ", netmask=" << tuple.netmask
283
                  << ", expirationTime=" << tuple.expirationTime
291
                          << ", expirationTime=" << tuple.expirationTime
284
                  << ")";
292
                          << ")";
285
                  return os;
293
  return os;
286
                }
294
}
287
295
288
296
289
                typedef std::set<Ipv4Address>                   MprSet; ///< MPR Set type.
297
typedef std::set<Ipv4Address>                   MprSet; //!< MPR Set type.
290
                typedef std::vector<MprSelectorTuple>           MprSelectorSet; ///< MPR Selector Set type.
298
typedef std::vector<MprSelectorTuple>           MprSelectorSet; //!< MPR Selector Set type.
291
                typedef std::vector<LinkTuple>                  LinkSet; ///< Link Set type.
299
typedef std::vector<LinkTuple>                  LinkSet; //!< Link Set type.
292
                typedef std::vector<NeighborTuple>              NeighborSet; ///< Neighbor Set type.
300
typedef std::vector<NeighborTuple>              NeighborSet; //!< Neighbor Set type.
293
                typedef std::vector<TwoHopNeighborTuple>        TwoHopNeighborSet; ///< 2-hop Neighbor Set type.
301
typedef std::vector<TwoHopNeighborTuple>        TwoHopNeighborSet; //!< 2-hop Neighbor Set type.
294
                typedef std::vector<TopologyTuple>              TopologySet; ///< Topology Set type.
302
typedef std::vector<TopologyTuple>              TopologySet; //!< Topology Set type.
295
                typedef std::vector<DuplicateTuple>             DuplicateSet; ///< Duplicate Set type.
303
typedef std::vector<DuplicateTuple>             DuplicateSet; //!< Duplicate Set type.
296
                typedef std::vector<IfaceAssocTuple>            IfaceAssocSet; ///< Interface Association Set type.
304
typedef std::vector<IfaceAssocTuple>            IfaceAssocSet; //!< Interface Association Set type.
297
                typedef std::vector<AssociationTuple>           AssociationSet; ///< Association Set type.
305
typedef std::vector<AssociationTuple>           AssociationSet; //!< Association Set type.
298
                typedef std::vector<Association>                Associations; ///< Association Set type.
306
typedef std::vector<Association>                Associations; //!< Association Set type.
299
307
300
308
301
                }} // namespace ns3, olsr
309
}} // namespace ns3, olsr
302
310
303
#endif /* OLSR_REPOSITORIES_H */
311
#endif /* OLSR_REPOSITORIES_H */
(-)a/src/olsr/model/olsr-routing-protocol.cc (-326 / +6 lines)
 Lines 550-556    Link Here 
550
550
551
namespace {
551
namespace {
552
///
552
///
553
/// \brief Remove all covered 2-hop neighbors from N2 set. This is a helper function used by MprComputation algorithm.
553
/// \brief Remove all covered 2-hop neighbors from N2 set.
554
/// This is a helper function used by MprComputation algorithm.
555
///
556
/// \param neighborMainAddr Neighbor main address.
557
/// \param N2 Reference to the 2-hop neighbor set.
554
///
558
///
555
void 
559
void 
556
CoverTwoHopNeighbors (Ipv4Address neighborMainAddr, TwoHopNeighborSet & N2)
560
CoverTwoHopNeighbors (Ipv4Address neighborMainAddr, TwoHopNeighborSet & N2)
 Lines 579-587    Link Here 
579
}
583
}
580
} // anonymous namespace
584
} // anonymous namespace
581
585
582
///
583
/// \brief Computates MPR set of a node following \RFC{3626} hints.
584
///
585
void
586
void
586
RoutingProtocol::MprComputation ()
587
RoutingProtocol::MprComputation ()
587
{
588
{
 Lines 869-880    Link Here 
869
  m_state.SetMprSet (mprSet);
870
  m_state.SetMprSet (mprSet);
870
}
871
}
871
872
872
///
873
/// \brief Gets the main address associated with a given interface address.
874
///
875
/// \param iface_addr the interface address.
876
/// \return the corresponding main address.
877
///
878
Ipv4Address
873
Ipv4Address
879
RoutingProtocol::GetMainAddress (Ipv4Address iface_addr) const
874
RoutingProtocol::GetMainAddress (Ipv4Address iface_addr) const
880
{
875
{
 Lines 887-895    Link Here 
887
    return iface_addr;
882
    return iface_addr;
888
}
883
}
889
884
890
///
891
/// \brief Creates the routing table of the node following \RFC{3626} hints.
892
///
893
void
885
void
894
RoutingProtocol::RoutingTableComputation ()
886
RoutingProtocol::RoutingTableComputation ()
895
{
887
{
 Lines 1205-1220    Link Here 
1205
}
1197
}
1206
1198
1207
1199
1208
///
1209
/// \brief Processes a HELLO message following \RFC{3626} specification.
1210
///
1211
/// Link sensing and population of the Neighbor Set, 2-hop Neighbor Set and MPR
1212
/// Selector Set are performed.
1213
///
1214
/// \param msg the %OLSR message which contains the HELLO message.
1215
/// \param receiver_iface the address of the interface where the message was received from.
1216
/// \param sender_iface the address of the interface where the message was sent from.
1217
///
1218
void
1200
void
1219
RoutingProtocol::ProcessHello (const olsr::MessageHeader &msg,
1201
RoutingProtocol::ProcessHello (const olsr::MessageHeader &msg,
1220
                               const Ipv4Address &receiverIface,
1202
                               const Ipv4Address &receiverIface,
 Lines 1269-1283    Link Here 
1269
  PopulateMprSelectorSet (msg, hello);
1251
  PopulateMprSelectorSet (msg, hello);
1270
}
1252
}
1271
1253
1272
///
1273
/// \brief Processes a TC message following \RFC{3626} specification.
1274
///
1275
/// The Topology Set is updated (if needed) with the information of
1276
/// the received TC message.
1277
///
1278
/// \param msg the %OLSR message which contains the TC message.
1279
/// \param sender_iface the address of the interface where the message was sent from.
1280
///
1281
void
1254
void
1282
RoutingProtocol::ProcessTc (const olsr::MessageHeader &msg,
1255
RoutingProtocol::ProcessTc (const olsr::MessageHeader &msg,
1283
                            const Ipv4Address &senderIface)
1256
                            const Ipv4Address &senderIface)
 Lines 1364-1378    Link Here 
1364
#endif // NS3_LOG_ENABLE
1337
#endif // NS3_LOG_ENABLE
1365
}
1338
}
1366
1339
1367
///
1368
/// \brief Processes a MID message following \RFC{3626} specification.
1369
///
1370
/// The Interface Association Set is updated (if needed) with the information
1371
/// of the received MID message.
1372
///
1373
/// \param msg the %OLSR message which contains the MID message.
1374
/// \param sender_iface the address of the interface where the message was sent from.
1375
///
1376
void
1340
void
1377
RoutingProtocol::ProcessMid (const olsr::MessageHeader &msg,
1341
RoutingProtocol::ProcessMid (const olsr::MessageHeader &msg,
1378
                             const Ipv4Address &senderIface)
1342
                             const Ipv4Address &senderIface)
 Lines 1443-1457    Link Here 
1443
  NS_LOG_DEBUG ("Node " << m_mainAddress << " ProcessMid from " << senderIface << " -> END.");
1407
  NS_LOG_DEBUG ("Node " << m_mainAddress << " ProcessMid from " << senderIface << " -> END.");
1444
}
1408
}
1445
1409
1446
///
1447
/// \brief Processes a HNA message following \RFC{3626} specification.
1448
///
1449
/// The Host Network Association Set is updated (if needed) with the information
1450
/// of the received HNA message.
1451
///
1452
/// \param msg the %OLSR message which contains the HNA message.
1453
/// \param sender_iface the address of the interface where the message was sent from.
1454
///
1455
void
1410
void
1456
RoutingProtocol::ProcessHna (const olsr::MessageHeader &msg,
1411
RoutingProtocol::ProcessHna (const olsr::MessageHeader &msg,
1457
                             const Ipv4Address &senderIface)
1412
                             const Ipv4Address &senderIface)
 Lines 1509-1525    Link Here 
1509
    }
1464
    }
1510
}
1465
}
1511
1466
1512
///
1513
/// \brief OLSR's default forwarding algorithm.
1514
///
1515
/// See \RFC{3626} for details.
1516
///
1517
/// \param p the %OLSR packet which has been received.
1518
/// \param msg the %OLSR message which must be forwarded.
1519
/// \param dup_tuple NULL if the message has never been considered for forwarding,
1520
/// or a duplicate tuple in other case.
1521
/// \param local_iface the address of the interface where the message was received from.
1522
///
1523
void
1467
void
1524
RoutingProtocol::ForwardDefault (olsr::MessageHeader olsrMessage,
1468
RoutingProtocol::ForwardDefault (olsr::MessageHeader olsrMessage,
1525
                                 DuplicateTuple *duplicated,
1469
                                 DuplicateTuple *duplicated,
 Lines 1586-1600    Link Here 
1586
    }
1530
    }
1587
}
1531
}
1588
1532
1589
///
1590
/// \brief Enques an %OLSR message which will be sent with a delay of (0, delay].
1591
///
1592
/// This buffering system is used in order to piggyback several %OLSR messages in
1593
/// a same %OLSR packet.
1594
///
1595
/// \param msg the %OLSR message which must be sent.
1596
/// \param delay maximum delay the %OLSR message is going to be buffered.
1597
///
1598
void
1533
void
1599
RoutingProtocol::QueueMessage (const olsr::MessageHeader &message, Time delay)
1534
RoutingProtocol::QueueMessage (const olsr::MessageHeader &message, Time delay)
1600
{
1535
{
 Lines 1630-1642    Link Here 
1630
    }
1565
    }
1631
}
1566
}
1632
1567
1633
///
1634
/// \brief Creates as many %OLSR packets as needed in order to send all buffered
1635
/// %OLSR messages.
1636
///
1637
/// Maximum number of messages which can be contained in an %OLSR packet is
1638
/// dictated by OLSR_MAX_MSGS constant.
1639
///
1640
void
1568
void
1641
RoutingProtocol::SendQueuedMessages ()
1569
RoutingProtocol::SendQueuedMessages ()
1642
{
1570
{
 Lines 1673-1681    Link Here 
1673
  m_queuedMessages.clear ();
1601
  m_queuedMessages.clear ();
1674
}
1602
}
1675
1603
1676
///
1677
/// \brief Creates a new %OLSR HELLO message which is buffered for being sent later on.
1678
///
1679
void
1604
void
1680
RoutingProtocol::SendHello ()
1605
RoutingProtocol::SendHello ()
1681
{
1606
{
 Lines 1784-1792    Link Here 
1784
  QueueMessage (msg, JITTER);
1709
  QueueMessage (msg, JITTER);
1785
}
1710
}
1786
1711
1787
///
1788
/// \brief Creates a new %OLSR TC message which is buffered for being sent later on.
1789
///
1790
void
1712
void
1791
RoutingProtocol::SendTc ()
1713
RoutingProtocol::SendTc ()
1792
{
1714
{
 Lines 1811-1819    Link Here 
1811
  QueueMessage (msg, JITTER);
1733
  QueueMessage (msg, JITTER);
1812
}
1734
}
1813
1735
1814
///
1815
/// \brief Creates a new %OLSR MID message which is buffered for being sent later on.
1816
///
1817
void
1736
void
1818
RoutingProtocol::SendMid ()
1737
RoutingProtocol::SendMid ()
1819
{
1738
{
 Lines 1855-1863    Link Here 
1855
  QueueMessage (msg, JITTER);
1774
  QueueMessage (msg, JITTER);
1856
}
1775
}
1857
1776
1858
///
1859
/// \brief Creates a new %OLSR HNA message which is buffered for being sent later on.
1860
///
1861
void
1777
void
1862
RoutingProtocol::SendHna ()
1778
RoutingProtocol::SendHna ()
1863
{
1779
{
 Lines 1891-1901    Link Here 
1891
  QueueMessage (msg, JITTER);
1807
  QueueMessage (msg, JITTER);
1892
}
1808
}
1893
1809
1894
///
1895
/// \brief Injects the specified (networkAddr, netmask) tuple in the list of
1896
///        local HNA associations to be sent by the node via HNA messages.
1897
///        If this tuple already exists, nothing is done.
1898
///
1899
void
1810
void
1900
RoutingProtocol::AddHostNetworkAssociation (Ipv4Address networkAddr, Ipv4Mask netmask)
1811
RoutingProtocol::AddHostNetworkAssociation (Ipv4Address networkAddr, Ipv4Mask netmask)
1901
{
1812
{
 Lines 1917-1927    Link Here 
1917
  m_state.InsertAssociation ( (Association) { networkAddr, netmask} );
1828
  m_state.InsertAssociation ( (Association) { networkAddr, netmask} );
1918
}
1829
}
1919
1830
1920
///
1921
/// \brief Removes the specified (networkAddr, netmask) tuple from the list of
1922
///        local HNA associations to be sent by the node via HNA messages.
1923
///        If this tuple does not exist, nothing is done (see "OlsrState::EraseAssociation()").
1924
///
1925
void
1831
void
1926
RoutingProtocol::RemoveHostNetworkAssociation (Ipv4Address networkAddr, Ipv4Mask netmask)
1832
RoutingProtocol::RemoveHostNetworkAssociation (Ipv4Address networkAddr, Ipv4Mask netmask)
1927
{
1833
{
 Lines 1929-1944    Link Here 
1929
  m_state.EraseAssociation ( (Association) { networkAddr, netmask} );
1835
  m_state.EraseAssociation ( (Association) { networkAddr, netmask} );
1930
}
1836
}
1931
1837
1932
///
1933
/// \brief Associates the specified Ipv4StaticRouting routing table
1934
///        to the OLSR routing protocol. Entries from this associated
1935
///        routing table that use non-olsr outgoing interfaces are added
1936
///        to the list of local HNA associations so that they are included
1937
///        in HNA messages sent by the node.
1938
///        If this method is called more than once, entries from the old
1939
///        association are deleted before entries from the new one are added.
1940
/// \param routingTable the Ipv4StaticRouting routing table to be associated.
1941
///
1942
void
1838
void
1943
RoutingProtocol::SetRoutingTableAssociation (Ptr<Ipv4StaticRouting> routingTable)
1839
RoutingProtocol::SetRoutingTableAssociation (Ptr<Ipv4StaticRouting> routingTable)
1944
{
1840
{
 Lines 1984-1994    Link Here 
1984
                "the associated routing table: " << m_state.GetAssociations ().size ());
1880
                "the associated routing table: " << m_state.GetAssociations ().size ());
1985
}
1881
}
1986
1882
1987
///
1988
/// \brief Tests whether or not the specified route uses a non-OLSR outgoing interface.
1989
///        Returns true if the outgoing interface of the specified route is a non-OLSR interface.
1990
///        Returns false otherwise.
1991
///
1992
bool
1883
bool
1993
RoutingProtocol::UsesNonOlsrOutgoingInterface (const Ipv4RoutingTableEntry &route)
1884
RoutingProtocol::UsesNonOlsrOutgoingInterface (const Ipv4RoutingTableEntry &route)
1994
{
1885
{
 Lines 1998-2006    Link Here 
1998
  return ci != m_interfaceExclusions.end ();
1889
  return ci != m_interfaceExclusions.end ();
1999
}
1890
}
2000
1891
2001
///
2002
/// \brief Updates Link Set according to a new received HELLO message
2003
/// (following \RFC{3626} specification). Neighbor Set is also updated if needed.
2004
void
1892
void
2005
RoutingProtocol::LinkSensing (const olsr::MessageHeader &msg,
1893
RoutingProtocol::LinkSensing (const olsr::MessageHeader &msg,
2006
                              const olsr::MessageHeader::Hello &hello,
1894
                              const olsr::MessageHeader::Hello &hello,
 Lines 2135-2143    Link Here 
2135
                    << ": LinkSensing END");
2023
                    << ": LinkSensing END");
2136
}
2024
}
2137
2025
2138
///
2139
/// \brief Updates the Neighbor Set according to the information contained in
2140
/// a new received HELLO message (following \RFC{3626}).
2141
void
2026
void
2142
RoutingProtocol::PopulateNeighborSet (const olsr::MessageHeader &msg,
2027
RoutingProtocol::PopulateNeighborSet (const olsr::MessageHeader &msg,
2143
                                      const olsr::MessageHeader::Hello &hello)
2028
                                      const olsr::MessageHeader::Hello &hello)
 Lines 2149-2158    Link Here 
2149
    }
2034
    }
2150
}
2035
}
2151
2036
2152
2153
///
2154
/// \brief Updates the 2-hop Neighbor Set according to the information contained
2155
/// in a new received HELLO message (following \RFC{3626}).
2156
void
2037
void
2157
RoutingProtocol::PopulateTwoHopNeighborSet (const olsr::MessageHeader &msg,
2038
RoutingProtocol::PopulateTwoHopNeighborSet (const olsr::MessageHeader &msg,
2158
                                            const olsr::MessageHeader::Hello &hello)
2039
                                            const olsr::MessageHeader::Hello &hello)
 Lines 2260-2270    Link Here 
2260
  NS_LOG_DEBUG ("Olsr node " << m_mainAddress << ": PopulateTwoHopNeighborSet END");
2141
  NS_LOG_DEBUG ("Olsr node " << m_mainAddress << ": PopulateTwoHopNeighborSet END");
2261
}
2142
}
2262
2143
2263
2264
2265
///
2266
/// \brief Updates the MPR Selector Set according to the information contained in
2267
/// a new received HELLO message (following \RFC{3626}).
2268
void
2144
void
2269
RoutingProtocol::PopulateMprSelectorSet (const olsr::MessageHeader &msg,
2145
RoutingProtocol::PopulateMprSelectorSet (const olsr::MessageHeader &msg,
2270
                                         const olsr::MessageHeader::Hello &hello)
2146
                                         const olsr::MessageHeader::Hello &hello)
 Lines 2324-2330    Link Here 
2324
#if 0
2200
#if 0
2325
///
2201
///
2326
/// \brief Drops a given packet because it couldn't be delivered to the corresponding
2202
/// \brief Drops a given packet because it couldn't be delivered to the corresponding
2327
/// destination by the MAC layer. This may cause a neighbor loss, and appropiate
2203
/// destination by the MAC layer. This may cause a neighbor loss, and appropriate
2328
/// actions are then taken.
2204
/// actions are then taken.
2329
///
2205
///
2330
/// \param p the packet which couldn't be delivered by the MAC layer.
2206
/// \param p the packet which couldn't be delivered by the MAC layer.
 Lines 2358-2370    Link Here 
2358
2234
2359
2235
2360
2236
2361
///
2362
/// \brief Performs all actions needed when a neighbor loss occurs.
2363
///
2364
/// Neighbor Set, 2-hop Neighbor Set, MPR Set and MPR Selector Set are updated.
2365
///
2366
/// \param tuple link tuple with the information of the link to the neighbor which has been lost.
2367
///
2368
void
2237
void
2369
RoutingProtocol::NeighborLoss (const LinkTuple &tuple)
2238
RoutingProtocol::NeighborLoss (const LinkTuple &tuple)
2370
{
2239
{
 Lines 2379-2389    Link Here 
2379
  RoutingTableComputation ();
2248
  RoutingTableComputation ();
2380
}
2249
}
2381
2250
2382
///
2383
/// \brief Adds a duplicate tuple to the Duplicate Set.
2384
///
2385
/// \param tuple the duplicate tuple to be added.
2386
///
2387
void
2251
void
2388
RoutingProtocol::AddDuplicateTuple (const DuplicateTuple &tuple)
2252
RoutingProtocol::AddDuplicateTuple (const DuplicateTuple &tuple)
2389
{
2253
{
 Lines 2395-2405    Link Here 
2395
  m_state.InsertDuplicateTuple (tuple);
2259
  m_state.InsertDuplicateTuple (tuple);
2396
}
2260
}
2397
2261
2398
///
2399
/// \brief Removes a duplicate tuple from the Duplicate Set.
2400
///
2401
/// \param tuple the duplicate tuple to be removed.
2402
///
2403
void
2262
void
2404
RoutingProtocol::RemoveDuplicateTuple (const DuplicateTuple &tuple)
2263
RoutingProtocol::RemoveDuplicateTuple (const DuplicateTuple &tuple)
2405
{
2264
{
 Lines 2431-2441    Link Here 
2431
  AddNeighborTuple (nb_tuple);
2290
  AddNeighborTuple (nb_tuple);
2432
}
2291
}
2433
2292
2434
///
2435
/// \brief Removes a link tuple from the Link Set.
2436
///
2437
/// \param tuple the link tuple to be removed.
2438
///
2439
void
2293
void
2440
RoutingProtocol::RemoveLinkTuple (const LinkTuple &tuple)
2294
RoutingProtocol::RemoveLinkTuple (const LinkTuple &tuple)
2441
{
2295
{
 Lines 2447-2458    Link Here 
2447
  m_state.EraseLinkTuple (tuple);
2301
  m_state.EraseLinkTuple (tuple);
2448
}
2302
}
2449
2303
2450
///
2451
/// \brief This function is invoked when a link tuple is updated. Its aim is to
2452
/// also update the corresponding neighbor tuple if it is needed.
2453
///
2454
/// \param tuple the link tuple which has been updated.
2455
///
2456
void
2304
void
2457
RoutingProtocol::LinkTupleUpdated (const LinkTuple &tuple, uint8_t willingness)
2305
RoutingProtocol::LinkTupleUpdated (const LinkTuple &tuple, uint8_t willingness)
2458
{
2306
{
 Lines 2509-2519    Link Here 
2509
    }
2357
    }
2510
}
2358
}
2511
2359
2512
///
2513
/// \brief Adds a neighbor tuple to the Neighbor Set.
2514
///
2515
/// \param tuple the neighbor tuple to be added.
2516
///
2517
void
2360
void
2518
RoutingProtocol::AddNeighborTuple (const NeighborTuple &tuple)
2361
RoutingProtocol::AddNeighborTuple (const NeighborTuple &tuple)
2519
{
2362
{
 Lines 2527-2537    Link Here 
2527
  IncrementAnsn ();
2370
  IncrementAnsn ();
2528
}
2371
}
2529
2372
2530
///
2531
/// \brief Removes a neighbor tuple from the Neighbor Set.
2532
///
2533
/// \param tuple the neighbor tuple to be removed.
2534
///
2535
void
2373
void
2536
RoutingProtocol::RemoveNeighborTuple (const NeighborTuple &tuple)
2374
RoutingProtocol::RemoveNeighborTuple (const NeighborTuple &tuple)
2537
{
2375
{
 Lines 2545-2555    Link Here 
2545
  IncrementAnsn ();
2383
  IncrementAnsn ();
2546
}
2384
}
2547
2385
2548
///
2549
/// \brief Adds a 2-hop neighbor tuple to the 2-hop Neighbor Set.
2550
///
2551
/// \param tuple the 2-hop neighbor tuple to be added.
2552
///
2553
void
2386
void
2554
RoutingProtocol::AddTwoHopNeighborTuple (const TwoHopNeighborTuple &tuple)
2387
RoutingProtocol::AddTwoHopNeighborTuple (const TwoHopNeighborTuple &tuple)
2555
{
2388
{
 Lines 2562-2572    Link Here 
2562
  m_state.InsertTwoHopNeighborTuple (tuple);
2395
  m_state.InsertTwoHopNeighborTuple (tuple);
2563
}
2396
}
2564
2397
2565
///
2566
/// \brief Removes a 2-hop neighbor tuple from the 2-hop Neighbor Set.
2567
///
2568
/// \param tuple the 2-hop neighbor tuple to be removed.
2569
///
2570
void
2398
void
2571
RoutingProtocol::RemoveTwoHopNeighborTuple (const TwoHopNeighborTuple &tuple)
2399
RoutingProtocol::RemoveTwoHopNeighborTuple (const TwoHopNeighborTuple &tuple)
2572
{
2400
{
 Lines 2585-2597    Link Here 
2585
  m_ansn = (m_ansn + 1) % (OLSR_MAX_SEQ_NUM + 1);
2413
  m_ansn = (m_ansn + 1) % (OLSR_MAX_SEQ_NUM + 1);
2586
}
2414
}
2587
2415
2588
///
2589
/// \brief Adds an MPR selector tuple to the MPR Selector Set.
2590
///
2591
/// Advertised Neighbor Sequence Number (ANSN) is also updated.
2592
///
2593
/// \param tuple the MPR selector tuple to be added.
2594
///
2595
void
2416
void
2596
RoutingProtocol::AddMprSelectorTuple (const MprSelectorTuple  &tuple)
2417
RoutingProtocol::AddMprSelectorTuple (const MprSelectorTuple  &tuple)
2597
{
2418
{
 Lines 2604-2616    Link Here 
2604
  IncrementAnsn ();
2425
  IncrementAnsn ();
2605
}
2426
}
2606
2427
2607
///
2608
/// \brief Removes an MPR selector tuple from the MPR Selector Set.
2609
///
2610
/// Advertised Neighbor Sequence Number (ANSN) is also updated.
2611
///
2612
/// \param tuple the MPR selector tuple to be removed.
2613
///
2614
void
2428
void
2615
RoutingProtocol::RemoveMprSelectorTuple (const MprSelectorTuple &tuple)
2429
RoutingProtocol::RemoveMprSelectorTuple (const MprSelectorTuple &tuple)
2616
{
2430
{
 Lines 2623-2633    Link Here 
2623
  IncrementAnsn ();
2437
  IncrementAnsn ();
2624
}
2438
}
2625
2439
2626
///
2627
/// \brief Adds a topology tuple to the Topology Set.
2628
///
2629
/// \param tuple the topology tuple to be added.
2630
///
2631
void
2440
void
2632
RoutingProtocol::AddTopologyTuple (const TopologyTuple &tuple)
2441
RoutingProtocol::AddTopologyTuple (const TopologyTuple &tuple)
2633
{
2442
{
 Lines 2641-2651    Link Here 
2641
  m_state.InsertTopologyTuple (tuple);
2450
  m_state.InsertTopologyTuple (tuple);
2642
}
2451
}
2643
2452
2644
///
2645
/// \brief Removes a topology tuple from the Topology Set.
2646
///
2647
/// \param tuple the topology tuple to be removed.
2648
///
2649
void
2453
void
2650
RoutingProtocol::RemoveTopologyTuple (const TopologyTuple &tuple)
2454
RoutingProtocol::RemoveTopologyTuple (const TopologyTuple &tuple)
2651
{
2455
{
 Lines 2659-2669    Link Here 
2659
  m_state.EraseTopologyTuple (tuple);
2463
  m_state.EraseTopologyTuple (tuple);
2660
}
2464
}
2661
2465
2662
///
2663
/// \brief Adds an interface association tuple to the Interface Association Set.
2664
///
2665
/// \param tuple the interface association tuple to be added.
2666
///
2667
void
2466
void
2668
RoutingProtocol::AddIfaceAssocTuple (const IfaceAssocTuple &tuple)
2467
RoutingProtocol::AddIfaceAssocTuple (const IfaceAssocTuple &tuple)
2669
{
2468
{
 Lines 2676-2686    Link Here 
2676
  m_state.InsertIfaceAssocTuple (tuple);
2475
  m_state.InsertIfaceAssocTuple (tuple);
2677
}
2476
}
2678
2477
2679
///
2680
/// \brief Removes an interface association tuple from the Interface Association Set.
2681
///
2682
/// \param tuple the interface association tuple to be removed.
2683
///
2684
void
2478
void
2685
RoutingProtocol::RemoveIfaceAssocTuple (const IfaceAssocTuple &tuple)
2479
RoutingProtocol::RemoveIfaceAssocTuple (const IfaceAssocTuple &tuple)
2686
{
2480
{
 Lines 2693-2740    Link Here 
2693
  m_state.EraseIfaceAssocTuple (tuple);
2487
  m_state.EraseIfaceAssocTuple (tuple);
2694
}
2488
}
2695
2489
2696
///
2697
/// \brief Adds a host network association tuple to the Association Set.
2698
///
2699
/// \param tuple the host network association tuple to be added.
2700
///
2701
void
2490
void
2702
RoutingProtocol::AddAssociationTuple (const AssociationTuple &tuple)
2491
RoutingProtocol::AddAssociationTuple (const AssociationTuple &tuple)
2703
{
2492
{
2704
  m_state.InsertAssociationTuple (tuple);
2493
  m_state.InsertAssociationTuple (tuple);
2705
}
2494
}
2706
2495
2707
///
2708
/// \brief Removes a host network association tuple from the Association Set.
2709
///
2710
/// \param tuple the host network association tuple to be removed.
2711
///
2712
void
2496
void
2713
RoutingProtocol::RemoveAssociationTuple (const AssociationTuple &tuple)
2497
RoutingProtocol::RemoveAssociationTuple (const AssociationTuple &tuple)
2714
{
2498
{
2715
  m_state.EraseAssociationTuple (tuple);
2499
  m_state.EraseAssociationTuple (tuple);
2716
}
2500
}
2717
2501
2718
2719
2720
uint16_t RoutingProtocol::GetPacketSequenceNumber ()
2502
uint16_t RoutingProtocol::GetPacketSequenceNumber ()
2721
{
2503
{
2722
  m_packetSequenceNumber = (m_packetSequenceNumber + 1) % (OLSR_MAX_SEQ_NUM + 1);
2504
  m_packetSequenceNumber = (m_packetSequenceNumber + 1) % (OLSR_MAX_SEQ_NUM + 1);
2723
  return m_packetSequenceNumber;
2505
  return m_packetSequenceNumber;
2724
}
2506
}
2725
2507
2726
/// Increments message sequence number and returns the new value.
2727
uint16_t RoutingProtocol::GetMessageSequenceNumber ()
2508
uint16_t RoutingProtocol::GetMessageSequenceNumber ()
2728
{
2509
{
2729
  m_messageSequenceNumber = (m_messageSequenceNumber + 1) % (OLSR_MAX_SEQ_NUM + 1);
2510
  m_messageSequenceNumber = (m_messageSequenceNumber + 1) % (OLSR_MAX_SEQ_NUM + 1);
2730
  return m_messageSequenceNumber;
2511
  return m_messageSequenceNumber;
2731
}
2512
}
2732
2513
2733
2734
///
2735
/// \brief Sends a HELLO message and reschedules the HELLO timer.
2736
/// \param e The event which has expired.
2737
///
2738
void
2514
void
2739
RoutingProtocol::HelloTimerExpire ()
2515
RoutingProtocol::HelloTimerExpire ()
2740
{
2516
{
 Lines 2742-2751    Link Here 
2742
  m_helloTimer.Schedule (m_helloInterval);
2518
  m_helloTimer.Schedule (m_helloInterval);
2743
}
2519
}
2744
2520
2745
///
2746
/// \brief Sends a TC message (if there exists any MPR selector) and reschedules the TC timer.
2747
/// \param e The event which has expired.
2748
///
2749
void
2521
void
2750
RoutingProtocol::TcTimerExpire ()
2522
RoutingProtocol::TcTimerExpire ()
2751
{
2523
{
 Lines 2760-2769    Link Here 
2760
  m_tcTimer.Schedule (m_tcInterval);
2532
  m_tcTimer.Schedule (m_tcInterval);
2761
}
2533
}
2762
2534
2763
///
2764
/// \brief Sends a MID message (if the node has more than one interface) and resets the MID timer.
2765
/// \param e The event which has expired.
2766
///
2767
void
2535
void
2768
RoutingProtocol::MidTimerExpire ()
2536
RoutingProtocol::MidTimerExpire ()
2769
{
2537
{
 Lines 2771-2779    Link Here 
2771
  m_midTimer.Schedule (m_midInterval);
2539
  m_midTimer.Schedule (m_midInterval);
2772
}
2540
}
2773
2541
2774
///
2775
/// \brief Sends an HNA message (if the node has associated hosts/networks) and reschedules the HNA timer.
2776
///
2777
void
2542
void
2778
RoutingProtocol::HnaTimerExpire ()
2543
RoutingProtocol::HnaTimerExpire ()
2779
{
2544
{
 Lines 2788-2800    Link Here 
2788
  m_hnaTimer.Schedule (m_hnaInterval);
2553
  m_hnaTimer.Schedule (m_hnaInterval);
2789
}
2554
}
2790
2555
2791
///
2792
/// \brief Removes tuple if expired. Else timer is rescheduled to expire at tuple.expirationTime.
2793
///
2794
/// The task of actually removing the tuple is left to the OLSR agent.
2795
///
2796
/// \param tuple The tuple which has expired.
2797
///
2798
void
2556
void
2799
RoutingProtocol::DupTupleTimerExpire (Ipv4Address address, uint16_t sequenceNumber)
2557
RoutingProtocol::DupTupleTimerExpire (Ipv4Address address, uint16_t sequenceNumber)
2800
{
2558
{
 Lines 2816-2832    Link Here 
2816
    }
2574
    }
2817
}
2575
}
2818
2576
2819
///
2820
/// \brief Removes tuple_ if expired. Else if symmetric time
2821
/// has expired then it is assumed a neighbor loss and agent_->nb_loss()
2822
/// is called. In this case the timer is rescheduled to expire at
2823
/// tuple_->time(). Otherwise the timer is rescheduled to expire at
2824
/// the minimum between tuple_->time() and tuple_->sym_time().
2825
///
2826
/// The task of actually removing the tuple is left to the OLSR agent.
2827
///
2828
/// \param e The event which has expired.
2829
///
2830
void
2577
void
2831
RoutingProtocol::LinkTupleTimerExpire (Ipv4Address neighborIfaceAddr)
2578
RoutingProtocol::LinkTupleTimerExpire (Ipv4Address neighborIfaceAddr)
2832
{
2579
{
 Lines 2861-2873    Link Here 
2861
    }
2608
    }
2862
}
2609
}
2863
2610
2864
///
2865
/// \brief Removes tuple_ if expired. Else the timer is rescheduled to expire at tuple_->time().
2866
///
2867
/// The task of actually removing the tuple is left to the OLSR agent.
2868
///
2869
/// \param e The event which has expired.
2870
///
2871
void
2611
void
2872
RoutingProtocol::Nb2hopTupleTimerExpire (Ipv4Address neighborMainAddr, Ipv4Address twoHopNeighborAddr)
2612
RoutingProtocol::Nb2hopTupleTimerExpire (Ipv4Address neighborMainAddr, Ipv4Address twoHopNeighborAddr)
2873
{
2613
{
 Lines 2889-2901    Link Here 
2889
    }
2629
    }
2890
}
2630
}
2891
2631
2892
///
2893
/// \brief Removes tuple_ if expired. Else the timer is rescheduled to expire at tuple_->time().
2894
///
2895
/// The task of actually removing the tuple is left to the OLSR agent.
2896
///
2897
/// \param e The event which has expired.
2898
///
2899
void
2632
void
2900
RoutingProtocol::MprSelTupleTimerExpire (Ipv4Address mainAddr)
2633
RoutingProtocol::MprSelTupleTimerExpire (Ipv4Address mainAddr)
2901
{
2634
{
 Lines 2916-2928    Link Here 
2916
    }
2649
    }
2917
}
2650
}
2918
2651
2919
///
2920
/// \brief Removes tuple_ if expired. Else the timer is rescheduled to expire at tuple_->time().
2921
///
2922
/// The task of actually removing the tuple is left to the OLSR agent.
2923
///
2924
/// \param e The event which has expired.
2925
///
2926
void
2652
void
2927
RoutingProtocol::TopologyTupleTimerExpire (Ipv4Address destAddr, Ipv4Address lastAddr)
2653
RoutingProtocol::TopologyTupleTimerExpire (Ipv4Address destAddr, Ipv4Address lastAddr)
2928
{
2654
{
 Lines 2943-2952    Link Here 
2943
    }
2669
    }
2944
}
2670
}
2945
2671
2946
///
2947
/// \brief Removes tuple_ if expired. Else timer is rescheduled to expire at tuple_->time().
2948
/// \param e The event which has expired.
2949
///
2950
void
2672
void
2951
RoutingProtocol::IfaceAssocTupleTimerExpire (Ipv4Address ifaceAddr)
2673
RoutingProtocol::IfaceAssocTupleTimerExpire (Ipv4Address ifaceAddr)
2952
{
2674
{
 Lines 2967-2975    Link Here 
2967
    }
2689
    }
2968
}
2690
}
2969
2691
2970
/// \brief Removes tuple_ if expired. Else timer is rescheduled to expire at tuple_->time().
2971
/// \param e The event which has expired.
2972
///
2973
void
2692
void
2974
RoutingProtocol::AssociationTupleTimerExpire (Ipv4Address gatewayAddr, Ipv4Address networkAddr, Ipv4Mask netmask)
2693
RoutingProtocol::AssociationTupleTimerExpire (Ipv4Address gatewayAddr, Ipv4Address networkAddr, Ipv4Mask netmask)
2975
{
2694
{
 Lines 2990-2998    Link Here 
2990
    }
2709
    }
2991
}
2710
}
2992
2711
2993
///
2994
/// \brief Clears the routing table and frees the memory assigned to each one of its entries.
2995
///
2996
void
2712
void
2997
RoutingProtocol::Clear ()
2713
RoutingProtocol::Clear ()
2998
{
2714
{
 Lines 3000-3021    Link Here 
3000
  m_table.clear ();
2716
  m_table.clear ();
3001
}
2717
}
3002
2718
3003
///
3004
/// \brief Deletes the entry whose destination address is given.
3005
/// \param dest address of the destination node.
3006
///
3007
void
2719
void
3008
RoutingProtocol::RemoveEntry (Ipv4Address const &dest)
2720
RoutingProtocol::RemoveEntry (Ipv4Address const &dest)
3009
{
2721
{
3010
  m_table.erase (dest);
2722
  m_table.erase (dest);
3011
}
2723
}
3012
2724
3013
///
3014
/// \brief Looks up an entry for the specified destination address.
3015
/// \param dest destination address.
3016
/// \param outEntry output parameter to hold the routing entry result, if fuond
3017
/// \return true if found, false if not found
3018
///
3019
bool
2725
bool
3020
RoutingProtocol::Lookup (Ipv4Address const &dest,
2726
RoutingProtocol::Lookup (Ipv4Address const &dest,
3021
                         RoutingTableEntry &outEntry) const
2727
                         RoutingTableEntry &outEntry) const
 Lines 3030-3051    Link Here 
3030
  return true;
2736
  return true;
3031
}
2737
}
3032
2738
3033
///
3034
/// \brief Finds the appropiate entry which must be used in order to forward
3035
/// a data packet to a next hop (given a destination).
3036
///
3037
/// Imagine a routing table like this: [A,B] [B,C] [C,C]; being each pair of the
3038
/// form [dest addr,next-hop addr]. In this case, if this function is invoked with
3039
/// [A,B] then pair [C,C] is returned because C is the next hop that must be used
3040
/// to forward a data packet destined to A. That is, C is a neighbor of this node,
3041
/// but B isn't. This function finds the appropiate neighbor for forwarding a packet.
3042
///
3043
/// \param entry the routing table entry which indicates the destination node
3044
/// we are interested in.
3045
/// \return the appropiate routing table entry which indicates the next
3046
/// hop which must be used for forwarding a data packet, or NULL
3047
/// if there is no such entry.
3048
///
3049
bool
2739
bool
3050
RoutingProtocol::FindSendEntry (RoutingTableEntry const &entry,
2740
RoutingProtocol::FindSendEntry (RoutingTableEntry const &entry,
3051
                                RoutingTableEntry &outEntry) const
2741
                                RoutingTableEntry &outEntry) const
 Lines 3251-3266    Link Here 
3251
{}
2941
{}
3252
2942
3253
2943
3254
///
3255
/// \brief Adds a new entry into the routing table.
3256
///
3257
/// If an entry for the given destination existed, it is deleted and freed.
3258
///
3259
/// \param dest address of the destination node.
3260
/// \param next address of the next hop node.
3261
/// \param iface address of the local interface.
3262
/// \param dist distance to the destination node.
3263
///
3264
void
2944
void
3265
RoutingProtocol::AddEntry (Ipv4Address const &dest,
2945
RoutingProtocol::AddEntry (Ipv4Address const &dest,
3266
                           Ipv4Address const &next,
2946
                           Ipv4Address const &next,
(-)a/src/olsr/model/olsr-routing-protocol.h (-59 / +489 lines)
 Lines 54-66    Link Here 
54
/// This section documents the API of the ns-3 OLSR module. For a generic 
54
/// This section documents the API of the ns-3 OLSR module. For a generic 
55
/// functional description, please refer to the ns-3 manual.
55
/// functional description, please refer to the ns-3 manual.
56
56
57
/// \ingroup olsr
57
/// An %OLSR's routing table entry.
58
/// An %OLSR's routing table entry.
58
struct RoutingTableEntry
59
struct RoutingTableEntry
59
{
60
{
60
  Ipv4Address destAddr; ///< Address of the destination node.
61
  Ipv4Address destAddr; //!< Address of the destination node.
61
  Ipv4Address nextAddr; ///< Address of the next hop.
62
  Ipv4Address nextAddr; //!< Address of the next hop.
62
  uint32_t interface; ///< Interface index
63
  uint32_t interface; //!< Interface index
63
  uint32_t distance; ///< Distance in hops to the destination.
64
  uint32_t distance; //!< Distance in hops to the destination.
64
65
65
  RoutingTableEntry () : // default values
66
  RoutingTableEntry () : // default values
66
                         destAddr (), nextAddr (),
67
                         destAddr (), nextAddr (),
 Lines 78-105    Link Here 
78
{
79
{
79
public:
80
public:
80
  friend class ::OlsrMprTestCase;
81
  friend class ::OlsrMprTestCase;
82
83
  /**
84
   * \brief Get the type ID.
85
   * \return The object TypeId.
86
   */
81
  static TypeId GetTypeId (void);
87
  static TypeId GetTypeId (void);
82
88
83
  RoutingProtocol ();
89
  RoutingProtocol ();
84
  virtual ~RoutingProtocol ();
90
  virtual ~RoutingProtocol ();
85
91
86
  ///
92
  /**
87
  /// \brief Set the OLSR main address to the first address on the indicated
93
   * \brief Set the OLSR main address to the first address on the indicated interface.
88
  ///        interface
94
   *
89
  /// \param interface IPv4 interface index
95
   * \param interface IPv4 interface index
90
  ///
96
   */
91
  void SetMainInterface (uint32_t interface);
97
  void SetMainInterface (uint32_t interface);
92
98
93
  ///
99
  /**
94
  /// Dump the neighbor table, two-hop neighbor table, and routing table
100
   * Dump the neighbor table, two-hop neighbor table, and routing table
95
  /// to logging output (NS_LOG_DEBUG log level).  If logging is disabled,
101
   * to logging output (NS_LOG_DEBUG log level).  If logging is disabled,
96
  /// this function does nothing.
102
   * this function does nothing.
97
  ///
103
   */
98
  void Dump (void);
104
  void Dump (void);
99
105
100
  /**
106
  /**
101
   * Return the list of routing table entries discovered by OLSR
107
   * Return the list of routing table entries discovered by OLSR
102
   **/
108
   */
103
  std::vector<RoutingTableEntry> GetRoutingTableEntries () const;
109
  std::vector<RoutingTableEntry> GetRoutingTableEntries () const;
104
110
105
 /**
111
 /**
 Lines 129-150    Link Here 
129
  typedef void (* TableChangeTracedCallback) (uint32_t size);
135
  typedef void (* TableChangeTracedCallback) (uint32_t size);
130
136
131
private:
137
private:
132
  std::set<uint32_t> m_interfaceExclusions;
138
  std::set<uint32_t> m_interfaceExclusions; //!< Set of interfaces excluded by OSLR.
133
  Ptr<Ipv4StaticRouting> m_routingTableAssociation;
139
  Ptr<Ipv4StaticRouting> m_routingTableAssociation; //!< Associations from an Ipv4StaticRouting instance
134
140
135
public:
141
public:
142
  /**
143
   * Get the excluded interfaces.
144
   * \returns Container of excluded interfaces.
145
   */
136
  std::set<uint32_t> GetInterfaceExclusions () const
146
  std::set<uint32_t> GetInterfaceExclusions () const
137
  {
147
  {
138
    return m_interfaceExclusions;
148
    return m_interfaceExclusions;
139
  }
149
  }
150
151
  /**
152
   * Set the interfaces to be excluded.
153
   * \param exceptions Container of excluded interfaces.
154
   */
140
  void SetInterfaceExclusions (std::set<uint32_t> exceptions);
155
  void SetInterfaceExclusions (std::set<uint32_t> exceptions);
141
156
142
  /// Inject Association to be sent in HNA message
157
  /**
158
   *  \brief Injects the specified (networkAddr, netmask) tuple in the list of
159
   *  local HNA associations to be sent by the node via HNA messages.
160
   *  If this tuple already exists, nothing is done.
161
   *
162
   * \param networkAddr The network address.
163
   * \param netmask The network mask.
164
   */
143
  void AddHostNetworkAssociation (Ipv4Address networkAddr, Ipv4Mask netmask);
165
  void AddHostNetworkAssociation (Ipv4Address networkAddr, Ipv4Mask netmask);
144
  /// Removes Association sent in HNA message
166
167
  /**
168
   * \brief Removes the specified (networkAddr, netmask) tuple from the list of
169
   * local HNA associations to be sent by the node via HNA messages.
170
   * If this tuple does not exist, nothing is done (see "OlsrState::EraseAssociation()").
171
   *
172
   * \param networkAddr The network address.
173
   * \param netmask The network mask.
174
   */
145
  void RemoveHostNetworkAssociation (Ipv4Address networkAddr, Ipv4Mask netmask);
175
  void RemoveHostNetworkAssociation (Ipv4Address networkAddr, Ipv4Mask netmask);
146
176
147
  /// Inject Associations from an Ipv4StaticRouting instance
177
  /**
178
   * \brief Associates the specified Ipv4StaticRouting routing table
179
   *         to the OLSR routing protocol. Entries from this associated
180
   *         routing table that use non-olsr outgoing interfaces are added
181
   *         to the list of local HNA associations so that they are included
182
   *         in HNA messages sent by the node.
183
   *         If this method is called more than once, entries from the old
184
   *         association are deleted before entries from the new one are added.
185
   *  \param routingTable the Ipv4StaticRouting routing table to be associated.
186
   */
148
  void SetRoutingTableAssociation (Ptr<Ipv4StaticRouting> routingTable);
187
  void SetRoutingTableAssociation (Ptr<Ipv4StaticRouting> routingTable);
149
188
150
  /**
189
  /**
 Lines 156-203    Link Here 
156
protected:
195
protected:
157
  virtual void DoInitialize (void);
196
  virtual void DoInitialize (void);
158
private:
197
private:
159
  std::map<Ipv4Address, RoutingTableEntry> m_table; ///< Data structure for the routing table.
198
  std::map<Ipv4Address, RoutingTableEntry> m_table; //!< Data structure for the routing table.
160
199
161
  Ptr<Ipv4StaticRouting> m_hnaRoutingTable;
200
  Ptr<Ipv4StaticRouting> m_hnaRoutingTable; //!< Routing table for HNA routes
162
201
163
  EventGarbageCollector m_events;
202
  EventGarbageCollector m_events; //!< Running events.
164
	
203
	
165
  /// Packets sequence number counter.
204
  uint16_t m_packetSequenceNumber;    //!< Packets sequence number counter.
166
  uint16_t m_packetSequenceNumber;
205
  uint16_t m_messageSequenceNumber;   //!< Messages sequence number counter.
167
  /// Messages sequence number counter.
206
  uint16_t m_ansn;  //!< Advertised Neighbor Set sequence number.
168
  uint16_t m_messageSequenceNumber;
169
  /// Advertised Neighbor Set sequence number.
170
  uint16_t m_ansn;
171
207
172
  /// HELLO messages' emission interval.
208
  Time m_helloInterval;   //!< HELLO messages' emission interval.
173
  Time m_helloInterval;
209
  Time m_tcInterval;      //!< TC messages' emission interval.
174
  /// TC messages' emission interval.
210
  Time m_midInterval;     //!< MID messages' emission interval.
175
  Time m_tcInterval;
211
  Time m_hnaInterval;     //!< HNA messages' emission interval.
176
  /// MID messages' emission interval.
212
  uint8_t m_willingness;  //!<  Willingness for forwarding packets on behalf of other nodes.
177
  Time m_midInterval;
178
  /// HNA messages' emission interval.
179
  Time m_hnaInterval;
180
  /// Willingness for forwarding packets on behalf of other nodes.
181
  uint8_t m_willingness;
182
213
183
  /// Internal state with all needed data structs.
214
  OlsrState m_state;  //!< Internal state with all needed data structs.
184
  OlsrState m_state;
215
  Ptr<Ipv4> m_ipv4;   //!< IPv4 object the routing is linked to.
185
216
186
  Ptr<Ipv4> m_ipv4;
217
  /**
218
   * \brief Clears the routing table and frees the memory assigned to each one of its entries.
219
   */
220
  void Clear ();
187
221
188
  void Clear ();
222
  /**
223
   * Returns the routing table size.
224
   * \return The routing table size.
225
   */
189
  uint32_t GetSize () const { return m_table.size (); }
226
  uint32_t GetSize () const { return m_table.size (); }
227
228
  /**
229
   * \brief Deletes the entry whose destination address is given.
230
   * \param dest address of the destination node.
231
   */
190
  void RemoveEntry (const Ipv4Address &dest);
232
  void RemoveEntry (const Ipv4Address &dest);
233
  /**
234
   * \brief Adds a new entry into the routing table.
235
   *
236
   * If an entry for the given destination existed, it is deleted and freed.
237
   *
238
   * \param dest address of the destination node.
239
   * \param next address of the next hop node.
240
   * \param interface address of the local interface.
241
   * \param distance distance to the destination node.
242
   */
191
  void AddEntry (const Ipv4Address &dest,
243
  void AddEntry (const Ipv4Address &dest,
192
                 const Ipv4Address &next,
244
                 const Ipv4Address &next,
193
                 uint32_t interface,
245
                 uint32_t interface,
194
                 uint32_t distance);
246
                 uint32_t distance);
247
  /**
248
   * \brief Adds a new entry into the routing table.
249
   *
250
   * If an entry for the given destination existed, an error is thrown.
251
   *
252
   * \param dest address of the destination node.
253
   * \param next address of the next hop node.
254
   * \param interfaceAddress address of the local interface.
255
   * \param distance distance to the destination node.
256
   */
195
  void AddEntry (const Ipv4Address &dest,
257
  void AddEntry (const Ipv4Address &dest,
196
                 const Ipv4Address &next,
258
                 const Ipv4Address &next,
197
                 const Ipv4Address &interfaceAddress,
259
                 const Ipv4Address &interfaceAddress,
198
                 uint32_t distance);
260
                 uint32_t distance);
261
262
  /**
263
   * \brief Looks up an entry for the specified destination address.
264
   * \param [in] dest Destination address.
265
   * \param [out] outEntry Holds the routing entry result, if found.
266
   * \return true if found, false if not found.
267
   */
199
  bool Lookup (const Ipv4Address &dest,
268
  bool Lookup (const Ipv4Address &dest,
200
               RoutingTableEntry &outEntry) const;
269
               RoutingTableEntry &outEntry) const;
270
271
  /**
272
   * \brief Finds the appropriate entry which must be used in order to forward
273
   * a data packet to a next hop (given a destination).
274
   *
275
   * Imagine a routing table like this: [A,B] [B,C] [C,C]; being each pair of the
276
   * form [dest addr, next-hop addr]. In this case, if this function is invoked
277
   * with [A,B] then pair [C,C] is returned because C is the next hop that must be used
278
   * to forward a data packet destined to A. That is, C is a neighbor of this node,
279
   * but B isn't. This function finds the appropriate neighbor for forwarding a packet.
280
   *
281
   * \param[in] entry The routing table entry which indicates the destination node
282
   * we are interested in.
283
   *
284
   * \param[out] outEntry The appropriate routing table entry which indicates the next
285
   * hop which must be used for forwarding a data packet, or NULL if there is no such entry.
286
   *
287
   * \return True if an entry was found, false otherwise.
288
   */
201
  bool FindSendEntry (const RoutingTableEntry &entry,
289
  bool FindSendEntry (const RoutingTableEntry &entry,
202
                      RoutingTableEntry &outEntry) const;
290
                      RoutingTableEntry &outEntry) const;
203
291
 Lines 222-317    Link Here 
222
310
223
  void DoDispose ();
311
  void DoDispose ();
224
312
313
  /**
314
   * Send an OLSR message.
315
   * \param packet The packet to be sent.
316
   * \param containedMessages The messages contained in the packet.
317
   */
225
  void SendPacket (Ptr<Packet> packet, const MessageList &containedMessages);
318
  void SendPacket (Ptr<Packet> packet, const MessageList &containedMessages);
226
319
227
  /// Increments packet sequence number and returns the new value.
320
  /**
321
   * Increments packet sequence number and returns the new value.
322
   * \return The packet sequence number.
323
   */
228
  inline uint16_t GetPacketSequenceNumber ();
324
  inline uint16_t GetPacketSequenceNumber ();
229
  /// Increments message sequence number and returns the new value.
325
326
  /**
327
   * Increments message sequence number and returns the new value.
328
   * \return The message sequence number.
329
   */
230
  inline uint16_t GetMessageSequenceNumber ();
330
  inline uint16_t GetMessageSequenceNumber ();
231
331
332
  /**
333
   * Receive an OLSR message.
334
   * \param socket The receiving socket.
335
   */
232
  void RecvOlsr (Ptr<Socket> socket);
336
  void RecvOlsr (Ptr<Socket> socket);
233
337
338
  /**
339
   * \brief Computates MPR set of a node following \RFC{3626} hints.
340
   */
234
  void MprComputation ();
341
  void MprComputation ();
342
343
  /**
344
   * \brief Creates the routing table of the node following \RFC{3626} hints.
345
   */
235
  void RoutingTableComputation ();
346
  void RoutingTableComputation ();
347
348
  /**
349
   * \brief Gets the main address associated with a given interface address.
350
   * \param iface_addr the interface address.
351
   * \return the corresponding main address.
352
   */
236
  Ipv4Address GetMainAddress (Ipv4Address iface_addr) const;
353
  Ipv4Address GetMainAddress (Ipv4Address iface_addr) const;
354
355
  /**
356
   *  \brief Tests whether or not the specified route uses a non-OLSR outgoing interface.
357
   *  \param route The route to be tested.
358
   *  \returns True if the outgoing interface of the specified route is a non-OLSR interface, false otherwise.
359
   */
237
  bool UsesNonOlsrOutgoingInterface (const Ipv4RoutingTableEntry &route);
360
  bool UsesNonOlsrOutgoingInterface (const Ipv4RoutingTableEntry &route);
238
361
239
  // Timer handlers
362
  // Timer handlers
240
  Timer m_helloTimer;
363
  Timer m_helloTimer; //!< Timer for the HELLO message.
364
  /**
365
   * \brief Sends a HELLO message and reschedules the HELLO timer.
366
   */
241
  void HelloTimerExpire ();
367
  void HelloTimerExpire ();
242
368
243
  Timer m_tcTimer;
369
  Timer m_tcTimer; //!< Timer for the TC message.
370
  /**
371
   * \brief Sends a TC message (if there exists any MPR selector) and reschedules the TC timer.
372
   */
244
  void TcTimerExpire ();
373
  void TcTimerExpire ();
245
374
246
  Timer m_midTimer;
375
  Timer m_midTimer; //!< Timer for the MID message.
376
  /**
377
   * \brief \brief Sends a MID message (if the node has more than one interface) and resets the MID timer.
378
   */
247
  void MidTimerExpire ();
379
  void MidTimerExpire ();
248
380
249
  Timer m_hnaTimer;
381
  Timer m_hnaTimer; //!< Timer for the HNA message.
382
  /**
383
   * \brief Sends an HNA message (if the node has associated hosts/networks) and reschedules the HNA timer.
384
   */
250
  void HnaTimerExpire ();
385
  void HnaTimerExpire ();
251
386
387
  /**
388
   * \brief Removes tuple if expired. Else timer is rescheduled to expire at tuple.expirationTime.
389
   *
390
   * The task of actually removing the tuple is left to the OLSR agent.
391
   *
392
   * \param address The address of the tuple.
393
   * \param sequenceNumber The sequence number of the tuple.
394
   */
252
  void DupTupleTimerExpire (Ipv4Address address, uint16_t sequenceNumber);
395
  void DupTupleTimerExpire (Ipv4Address address, uint16_t sequenceNumber);
253
  bool m_linkTupleTimerFirstTime;
396
397
  bool m_linkTupleTimerFirstTime; //!< Flag to indicate if it is the first time the LinkTupleTimer fires.
398
  /**
399
   * \brief Removes tuple_ if expired. Else if symmetric time
400
   * has expired then it is assumed a neighbor loss and agent_->nb_loss()
401
   * is called. In this case the timer is rescheduled to expire at
402
   * tuple_->time(). Otherwise the timer is rescheduled to expire at
403
   * the minimum between tuple_->time() and tuple_->sym_time().
404
   *
405
   * The task of actually removing the tuple is left to the OLSR agent.
406
   *
407
   * \param neighborIfaceAddr The tuple neighbor interface address.
408
   */
254
  void LinkTupleTimerExpire (Ipv4Address neighborIfaceAddr);
409
  void LinkTupleTimerExpire (Ipv4Address neighborIfaceAddr);
410
411
  /**
412
   * \brief Removes 2_hop neighbor tuple_ if expired. Else the timer is rescheduled to expire at tuple_->time().
413
   *
414
   * The task of actually removing the tuple is left to the OLSR agent.
415
   *
416
   * \param neighborMainAddr The neighbor main address.
417
   * \param twoHopNeighborAddr The 2-hop neighbor address.
418
   */
255
  void Nb2hopTupleTimerExpire (Ipv4Address neighborMainAddr, Ipv4Address twoHopNeighborAddr);
419
  void Nb2hopTupleTimerExpire (Ipv4Address neighborMainAddr, Ipv4Address twoHopNeighborAddr);
420
421
  /**
422
   * \brief Removes MPR selector tuple_ if expired. Else the timer is rescheduled to expire at tuple_->time().
423
   *
424
   * The task of actually removing the tuple is left to the OLSR agent.
425
   *
426
   * \param mainAddr The tuple IPv4 address.
427
   */
256
  void MprSelTupleTimerExpire (Ipv4Address mainAddr);
428
  void MprSelTupleTimerExpire (Ipv4Address mainAddr);
429
430
  /**
431
   * \brief Removes topology tuple_ if expired. Else the timer is rescheduled to expire at tuple_->time().
432
   *
433
   * The task of actually removing the tuple is left to the OLSR agent.
434
   *
435
   * \param destAddr The destination address.
436
   * \param lastAddr The last address.
437
   */
257
  void TopologyTupleTimerExpire (Ipv4Address destAddr, Ipv4Address lastAddr);
438
  void TopologyTupleTimerExpire (Ipv4Address destAddr, Ipv4Address lastAddr);
439
440
  /**
441
   * \brief Removes interface association tuple_ if expired. Else the timer is rescheduled to expire at tuple_->time().
442
   *
443
   * \param ifaceAddr The interface address.
444
   */
258
  void IfaceAssocTupleTimerExpire (Ipv4Address ifaceAddr);
445
  void IfaceAssocTupleTimerExpire (Ipv4Address ifaceAddr);
446
447
  /**
448
   * \brief Removes association tuple_ if expired. Else timer is rescheduled to expire at tuple_->time().
449
   *
450
   * \param gatewayAddr The gateway address.
451
   * \param networkAddr The network address.
452
   * \param netmask  The network mask.
453
   */
259
  void AssociationTupleTimerExpire (Ipv4Address gatewayAddr, Ipv4Address networkAddr, Ipv4Mask netmask);
454
  void AssociationTupleTimerExpire (Ipv4Address gatewayAddr, Ipv4Address networkAddr, Ipv4Mask netmask);
260
455
456
  /**
457
   * Increments the ANSN counter.
458
   */
261
  void IncrementAnsn ();
459
  void IncrementAnsn ();
262
460
263
  /// A list of pending messages which are buffered awaiting for being sent.
461
  /// A list of pending messages which are buffered awaiting for being sent.
264
  olsr::MessageList m_queuedMessages;
462
  olsr::MessageList m_queuedMessages;
265
  Timer m_queuedMessagesTimer; // timer for throttling outgoing messages
463
  Timer m_queuedMessagesTimer; //!< timer for throttling outgoing messages
266
464
465
  /**
466
   * \brief OLSR's default forwarding algorithm.
467
   *
468
   * See \RFC{3626} for details.
469
   *
470
   * \param olsrMessage The %OLSR message which must be forwarded.
471
   * \param duplicated NULL if the message has never been considered for forwarding, or a duplicate tuple in other case.
472
   * \param localIface The address of the interface where the message was received from.
473
   * \param senderAddress The sender IPv4 address.
474
   */
267
  void ForwardDefault (olsr::MessageHeader olsrMessage,
475
  void ForwardDefault (olsr::MessageHeader olsrMessage,
268
                       DuplicateTuple *duplicated,
476
                       DuplicateTuple *duplicated,
269
                       const Ipv4Address &localIface,
477
                       const Ipv4Address &localIface,
270
                       const Ipv4Address &senderAddress);
478
                       const Ipv4Address &senderAddress);
479
480
  /**
481
   * \brief Enques an %OLSR message which will be sent with a delay of (0, delay].
482
   *
483
   * This buffering system is used in order to piggyback several %OLSR messages in
484
   * a same %OLSR packet.
485
   *
486
   * \param message the %OLSR message which must be sent.
487
   * \param delay maximum delay the %OLSR message is going to be buffered.
488
   */
271
  void QueueMessage (const olsr::MessageHeader &message, Time delay);
489
  void QueueMessage (const olsr::MessageHeader &message, Time delay);
490
491
  /**
492
   * \brief Creates as many %OLSR packets as needed in order to send all buffered
493
   * %OLSR messages.
494
   *
495
   * Maximum number of messages which can be contained in an %OLSR packet is
496
   * dictated by OLSR_MAX_MSGS constant.
497
   */
272
  void SendQueuedMessages ();
498
  void SendQueuedMessages ();
273
  void SendHello ();
499
500
  /**
501
   * \brief Creates a new %OLSR HELLO message which is buffered for being sent later on.
502
   */
503
 void SendHello ();
504
505
  /**
506
   * \brief Creates a new %OLSR TC message which is buffered for being sent later on.
507
   */
274
  void SendTc ();
508
  void SendTc ();
509
510
  /**
511
   * \brief Creates a new %OLSR MID message which is buffered for being sent later on.
512
   */
275
  void SendMid ();
513
  void SendMid ();
514
515
  /**
516
   * \brief Creates a new %OLSR HNA message which is buffered for being sent later on.
517
   */
276
  void SendHna ();
518
  void SendHna ();
277
519
520
  /**
521
   * \brief Performs all actions needed when a neighbor loss occurs.
522
   *
523
   * Neighbor Set, 2-hop Neighbor Set, MPR Set and MPR Selector Set are updated.
524
   *
525
   * \param tuple link tuple with the information of the link to the neighbor which has been lost.
526
   */
278
  void NeighborLoss (const LinkTuple &tuple);
527
  void NeighborLoss (const LinkTuple &tuple);
528
529
  /**
530
   * \brief Adds a duplicate tuple to the Duplicate Set.
531
   *
532
   * \param tuple The duplicate tuple to be added.
533
   */
279
  void AddDuplicateTuple (const DuplicateTuple &tuple);
534
  void AddDuplicateTuple (const DuplicateTuple &tuple);
535
536
  /**
537
   * \brief Removes a duplicate tuple from the Duplicate Set.
538
   *
539
   * \param tuple The duplicate tuple to be removed.
540
   */
280
  void RemoveDuplicateTuple (const DuplicateTuple &tuple);
541
  void RemoveDuplicateTuple (const DuplicateTuple &tuple);
542
543
  /**
544
   * Adds a link tuple.
545
   * \param tuple Thetuple to be added.
546
   * \param willingness The tuple willingness.
547
   */
281
  void LinkTupleAdded (const LinkTuple &tuple, uint8_t willingness);
548
  void LinkTupleAdded (const LinkTuple &tuple, uint8_t willingness);
549
550
  /**
551
   * \brief Removes a link tuple from the Link Set.
552
   *
553
   * \param tuple The link tuple to be removed.
554
   */
282
  void RemoveLinkTuple (const LinkTuple &tuple);
555
  void RemoveLinkTuple (const LinkTuple &tuple);
556
557
  /**
558
   * \brief This function is invoked when a link tuple is updated. Its aim is to
559
   * also update the corresponding neighbor tuple if it is needed.
560
   *
561
   * \param tuple The link tuple which has been updated.
562
   * \param willingness The tuple willingness.
563
   */
283
  void LinkTupleUpdated (const LinkTuple &tuple, uint8_t willingness);
564
  void LinkTupleUpdated (const LinkTuple &tuple, uint8_t willingness);
565
566
  /**
567
   * \brief Adds a neighbor tuple to the Neighbor Set.
568
   *
569
   * \param tuple The neighbor tuple to be added.
570
   */
284
  void AddNeighborTuple (const NeighborTuple &tuple);
571
  void AddNeighborTuple (const NeighborTuple &tuple);
572
573
  /**
574
   * \brief Removes a neighbor tuple from the Neighbor Set.
575
   *
576
   * \param tuple The neighbor tuple to be removed.
577
   */
285
  void RemoveNeighborTuple (const NeighborTuple &tuple);
578
  void RemoveNeighborTuple (const NeighborTuple &tuple);
579
580
  /**
581
   * \brief Adds a 2-hop neighbor tuple to the 2-hop Neighbor Set.
582
   *
583
   * \param tuple The 2-hop neighbor tuple to be added.
584
   */
286
  void AddTwoHopNeighborTuple (const TwoHopNeighborTuple &tuple);
585
  void AddTwoHopNeighborTuple (const TwoHopNeighborTuple &tuple);
586
587
  /**
588
   * \brief Removes a 2-hop neighbor tuple from the 2-hop Neighbor Set.
589
   *
590
   * \param tuple The 2-hop neighbor tuple to be removed.
591
   */
287
  void RemoveTwoHopNeighborTuple (const TwoHopNeighborTuple &tuple);
592
  void RemoveTwoHopNeighborTuple (const TwoHopNeighborTuple &tuple);
593
594
  /**
595
   * \brief Adds an MPR selector tuple to the MPR Selector Set.
596
   * Advertised Neighbor Sequence Number (ANSN) is also updated.
597
   *
598
   * \param tuple The MPR selector tuple to be added.
599
   */
288
  void AddMprSelectorTuple (const MprSelectorTuple  &tuple);
600
  void AddMprSelectorTuple (const MprSelectorTuple  &tuple);
601
602
  /**
603
   * \brief Removes an MPR selector tuple from the MPR Selector Set.
604
   * Advertised Neighbor Sequence Number (ANSN) is also updated.
605
   *
606
   * \param tuple The MPR selector tuple to be removed.
607
   */
289
  void RemoveMprSelectorTuple (const MprSelectorTuple &tuple);
608
  void RemoveMprSelectorTuple (const MprSelectorTuple &tuple);
609
610
  /**
611
   * \brief Adds a topology tuple to the Topology Set.
612
   *
613
   * \param tuple The topology tuple to be added.
614
   */
290
  void AddTopologyTuple (const TopologyTuple &tuple);
615
  void AddTopologyTuple (const TopologyTuple &tuple);
616
617
  /**
618
   * \brief Removes a topology tuple to the Topology Set.
619
   *
620
   * \param tuple The topology tuple to be removed.
621
   */
291
  void RemoveTopologyTuple (const TopologyTuple &tuple);
622
  void RemoveTopologyTuple (const TopologyTuple &tuple);
623
624
  /**
625
   * \brief Adds an interface association tuple to the Interface Association Set.
626
   *
627
   * \param tuple The interface association tuple to be added.
628
   */
292
  void AddIfaceAssocTuple (const IfaceAssocTuple &tuple);
629
  void AddIfaceAssocTuple (const IfaceAssocTuple &tuple);
630
631
  /**
632
   * \brief Removed an interface association tuple to the Interface Association Set.
633
   *
634
   * \param tuple The interface association tuple to be removed.
635
   */
293
  void RemoveIfaceAssocTuple (const IfaceAssocTuple &tuple);
636
  void RemoveIfaceAssocTuple (const IfaceAssocTuple &tuple);
637
638
  /**
639
   * \brief Adds a host network association tuple to the Association Set.
640
   *
641
   * \param tuple The host network association tuple to be added.
642
   */
294
  void AddAssociationTuple (const AssociationTuple &tuple);
643
  void AddAssociationTuple (const AssociationTuple &tuple);
644
645
  /**
646
   * \brief Removes a host network association tuple to the Association Set.
647
   *
648
   * \param tuple The host network association tuple to be removed.
649
   */
295
  void RemoveAssociationTuple (const AssociationTuple &tuple);
650
  void RemoveAssociationTuple (const AssociationTuple &tuple);
296
651
652
  /**
653
   * \brief Processes a HELLO message following \RFC{3626} specification.
654
   *
655
   * Link sensing and population of the Neighbor Set, 2-hop Neighbor Set and MPR
656
   * Selector Set are performed.
657
   *
658
   * \param msg the %OLSR message which contains the HELLO message.
659
   * \param receiverIface the address of the interface where the message was received from.
660
   * \param senderIface the address of the interface where the message was sent from.
661
   */
297
  void ProcessHello (const olsr::MessageHeader &msg,
662
  void ProcessHello (const olsr::MessageHeader &msg,
298
                     const Ipv4Address &receiverIface,
663
                     const Ipv4Address &receiverIface,
299
                     const Ipv4Address &senderIface);
664
                     const Ipv4Address &senderIface);
665
666
  /**
667
   * \brief Processes a TC message following \RFC{3626} specification.
668
   *
669
   * The Topology Set is updated (if needed) with the information of
670
   * the received TC message.
671
   *
672
   * \param msg The %OLSR message which contains the TC message.
673
   * \param senderIface The address of the interface where the message was sent from.
674
   *
675
   */
300
  void ProcessTc (const olsr::MessageHeader &msg,
676
  void ProcessTc (const olsr::MessageHeader &msg,
301
                  const Ipv4Address &senderIface);
677
                  const Ipv4Address &senderIface);
678
679
  /**
680
   * \brief Processes a MID message following \RFC{3626} specification.
681
   *
682
   * The Interface Association Set is updated (if needed) with the information
683
   * of the received MID message.
684
   *
685
   * \param msg the %OLSR message which contains the MID message.
686
   * \param senderIface the address of the interface where the message was sent from.
687
   */
302
  void ProcessMid (const olsr::MessageHeader &msg,
688
  void ProcessMid (const olsr::MessageHeader &msg,
303
                   const Ipv4Address &senderIface);
689
                   const Ipv4Address &senderIface);
690
691
  /**
692
   *
693
   * \brief Processes a HNA message following \RFC{3626} specification.
694
   *
695
   * The Host Network Association Set is updated (if needed) with the information
696
   * of the received HNA message.
697
   *
698
   * \param msg the %OLSR message which contains the HNA message.
699
   * \param senderIface the address of the interface where the message was sent from.
700
   *
701
   */
304
  void ProcessHna (const olsr::MessageHeader &msg,
702
  void ProcessHna (const olsr::MessageHeader &msg,
305
                   const Ipv4Address &senderIface);
703
                   const Ipv4Address &senderIface);
306
704
705
  /**
706
   * \brief Updates Link Set according to a new received HELLO message
707
   * (following \RFC{3626} specification). Neighbor Set is also updated if needed.
708
   * \param msg The received message.
709
   * \param hello The received HELLO sub-message.
710
   * \param receiverIface The interface that received the message.
711
   * \param senderIface The sender interface.
712
   */
307
  void LinkSensing (const olsr::MessageHeader &msg,
713
  void LinkSensing (const olsr::MessageHeader &msg,
308
                    const olsr::MessageHeader::Hello &hello,
714
                    const olsr::MessageHeader::Hello &hello,
309
                    const Ipv4Address &receiverIface,
715
                    const Ipv4Address &receiverIface,
310
                    const Ipv4Address &sender_iface);
716
                    const Ipv4Address &senderIface);
717
718
  /**
719
   * \brief Updates the Neighbor Set according to the information contained in
720
   * a new received HELLO message (following \RFC{3626}).
721
   * \param msg The received message.
722
   * \param hello The received HELLO sub-message.
723
   */
311
  void PopulateNeighborSet (const olsr::MessageHeader &msg,
724
  void PopulateNeighborSet (const olsr::MessageHeader &msg,
312
                            const olsr::MessageHeader::Hello &hello);
725
                            const olsr::MessageHeader::Hello &hello);
726
727
  /**
728
   * \brief Updates the 2-hop Neighbor Set according to the information contained
729
   * in a new received HELLO message (following \RFC{3626}).
730
   * \param msg The received message.
731
   * \param hello The received HELLO sub-message.
732
   */
313
  void PopulateTwoHopNeighborSet (const olsr::MessageHeader &msg,
733
  void PopulateTwoHopNeighborSet (const olsr::MessageHeader &msg,
314
                                  const olsr::MessageHeader::Hello &hello);
734
                                  const olsr::MessageHeader::Hello &hello);
735
736
  /**
737
   * \brief Updates the MPR Selector Set according to the information contained in
738
   * a new received HELLO message (following \RFC{3626}).
739
   * \param msg The received message.
740
   * \param hello The received HELLO sub-message.
741
   */
315
  void PopulateMprSelectorSet (const olsr::MessageHeader &msg,
742
  void PopulateMprSelectorSet (const olsr::MessageHeader &msg,
316
                               const olsr::MessageHeader::Hello &hello);
743
                               const olsr::MessageHeader::Hello &hello);
317
744
 Lines 319-335    Link Here 
319
  /// Check that address is one of my interfaces
746
  /// Check that address is one of my interfaces
320
  bool IsMyOwnAddress (const Ipv4Address & a) const;
747
  bool IsMyOwnAddress (const Ipv4Address & a) const;
321
748
322
  Ipv4Address m_mainAddress;
749
  Ipv4Address m_mainAddress; //!< the node main address.
323
750
324
  // One socket per interface, each bound to that interface's address
751
  // One socket per interface, each bound to that interface's address
325
  // (reason: for OLSR Link Sensing we need to know on which interface
752
  // (reason: for OLSR Link Sensing we need to know on which interface
326
  // HELLO messages arrive)
753
  // HELLO messages arrive)
327
  std::map< Ptr<Socket>, Ipv4InterfaceAddress > m_socketAddresses;
754
  std::map< Ptr<Socket>, Ipv4InterfaceAddress > m_socketAddresses; //!< Container of sockets and the interfaces they are opened onto.
328
755
329
  TracedCallback <const PacketHeader &,
756
  /// Rx packet trace.
330
                  const MessageList &> m_rxPacketTrace;
757
  TracedCallback <const PacketHeader &, const MessageList &> m_rxPacketTrace;
331
  TracedCallback <const PacketHeader &,
758
332
                  const MessageList &> m_txPacketTrace;
759
  /// Tx packet trace.
760
  TracedCallback <const PacketHeader &, const MessageList &> m_txPacketTrace;
761
762
  /// Routing table chanes challback
333
  TracedCallback <uint32_t> m_routingTableChanged;
763
  TracedCallback <uint32_t> m_routingTableChanged;
334
764
335
  /// Provides uniform random variables.
765
  /// Provides uniform random variables.
(-)a/src/olsr/model/olsr-state.h (-14 / +270 lines)
 Lines 30-51    Link Here 
30
namespace ns3 {
30
namespace ns3 {
31
namespace olsr {
31
namespace olsr {
32
32
33
/// \ingroup olsr
33
/// This class encapsulates all data structures needed for maintaining internal state of an OLSR node.
34
/// This class encapsulates all data structures needed for maintaining internal state of an OLSR node.
34
class OlsrState
35
class OlsrState
35
{
36
{
36
  //  friend class Olsr;
37
  //  friend class Olsr;
37
38
38
protected:
39
protected:
39
  LinkSet m_linkSet;    ///< Link Set (\RFC{3626}, section 4.2.1).
40
  LinkSet m_linkSet;    //!< Link Set (\RFC{3626}, section 4.2.1).
40
  NeighborSet m_neighborSet;            ///< Neighbor Set (\RFC{3626}, section 4.3.1).
41
  NeighborSet m_neighborSet;            //!< Neighbor Set (\RFC{3626}, section 4.3.1).
41
  TwoHopNeighborSet m_twoHopNeighborSet;        ///< 2-hop Neighbor Set (\RFC{3626}, section 4.3.2).
42
  TwoHopNeighborSet m_twoHopNeighborSet;        //!< 2-hop Neighbor Set (\RFC{3626}, section 4.3.2).
42
  TopologySet m_topologySet;    ///< Topology Set (\RFC{3626}, section 4.4).
43
  TopologySet m_topologySet;    //!< Topology Set (\RFC{3626}, section 4.4).
43
  MprSet m_mprSet;      ///< MPR Set (\RFC{3626}, section 4.3.3).
44
  MprSet m_mprSet;      //!< MPR Set (\RFC{3626}, section 4.3.3).
44
  MprSelectorSet m_mprSelectorSet;      ///< MPR Selector Set (\RFC{3626}, section 4.3.4).
45
  MprSelectorSet m_mprSelectorSet;      //!< MPR Selector Set (\RFC{3626}, section 4.3.4).
45
  DuplicateSet m_duplicateSet;  ///< Duplicate Set (\RFC{3626}, section 3.4).
46
  DuplicateSet m_duplicateSet;  //!< Duplicate Set (\RFC{3626}, section 3.4).
46
  IfaceAssocSet m_ifaceAssocSet;        ///< Interface Association Set (\RFC{3626}, section 4.1).
47
  IfaceAssocSet m_ifaceAssocSet;        //!< Interface Association Set (\RFC{3626}, section 4.1).
47
  AssociationSet m_associationSet; ///<	Association Set (\RFC{3626}, section12.2). Associations obtained from HNA messages generated by other nodes.
48
  AssociationSet m_associationSet; //!<	Association Set (\RFC{3626}, section12.2). Associations obtained from HNA messages generated by other nodes.
48
  Associations m_associations;  ///< The node's local Host Network Associations that will be advertised using HNA messages.
49
  Associations m_associations;  //!< The node's local Host Network Associations that will be advertised using HNA messages.
49
50
50
public:
51
public:
51
52
 Lines 53-174    Link Here 
53
  {}
54
  {}
54
55
55
  // MPR selector
56
  // MPR selector
57
58
  /**
59
   * Gets the MPR selectors.
60
   * \returns The MPR selectors.
61
   */
56
  const MprSelectorSet & GetMprSelectors () const
62
  const MprSelectorSet & GetMprSelectors () const
57
  {
63
  {
58
    return m_mprSelectorSet;
64
    return m_mprSelectorSet;
59
  }
65
  }
66
67
  /**
68
   * Finds a MPR selector tuple.
69
   * \param mainAddr The MPR selector main address.
70
   * \returns The MPR selector, if found. Else it returns a null pointer.
71
   */
60
  MprSelectorTuple* FindMprSelectorTuple (const Ipv4Address &mainAddr);
72
  MprSelectorTuple* FindMprSelectorTuple (const Ipv4Address &mainAddr);
73
74
  /**
75
   * Erases a MPR selector tuple.
76
   * \param tuple The MPR selector tuple.
77
   */
61
  void EraseMprSelectorTuple (const MprSelectorTuple &tuple);
78
  void EraseMprSelectorTuple (const MprSelectorTuple &tuple);
79
80
  /**
81
   * Erases all MPR selector tuples belonging to the same address.
82
   * \param mainAddr The MPR selector main address.
83
   */
62
  void EraseMprSelectorTuples (const Ipv4Address &mainAddr);
84
  void EraseMprSelectorTuples (const Ipv4Address &mainAddr);
85
86
  /**
87
   * Inserts a MPR selector tuple
88
   * \param tuple The MPR selector tuple.
89
   */
63
  void InsertMprSelectorTuple (const MprSelectorTuple &tuple);
90
  void InsertMprSelectorTuple (const MprSelectorTuple &tuple);
91
92
  /**
93
   * Prints the MPR selector sets.
94
   * \return a string with the output data.
95
   */
64
  std::string PrintMprSelectorSet () const;
96
  std::string PrintMprSelectorSet () const;
65
97
66
  // Neighbor
98
  // Neighbor
99
100
  /**
101
   * Gets the neighbor set.
102
   * \returns The neighbor set.
103
   */
67
  const NeighborSet & GetNeighbors () const
104
  const NeighborSet & GetNeighbors () const
68
  {
105
  {
69
    return m_neighborSet;
106
    return m_neighborSet;
70
  }
107
  }
108
  /**
109
   * Gets the neighbor set.
110
   * \returns The neighbor set.
111
   */
71
  NeighborSet & GetNeighbors ()
112
  NeighborSet & GetNeighbors ()
72
  {
113
  {
73
    return m_neighborSet;
114
    return m_neighborSet;
74
  }
115
  }
116
117
  /**
118
   * Finds a neighbor tuple.
119
   * \param mainAddr The neighbor tuple main address.
120
   * \returns The neighbor tuple, if found. Else it returns a null pointer.
121
   */
75
  NeighborTuple* FindNeighborTuple (const Ipv4Address &mainAddr);
122
  NeighborTuple* FindNeighborTuple (const Ipv4Address &mainAddr);
123
124
  /**
125
   * Finds a symmetrical neighbor tuple.
126
   * \param mainAddr The neighbor tuple main address.
127
   * \returns The neighbor tuple, if found. Else it returns a null pointer.
128
   */
76
  const NeighborTuple* FindSymNeighborTuple (const Ipv4Address &mainAddr) const;
129
  const NeighborTuple* FindSymNeighborTuple (const Ipv4Address &mainAddr) const;
130
131
  /**
132
   * Finds a neighbor tuple.
133
   * \param mainAddr The neighbor tuple main address.
134
   * \param willingness The neighbor willingness.
135
   * \returns The neighbor tuple, if found. Else it returns a null pointer.
136
   */
77
  NeighborTuple* FindNeighborTuple (const Ipv4Address &mainAddr,
137
  NeighborTuple* FindNeighborTuple (const Ipv4Address &mainAddr,
78
                                    uint8_t willingness);
138
                                    uint8_t willingness);
139
140
  /**
141
   * Erases a neighbor tuple.
142
   * \param neighborTuple The neighbor tuple.
143
   */
79
  void EraseNeighborTuple (const NeighborTuple &neighborTuple);
144
  void EraseNeighborTuple (const NeighborTuple &neighborTuple);
145
  /**
146
   * Erases a neighbor tuple.
147
   * \param mainAddr The neighbor tuple main address.
148
   */
80
  void EraseNeighborTuple (const Ipv4Address &mainAddr);
149
  void EraseNeighborTuple (const Ipv4Address &mainAddr);
150
151
  /**
152
   * Inserts a neighbor tuple.
153
   * \param tuple The neighbor tuple.
154
   */
81
  void InsertNeighborTuple (const NeighborTuple &tuple);
155
  void InsertNeighborTuple (const NeighborTuple &tuple);
82
156
83
  // Two-hop neighbor
157
  // Two-hop neighbor
158
159
  /**
160
   * Gets the 2-hop neighbor set.
161
   * \returns The 2-hop neighbor set.
162
   */
84
  const TwoHopNeighborSet & GetTwoHopNeighbors () const
163
  const TwoHopNeighborSet & GetTwoHopNeighbors () const
85
  {
164
  {
86
    return m_twoHopNeighborSet;
165
    return m_twoHopNeighborSet;
87
  }
166
  }
167
  /**
168
   * Gets the 2-hop neighbor set.
169
   * \returns The 2-hop neighbor set.
170
   */
88
  TwoHopNeighborSet & GetTwoHopNeighbors ()
171
  TwoHopNeighborSet & GetTwoHopNeighbors ()
89
  {
172
  {
90
    return m_twoHopNeighborSet;
173
    return m_twoHopNeighborSet;
91
  }
174
  }
175
176
  /**
177
   * Finds a 2-hop neighbor tuple.
178
   * \param neighbor The neighbor main address.
179
   * \param twoHopNeighbor The 2-hop neighbor main address.
180
   * \returns The 2-hop neighbor tuple, if found. Else it returns a null pointer.
181
   */
92
  TwoHopNeighborTuple* FindTwoHopNeighborTuple (const Ipv4Address &neighbor,
182
  TwoHopNeighborTuple* FindTwoHopNeighborTuple (const Ipv4Address &neighbor,
93
                                                const Ipv4Address &twoHopNeighbor);
183
                                                const Ipv4Address &twoHopNeighbor);
184
185
  /**
186
   * Erases a 2-hop neighbor tuple.
187
   * \param tuple The 2-hop neighbor tuple.
188
   */
94
  void EraseTwoHopNeighborTuple (const TwoHopNeighborTuple &tuple);
189
  void EraseTwoHopNeighborTuple (const TwoHopNeighborTuple &tuple);
190
  /**
191
   * Erases the 2-hop neighbor tuples with the same 1-hop neighbor.
192
   * \param neighbor The neighbor address.
193
   */
95
  void EraseTwoHopNeighborTuples (const Ipv4Address &neighbor);
194
  void EraseTwoHopNeighborTuples (const Ipv4Address &neighbor);
195
  /**
196
   * Erases the 2-hop neighbor tuples with matching predicates.
197
   * \param neighbor The neighbor address.
198
   * \param twoHopNeighbor The 2-hop neighbor main address.
199
   */
96
  void EraseTwoHopNeighborTuples (const Ipv4Address &neighbor,
200
  void EraseTwoHopNeighborTuples (const Ipv4Address &neighbor,
97
                                  const Ipv4Address &twoHopNeighbor);
201
                                  const Ipv4Address &twoHopNeighbor);
202
  /**
203
   * Inserts a 2-hop neighbor tuple.
204
   * \param tuple The 2-hop neighbor tuple.
205
   */
98
  void InsertTwoHopNeighborTuple (const TwoHopNeighborTuple &tuple);
206
  void InsertTwoHopNeighborTuple (const TwoHopNeighborTuple &tuple);
99
207
100
  // MPR
208
  // MPR
209
210
  /**
211
   * Checks if there's an MPR with a specific address.
212
   * \param address The address to test.
213
   * \return True if a MPR with the specified address exists.
214
   */
101
  bool FindMprAddress (const Ipv4Address &address);
215
  bool FindMprAddress (const Ipv4Address &address);
102
  /// MprSet is set by routing protocol after MprCompute
216
217
  /**
218
   * Sets the MPR set to the one specified.
219
   * \param mprSet The new MPR set.
220
   */
103
  void SetMprSet (MprSet mprSet);
221
  void SetMprSet (MprSet mprSet);
104
  /// Gets an MPR Set needed by tests
222
223
  /**
224
   * Gets the MPR set.
225
   * \return The MPR set.
226
   */
105
  MprSet GetMprSet () const;
227
  MprSet GetMprSet () const;
106
228
107
  // Duplicate
229
  // Duplicate
230
231
  /**
232
   * Finds a duplicate tuple.
233
   * \param address The duplicate tuple address.
234
   * \param sequenceNumber The duplicate tuple sequence number.
235
   * \returns The duplicate tuple, or a null pointer if no match.
236
   */
108
  DuplicateTuple* FindDuplicateTuple (const Ipv4Address &address,
237
  DuplicateTuple* FindDuplicateTuple (const Ipv4Address &address,
109
                                      uint16_t sequenceNumber);
238
                                      uint16_t sequenceNumber);
239
240
  /**
241
   * Erases a duplicate tuple.
242
   * \param tuple The tuple to erase.
243
   */
110
  void EraseDuplicateTuple (const DuplicateTuple &tuple);
244
  void EraseDuplicateTuple (const DuplicateTuple &tuple);
245
  /**
246
   * Inserts a duplicate tuple.
247
   * \param tuple The tuple to insert.
248
   */
111
  void InsertDuplicateTuple (const DuplicateTuple &tuple);
249
  void InsertDuplicateTuple (const DuplicateTuple &tuple);
112
250
113
  // Link
251
  // Link
252
253
  /**
254
   * Gets the Link set.
255
   * \return The Link set.
256
   */
114
  const LinkSet & GetLinks () const
257
  const LinkSet & GetLinks () const
115
  {
258
  {
116
    return m_linkSet;
259
    return m_linkSet;
117
  }
260
  }
261
  /**
262
   * Finds a link tuple.
263
   * \param ifaceAddr The interface address of the link.
264
   * \returns The link tuple, or a null pointer if no match.
265
   */
118
  LinkTuple* FindLinkTuple (const Ipv4Address &ifaceAddr);
266
  LinkTuple* FindLinkTuple (const Ipv4Address &ifaceAddr);
267
  /**
268
   * Finds a symmetrical link tuple.
269
   * \param ifaceAddr The interface address of the link.
270
   * \param time The time at which the link should be considered symmetrical.
271
   * \returns The link tuple, or a null pointer if no match.
272
   */
119
  LinkTuple* FindSymLinkTuple (const Ipv4Address &ifaceAddr, Time time);
273
  LinkTuple* FindSymLinkTuple (const Ipv4Address &ifaceAddr, Time time);
274
  /**
275
   * Erases a link tuple.
276
   * \param tuple The tuple to erase.
277
   */
120
  void EraseLinkTuple (const LinkTuple &tuple);
278
  void EraseLinkTuple (const LinkTuple &tuple);
279
  /**
280
   * Inserts a link tuple.
281
   * \param tuple The tuple to insert.
282
   * \returns A reference to the inserted tuple.
283
   */
121
  LinkTuple& InsertLinkTuple (const LinkTuple &tuple);
284
  LinkTuple& InsertLinkTuple (const LinkTuple &tuple);
122
285
123
  // Topology
286
  // Topology
287
288
  /**
289
   * Gets the topology set.
290
   * \returns The topology set.
291
   */
124
  const TopologySet & GetTopologySet () const
292
  const TopologySet & GetTopologySet () const
125
  {
293
  {
126
    return m_topologySet;
294
    return m_topologySet;
127
  }
295
  }
296
  /**
297
   * Finds a topology tuple.
298
   * \param destAddr The destination address.
299
   * \param lastAddr The address of the node previous to the destination.
300
   * \returns The topology tuple, or a null pointer if no match.
301
   */
128
  TopologyTuple* FindTopologyTuple (const Ipv4Address &destAddr,
302
  TopologyTuple* FindTopologyTuple (const Ipv4Address &destAddr,
129
                                    const Ipv4Address &lastAddr);
303
                                    const Ipv4Address &lastAddr);
304
  /**
305
   * Finds a topology tuple.
306
   * \param lastAddr The address of the node previous to the destination.
307
   * \param ansn The Advertised Neighbor Sequence Number.
308
   * \returns The topology tuple, or a null pointer if no match.
309
   */
130
  TopologyTuple* FindNewerTopologyTuple (const Ipv4Address &lastAddr,
310
  TopologyTuple* FindNewerTopologyTuple (const Ipv4Address &lastAddr,
131
                                         uint16_t ansn);
311
                                         uint16_t ansn);
312
  /**
313
   * Erases a topology tuple.
314
   * \param tuple The tuple to erase.
315
   */
132
  void EraseTopologyTuple (const TopologyTuple &tuple);
316
  void EraseTopologyTuple (const TopologyTuple &tuple);
317
  /**
318
   * Erases a topology tuple.
319
   * \param lastAddr The address of the node previous to the destination.
320
   * \param ansn The Advertised Neighbor Sequence Number.
321
   */
133
  void EraseOlderTopologyTuples (const Ipv4Address &lastAddr,
322
  void EraseOlderTopologyTuples (const Ipv4Address &lastAddr,
134
                                 uint16_t ansn);
323
                                 uint16_t ansn);
324
  /**
325
   * Inserts a topology tuple.
326
   * \param tuple The tuple to insert.
327
   */
135
  void InsertTopologyTuple (const TopologyTuple &tuple);
328
  void InsertTopologyTuple (const TopologyTuple &tuple);
136
329
137
  // Interface association
330
  // Interface association
331
332
  /**
333
   * Gets the interface association set.
334
   * \returns The interface association set.
335
   */
138
  const IfaceAssocSet & GetIfaceAssocSet () const
336
  const IfaceAssocSet & GetIfaceAssocSet () const
139
  {
337
  {
140
    return m_ifaceAssocSet;
338
    return m_ifaceAssocSet;
141
  }
339
  }
340
  /**
341
   * Gets a mutable reference to the interface association set.
342
   * \returns The interface association set.
343
   */
142
  IfaceAssocSet & GetIfaceAssocSetMutable ()
344
  IfaceAssocSet & GetIfaceAssocSetMutable ()
143
  {
345
  {
144
    return m_ifaceAssocSet;
346
    return m_ifaceAssocSet;
145
  }
347
  }
348
349
  /**
350
   * Finds a interface association tuple.
351
   * \param ifaceAddr The interface address.
352
   * \returns The interface association  tuple, or a null pointer if no match.
353
   */
146
  IfaceAssocTuple* FindIfaceAssocTuple (const Ipv4Address &ifaceAddr);
354
  IfaceAssocTuple* FindIfaceAssocTuple (const Ipv4Address &ifaceAddr);
355
  /**
356
   * Finds a interface association tuple.
357
   * \param ifaceAddr The interface address.
358
   * \returns The interface association  tuple, or a null pointer if no match.
359
   */
147
  const IfaceAssocTuple* FindIfaceAssocTuple (const Ipv4Address &ifaceAddr) const;
360
  const IfaceAssocTuple* FindIfaceAssocTuple (const Ipv4Address &ifaceAddr) const;
361
  /**
362
   * Erases a interface association tuple.
363
   * \param tuple The tuple to erase.
364
   */
148
  void EraseIfaceAssocTuple (const IfaceAssocTuple &tuple);
365
  void EraseIfaceAssocTuple (const IfaceAssocTuple &tuple);
366
  /**
367
   * Inserts a interface association tuple.
368
   * \param tuple The tuple to insert.
369
   */
149
  void InsertIfaceAssocTuple (const IfaceAssocTuple &tuple);
370
  void InsertIfaceAssocTuple (const IfaceAssocTuple &tuple);
150
371
151
  // Host-Network Association
372
  // Host-Network Association
373
  /**
374
   * Gets the association set known to the node.
375
   * \returns The association set known to the node.
376
   */
152
  const AssociationSet & GetAssociationSet () const  // Associations known to the node
377
  const AssociationSet & GetAssociationSet () const  // Associations known to the node
153
  {
378
  {
154
    return m_associationSet;
379
    return m_associationSet;
155
  }
380
  }
156
381
382
  /**
383
   * Gets the association set the node has.
384
   * \returns The association set the node has.
385
   */
157
  const Associations & GetAssociations () const  // Set of associations that the node has
386
  const Associations & GetAssociations () const  // Set of associations that the node has
158
  {
387
  {
159
    return m_associations;
388
    return m_associations;
160
  }
389
  }
161
390
391
  /**
392
   * Finds an association tuple.
393
   * \param gatewayAddr The gateway address.
394
   * \param networkAddr The network address.
395
   * \param netmask The network mask.
396
   * \returns The association  tuple, or a null pointer if no match.
397
   */
162
  AssociationTuple* FindAssociationTuple (const Ipv4Address &gatewayAddr, \
398
  AssociationTuple* FindAssociationTuple (const Ipv4Address &gatewayAddr, \
163
                                          const Ipv4Address &networkAddr, \
399
                                          const Ipv4Address &networkAddr, \
164
                                          const Ipv4Mask &netmask);
400
                                          const Ipv4Mask &netmask);
401
  /**
402
   * Erases a known association tuple.
403
   * \param tuple The tuple to erase.
404
   */
165
  void EraseAssociationTuple (const AssociationTuple &tuple);
405
  void EraseAssociationTuple (const AssociationTuple &tuple);
406
  /**
407
   * Inserts a known association tuple.
408
   * \param tuple The tuple to insert.
409
   */
166
  void InsertAssociationTuple (const AssociationTuple &tuple);
410
  void InsertAssociationTuple (const AssociationTuple &tuple);
411
  /**
412
   * Erases an association.
413
   * \param tuple The tuple to erase.
414
   */
167
  void EraseAssociation (const Association &tuple);
415
  void EraseAssociation (const Association &tuple);
416
  /**
417
   * Inserts an association tuple.
418
   * \param tuple The tuple to insert.
419
   */
168
  void InsertAssociation (const Association &tuple);
420
  void InsertAssociation (const Association &tuple);
169
421
170
  // Returns a vector of all interfaces of a given neighbor, with the
422
  /**
171
  // exception of the "main" one.
423
   * Returns a vector of all interfaces of a given neighbor, with the
424
   * exception of the "main" one.
425
   * \param neighborMainAddr The neighbor main address
426
   * \returns A container of the neighbor addresses (excluding the main one).
427
   */
172
  std::vector<Ipv4Address>
428
  std::vector<Ipv4Address>
173
  FindNeighborInterfaces (const Ipv4Address &neighborMainAddr) const;
429
  FindNeighborInterfaces (const Ipv4Address &neighborMainAddr) const;
174
430

Return to bug 938