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

(-)a/src/olsr/examples/olsr-hna.cc (-11 / +11 lines)
 Lines 18-27    Link Here 
18
 *
18
 *
19
 */
19
 */
20
20
21
// 
21
//
22
// This script, adapted from examples/wireless/wifi-simple-adhoc illustrates
22
// This script, adapted from examples/wireless/wifi-simple-adhoc illustrates
23
// the use of OLSR HNA.
23
// the use of OLSR HNA.
24
// 
24
//
25
// Network Topology:
25
// Network Topology:
26
//
26
//
27
//             |------ OLSR ------|   |---- non-OLSR ----|
27
//             |------ OLSR ------|   |---- non-OLSR ----|
 Lines 74-87    Link Here 
74
  NS_LOG_UNCOND ("Received one packet!");
74
  NS_LOG_UNCOND ("Received one packet!");
75
}
75
}
76
76
77
static void GenerateTraffic (Ptr<Socket> socket, uint32_t pktSize, 
77
static void GenerateTraffic (Ptr<Socket> socket, uint32_t pktSize,
78
                             uint32_t pktCount, Time pktInterval )
78
                             uint32_t pktCount, Time pktInterval )
79
{
79
{
80
  if (pktCount > 0)
80
  if (pktCount > 0)
81
    {
81
    {
82
      socket->Send (Create<Packet> (pktSize));
82
      socket->Send (Create<Packet> (pktSize));
83
      Simulator::Schedule (pktInterval, &GenerateTraffic, 
83
      Simulator::Schedule (pktInterval, &GenerateTraffic,
84
                           socket, pktSize,pktCount-1, pktInterval);
84
                           socket, pktSize,pktCount - 1, pktInterval);
85
    }
85
    }
86
  else
86
  else
87
    {
87
    {
 Lines 121-127    Link Here 
121
  // turn off RTS/CTS for frames below 2200 bytes
121
  // turn off RTS/CTS for frames below 2200 bytes
122
  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("2200"));
122
  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("2200"));
123
  // Fix non-unicast data rate to be the same as that of unicast
123
  // Fix non-unicast data rate to be the same as that of unicast
124
  Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode", 
124
  Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",
125
                      StringValue (phyMode));
125
                      StringValue (phyMode));
126
126
127
  NodeContainer olsrNodes;
127
  NodeContainer olsrNodes;
 Lines 141-147    Link Here 
141
  YansWifiPhyHelper wifiPhy =  YansWifiPhyHelper::Default ();
141
  YansWifiPhyHelper wifiPhy =  YansWifiPhyHelper::Default ();
142
  // This is one parameter that matters when using FixedRssLossModel
142
  // This is one parameter that matters when using FixedRssLossModel
143
  // set it to zero; otherwise, gain will be added
143
  // set it to zero; otherwise, gain will be added
144
  wifiPhy.Set ("RxGain", DoubleValue (0) ); 
144
  wifiPhy.Set ("RxGain", DoubleValue (0) );
145
  // ns-3 supports RadioTap and Prism tracing extensions for 802.11b
145
  // ns-3 supports RadioTap and Prism tracing extensions for 802.11b
146
  wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO);
146
  wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO);
147
147
 Lines 166-173    Link Here 
166
  csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2)));
166
  csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2)));
167
  NetDeviceContainer csmaDevices = csma.Install (NodeContainer (csmaNodes.Get (0), olsrNodes.Get (1)));
167
  NetDeviceContainer csmaDevices = csma.Install (NodeContainer (csmaNodes.Get (0), olsrNodes.Get (1)));
168
168
169
  // Note that with FixedRssLossModel, the positions below are not 
169
  // Note that with FixedRssLossModel, the positions below are not
170
  // used for received signal strength. 
170
  // used for received signal strength.
171
  MobilityHelper mobility;
171
  MobilityHelper mobility;
172
  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
172
  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
173
  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
173
  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
 Lines 242-248    Link Here 
242
      hnaEntries->AddNetworkRouteTo (Ipv4Address ("172.16.1.0"), Ipv4Mask ("255.255.255.0"), uint32_t (2), uint32_t (1));
242
      hnaEntries->AddNetworkRouteTo (Ipv4Address ("172.16.1.0"), Ipv4Mask ("255.255.255.0"), uint32_t (2), uint32_t (1));
243
      olsrrp_Gw->SetRoutingTableAssociation (hnaEntries);
243
      olsrrp_Gw->SetRoutingTableAssociation (hnaEntries);
244
    }
244
    }
245
 
245
246
  if (assocMethod2)
246
  if (assocMethod2)
247
    {
247
    {
248
      // Specify the required associations directly.
248
      // Specify the required associations directly.
 Lines 254-260    Link Here 
254
  csma.EnablePcap ("olsr-hna", csmaDevices, false);
254
  csma.EnablePcap ("olsr-hna", csmaDevices, false);
255
255
256
  Simulator::ScheduleWithContext (source->GetNode ()->GetId (),
256
  Simulator::ScheduleWithContext (source->GetNode ()->GetId (),
257
                                  Seconds (15.0), &GenerateTraffic, 
257
                                  Seconds (15.0), &GenerateTraffic,
258
                                  source, packetSize, numPackets, interPacketInterval);
258
                                  source, packetSize, numPackets, interPacketInterval);
259
259
260
  Simulator::Stop (Seconds (20.0));
260
  Simulator::Stop (Seconds (20.0));
(-)a/src/olsr/examples/simple-point-to-point-olsr.cc (-5 / +5 lines)
 Lines 32-38    Link Here 
32
// - CBR/UDP flows from n0 to n4, and from n3 to n1
32
// - CBR/UDP flows from n0 to n4, and from n3 to n1
33
// - UDP packet size of 210 bytes, with per-packet interval 0.00375 sec.
33
// - UDP packet size of 210 bytes, with per-packet interval 0.00375 sec.
34
//   (i.e., DataRate of 448,000 bps)
34
//   (i.e., DataRate of 448,000 bps)
35
// - DropTail queues 
35
// - DropTail queues
36
// - Tracing of queues and packet receptions to file "simple-point-to-point-olsr.tr"
36
// - Tracing of queues and packet receptions to file "simple-point-to-point-olsr.tr"
37
37
38
#include <iostream>
38
#include <iostream>
 Lines 53-68    Link Here 
53
53
54
NS_LOG_COMPONENT_DEFINE ("SimplePointToPointOlsrExample");
54
NS_LOG_COMPONENT_DEFINE ("SimplePointToPointOlsrExample");
55
55
56
int 
56
int
57
main (int argc, char *argv[])
57
main (int argc, char *argv[])
58
{
58
{
59
  // Users may find it convenient to turn on explicit debugging
59
  // Users may find it convenient to turn on explicit debugging
60
  // for selected modules; the below lines suggest how to do this
60
  // for selected modules; the below lines suggest how to do this
61
#if 0 
61
#if 0
62
  LogComponentEnable ("SimpleGlobalRoutingExample", LOG_LEVEL_INFO);
62
  LogComponentEnable ("SimpleGlobalRoutingExample", LOG_LEVEL_INFO);
63
#endif
63
#endif
64
64
65
  // Set up some default values for the simulation.  Use the 
65
  // Set up some default values for the simulation.  Use the
66
66
67
  Config::SetDefault ("ns3::OnOffApplication::PacketSize", UintegerValue (210));
67
  Config::SetDefault ("ns3::OnOffApplication::PacketSize", UintegerValue (210));
68
  Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue ("448kb/s"));
68
  Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue ("448kb/s"));
 Lines 130-136    Link Here 
130
  NS_LOG_INFO ("Create Applications.");
130
  NS_LOG_INFO ("Create Applications.");
131
  uint16_t port = 9;   // Discard port (RFC 863)
131
  uint16_t port = 9;   // Discard port (RFC 863)
132
132
133
  OnOffHelper onoff ("ns3::UdpSocketFactory", 
133
  OnOffHelper onoff ("ns3::UdpSocketFactory",
134
                     InetSocketAddress (i34.GetAddress (1), port));
134
                     InetSocketAddress (i34.GetAddress (1), port));
135
  onoff.SetConstantRate (DataRate ("448kb/s"));
135
  onoff.SetConstantRate (DataRate ("448kb/s"));
136
136
(-)a/src/olsr/helper/olsr-helper.cc (-9 / +9 lines)
 Lines 37-46    Link Here 
37
  m_interfaceExclusions = o.m_interfaceExclusions;
37
  m_interfaceExclusions = o.m_interfaceExclusions;
38
}
38
}
39
39
40
OlsrHelper* 
40
OlsrHelper*
41
OlsrHelper::Copy (void) const 
41
OlsrHelper::Copy (void) const
42
{
42
{
43
  return new OlsrHelper (*this); 
43
  return new OlsrHelper (*this);
44
}
44
}
45
45
46
void
46
void
 Lines 48-54    Link Here 
48
{
48
{
49
  std::map< Ptr<Node>, std::set<uint32_t> >::iterator it = m_interfaceExclusions.find (node);
49
  std::map< Ptr<Node>, std::set<uint32_t> >::iterator it = m_interfaceExclusions.find (node);
50
50
51
  if(it == m_interfaceExclusions.end ())
51
  if (it == m_interfaceExclusions.end ())
52
    {
52
    {
53
      std::set<uint32_t> interfaces;
53
      std::set<uint32_t> interfaces;
54
      interfaces.insert (interface);
54
      interfaces.insert (interface);
 Lines 61-74    Link Here 
61
    }
61
    }
62
}
62
}
63
63
64
Ptr<Ipv4RoutingProtocol> 
64
Ptr<Ipv4RoutingProtocol>
65
OlsrHelper::Create (Ptr<Node> node) const
65
OlsrHelper::Create (Ptr<Node> node) const
66
{
66
{
67
  Ptr<olsr::RoutingProtocol> agent = m_agentFactory.Create<olsr::RoutingProtocol> ();
67
  Ptr<olsr::RoutingProtocol> agent = m_agentFactory.Create<olsr::RoutingProtocol> ();
68
68
69
  std::map<Ptr<Node>, std::set<uint32_t> >::const_iterator it = m_interfaceExclusions.find (node);
69
  std::map<Ptr<Node>, std::set<uint32_t> >::const_iterator it = m_interfaceExclusions.find (node);
70
70
71
  if(it != m_interfaceExclusions.end ())
71
  if (it != m_interfaceExclusions.end ())
72
    {
72
    {
73
      agent->SetInterfaceExclusions (it->second);
73
      agent->SetInterfaceExclusions (it->second);
74
    }
74
    }
 Lines 77-89    Link Here 
77
  return agent;
77
  return agent;
78
}
78
}
79
79
80
void 
80
void
81
OlsrHelper::Set (std::string name, const AttributeValue &value)
81
OlsrHelper::Set (std::string name, const AttributeValue &value)
82
{
82
{
83
  m_agentFactory.Set (name, value);
83
  m_agentFactory.Set (name, value);
84
}
84
}
85
85
86
int64_t 
86
int64_t
87
OlsrHelper::AssignStreams (NodeContainer c, int64_t stream)
87
OlsrHelper::AssignStreams (NodeContainer c, int64_t stream)
88
{
88
{
89
  int64_t currentStream = stream;
89
  int64_t currentStream = stream;
 Lines 108-114    Link Here 
108
          int16_t priority;
108
          int16_t priority;
109
          Ptr<Ipv4RoutingProtocol> listProto;
109
          Ptr<Ipv4RoutingProtocol> listProto;
110
          Ptr<olsr::RoutingProtocol> listOlsr;
110
          Ptr<olsr::RoutingProtocol> listOlsr;
111
          for (uint32_t i = 0; i < list->GetNRoutingProtocols (); i++) 
111
          for (uint32_t i = 0; i < list->GetNRoutingProtocols (); i++)
112
            {
112
            {
113
              listProto = list->GetRoutingProtocol (i, priority);
113
              listProto = list->GetRoutingProtocol (i, priority);
114
              listOlsr = DynamicCast<olsr::RoutingProtocol> (listProto);
114
              listOlsr = DynamicCast<olsr::RoutingProtocol> (listProto);
(-)a/src/olsr/helper/olsr-helper.h (-14 / +14 lines)
 Lines 34-40    Link Here 
34
 *
34
 *
35
 * \brief Helper class that adds OLSR routing to nodes.
35
 * \brief Helper class that adds OLSR routing to nodes.
36
 *
36
 *
37
 * This class is expected to be used in conjunction with 
37
 * This class is expected to be used in conjunction with
38
 * ns3::InternetStackHelper::SetRoutingHelper
38
 * ns3::InternetStackHelper::SetRoutingHelper
39
 */
39
 */
40
class OlsrHelper : public Ipv4RoutingHelper
40
class OlsrHelper : public Ipv4RoutingHelper
 Lines 53-60    Link Here 
53
  OlsrHelper (const OlsrHelper &);
53
  OlsrHelper (const OlsrHelper &);
54
54
55
  /**
55
  /**
56
   * \returns pointer to clone of this OlsrHelper 
56
   * \returns pointer to clone of this OlsrHelper
57
   * 
57
   *
58
   * This method is mainly for internal use by the other helpers;
58
   * This method is mainly for internal use by the other helpers;
59
   * clients are expected to free the dynamic memory allocated by this method
59
   * clients are expected to free the dynamic memory allocated by this method
60
   */
60
   */
 Lines 84-100    Link Here 
84
   */
84
   */
85
  void Set (std::string name, const AttributeValue &value);
85
  void Set (std::string name, const AttributeValue &value);
86
86
87
 /**
87
  /**
88
  * Assign a fixed random variable stream number to the random variables
88
   * Assign a fixed random variable stream number to the random variables
89
  * used by this model.  Return the number of streams (possibly zero) that
89
   * used by this model.  Return the number of streams (possibly zero) that
90
  * have been assigned.  The Install() method of the InternetStackHelper
90
   * have been assigned.  The Install() method of the InternetStackHelper
91
  * should have previously been called by the user.
91
   * should have previously been called by the user.
92
  *
92
   *
93
  * \param stream first stream index to use
93
   * \param stream first stream index to use
94
  * \param c NodeContainer of the set of nodes for which the OlsrRoutingProtocol
94
   * \param c NodeContainer of the set of nodes for which the OlsrRoutingProtocol
95
  *          should be modified to use a fixed stream
95
   *          should be modified to use a fixed stream
96
  * \return the number of stream indices assigned by this helper
96
   * \return the number of stream indices assigned by this helper
97
  */
97
   */
98
  int64_t AssignStreams (NodeContainer c, int64_t stream);
98
  int64_t AssignStreams (NodeContainer c, int64_t stream);
99
99
100
private:
100
private:
(-)a/src/olsr/model/olsr-header.cc (-23 / +28 lines)
 Lines 30-36    Link Here 
30
#define OLSR_PKT_HEADER_SIZE 4
30
#define OLSR_PKT_HEADER_SIZE 4
31
31
32
namespace ns3 {
32
namespace ns3 {
33
  
33
34
NS_LOG_COMPONENT_DEFINE ("OlsrHeader");
34
NS_LOG_COMPONENT_DEFINE ("OlsrHeader");
35
35
36
namespace olsr {
36
namespace olsr {
 Lines 51-67    Link Here 
51
  int a, b = 0;
51
  int a, b = 0;
52
52
53
  // find the largest integer 'b' such that: T/C >= 2^b
53
  // find the largest integer 'b' such that: T/C >= 2^b
54
  for (b = 0; (seconds/OLSR_C) >= (1 << b); ++b)
54
  for (b = 0; (seconds / OLSR_C) >= (1 << b); ++b)
55
    ;
55
    {
56
  NS_ASSERT ((seconds/OLSR_C) < (1 << b));
56
    }
57
  NS_ASSERT ((seconds / OLSR_C) < (1 << b));
57
  b--;
58
  b--;
58
  NS_ASSERT ((seconds/OLSR_C) >= (1 << b));
59
  NS_ASSERT ((seconds / OLSR_C) >= (1 << b));
59
60
60
  // compute the expression 16*(T/(C*(2^b))-1), which may not be a integer
61
  // compute the expression 16*(T/(C*(2^b))-1), which may not be a integer
61
  double tmp = 16*(seconds/(OLSR_C*(1<<b))-1);
62
  double tmp = 16 * (seconds / (OLSR_C * (1 << b)) - 1);
62
63
63
  // round it up.  This results in the value for 'a'
64
  // round it up.  This results in the value for 'a'
64
  a = (int) std::ceil (tmp-0.5);
65
  a = (int) std::ceil (tmp - 0.5);
65
66
66
  // if 'a' is equal to 16: increment 'b' by one, and set 'a' to 0
67
  // if 'a' is equal to 16: increment 'b' by one, and set 'a' to 0
67
  if (a == 16)
68
  if (a == 16)
 Lines 90-96    Link Here 
90
  int a = (olsrFormat >> 4);
91
  int a = (olsrFormat >> 4);
91
  int b = (olsrFormat & 0xf);
92
  int b = (olsrFormat & 0xf);
92
  // value = C*(1+a/16)*2^b [in seconds]
93
  // value = C*(1+a/16)*2^b [in seconds]
93
  return OLSR_C * (1 + a/16.0) * (1 << b);
94
  return OLSR_C * (1 + a / 16.0) * (1 << b);
94
}
95
}
95
96
96
97
 Lines 123-135    Link Here 
123
  return GetTypeId ();
124
  return GetTypeId ();
124
}
125
}
125
126
126
uint32_t 
127
uint32_t
127
PacketHeader::GetSerializedSize (void) const
128
PacketHeader::GetSerializedSize (void) const
128
{
129
{
129
  return OLSR_PKT_HEADER_SIZE;
130
  return OLSR_PKT_HEADER_SIZE;
130
}
131
}
131
132
132
void 
133
void
133
PacketHeader::Print (std::ostream &os) const
134
PacketHeader::Print (std::ostream &os) const
134
{
135
{
135
  /// \todo
136
  /// \todo
 Lines 207-213    Link Here 
207
  return size;
208
  return size;
208
}
209
}
209
210
210
void 
211
void
211
MessageHeader::Print (std::ostream &os) const
212
MessageHeader::Print (std::ostream &os) const
212
{
213
{
213
  /// \todo
214
  /// \todo
 Lines 282-294    Link Here 
282
283
283
// ---------------- OLSR MID Message -------------------------------
284
// ---------------- OLSR MID Message -------------------------------
284
285
285
uint32_t 
286
uint32_t
286
MessageHeader::Mid::GetSerializedSize (void) const
287
MessageHeader::Mid::GetSerializedSize (void) const
287
{
288
{
288
  return this->interfaceAddresses.size () * IPV4_ADDRESS_SIZE;
289
  return this->interfaceAddresses.size () * IPV4_ADDRESS_SIZE;
289
}
290
}
290
291
291
void 
292
void
292
MessageHeader::Mid::Print (std::ostream &os) const
293
MessageHeader::Mid::Print (std::ostream &os) const
293
{
294
{
294
  /// \todo
295
  /// \todo
 Lines 318-324    Link Here 
318
  this->interfaceAddresses.erase (this->interfaceAddresses.begin (),
319
  this->interfaceAddresses.erase (this->interfaceAddresses.begin (),
319
                                  this->interfaceAddresses.end ());
320
                                  this->interfaceAddresses.end ());
320
  for (int n = 0; n < numAddresses; ++n)
321
  for (int n = 0; n < numAddresses; ++n)
321
    this->interfaceAddresses.push_back (Ipv4Address (i.ReadNtohU32 ()));
322
    {
323
      this->interfaceAddresses.push_back (Ipv4Address (i.ReadNtohU32 ()));
324
    }
322
  return GetSerializedSize ();
325
  return GetSerializedSize ();
323
}
326
}
324
327
 Lines 326-332    Link Here 
326
329
327
// ---------------- OLSR HELLO Message -------------------------------
330
// ---------------- OLSR HELLO Message -------------------------------
328
331
329
uint32_t 
332
uint32_t
330
MessageHeader::Hello::GetSerializedSize (void) const
333
MessageHeader::Hello::GetSerializedSize (void) const
331
{
334
{
332
  uint32_t size = 4;
335
  uint32_t size = 4;
 Lines 340-346    Link Here 
340
  return size;
343
  return size;
341
}
344
}
342
345
343
void 
346
void
344
MessageHeader::Hello::Print (std::ostream &os) const
347
MessageHeader::Hello::Print (std::ostream &os) const
345
{
348
{
346
  /// \todo
349
  /// \todo
 Lines 417-429    Link Here 
417
420
418
// ---------------- OLSR TC Message -------------------------------
421
// ---------------- OLSR TC Message -------------------------------
419
422
420
uint32_t 
423
uint32_t
421
MessageHeader::Tc::GetSerializedSize (void) const
424
MessageHeader::Tc::GetSerializedSize (void) const
422
{
425
{
423
  return 4 + this->neighborAddresses.size () * IPV4_ADDRESS_SIZE;
426
  return 4 + this->neighborAddresses.size () * IPV4_ADDRESS_SIZE;
424
}
427
}
425
428
426
void 
429
void
427
MessageHeader::Tc::Print (std::ostream &os) const
430
MessageHeader::Tc::Print (std::ostream &os) const
428
{
431
{
429
  /// \todo
432
  /// \todo
 Lines 459-465    Link Here 
459
  int numAddresses = (messageSize - 4) / IPV4_ADDRESS_SIZE;
462
  int numAddresses = (messageSize - 4) / IPV4_ADDRESS_SIZE;
460
  this->neighborAddresses.clear ();
463
  this->neighborAddresses.clear ();
461
  for (int n = 0; n < numAddresses; ++n)
464
  for (int n = 0; n < numAddresses; ++n)
462
    this->neighborAddresses.push_back (Ipv4Address (i.ReadNtohU32 ()));
465
    {
466
      this->neighborAddresses.push_back (Ipv4Address (i.ReadNtohU32 ()));
467
    }
463
468
464
  return messageSize;
469
  return messageSize;
465
}
470
}
 Lines 467-479    Link Here 
467
472
468
// ---------------- OLSR HNA Message -------------------------------
473
// ---------------- OLSR HNA Message -------------------------------
469
474
470
uint32_t 
475
uint32_t
471
MessageHeader::Hna::GetSerializedSize (void) const
476
MessageHeader::Hna::GetSerializedSize (void) const
472
{
477
{
473
  return 2*this->associations.size () * IPV4_ADDRESS_SIZE;
478
  return 2 * this->associations.size () * IPV4_ADDRESS_SIZE;
474
}
479
}
475
480
476
void 
481
void
477
MessageHeader::Hna::Print (std::ostream &os) const
482
MessageHeader::Hna::Print (std::ostream &os) const
478
{
483
{
479
  /// \todo
484
  /// \todo
 Lines 496-502    Link Here 
496
{
501
{
497
  Buffer::Iterator i = start;
502
  Buffer::Iterator i = start;
498
503
499
  NS_ASSERT (messageSize % (IPV4_ADDRESS_SIZE*2) == 0);
504
  NS_ASSERT (messageSize % (IPV4_ADDRESS_SIZE * 2) == 0);
500
  int numAddresses = messageSize / IPV4_ADDRESS_SIZE / 2;
505
  int numAddresses = messageSize / IPV4_ADDRESS_SIZE / 2;
501
  this->associations.clear ();
506
  this->associations.clear ();
502
  for (int n = 0; n < numAddresses; ++n)
507
  for (int n = 0; n < numAddresses; ++n)
(-)a/src/olsr/model/olsr-header.h (-52 / +53 lines)
 Lines 157-167    Link Here 
157
class MessageHeader : public Header
157
class MessageHeader : public Header
158
{
158
{
159
public:
159
public:
160
161
  /**
160
  /**
162
   * Message type
161
   * Message type
163
   */
162
   */
164
  enum MessageType {
163
  enum MessageType
164
  {
165
    HELLO_MESSAGE = 1,
165
    HELLO_MESSAGE = 1,
166
    TC_MESSAGE    = 2,
166
    TC_MESSAGE    = 2,
167
    MID_MESSAGE   = 3,
167
    MID_MESSAGE   = 3,
 Lines 340-346    Link Here 
340
     * \param messageSize the message size.
340
     * \param messageSize the message size.
341
     * \returns the number of bytes read.
341
     * \returns the number of bytes read.
342
     */
342
     */
343
   uint32_t Deserialize (Buffer::Iterator start, uint32_t messageSize);
343
    uint32_t Deserialize (Buffer::Iterator start, uint32_t messageSize);
344
  };
344
  };
345
345
346
  /**
346
  /**
 Lines 373-384    Link Here 
373
     (etc.)
373
     (etc.)
374
  \endverbatim
374
  \endverbatim
375
  */
375
  */
376
 struct Hello
376
  struct Hello
377
  {
377
  {
378
    /**
378
    /**
379
     * Link message item
379
     * Link message item
380
     */
380
     */
381
    struct LinkMessage {
381
    struct LinkMessage
382
    {
382
      uint8_t linkCode;       //!< Link code
383
      uint8_t linkCode;       //!< Link code
383
      std::vector<Ipv4Address> neighborInterfaceAddresses;  //!< Neighbor interface address container.
384
      std::vector<Ipv4Address> neighborInterfaceAddresses;  //!< Neighbor interface address container.
384
    };
385
    };
 Lines 436-460    Link Here 
436
    uint32_t Deserialize (Buffer::Iterator start, uint32_t messageSize);
437
    uint32_t Deserialize (Buffer::Iterator start, uint32_t messageSize);
437
  };
438
  };
438
439
439
 /**
440
  /**
440
  * \ingroup olsr
441
   * \ingroup olsr
441
  * TC Message Format
442
   * TC Message Format
442
  *
443
   *
443
  \verbatim
444
   \verbatim
444
    0                   1                   2                   3
445
     0                   1                   2                   3
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
446
     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
446
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
447
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
447
   |              ANSN             |           Reserved            |
448
    |              ANSN             |           Reserved            |
448
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
449
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
449
   |               Advertised Neighbor Main Address                |
450
    |               Advertised Neighbor Main Address                |
450
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
451
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
451
   |               Advertised Neighbor Main Address                |
452
    |               Advertised Neighbor Main Address                |
452
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
453
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
453
   |                              ...                              |
454
    |                              ...                              |
454
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
455
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
455
  \endverbatim
456
   \endverbatim
456
  */
457
   */
457
 struct Tc
458
  struct Tc
458
  {
459
  {
459
    std::vector<Ipv4Address> neighborAddresses; //!< Neighbor address container.
460
    std::vector<Ipv4Address> neighborAddresses; //!< Neighbor address container.
460
    uint16_t ansn;  //!< Advertised Neighbor Sequence Number.
461
    uint16_t ansn;  //!< Advertised Neighbor Sequence Number.
 Lines 486-520    Link Here 
486
     * \param messageSize the message size.
487
     * \param messageSize the message size.
487
     * \returns the number of bytes read.
488
     * \returns the number of bytes read.
488
     */
489
     */
489
   uint32_t Deserialize (Buffer::Iterator start, uint32_t messageSize);
490
    uint32_t Deserialize (Buffer::Iterator start, uint32_t messageSize);
490
  };
491
  };
491
492
492
493
493
 /**
494
  /**
494
  * \ingroup olsr
495
   * \ingroup olsr
495
  * HNA (Host Network Association) Message Format
496
   * HNA (Host Network Association) Message Format
496
  *
497
   *
497
  \verbatim
498
   \verbatim
498
    0                   1                   2                   3
499
     0                   1                   2                   3
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
500
     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
500
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
501
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
501
   |                         Network Address                       |
502
    |                         Network Address                       |
502
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
503
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
503
   |                             Netmask                           |
504
    |                             Netmask                           |
504
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
505
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
505
   |                         Network Address                       |
506
    |                         Network Address                       |
506
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
507
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
507
   |                             Netmask                           |
508
    |                             Netmask                           |
508
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
509
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
509
   |                              ...                              |
510
    |                              ...                              |
510
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
511
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
511
  \endverbatim
512
   \endverbatim
512
  */
513
   */
513
  struct Hna
514
  struct Hna
514
  {
515
  {
515
   /**
516
    /**
516
    * Association item structure.
517
     * Association item structure.
517
    */
518
     */
518
    struct Association
519
    struct Association
519
    {
520
    {
520
      Ipv4Address address; //!< IPv4 Address.
521
      Ipv4Address address; //!< IPv4 Address.
 Lines 554-560    Link Here 
554
  };
555
  };
555
556
556
private:
557
private:
557
558
  /**
558
  /**
559
   * Structure holding the message content.
559
   * Structure holding the message content.
560
   */
560
   */
 Lines 567-573    Link Here 
567
  } m_message; //!< The actual message being carried.
567
  } m_message; //!< The actual message being carried.
568
568
569
public:
569
public:
570
571
  /**
570
  /**
572
   * Set the message type to MID and return the message content.
571
   * Set the message type to MID and return the message content.
573
   * \returns The MID message.
572
   * \returns The MID message.
 Lines 702-709    Link Here 
702
       messageIter != messages.end (); messageIter++)
701
       messageIter != messages.end (); messageIter++)
703
    {
702
    {
704
      messageIter->Print (os);
703
      messageIter->Print (os);
705
      if (messageIter+1 != messages.end ())
704
      if (messageIter + 1 != messages.end ())
706
        os << ", ";
705
        {
706
          os << ", ";
707
        }
707
    }
708
    }
708
  os << "]";
709
  os << "]";
709
  return os;
710
  return os;
(-)a/src/olsr/model/olsr-repositories.h (-37 / +40 lines)
 Lines 1-6    Link Here 
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
2
/*
3
 * Copyright (c) 2004 Francisco J. Ros 
3
 * Copyright (c) 2004 Francisco J. Ros
4
 * Copyright (c) 2007 INESC Porto
4
 * Copyright (c) 2007 INESC Porto
5
 *
5
 *
6
 * This program is free software; you can redistribute it and/or modify
6
 * This program is free software; you can redistribute it and/or modify
 Lines 33-39    Link Here 
33
#include "ns3/ipv4-address.h"
33
#include "ns3/ipv4-address.h"
34
#include "ns3/nstime.h"
34
#include "ns3/nstime.h"
35
35
36
namespace ns3 { namespace olsr {
36
namespace ns3 {
37
namespace olsr {
37
38
38
39
39
/// \ingroup olsr
40
/// \ingroup olsr
 Lines 52-66    Link Here 
52
operator == (const IfaceAssocTuple &a, const IfaceAssocTuple &b)
53
operator == (const IfaceAssocTuple &a, const IfaceAssocTuple &b)
53
{
54
{
54
  return (a.ifaceAddr == b.ifaceAddr
55
  return (a.ifaceAddr == b.ifaceAddr
55
      && a.mainAddr == b.mainAddr);
56
          && a.mainAddr == b.mainAddr);
56
}
57
}
57
58
58
static inline std::ostream&
59
static inline std::ostream&
59
operator << (std::ostream &os, const IfaceAssocTuple &tuple)
60
operator << (std::ostream &os, const IfaceAssocTuple &tuple)
60
{
61
{
61
  os << "IfaceAssocTuple(ifaceAddr=" << tuple.ifaceAddr
62
  os << "IfaceAssocTuple(ifaceAddr=" << tuple.ifaceAddr
62
                         << ", mainAddr=" << tuple.mainAddr
63
     << ", mainAddr=" << tuple.mainAddr
63
                         << ", time=" << tuple.time << ")";
64
     << ", time=" << tuple.time << ")";
64
  return os;
65
  return os;
65
}
66
}
66
67
 Lines 84-101    Link Here 
84
operator == (const LinkTuple &a, const LinkTuple &b)
85
operator == (const LinkTuple &a, const LinkTuple &b)
85
{
86
{
86
  return (a.localIfaceAddr == b.localIfaceAddr
87
  return (a.localIfaceAddr == b.localIfaceAddr
87
      && a.neighborIfaceAddr == b.neighborIfaceAddr);
88
          && a.neighborIfaceAddr == b.neighborIfaceAddr);
88
}
89
}
89
90
90
static inline std::ostream&
91
static inline std::ostream&
91
operator << (std::ostream &os, const LinkTuple &tuple)
92
operator << (std::ostream &os, const LinkTuple &tuple)
92
{
93
{
93
  os << "LinkTuple(localIfaceAddr=" << tuple.localIfaceAddr
94
  os << "LinkTuple(localIfaceAddr=" << tuple.localIfaceAddr
94
                   << ", neighborIfaceAddr=" << tuple.neighborIfaceAddr
95
     << ", neighborIfaceAddr=" << tuple.neighborIfaceAddr
95
                   << ", symTime=" << tuple.symTime
96
     << ", symTime=" << tuple.symTime
96
                   << ", asymTime=" << tuple.asymTime
97
     << ", asymTime=" << tuple.asymTime
97
                   << ", expTime=" << tuple.time
98
     << ", expTime=" << tuple.time
98
                   << ")";
99
     << ")";
99
  return os;
100
  return os;
100
}
101
}
101
102
 Lines 106-112    Link Here 
106
  /// Main address of a neighbor node.
107
  /// Main address of a neighbor node.
107
  Ipv4Address neighborMainAddr;
108
  Ipv4Address neighborMainAddr;
108
  /// Status of the link (Symmetric or not Symmetric).
109
  /// Status of the link (Symmetric or not Symmetric).
109
  enum Status {
110
  enum Status
111
  {
110
    STATUS_NOT_SYM = 0, // "not symmetric"
112
    STATUS_NOT_SYM = 0, // "not symmetric"
111
    STATUS_SYM = 1, // "symmetric"
113
    STATUS_SYM = 1, // "symmetric"
112
  } status; //!< Status of the link.
114
  } status; //!< Status of the link.
 Lines 118-133    Link Here 
118
operator == (const NeighborTuple &a, const NeighborTuple &b)
120
operator == (const NeighborTuple &a, const NeighborTuple &b)
119
{
121
{
120
  return (a.neighborMainAddr == b.neighborMainAddr
122
  return (a.neighborMainAddr == b.neighborMainAddr
121
      && a.status == b.status
123
          && a.status == b.status
122
      && a.willingness == b.willingness);
124
          && a.willingness == b.willingness);
123
}
125
}
124
126
125
static inline std::ostream&
127
static inline std::ostream&
126
operator << (std::ostream &os, const NeighborTuple &tuple)
128
operator << (std::ostream &os, const NeighborTuple &tuple)
127
{
129
{
128
  os << "NeighborTuple(neighborMainAddr=" << tuple.neighborMainAddr
130
  os << "NeighborTuple(neighborMainAddr=" << tuple.neighborMainAddr
129
                       << ", status=" << (tuple.status == NeighborTuple::STATUS_SYM ? "SYM" : "NOT_SYM")
131
     << ", status=" << (tuple.status == NeighborTuple::STATUS_SYM ? "SYM" : "NOT_SYM")
130
                       << ", willingness=" << (int) tuple.willingness << ")";
132
     << ", willingness=" << (int) tuple.willingness << ")";
131
  return os;
133
  return os;
132
}
134
}
133
135
 Lines 147-155    Link Here 
147
operator << (std::ostream &os, const TwoHopNeighborTuple &tuple)
149
operator << (std::ostream &os, const TwoHopNeighborTuple &tuple)
148
{
150
{
149
  os << "TwoHopNeighborTuple(neighborMainAddr=" << tuple.neighborMainAddr
151
  os << "TwoHopNeighborTuple(neighborMainAddr=" << tuple.neighborMainAddr
150
      << ", twoHopNeighborAddr=" << tuple.twoHopNeighborAddr
152
     << ", twoHopNeighborAddr=" << tuple.twoHopNeighborAddr
151
      << ", expirationTime=" << tuple.expirationTime
153
     << ", expirationTime=" << tuple.expirationTime
152
      << ")";
154
     << ")";
153
  return os;
155
  return os;
154
}
156
}
155
157
 Lines 157-163    Link Here 
157
operator == (const TwoHopNeighborTuple &a, const TwoHopNeighborTuple &b)
159
operator == (const TwoHopNeighborTuple &a, const TwoHopNeighborTuple &b)
158
{
160
{
159
  return (a.neighborMainAddr == b.neighborMainAddr
161
  return (a.neighborMainAddr == b.neighborMainAddr
160
      && a.twoHopNeighborAddr == b.twoHopNeighborAddr);
162
          && a.twoHopNeighborAddr == b.twoHopNeighborAddr);
161
}
163
}
162
164
163
/// \ingroup olsr
165
/// \ingroup olsr
 Lines 200-206    Link Here 
200
operator == (const DuplicateTuple &a, const DuplicateTuple &b)
202
operator == (const DuplicateTuple &a, const DuplicateTuple &b)
201
{
203
{
202
  return (a.address == b.address
204
  return (a.address == b.address
203
      && a.sequenceNumber == b.sequenceNumber);
205
          && a.sequenceNumber == b.sequenceNumber);
204
}
206
}
205
207
206
/// \ingroup olsr
208
/// \ingroup olsr
 Lines 221-238    Link Here 
221
operator == (const TopologyTuple &a, const TopologyTuple &b)
223
operator == (const TopologyTuple &a, const TopologyTuple &b)
222
{
224
{
223
  return (a.destAddr == b.destAddr
225
  return (a.destAddr == b.destAddr
224
      && a.lastAddr == b.lastAddr
226
          && a.lastAddr == b.lastAddr
225
      && a.sequenceNumber == b.sequenceNumber);
227
          && a.sequenceNumber == b.sequenceNumber);
226
}
228
}
227
229
228
static inline std::ostream&
230
static inline std::ostream&
229
operator << (std::ostream &os, const TopologyTuple &tuple)
231
operator << (std::ostream &os, const TopologyTuple &tuple)
230
{
232
{
231
  os << "TopologyTuple(destAddr=" << tuple.destAddr
233
  os << "TopologyTuple(destAddr=" << tuple.destAddr
232
                       << ", lastAddr=" << tuple.lastAddr
234
     << ", lastAddr=" << tuple.lastAddr
233
                       << ", sequenceNumber=" << (int) tuple.sequenceNumber
235
     << ", sequenceNumber=" << (int) tuple.sequenceNumber
234
                       << ", expirationTime=" << tuple.expirationTime
236
     << ", expirationTime=" << tuple.expirationTime
235
                       << ")";
237
     << ")";
236
  return os;
238
  return os;
237
}
239
}
238
240
 Lines 248-262    Link Here 
248
operator == (const Association &a, const Association &b)
250
operator == (const Association &a, const Association &b)
249
{
251
{
250
  return (a.networkAddr == b.networkAddr
252
  return (a.networkAddr == b.networkAddr
251
      && a.netmask == b.netmask);
253
          && a.netmask == b.netmask);
252
}
254
}
253
255
254
static inline std::ostream&
256
static inline std::ostream&
255
operator << (std::ostream &os, const Association &tuple)
257
operator << (std::ostream &os, const Association &tuple)
256
{
258
{
257
  os << "Association(networkAddr=" << tuple.networkAddr
259
  os << "Association(networkAddr=" << tuple.networkAddr
258
                     << ", netmask=" << tuple.netmask
260
     << ", netmask=" << tuple.netmask
259
                     << ")";
261
     << ")";
260
  return os;
262
  return os;
261
}
263
}
262
264
 Lines 278-295    Link Here 
278
operator == (const AssociationTuple &a, const AssociationTuple &b)
280
operator == (const AssociationTuple &a, const AssociationTuple &b)
279
{
281
{
280
  return (a.gatewayAddr == b.gatewayAddr
282
  return (a.gatewayAddr == b.gatewayAddr
281
      && a.networkAddr == b.networkAddr
283
          && a.networkAddr == b.networkAddr
282
      && a.netmask == b.netmask);
284
          && a.netmask == b.netmask);
283
}
285
}
284
286
285
static inline std::ostream&
287
static inline std::ostream&
286
operator << (std::ostream &os, const AssociationTuple &tuple)
288
operator << (std::ostream &os, const AssociationTuple &tuple)
287
{
289
{
288
  os << "AssociationTuple(gatewayAddr=" << tuple.gatewayAddr
290
  os << "AssociationTuple(gatewayAddr=" << tuple.gatewayAddr
289
                          << ", networkAddr=" << tuple.networkAddr
291
     << ", networkAddr=" << tuple.networkAddr
290
                          << ", netmask=" << tuple.netmask
292
     << ", netmask=" << tuple.netmask
291
                          << ", expirationTime=" << tuple.expirationTime
293
     << ", expirationTime=" << tuple.expirationTime
292
                          << ")";
294
     << ")";
293
  return os;
295
  return os;
294
}
296
}
295
297
 Lines 306-311    Link Here 
306
typedef std::vector<Association>                Associations; //!< Association Set type.
308
typedef std::vector<Association>                Associations; //!< Association Set type.
307
309
308
310
309
}} // namespace ns3, olsr
311
}
312
}  // namespace ns3, olsr
310
313
311
#endif /* OLSR_REPOSITORIES_H */
314
#endif /* OLSR_REPOSITORIES_H */
(-)a/src/olsr/model/olsr-routing-protocol.cc (-86 / +158 lines)
 Lines 1-6    Link Here 
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
2
/*
3
 * Copyright (c) 2004 Francisco J. Ros 
3
 * Copyright (c) 2004 Francisco J. Ros
4
 * Copyright (c) 2007 INESC Porto
4
 * Copyright (c) 2007 INESC Porto
5
 *
5
 *
6
 * This program is free software; you can redistribute it and/or modify
6
 * This program is free software; you can redistribute it and/or modify
 Lines 141-154    Link Here 
141
namespace ns3 {
141
namespace ns3 {
142
142
143
NS_LOG_COMPONENT_DEFINE ("OlsrRoutingProtocol");
143
NS_LOG_COMPONENT_DEFINE ("OlsrRoutingProtocol");
144
  
144
145
namespace olsr {
145
namespace olsr {
146
146
147
/********** OLSR class **********/
147
/********** OLSR class **********/
148
148
149
NS_OBJECT_ENSURE_REGISTERED (RoutingProtocol);
149
NS_OBJECT_ENSURE_REGISTERED (RoutingProtocol);
150
150
151
TypeId 
151
TypeId
152
RoutingProtocol::GetTypeId (void)
152
RoutingProtocol::GetTypeId (void)
153
{
153
{
154
  static TypeId tid = TypeId ("ns3::olsr::RoutingProtocol")
154
  static TypeId tid = TypeId ("ns3::olsr::RoutingProtocol")
 Lines 195-206    Link Here 
195
195
196
RoutingProtocol::RoutingProtocol ()
196
RoutingProtocol::RoutingProtocol ()
197
  : m_routingTableAssociation (0),
197
  : m_routingTableAssociation (0),
198
    m_ipv4 (0),
198
  m_ipv4 (0),
199
    m_helloTimer (Timer::CANCEL_ON_DESTROY),
199
  m_helloTimer (Timer::CANCEL_ON_DESTROY),
200
    m_tcTimer (Timer::CANCEL_ON_DESTROY),
200
  m_tcTimer (Timer::CANCEL_ON_DESTROY),
201
    m_midTimer (Timer::CANCEL_ON_DESTROY),
201
  m_midTimer (Timer::CANCEL_ON_DESTROY),
202
    m_hnaTimer (Timer::CANCEL_ON_DESTROY),
202
  m_hnaTimer (Timer::CANCEL_ON_DESTROY),
203
    m_queuedMessagesTimer (Timer::CANCEL_ON_DESTROY)
203
  m_queuedMessagesTimer (Timer::CANCEL_ON_DESTROY)
204
{
204
{
205
  m_uniformRandomVariable = CreateObject<UniformRandomVariable> ();
205
  m_uniformRandomVariable = CreateObject<UniformRandomVariable> ();
206
206
 Lines 256-262    Link Here 
256
  std::ostream* os = stream->GetStream ();
256
  std::ostream* os = stream->GetStream ();
257
257
258
  *os << "Node: " << m_ipv4->GetObject<Node> ()->GetId ()
258
  *os << "Node: " << m_ipv4->GetObject<Node> ()->GetId ()
259
      << ", Time: " << Now().As (Time::S)
259
      << ", Time: " << Now ().As (Time::S)
260
      << ", Local time: " << GetObject<Node> ()->GetLocalTime ().As (Time::S)
260
      << ", Local time: " << GetObject<Node> ()->GetLocalTime ().As (Time::S)
261
      << ", OLSR Routing table" << std::endl;
261
      << ", OLSR Routing table" << std::endl;
262
262
 Lines 319-325    Link Here 
319
    {
319
    {
320
      Ipv4Address addr = m_ipv4->GetAddress (i, 0).GetLocal ();
320
      Ipv4Address addr = m_ipv4->GetAddress (i, 0).GetLocal ();
321
      if (addr == loopback)
321
      if (addr == loopback)
322
        continue;
322
        {
323
          continue;
324
        }
323
325
324
      if (addr != m_mainAddress)
326
      if (addr != m_mainAddress)
325
        {
327
        {
 Lines 333-343    Link Here 
333
          NS_ASSERT (GetMainAddress (addr) == m_mainAddress);
335
          NS_ASSERT (GetMainAddress (addr) == m_mainAddress);
334
        }
336
        }
335
337
336
      if(m_interfaceExclusions.find (i) != m_interfaceExclusions.end ())
338
      if (m_interfaceExclusions.find (i) != m_interfaceExclusions.end ())
337
        continue;
339
        {
340
          continue;
341
        }
338
342
339
      // Create a socket to listen only on this interface
343
      // Create a socket to listen only on this interface
340
      Ptr<Socket> socket = Socket::CreateSocket (GetObject<Node> (), 
344
      Ptr<Socket> socket = Socket::CreateSocket (GetObject<Node> (),
341
                                                 UdpSocketFactory::GetTypeId ());
345
                                                 UdpSocketFactory::GetTypeId ());
342
      socket->SetAllowBroadcast (true);
346
      socket->SetAllowBroadcast (true);
343
      InetSocketAddress inetAddr (m_ipv4->GetAddress (i, 0).GetLocal (), OLSR_PORT_NUMBER);
347
      InetSocketAddress inetAddr (m_ipv4->GetAddress (i, 0).GetLocal (), OLSR_PORT_NUMBER);
 Lines 352-358    Link Here 
352
      canRunOlsr = true;
356
      canRunOlsr = true;
353
    }
357
    }
354
358
355
  if(canRunOlsr)
359
  if (canRunOlsr)
356
    {
360
    {
357
      HelloTimerExpire ();
361
      HelloTimerExpire ();
358
      TcTimerExpire ();
362
      TcTimerExpire ();
 Lines 406-412    Link Here 
406
    {
410
    {
407
      MessageHeader messageHeader;
411
      MessageHeader messageHeader;
408
      if (packet->RemoveHeader (messageHeader) == 0)
412
      if (packet->RemoveHeader (messageHeader) == 0)
409
        NS_ASSERT (false);
413
        {
414
          NS_ASSERT (false);
415
        }
410
416
411
      sizeLeft -= messageHeader.GetSerializedSize ();
417
      sizeLeft -= messageHeader.GetSerializedSize ();
412
418
 Lines 481-487    Link Here 
481
                            << "s OLSR node " << m_mainAddress
487
                            << "s OLSR node " << m_mainAddress
482
                            <<  " received HNA message of size " << messageHeader.GetSerializedSize ());
488
                            <<  " received HNA message of size " << messageHeader.GetSerializedSize ());
483
              ProcessHna (messageHeader, senderIfaceAddr);
489
              ProcessHna (messageHeader, senderIfaceAddr);
484
              break; 
490
              break;
485
491
486
            default:
492
            default:
487
              NS_LOG_DEBUG ("OLSR message type " <<
493
              NS_LOG_DEBUG ("OLSR message type " <<
 Lines 542-548    Link Here 
542
          const NeighborTuple *nb_tuple =
548
          const NeighborTuple *nb_tuple =
543
            m_state.FindNeighborTuple (nb2hop_tuple.neighborMainAddr);
549
            m_state.FindNeighborTuple (nb2hop_tuple.neighborMainAddr);
544
          if (nb_tuple == NULL)
550
          if (nb_tuple == NULL)
545
            degree++;
551
            {
552
              degree++;
553
            }
546
        }
554
        }
547
    }
555
    }
548
  return degree;
556
  return degree;
 Lines 556-562    Link Here 
556
/// \param neighborMainAddr Neighbor main address.
564
/// \param neighborMainAddr Neighbor main address.
557
/// \param N2 Reference to the 2-hop neighbor set.
565
/// \param N2 Reference to the 2-hop neighbor set.
558
///
566
///
559
void 
567
void
560
CoverTwoHopNeighbors (Ipv4Address neighborMainAddr, TwoHopNeighborSet & N2)
568
CoverTwoHopNeighbors (Ipv4Address neighborMainAddr, TwoHopNeighborSet & N2)
561
{
569
{
562
  // first gather all 2-hop neighbors to be removed
570
  // first gather all 2-hop neighbors to be removed
 Lines 676-682    Link Here 
676
        next++;
684
        next++;
677
        os << iter->neighborMainAddr << "->" << iter->twoHopNeighborAddr;
685
        os << iter->neighborMainAddr << "->" << iter->twoHopNeighborAddr;
678
        if (next != N2.end ())
686
        if (next != N2.end ())
679
          os << ", ";
687
          {
688
            os << ", ";
689
          }
680
      }
690
      }
681
    os << "]";
691
    os << "]";
682
    NS_LOG_DEBUG ("N2: " << os.str ());
692
    NS_LOG_DEBUG ("N2: " << os.str ());
 Lines 741-747    Link Here 
741
    {
751
    {
742
      if (coveredTwoHopNeighbors.find (twoHopNeigh->twoHopNeighborAddr) != coveredTwoHopNeighbors.end ())
752
      if (coveredTwoHopNeighbors.find (twoHopNeigh->twoHopNeighborAddr) != coveredTwoHopNeighbors.end ())
743
        {
753
        {
744
          // This works correctly only because it is known that twoHopNeigh is reachable by exactly one neighbor, 
754
          // This works correctly only because it is known that twoHopNeigh is reachable by exactly one neighbor,
745
          // so only one record in N2 exists for each of them. This record is erased here.
755
          // so only one record in N2 exists for each of them. This record is erased here.
746
          NS_LOG_LOGIC ("2-hop neigh. " << twoHopNeigh->twoHopNeighborAddr << " is already covered by an MPR.");
756
          NS_LOG_LOGIC ("2-hop neigh. " << twoHopNeigh->twoHopNeighborAddr << " is already covered by an MPR.");
747
          twoHopNeigh = N2.erase (twoHopNeigh);
757
          twoHopNeigh = N2.erase (twoHopNeigh);
 Lines 768-774    Link Here 
768
            next++;
778
            next++;
769
            os << iter->neighborMainAddr << "->" << iter->twoHopNeighborAddr;
779
            os << iter->neighborMainAddr << "->" << iter->twoHopNeighborAddr;
770
            if (next != N2.end ())
780
            if (next != N2.end ())
771
              os << ", ";
781
              {
782
                os << ", ";
783
              }
772
          }
784
          }
773
        os << "]";
785
        os << "]";
774
        NS_LOG_DEBUG ("Step 4 iteration: N2=" << os.str ());
786
        NS_LOG_DEBUG ("Step 4 iteration: N2=" << os.str ());
 Lines 790-796    Link Here 
790
            {
802
            {
791
              TwoHopNeighborTuple const &nb2hop_tuple = *it2;
803
              TwoHopNeighborTuple const &nb2hop_tuple = *it2;
792
              if (nb_tuple.neighborMainAddr == nb2hop_tuple.neighborMainAddr)
804
              if (nb_tuple.neighborMainAddr == nb2hop_tuple.neighborMainAddr)
793
                r++;
805
                {
806
                  r++;
807
                }
794
            }
808
            }
795
          rs.insert (r);
809
          rs.insert (r);
796
          reachability[r].push_back (&nb_tuple);
810
          reachability[r].push_back (&nb_tuple);
 Lines 860-866    Link Here 
860
        next++;
874
        next++;
861
        os << *iter;
875
        os << *iter;
862
        if (next != mprSet.end ())
876
        if (next != mprSet.end ())
863
          os << ", ";
877
          {
878
            os << ", ";
879
          }
864
      }
880
      }
865
    os << "]";
881
    os << "]";
866
    NS_LOG_DEBUG ("Computed MPR set for node " << m_mainAddress << ": " << os.str ());
882
    NS_LOG_DEBUG ("Computed MPR set for node " << m_mainAddress << ": " << os.str ());
 Lines 877-885    Link Here 
877
    m_state.FindIfaceAssocTuple (iface_addr);
893
    m_state.FindIfaceAssocTuple (iface_addr);
878
894
879
  if (tuple != NULL)
895
  if (tuple != NULL)
880
    return tuple->mainAddr;
896
    {
897
      return tuple->mainAddr;
898
    }
881
  else
899
  else
882
    return iface_addr;
900
    {
901
      return iface_addr;
902
    }
883
}
903
}
884
904
885
void
905
void
 Lines 1083-1089    Link Here 
1083
        }
1103
        }
1084
1104
1085
      if (!added)
1105
      if (!added)
1086
        break;
1106
        {
1107
          break;
1108
        }
1087
    }
1109
    }
1088
1110
1089
  // 4. For each entry in the multiple interface association base
1111
  // 4. For each entry in the multiple interface association base
 Lines 1164-1171    Link Here 
1164
      for (routeIndex = 0; routeIndex < m_hnaRoutingTable->GetNRoutes (); routeIndex++)
1186
      for (routeIndex = 0; routeIndex < m_hnaRoutingTable->GetNRoutes (); routeIndex++)
1165
        {
1187
        {
1166
          Ipv4RoutingTableEntry route = m_hnaRoutingTable->GetRoute (routeIndex);
1188
          Ipv4RoutingTableEntry route = m_hnaRoutingTable->GetRoute (routeIndex);
1167
          if (route.GetDestNetwork () == tuple.networkAddr &&
1189
          if (route.GetDestNetwork () == tuple.networkAddr
1168
              route.GetDestNetworkMask () == tuple.netmask)
1190
              && route.GetDestNetworkMask () == tuple.netmask)
1169
            {
1191
            {
1170
              break;
1192
              break;
1171
            }
1193
            }
 Lines 1175-1187    Link Here 
1175
        {
1197
        {
1176
          addRoute = true;
1198
          addRoute = true;
1177
        }
1199
        }
1178
      else if(gatewayEntryExists && m_hnaRoutingTable->GetMetric (routeIndex) > gatewayEntry.distance)
1200
      else if (gatewayEntryExists && m_hnaRoutingTable->GetMetric (routeIndex) > gatewayEntry.distance)
1179
        {
1201
        {
1180
          m_hnaRoutingTable->RemoveRoute (routeIndex);
1202
          m_hnaRoutingTable->RemoveRoute (routeIndex);
1181
          addRoute = true;
1203
          addRoute = true;
1182
        }
1204
        }
1183
1205
1184
      if(addRoute && gatewayEntryExists)
1206
      if (addRoute && gatewayEntryExists)
1185
        {
1207
        {
1186
          m_hnaRoutingTable->AddNetworkRouteTo (tuple.networkAddr,
1208
          m_hnaRoutingTable->AddNetworkRouteTo (tuple.networkAddr,
1187
                                                tuple.netmask,
1209
                                                tuple.netmask,
 Lines 1262-1268    Link Here 
1262
  // 1-hop neighborhood of this node, the message MUST be discarded.
1284
  // 1-hop neighborhood of this node, the message MUST be discarded.
1263
  const LinkTuple *link_tuple = m_state.FindSymLinkTuple (senderIface, now);
1285
  const LinkTuple *link_tuple = m_state.FindSymLinkTuple (senderIface, now);
1264
  if (link_tuple == NULL)
1286
  if (link_tuple == NULL)
1265
    return;
1287
    {
1288
      return;
1289
    }
1266
1290
1267
  // 2. If there exist some tuple in the topology set where:
1291
  // 2. If there exist some tuple in the topology set where:
1268
  //    T_last_addr == originator address AND
1292
  //    T_last_addr == originator address AND
 Lines 1272-1278    Link Here 
1272
  const TopologyTuple *topologyTuple =
1296
  const TopologyTuple *topologyTuple =
1273
    m_state.FindNewerTopologyTuple (msg.GetOriginatorAddress (), tc.ansn);
1297
    m_state.FindNewerTopologyTuple (msg.GetOriginatorAddress (), tc.ansn);
1274
  if (topologyTuple != NULL)
1298
  if (topologyTuple != NULL)
1275
    return;
1299
    {
1300
      return;
1301
    }
1276
1302
1277
  // 3. All tuples in the topology set where:
1303
  // 3. All tuples in the topology set where:
1278
  //    T_last_addr == originator address AND
1304
  //    T_last_addr == originator address AND
 Lines 1306-1312    Link Here 
1306
          //      T_last_addr = originator address,
1332
          //      T_last_addr = originator address,
1307
          //      T_seq       = ANSN,
1333
          //      T_seq       = ANSN,
1308
          //      T_time      = current time + validity time.
1334
          //      T_time      = current time + validity time.
1309
          TopologyTuple topologyTuple;;
1335
          TopologyTuple topologyTuple;
1310
          topologyTuple.destAddr = addr;
1336
          topologyTuple.destAddr = addr;
1311
          topologyTuple.lastAddr = msg.GetOriginatorAddress ();
1337
          topologyTuple.lastAddr = msg.GetOriginatorAddress ();
1312
          topologyTuple.sequenceNumber = tc.ansn;
1338
          topologyTuple.sequenceNumber = tc.ansn;
 Lines 1419-1425    Link Here 
1419
  // 1-hop neighborhood of this node, the message MUST be discarded.
1445
  // 1-hop neighborhood of this node, the message MUST be discarded.
1420
  const LinkTuple *link_tuple = m_state.FindSymLinkTuple (senderIface, now);
1446
  const LinkTuple *link_tuple = m_state.FindSymLinkTuple (senderIface, now);
1421
  if (link_tuple == NULL)
1447
  if (link_tuple == NULL)
1422
    return;
1448
    {
1449
      return;
1450
    }
1423
1451
1424
  // 2. Otherwise, for each (network address, netmask) pair in the
1452
  // 2. Otherwise, for each (network address, netmask) pair in the
1425
  // message:
1453
  // message:
 Lines 1435-1441    Link Here 
1435
      //          A_netmask      == netmask
1463
      //          A_netmask      == netmask
1436
      //      then the holding time for that tuple MUST be set to:
1464
      //      then the holding time for that tuple MUST be set to:
1437
      //          A_time         =  current time + validity time
1465
      //          A_time         =  current time + validity time
1438
      if(tuple != NULL)
1466
      if (tuple != NULL)
1439
        {
1467
        {
1440
          tuple->expirationTime = now + msg.GetVTime ();
1468
          tuple->expirationTime = now + msg.GetVTime ();
1441
        }
1469
        }
 Lines 1476-1482    Link Here 
1476
  // 1-hop neighborhood the message must not be forwarded
1504
  // 1-hop neighborhood the message must not be forwarded
1477
  const LinkTuple *linkTuple = m_state.FindSymLinkTuple (senderAddress, now);
1505
  const LinkTuple *linkTuple = m_state.FindSymLinkTuple (senderAddress, now);
1478
  if (linkTuple == NULL)
1506
  if (linkTuple == NULL)
1479
    return;
1507
    {
1508
      return;
1509
    }
1480
1510
1481
  // If the message has already been considered for forwarding,
1511
  // If the message has already been considered for forwarding,
1482
  // it must not be retransmitted again
1512
  // it must not be retransmitted again
 Lines 1542-1548    Link Here 
1542
}
1572
}
1543
1573
1544
void
1574
void
1545
RoutingProtocol::SendPacket (Ptr<Packet> packet, 
1575
RoutingProtocol::SendPacket (Ptr<Packet> packet,
1546
                             const MessageList &containedMessages)
1576
                             const MessageList &containedMessages)
1547
{
1577
{
1548
  NS_LOG_DEBUG ("OLSR node " << m_mainAddress << " sending a OLSR packet");
1578
  NS_LOG_DEBUG ("OLSR node " << m_mainAddress << " sending a OLSR packet");
 Lines 1760-1769    Link Here 
1760
    {
1790
    {
1761
      Ipv4Address addr = m_ipv4->GetAddress (i, 0).GetLocal ();
1791
      Ipv4Address addr = m_ipv4->GetAddress (i, 0).GetLocal ();
1762
      if (addr != m_mainAddress && addr != loopback && m_interfaceExclusions.find (i) == m_interfaceExclusions.end ())
1792
      if (addr != m_mainAddress && addr != loopback && m_interfaceExclusions.find (i) == m_interfaceExclusions.end ())
1763
        mid.interfaceAddresses.push_back (addr);
1793
        {
1794
          mid.interfaceAddresses.push_back (addr);
1795
        }
1764
    }
1796
    }
1765
  if (mid.interfaceAddresses.size () == 0)
1797
  if (mid.interfaceAddresses.size () == 0)
1766
    return;
1798
    {
1799
      return;
1800
    }
1767
1801
1768
  msg.SetVTime (OLSR_MID_HOLD_TIME);
1802
  msg.SetVTime (OLSR_MID_HOLD_TIME);
1769
  msg.SetOriginatorAddress (m_mainAddress);
1803
  msg.SetOriginatorAddress (m_mainAddress);
 Lines 1935-1944    Link Here 
1935
      const char *linkTypeName;
1969
      const char *linkTypeName;
1936
      switch (lt)
1970
      switch (lt)
1937
        {
1971
        {
1938
        case OLSR_UNSPEC_LINK: linkTypeName = "UNSPEC_LINK"; break;
1972
        case OLSR_UNSPEC_LINK:
1939
        case OLSR_ASYM_LINK: linkTypeName = "ASYM_LINK"; break;
1973
          linkTypeName = "UNSPEC_LINK";
1940
        case OLSR_SYM_LINK: linkTypeName = "SYM_LINK"; break;
1974
          break;
1941
        case OLSR_LOST_LINK: linkTypeName = "LOST_LINK"; break;
1975
        case OLSR_ASYM_LINK:
1976
          linkTypeName = "ASYM_LINK";
1977
          break;
1978
        case OLSR_SYM_LINK:
1979
          linkTypeName = "SYM_LINK";
1980
          break;
1981
        case OLSR_LOST_LINK:
1982
          linkTypeName = "LOST_LINK";
1983
          break;
1942
          /*  no default, since lt must be in 0..3, covered above
1984
          /*  no default, since lt must be in 0..3, covered above
1943
        default: linkTypeName = "(invalid value!)";
1985
        default: linkTypeName = "(invalid value!)";
1944
          */
1986
          */
 Lines 1947-1956    Link Here 
1947
      const char *neighborTypeName;
1989
      const char *neighborTypeName;
1948
      switch (nt)
1990
      switch (nt)
1949
        {
1991
        {
1950
        case OLSR_NOT_NEIGH: neighborTypeName = "NOT_NEIGH"; break;
1992
        case OLSR_NOT_NEIGH:
1951
        case OLSR_SYM_NEIGH: neighborTypeName = "SYM_NEIGH"; break;
1993
          neighborTypeName = "NOT_NEIGH";
1952
        case OLSR_MPR_NEIGH: neighborTypeName = "MPR_NEIGH"; break;
1994
          break;
1953
        default: neighborTypeName = "(invalid value!)";
1995
        case OLSR_SYM_NEIGH:
1996
          neighborTypeName = "SYM_NEIGH";
1997
          break;
1998
        case OLSR_MPR_NEIGH:
1999
          neighborTypeName = "MPR_NEIGH";
2000
          break;
2001
        default:
2002
          neighborTypeName = "(invalid value!)";
1954
        }
2003
        }
1955
2004
1956
      NS_LOG_DEBUG ("Looking at HELLO link messages with Link Type "
2005
      NS_LOG_DEBUG ("Looking at HELLO link messages with Link Type "
 Lines 1960-1968    Link Here 
1960
#endif // NS3_LOG_ENABLE
2009
#endif // NS3_LOG_ENABLE
1961
2010
1962
      // We must not process invalid advertised links
2011
      // We must not process invalid advertised links
1963
      if ((lt == OLSR_SYM_LINK && nt == OLSR_NOT_NEIGH) ||
2012
      if ((lt == OLSR_SYM_LINK && nt == OLSR_NOT_NEIGH)
1964
          (nt != OLSR_SYM_NEIGH && nt != OLSR_MPR_NEIGH
2013
          || (nt != OLSR_SYM_NEIGH && nt != OLSR_MPR_NEIGH
1965
           && nt != OLSR_NOT_NEIGH))
2014
              && nt != OLSR_NOT_NEIGH))
1966
        {
2015
        {
1967
          NS_LOG_LOGIC ("HELLO link code is invalid => IGNORING");
2016
          NS_LOG_LOGIC ("HELLO link code is invalid => IGNORING");
1968
          continue;
2017
          continue;
 Lines 2206-2212    Link Here 
2206
/// \param p the packet which couldn't be delivered by the MAC layer.
2255
/// \param p the packet which couldn't be delivered by the MAC layer.
2207
///
2256
///
2208
void
2257
void
2209
OLSR::mac_failed (Ptr<Packet> p) {
2258
OLSR::mac_failed (Ptr<Packet> p)
2259
{
2210
  double now              = Simulator::Now ();
2260
  double now              = Simulator::Now ();
2211
  struct hdr_ip* ih       = HDR_IP (p);
2261
  struct hdr_ip* ih       = HDR_IP (p);
2212
  struct hdr_cmn* ch      = HDR_CMN (p);
2262
  struct hdr_cmn* ch      = HDR_CMN (p);
 Lines 2216-2228    Link Here 
2216
         OLSR::node_id (ra_addr ()),
2266
         OLSR::node_id (ra_addr ()),
2217
         OLSR::node_id (ch->next_hop ()));
2267
         OLSR::node_id (ch->next_hop ()));
2218
2268
2219
  if ((u_int32_t)ih->daddr () == IP_BROADCAST) {
2269
  if ((u_int32_t)ih->daddr () == IP_BROADCAST)
2270
    {
2220
      drop (p, DROP_RTR_MAC_CALLBACK);
2271
      drop (p, DROP_RTR_MAC_CALLBACK);
2221
      return;
2272
      return;
2222
    }
2273
    }
2223
2274
2224
  OLSR_link_tuple* link_tuple = state_.find_link_tuple (ch->next_hop ());
2275
  OLSR_link_tuple* link_tuple = state_.find_link_tuple (ch->next_hop ());
2225
  if (link_tuple != NULL) {
2276
  if (link_tuple != NULL)
2277
    {
2226
      link_tuple->lost_time () = now + OLSR_NEIGHB_HOLD_TIME;
2278
      link_tuple->lost_time () = now + OLSR_NEIGHB_HOLD_TIME;
2227
      link_tuple->time ()      = now + OLSR_NEIGHB_HOLD_TIME;
2279
      link_tuple->time ()      = now + OLSR_NEIGHB_HOLD_TIME;
2228
      nb_loss (link_tuple);
2280
      nb_loss (link_tuple);
 Lines 2592-2600    Link Here 
2592
  else if (tuple->symTime < now)
2644
  else if (tuple->symTime < now)
2593
    {
2645
    {
2594
      if (m_linkTupleTimerFirstTime)
2646
      if (m_linkTupleTimerFirstTime)
2595
        m_linkTupleTimerFirstTime = false;
2647
        {
2648
          m_linkTupleTimerFirstTime = false;
2649
        }
2596
      else
2650
      else
2597
        NeighborLoss (*tuple);
2651
        {
2652
          NeighborLoss (*tuple);
2653
        }
2598
2654
2599
      m_events.Track (Simulator::Schedule (DELAY (tuple->time),
2655
      m_events.Track (Simulator::Schedule (DELAY (tuple->time),
2600
                                           &RoutingProtocol::LinkTupleTimerExpire, this,
2656
                                           &RoutingProtocol::LinkTupleTimerExpire, this,
 Lines 2731-2737    Link Here 
2731
    m_table.find (dest);
2787
    m_table.find (dest);
2732
  // If there is no route to "dest", return NULL
2788
  // If there is no route to "dest", return NULL
2733
  if (it == m_table.end ())
2789
  if (it == m_table.end ())
2734
    return false;
2790
    {
2791
      return false;
2792
    }
2735
  outEntry = it->second;
2793
  outEntry = it->second;
2736
  return true;
2794
  return true;
2737
}
2795
}
 Lines 2744-2750    Link Here 
2744
  while (outEntry.destAddr != outEntry.nextAddr)
2802
  while (outEntry.destAddr != outEntry.nextAddr)
2745
    {
2803
    {
2746
      if (not Lookup (outEntry.nextAddr, outEntry))
2804
      if (not Lookup (outEntry.nextAddr, outEntry))
2747
        return false;
2805
        {
2806
          return false;
2807
        }
2748
    }
2808
    }
2749
  return true;
2809
  return true;
2750
}
2810
}
 Lines 2768-2776    Link Here 
2768
      if (oif && m_ipv4->GetInterfaceForDevice (oif) != static_cast<int> (interfaceIdx))
2828
      if (oif && m_ipv4->GetInterfaceForDevice (oif) != static_cast<int> (interfaceIdx))
2769
        {
2829
        {
2770
          // We do not attempt to perform a constrained routing search
2830
          // We do not attempt to perform a constrained routing search
2771
          // if the caller specifies the oif; we just enforce that 
2831
          // if the caller specifies the oif; we just enforce that
2772
          // that the found route matches the requested outbound interface 
2832
          // that the found route matches the requested outbound interface
2773
          NS_LOG_DEBUG ("Olsr node " << m_mainAddress 
2833
          NS_LOG_DEBUG ("Olsr node " << m_mainAddress
2774
                                     << ": RouteOutput for dest=" << header.GetDestination ()
2834
                                     << ": RouteOutput for dest=" << header.GetDestination ()
2775
                                     << " Route interface " << interfaceIdx
2835
                                     << " Route interface " << interfaceIdx
2776
                                     << " does not match requested output interface "
2836
                                     << " does not match requested output interface "
 Lines 2781-2795    Link Here 
2781
      rtentry = Create<Ipv4Route> ();
2841
      rtentry = Create<Ipv4Route> ();
2782
      rtentry->SetDestination (header.GetDestination ());
2842
      rtentry->SetDestination (header.GetDestination ());
2783
      // the source address is the interface address that matches
2843
      // the source address is the interface address that matches
2784
      // the destination address (when multiple are present on the 
2844
      // the destination address (when multiple are present on the
2785
      // outgoing interface, one is selected via scoping rules)
2845
      // outgoing interface, one is selected via scoping rules)
2786
      NS_ASSERT (m_ipv4);
2846
      NS_ASSERT (m_ipv4);
2787
      uint32_t numOifAddresses = m_ipv4->GetNAddresses (interfaceIdx);
2847
      uint32_t numOifAddresses = m_ipv4->GetNAddresses (interfaceIdx);
2788
      NS_ASSERT (numOifAddresses > 0);
2848
      NS_ASSERT (numOifAddresses > 0);
2789
      Ipv4InterfaceAddress ifAddr;
2849
      Ipv4InterfaceAddress ifAddr;
2790
      if (numOifAddresses == 1) {
2850
      if (numOifAddresses == 1)
2851
        {
2791
          ifAddr = m_ipv4->GetAddress (interfaceIdx, 0);
2852
          ifAddr = m_ipv4->GetAddress (interfaceIdx, 0);
2792
        } else {
2853
        }
2854
      else
2855
        {
2793
          /// \todo Implment IP aliasing and OLSR
2856
          /// \todo Implment IP aliasing and OLSR
2794
          NS_FATAL_ERROR ("XXX Not implemented yet:  IP aliasing and OLSR");
2857
          NS_FATAL_ERROR ("XXX Not implemented yet:  IP aliasing and OLSR");
2795
        }
2858
        }
 Lines 2797-2803    Link Here 
2797
      rtentry->SetGateway (entry2.nextAddr);
2860
      rtentry->SetGateway (entry2.nextAddr);
2798
      rtentry->SetOutputDevice (m_ipv4->GetNetDevice (interfaceIdx));
2861
      rtentry->SetOutputDevice (m_ipv4->GetNetDevice (interfaceIdx));
2799
      sockerr = Socket::ERROR_NOTERROR;
2862
      sockerr = Socket::ERROR_NOTERROR;
2800
      NS_LOG_DEBUG ("Olsr node " << m_mainAddress 
2863
      NS_LOG_DEBUG ("Olsr node " << m_mainAddress
2801
                                 << ": RouteOutput for dest=" << header.GetDestination ()
2864
                                 << ": RouteOutput for dest=" << header.GetDestination ()
2802
                                 << " --> nextHop=" << entry2.nextAddr
2865
                                 << " --> nextHop=" << entry2.nextAddr
2803
                                 << " interface=" << entry2.interface);
2866
                                 << " interface=" << entry2.interface);
 Lines 2805-2811    Link Here 
2805
      found = true;
2868
      found = true;
2806
    }
2869
    }
2807
  else
2870
  else
2808
    { 
2871
    {
2809
      rtentry = m_hnaRoutingTable->RouteOutput (p, header, oif, sockerr);
2872
      rtentry = m_hnaRoutingTable->RouteOutput (p, header, oif, sockerr);
2810
2873
2811
      if (rtentry)
2874
      if (rtentry)
 Lines 2817-2823    Link Here 
2817
2880
2818
  if (!found)
2881
  if (!found)
2819
    {
2882
    {
2820
      NS_LOG_DEBUG ("Olsr node " << m_mainAddress 
2883
      NS_LOG_DEBUG ("Olsr node " << m_mainAddress
2821
                                 << ": RouteOutput for dest=" << header.GetDestination ()
2884
                                 << ": RouteOutput for dest=" << header.GetDestination ()
2822
                                 << " No route to host");
2885
                                 << " No route to host");
2823
      sockerr = Socket::ERROR_NOROUTETOHOST;
2886
      sockerr = Socket::ERROR_NOROUTETOHOST;
 Lines 2825-2831    Link Here 
2825
  return rtentry;
2888
  return rtentry;
2826
}
2889
}
2827
2890
2828
bool RoutingProtocol::RouteInput  (Ptr<const Packet> p, 
2891
bool RoutingProtocol::RouteInput  (Ptr<const Packet> p,
2829
                                   const Ipv4Header &header, Ptr<const NetDevice> idev,
2892
                                   const Ipv4Header &header, Ptr<const NetDevice> idev,
2830
                                   UnicastForwardCallback ucb, MulticastForwardCallback mcb,
2893
                                   UnicastForwardCallback ucb, MulticastForwardCallback mcb,
2831
                                   LocalDeliverCallback lcb, ErrorCallback ecb)
2894
                                   LocalDeliverCallback lcb, ErrorCallback ecb)
 Lines 2838-2844    Link Here 
2838
  // Consume self-originated packets
2901
  // Consume self-originated packets
2839
  if (IsMyOwnAddress (origin) == true)
2902
  if (IsMyOwnAddress (origin) == true)
2840
    {
2903
    {
2841
      return true; 
2904
      return true;
2842
    }
2905
    }
2843
2906
2844
  // Local delivery
2907
  // Local delivery
 Lines 2855-2861    Link Here 
2855
      else
2918
      else
2856
        {
2919
        {
2857
          // The local delivery callback is null.  This may be a multicast
2920
          // The local delivery callback is null.  This may be a multicast
2858
          // or broadcast packet, so return false so that another 
2921
          // or broadcast packet, so return false so that another
2859
          // multicast routing protocol can handle it.  It should be possible
2922
          // multicast routing protocol can handle it.  It should be possible
2860
          // to extend this to explicitly check whether it is a unicast
2923
          // to extend this to explicitly check whether it is a unicast
2861
          // packet, and invoke the error callback if so
2924
          // packet, and invoke the error callback if so
 Lines 2865-2876    Link Here 
2865
2928
2866
  // Forwarding
2929
  // Forwarding
2867
  Ptr<Ipv4Route> rtentry;
2930
  Ptr<Ipv4Route> rtentry;
2868
  RoutingTableEntry entry1, entry2; 
2931
  RoutingTableEntry entry1, entry2;
2869
  if (Lookup (header.GetDestination (), entry1))
2932
  if (Lookup (header.GetDestination (), entry1))
2870
    { 
2933
    {
2871
      bool foundSendEntry = FindSendEntry (entry1, entry2);
2934
      bool foundSendEntry = FindSendEntry (entry1, entry2);
2872
      if (!foundSendEntry)
2935
      if (!foundSendEntry)
2873
        NS_FATAL_ERROR ("FindSendEntry failure");
2936
        {
2937
          NS_FATAL_ERROR ("FindSendEntry failure");
2938
        }
2874
      rtentry = Create<Ipv4Route> ();
2939
      rtentry = Create<Ipv4Route> ();
2875
      rtentry->SetDestination (header.GetDestination ());
2940
      rtentry->SetDestination (header.GetDestination ());
2876
      uint32_t interfaceIdx = entry2.interface;
2941
      uint32_t interfaceIdx = entry2.interface;
 Lines 2881-2889    Link Here 
2881
      uint32_t numOifAddresses = m_ipv4->GetNAddresses (interfaceIdx);
2946
      uint32_t numOifAddresses = m_ipv4->GetNAddresses (interfaceIdx);
2882
      NS_ASSERT (numOifAddresses > 0);
2947
      NS_ASSERT (numOifAddresses > 0);
2883
      Ipv4InterfaceAddress ifAddr;
2948
      Ipv4InterfaceAddress ifAddr;
2884
      if (numOifAddresses == 1) {
2949
      if (numOifAddresses == 1)
2950
        {
2885
          ifAddr = m_ipv4->GetAddress (interfaceIdx, 0);
2951
          ifAddr = m_ipv4->GetAddress (interfaceIdx, 0);
2886
        } else {
2952
        }
2953
      else
2954
        {
2887
          /// \todo Implment IP aliasing and OLSR
2955
          /// \todo Implment IP aliasing and OLSR
2888
          NS_FATAL_ERROR ("XXX Not implemented yet:  IP aliasing and OLSR");
2956
          NS_FATAL_ERROR ("XXX Not implemented yet:  IP aliasing and OLSR");
2889
        }
2957
        }
 Lines 2901-2907    Link Here 
2901
    }
2969
    }
2902
  else
2970
  else
2903
    {
2971
    {
2904
      if(m_hnaRoutingTable->RouteInput (p, header, idev, ucb, mcb, lcb, ecb))
2972
      if (m_hnaRoutingTable->RouteInput (p, header, idev, ucb, mcb, lcb, ecb))
2905
        {
2973
        {
2906
          return true;
2974
          return true;
2907
        }
2975
        }
 Lines 2909-2915    Link Here 
2909
        {
2977
        {
2910
2978
2911
#ifdef NS3_LOG_ENABLE
2979
#ifdef NS3_LOG_ENABLE
2912
          NS_LOG_DEBUG ("Olsr node " << m_mainAddress 
2980
          NS_LOG_DEBUG ("Olsr node " << m_mainAddress
2913
                                     << ": RouteInput for dest=" << header.GetDestination ()
2981
                                     << ": RouteInput for dest=" << header.GetDestination ()
2914
                                     << " --> NOT FOUND; ** Dumping routing table...");
2982
                                     << " --> NOT FOUND; ** Dumping routing table...");
2915
2983
 Lines 2927-2944    Link Here 
2927
        }
2995
        }
2928
    }
2996
    }
2929
}
2997
}
2930
void 
2998
void
2931
RoutingProtocol::NotifyInterfaceUp (uint32_t i)
2999
RoutingProtocol::NotifyInterfaceUp (uint32_t i)
2932
{}
3000
{
2933
void 
3001
}
3002
void
2934
RoutingProtocol::NotifyInterfaceDown (uint32_t i)
3003
RoutingProtocol::NotifyInterfaceDown (uint32_t i)
2935
{}
3004
{
2936
void 
3005
}
3006
void
2937
RoutingProtocol::NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress address)
3007
RoutingProtocol::NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress address)
2938
{}
3008
{
2939
void 
3009
}
3010
void
2940
RoutingProtocol::NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress address)
3011
RoutingProtocol::NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress address)
2941
{}
3012
{
3013
}
2942
3014
2943
3015
2944
void
3016
void
 Lines 3040-3046    Link Here 
3040
       iter != m_state.GetTwoHopNeighbors ().end (); iter++)
3112
       iter != m_state.GetTwoHopNeighbors ().end (); iter++)
3041
    {
3113
    {
3042
      if (now < iter->expirationTime)
3114
      if (now < iter->expirationTime)
3043
        { 
3115
        {
3044
          NS_LOG_DEBUG ("  " << *iter);
3116
          NS_LOG_DEBUG ("  " << *iter);
3045
        }
3117
        }
3046
    }
3118
    }
(-)a/src/olsr/model/olsr-routing-protocol.h (-17 / +21 lines)
 Lines 51-57    Link Here 
51
51
52
///
52
///
53
/// \defgroup olsr OLSR Routing
53
/// \defgroup olsr OLSR Routing
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
/// \ingroup olsr
 Lines 64-71    Link Here 
64
  uint32_t distance; //!< Distance in hops to the destination.
64
  uint32_t distance; //!< Distance in hops to the destination.
65
65
66
  RoutingTableEntry () : // default values
66
  RoutingTableEntry () : // default values
67
                         destAddr (), nextAddr (),
67
    destAddr (), nextAddr (),
68
                         interface (0), distance (0) {};
68
    interface (0), distance (0)
69
  {
70
  }
69
};
71
};
70
72
71
class RoutingProtocol;
73
class RoutingProtocol;
 Lines 108-121    Link Here 
108
   */
110
   */
109
  std::vector<RoutingTableEntry> GetRoutingTableEntries () const;
111
  std::vector<RoutingTableEntry> GetRoutingTableEntries () const;
110
112
111
 /**
113
  /**
112
  * Assign a fixed random variable stream number to the random variables
114
   * Assign a fixed random variable stream number to the random variables
113
  * used by this model.  Return the number of streams (possibly zero) that
115
   * used by this model.  Return the number of streams (possibly zero) that
114
  * have been assigned.
116
   * have been assigned.
115
  *
117
   *
116
  * \param stream first stream index to use
118
   * \param stream first stream index to use
117
  * \return the number of stream indices assigned by this model
119
   * \return the number of stream indices assigned by this model
118
  */
120
   */
119
  int64_t AssignStreams (int64_t stream);
121
  int64_t AssignStreams (int64_t stream);
120
122
121
  /**
123
  /**
 Lines 124-131    Link Here 
124
   * \param [in] header
126
   * \param [in] header
125
   * \param [in] messages
127
   * \param [in] messages
126
   */
128
   */
127
  typedef void (* PacketTxRxTracedCallback)
129
  typedef void (* PacketTxRxTracedCallback)(const PacketHeader & header, const MessageList & messages);
128
    (const PacketHeader & header, const MessageList & messages);
129
130
130
  /**
131
  /**
131
   * TracedCallback signature for routing table computation.
132
   * TracedCallback signature for routing table computation.
 Lines 200-206    Link Here 
200
  Ptr<Ipv4StaticRouting> m_hnaRoutingTable; //!< Routing table for HNA routes
201
  Ptr<Ipv4StaticRouting> m_hnaRoutingTable; //!< Routing table for HNA routes
201
202
202
  EventGarbageCollector m_events; //!< Running events.
203
  EventGarbageCollector m_events; //!< Running events.
203
	
204
204
  uint16_t m_packetSequenceNumber;    //!< Packets sequence number counter.
205
  uint16_t m_packetSequenceNumber;    //!< Packets sequence number counter.
205
  uint16_t m_messageSequenceNumber;   //!< Messages sequence number counter.
206
  uint16_t m_messageSequenceNumber;   //!< Messages sequence number counter.
206
  uint16_t m_ansn;  //!< Advertised Neighbor Set sequence number.
207
  uint16_t m_ansn;  //!< Advertised Neighbor Set sequence number.
 Lines 223-229    Link Here 
223
   * Returns the routing table size.
224
   * Returns the routing table size.
224
   * \return The routing table size.
225
   * \return The routing table size.
225
   */
226
   */
226
  uint32_t GetSize () const { return m_table.size (); }
227
  uint32_t GetSize () const
228
  {
229
    return m_table.size ();
230
  }
227
231
228
  /**
232
  /**
229
   * \brief Deletes the entry whose destination address is given.
233
   * \brief Deletes the entry whose destination address is given.
 Lines 500-506    Link Here 
500
  /**
504
  /**
501
   * \brief Creates a new %OLSR HELLO message which is buffered for being sent later on.
505
   * \brief Creates a new %OLSR HELLO message which is buffered for being sent later on.
502
   */
506
   */
503
 void SendHello ();
507
  void SendHello ();
504
508
505
  /**
509
  /**
506
   * \brief Creates a new %OLSR TC message which is buffered for being sent later on.
510
   * \brief Creates a new %OLSR TC message which is buffered for being sent later on.
 Lines 763-769    Link Here 
763
  TracedCallback <uint32_t> m_routingTableChanged;
767
  TracedCallback <uint32_t> m_routingTableChanged;
764
768
765
  /// Provides uniform random variables.
769
  /// Provides uniform random variables.
766
  Ptr<UniformRandomVariable> m_uniformRandomVariable;  
770
  Ptr<UniformRandomVariable> m_uniformRandomVariable;
767
771
768
};
772
};
769
773
(-)a/src/olsr/model/olsr-state.cc (-20 / +49 lines)
 Lines 1-6    Link Here 
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
2
/*
3
 * Copyright (c) 2004 Francisco J. Ros 
3
 * Copyright (c) 2004 Francisco J. Ros
4
 * Copyright (c) 2007 INESC Porto
4
 * Copyright (c) 2007 INESC Porto
5
 *
5
 *
6
 * This program is free software; you can redistribute it and/or modify
6
 * This program is free software; you can redistribute it and/or modify
 Lines 41-47    Link Here 
41
       it != m_mprSelectorSet.end (); it++)
41
       it != m_mprSelectorSet.end (); it++)
42
    {
42
    {
43
      if (it->mainAddr == mainAddr)
43
      if (it->mainAddr == mainAddr)
44
        return &(*it);
44
        {
45
          return &(*it);
46
        }
45
    }
47
    }
46
  return NULL;
48
  return NULL;
47
}
49
}
 Lines 64-70    Link Here 
64
OlsrState::EraseMprSelectorTuples (const Ipv4Address &mainAddr)
66
OlsrState::EraseMprSelectorTuples (const Ipv4Address &mainAddr)
65
{
67
{
66
  for (MprSelectorSet::iterator it = m_mprSelectorSet.begin ();
68
  for (MprSelectorSet::iterator it = m_mprSelectorSet.begin ();
67
       it != m_mprSelectorSet.end ();)
69
       it != m_mprSelectorSet.end (); )
68
    {
70
    {
69
      if (it->mainAddr == mainAddr)
71
      if (it->mainAddr == mainAddr)
70
        {
72
        {
 Lines 95-101    Link Here 
95
      next++;
97
      next++;
96
      os << iter->mainAddr;
98
      os << iter->mainAddr;
97
      if (next != m_mprSelectorSet.end ())
99
      if (next != m_mprSelectorSet.end ())
98
        os << ", ";
100
        {
101
          os << ", ";
102
        }
99
    }
103
    }
100
  os << "]";
104
  os << "]";
101
  return os.str ();
105
  return os.str ();
 Lines 111-117    Link Here 
111
       it != m_neighborSet.end (); it++)
115
       it != m_neighborSet.end (); it++)
112
    {
116
    {
113
      if (it->neighborMainAddr == mainAddr)
117
      if (it->neighborMainAddr == mainAddr)
114
        return &(*it);
118
        {
119
          return &(*it);
120
        }
115
    }
121
    }
116
  return NULL;
122
  return NULL;
117
}
123
}
 Lines 123-129    Link Here 
123
       it != m_neighborSet.end (); it++)
129
       it != m_neighborSet.end (); it++)
124
    {
130
    {
125
      if (it->neighborMainAddr == mainAddr && it->status == NeighborTuple::STATUS_SYM)
131
      if (it->neighborMainAddr == mainAddr && it->status == NeighborTuple::STATUS_SYM)
126
        return &(*it);
132
        {
133
          return &(*it);
134
        }
127
    }
135
    }
128
  return NULL;
136
  return NULL;
129
}
137
}
 Lines 135-141    Link Here 
135
       it != m_neighborSet.end (); it++)
143
       it != m_neighborSet.end (); it++)
136
    {
144
    {
137
      if (it->neighborMainAddr == mainAddr && it->willingness == willingness)
145
      if (it->neighborMainAddr == mainAddr && it->willingness == willingness)
138
        return &(*it);
146
        {
147
          return &(*it);
148
        }
139
    }
149
    }
140
  return NULL;
150
  return NULL;
141
}
151
}
 Lines 221-227    Link Here 
221
                                      const Ipv4Address &twoHopNeighborAddr)
231
                                      const Ipv4Address &twoHopNeighborAddr)
222
{
232
{
223
  for (TwoHopNeighborSet::iterator it = m_twoHopNeighborSet.begin ();
233
  for (TwoHopNeighborSet::iterator it = m_twoHopNeighborSet.begin ();
224
       it != m_twoHopNeighborSet.end ();)
234
       it != m_twoHopNeighborSet.end (); )
225
    {
235
    {
226
      if (it->neighborMainAddr == neighborMainAddr
236
      if (it->neighborMainAddr == neighborMainAddr
227
          && it->twoHopNeighborAddr == twoHopNeighborAddr)
237
          && it->twoHopNeighborAddr == twoHopNeighborAddr)
 Lines 239-245    Link Here 
239
OlsrState::EraseTwoHopNeighborTuples (const Ipv4Address &neighborMainAddr)
249
OlsrState::EraseTwoHopNeighborTuples (const Ipv4Address &neighborMainAddr)
240
{
250
{
241
  for (TwoHopNeighborSet::iterator it = m_twoHopNeighborSet.begin ();
251
  for (TwoHopNeighborSet::iterator it = m_twoHopNeighborSet.begin ();
242
       it != m_twoHopNeighborSet.end ();)
252
       it != m_twoHopNeighborSet.end (); )
243
    {
253
    {
244
      if (it->neighborMainAddr == neighborMainAddr)
254
      if (it->neighborMainAddr == neighborMainAddr)
245
        {
255
        {
 Lines 287-293    Link Here 
287
       it != m_duplicateSet.end (); it++)
297
       it != m_duplicateSet.end (); it++)
288
    {
298
    {
289
      if (it->address == addr && it->sequenceNumber == sequenceNumber)
299
      if (it->address == addr && it->sequenceNumber == sequenceNumber)
290
        return &(*it);
300
        {
301
          return &(*it);
302
        }
291
    }
303
    }
292
  return NULL;
304
  return NULL;
293
}
305
}
 Lines 321-327    Link Here 
321
       it != m_linkSet.end (); it++)
333
       it != m_linkSet.end (); it++)
322
    {
334
    {
323
      if (it->neighborIfaceAddr == ifaceAddr)
335
      if (it->neighborIfaceAddr == ifaceAddr)
324
        return &(*it);
336
        {
337
          return &(*it);
338
        }
325
    }
339
    }
326
  return NULL;
340
  return NULL;
327
}
341
}
 Lines 335-343    Link Here 
335
      if (it->neighborIfaceAddr == ifaceAddr)
349
      if (it->neighborIfaceAddr == ifaceAddr)
336
        {
350
        {
337
          if (it->symTime > now)
351
          if (it->symTime > now)
338
            return &(*it);
352
            {
353
              return &(*it);
354
            }
339
          else
355
          else
340
            break;
356
            {
357
              break;
358
            }
341
        }
359
        }
342
    }
360
    }
343
  return NULL;
361
  return NULL;
 Lines 374-380    Link Here 
374
       it != m_topologySet.end (); it++)
392
       it != m_topologySet.end (); it++)
375
    {
393
    {
376
      if (it->destAddr == destAddr && it->lastAddr == lastAddr)
394
      if (it->destAddr == destAddr && it->lastAddr == lastAddr)
377
        return &(*it);
395
        {
396
          return &(*it);
397
        }
378
    }
398
    }
379
  return NULL;
399
  return NULL;
380
}
400
}
 Lines 386-392    Link Here 
386
       it != m_topologySet.end (); it++)
406
       it != m_topologySet.end (); it++)
387
    {
407
    {
388
      if (it->lastAddr == lastAddr && it->sequenceNumber > ansn)
408
      if (it->lastAddr == lastAddr && it->sequenceNumber > ansn)
389
        return &(*it);
409
        {
410
          return &(*it);
411
        }
390
    }
412
    }
391
  return NULL;
413
  return NULL;
392
}
414
}
 Lines 409-415    Link Here 
409
OlsrState::EraseOlderTopologyTuples (const Ipv4Address &lastAddr, uint16_t ansn)
431
OlsrState::EraseOlderTopologyTuples (const Ipv4Address &lastAddr, uint16_t ansn)
410
{
432
{
411
  for (TopologySet::iterator it = m_topologySet.begin ();
433
  for (TopologySet::iterator it = m_topologySet.begin ();
412
       it != m_topologySet.end ();)
434
       it != m_topologySet.end (); )
413
    {
435
    {
414
      if (it->lastAddr == lastAddr && it->sequenceNumber < ansn)
436
      if (it->lastAddr == lastAddr && it->sequenceNumber < ansn)
415
        {
437
        {
 Lines 437-443    Link Here 
437
       it != m_ifaceAssocSet.end (); it++)
459
       it != m_ifaceAssocSet.end (); it++)
438
    {
460
    {
439
      if (it->ifaceAddr == ifaceAddr)
461
      if (it->ifaceAddr == ifaceAddr)
440
        return &(*it);
462
        {
463
          return &(*it);
464
        }
441
    }
465
    }
442
  return NULL;
466
  return NULL;
443
}
467
}
 Lines 449-455    Link Here 
449
       it != m_ifaceAssocSet.end (); it++)
473
       it != m_ifaceAssocSet.end (); it++)
450
    {
474
    {
451
      if (it->ifaceAddr == ifaceAddr)
475
      if (it->ifaceAddr == ifaceAddr)
452
        return &(*it);
476
        {
477
          return &(*it);
478
        }
453
    }
479
    }
454
  return NULL;
480
  return NULL;
455
}
481
}
 Lines 482-488    Link Here 
482
       it != m_ifaceAssocSet.end (); it++)
508
       it != m_ifaceAssocSet.end (); it++)
483
    {
509
    {
484
      if (it->mainAddr == neighborMainAddr)
510
      if (it->mainAddr == neighborMainAddr)
485
        retval.push_back (it->ifaceAddr);
511
        {
512
          retval.push_back (it->ifaceAddr);
513
        }
486
    }
514
    }
487
  return retval;
515
  return retval;
488
}
516
}
 Lines 543-546    Link Here 
543
  m_associations.push_back (tuple);
571
  m_associations.push_back (tuple);
544
}
572
}
545
573
546
}} // namespace olsr, ns3
574
}
575
}  // namespace olsr, ns3
(-)a/src/olsr/model/olsr-state.h (-4 / +5 lines)
 Lines 1-6    Link Here 
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
2
/*
3
 * Copyright (c) 2004 Francisco J. Ros 
3
 * Copyright (c) 2004 Francisco J. Ros
4
 * Copyright (c) 2007 INESC Porto
4
 * Copyright (c) 2007 INESC Porto
5
 *
5
 *
6
 * This program is free software; you can redistribute it and/or modify
6
 * This program is free software; you can redistribute it and/or modify
 Lines 49-57    Link Here 
49
  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.
50
50
51
public:
51
public:
52
53
  OlsrState ()
52
  OlsrState ()
54
  {}
53
  {
54
  }
55
55
56
  // MPR selector
56
  // MPR selector
57
57
 Lines 430-435    Link Here 
430
430
431
};
431
};
432
432
433
}} // namespace olsr,ns3
433
}
434
}  // namespace olsr,ns3
434
435
435
#endif /* OLSR_STATE_H */
436
#endif /* OLSR_STATE_H */
(-)a/src/olsr/test/bug780-test.cc (-8 / +6 lines)
 Lines 17-23    Link Here 
17
17
18
// OLSR was observed to not converge in simple 3-nodes varying topology.
18
// OLSR was observed to not converge in simple 3-nodes varying topology.
19
// https://www.nsnam.org/bugzilla/show_bug.cgi?id=780
19
// https://www.nsnam.org/bugzilla/show_bug.cgi?id=780
20
// tcpdump -r bug780-0-0.pcap -nn -tt icmp | wc  
20
// tcpdump -r bug780-0-0.pcap -nn -tt icmp | wc
21
// should show about 395 packets; there is a ping outage from time
21
// should show about 395 packets; there is a ping outage from time
22
// 123-127 due to the mobility.
22
// 123-127 due to the mobility.
23
23
 Lines 40-57    Link Here 
40
#include "ns3/icmpv4.h"
40
#include "ns3/icmpv4.h"
41
#include "bug780-test.h"
41
#include "bug780-test.h"
42
42
43
namespace ns3
43
namespace ns3 {
44
{
44
namespace olsr {
45
namespace olsr
46
{
47
45
48
Bug780Test::Bug780Test() : 
46
Bug780Test::Bug780Test () :
49
  TestCase ("Test OLSR bug 780"),
47
  TestCase ("Test OLSR bug 780"),
50
  m_time (Seconds (200.0)), m_seq (0), m_recvCount (0)
48
  m_time (Seconds (200.0)), m_seq (0), m_recvCount (0)
51
{
49
{
52
}
50
}
53
51
54
Bug780Test::~Bug780Test()
52
Bug780Test::~Bug780Test ()
55
{
53
{
56
}
54
}
57
55
 Lines 162-168    Link Here 
162
      p->RemoveHeader (icmp);
160
      p->RemoveHeader (icmp);
163
      if (icmp.GetType () == Icmpv4Header::ECHO_REPLY)
161
      if (icmp.GetType () == Icmpv4Header::ECHO_REPLY)
164
        {
162
        {
165
          m_recvCount ++;
163
          m_recvCount++;
166
        }
164
        }
167
    }
165
    }
168
}
166
}
(-)a/src/olsr/test/bug780-test.h (-6 / +4 lines)
 Lines 23-37    Link Here 
23
#include "ns3/nstime.h"
23
#include "ns3/nstime.h"
24
#include "ns3/node-container.h"
24
#include "ns3/node-container.h"
25
25
26
namespace ns3
26
namespace ns3 {
27
{
27
namespace olsr {
28
namespace olsr
28
/** See \bugid{780} */
29
{
30
  /** See \bugid{780} */
31
class Bug780Test : public TestCase
29
class Bug780Test : public TestCase
32
{
30
{
33
public:
31
public:
34
  Bug780Test (); 
32
  Bug780Test ();
35
  ~Bug780Test ();
33
  ~Bug780Test ();
36
private:
34
private:
37
  /// Total simulation time
35
  /// Total simulation time
(-)a/src/olsr/test/hello-regression-test.cc (-10 / +8 lines)
 Lines 37-54    Link Here 
37
#include "ns3/udp-header.h"
37
#include "ns3/udp-header.h"
38
#include "ns3/olsr-header.h"
38
#include "ns3/olsr-header.h"
39
39
40
namespace ns3
40
namespace ns3 {
41
{
41
namespace olsr {
42
namespace olsr
43
{
44
42
45
HelloRegressionTest::HelloRegressionTest() : 
43
HelloRegressionTest::HelloRegressionTest () :
46
  TestCase ("Test OLSR Hello messages generation"),
44
  TestCase ("Test OLSR Hello messages generation"),
47
  m_time (Seconds (5)), m_countA (0), m_countB (0)
45
  m_time (Seconds (5)), m_countA (0), m_countB (0)
48
{
46
{
49
}
47
}
50
48
51
HelloRegressionTest::~HelloRegressionTest()
49
HelloRegressionTest::~HelloRegressionTest ()
52
{
50
{
53
}
51
}
54
52
 Lines 133-139    Link Here 
133
    }
131
    }
134
132
135
  std::vector<olsr::MessageHeader::Hello::LinkMessage>::const_iterator iter;
133
  std::vector<olsr::MessageHeader::Hello::LinkMessage>::const_iterator iter;
136
  for (iter = hello.linkMessages.begin (); iter != hello.linkMessages.end (); iter ++)
134
  for (iter = hello.linkMessages.begin (); iter != hello.linkMessages.end (); iter++)
137
    {
135
    {
138
      if (m_countA == 1)
136
      if (m_countA == 1)
139
        {
137
        {
 Lines 148-154    Link Here 
148
      NS_TEST_EXPECT_MSG_EQ (iter->neighborInterfaceAddresses[0], Ipv4Address ("10.1.1.1"), "Only one neighbor.");
146
      NS_TEST_EXPECT_MSG_EQ (iter->neighborInterfaceAddresses[0], Ipv4Address ("10.1.1.1"), "Only one neighbor.");
149
    }
147
    }
150
148
151
  m_countA ++;
149
  m_countA++;
152
}
150
}
153
151
154
void
152
void
 Lines 181-187    Link Here 
181
    }
179
    }
182
180
183
  std::vector<olsr::MessageHeader::Hello::LinkMessage>::const_iterator iter;
181
  std::vector<olsr::MessageHeader::Hello::LinkMessage>::const_iterator iter;
184
  for (iter = hello.linkMessages.begin (); iter != hello.linkMessages.end (); iter ++)
182
  for (iter = hello.linkMessages.begin (); iter != hello.linkMessages.end (); iter++)
185
    {
183
    {
186
      if (m_countA == 1)
184
      if (m_countA == 1)
187
        {
185
        {
 Lines 196-202    Link Here 
196
      NS_TEST_EXPECT_MSG_EQ (iter->neighborInterfaceAddresses[0], Ipv4Address ("10.1.1.2"), "Only one neighbor.");
194
      NS_TEST_EXPECT_MSG_EQ (iter->neighborInterfaceAddresses[0], Ipv4Address ("10.1.1.2"), "Only one neighbor.");
197
    }
195
    }
198
196
199
  m_countB ++;
197
  m_countB++;
200
}
198
}
201
199
202
}
200
}
(-)a/src/olsr/test/hello-regression-test.h (-9 / +7 lines)
 Lines 27-43    Link Here 
27
#include "ns3/ipv4-raw-socket-impl.h"
27
#include "ns3/ipv4-raw-socket-impl.h"
28
#include "ns3/node-container.h"
28
#include "ns3/node-container.h"
29
29
30
namespace ns3
30
namespace ns3 {
31
{
31
namespace olsr {
32
namespace olsr
33
{
34
/**
32
/**
35
 * \ingroup olsr
33
 * \ingroup olsr
36
 * \brief Trivial (still useful) test of OLSR operation
34
 * \brief Trivial (still useful) test of OLSR operation
37
 * 
35
 *
38
 * This test creates 2 stations with point-to-point link and runs OLSR without any extra traffic. 
36
 * This test creates 2 stations with point-to-point link and runs OLSR without any extra traffic.
39
 * It is expected that only HELLO messages will be sent.
37
 * It is expected that only HELLO messages will be sent.
40
 * 
38
 *
41
 * Expected trace (5 seconds):
39
 * Expected trace (5 seconds):
42
   \verbatim
40
   \verbatim
43
    1       2
41
    1       2
 Lines 47-58    Link Here 
47
    |<------|   HELLO (Link type: Asymmetric link, Neighbor address: 10.1.1.1) src = 10.1.1.2
45
    |<------|   HELLO (Link type: Asymmetric link, Neighbor address: 10.1.1.1) src = 10.1.1.2
48
    |------>|   HELLO (Link type: Symmetric link, Neighbor address: 10.1.1.2) src = 10.1.1.1
46
    |------>|   HELLO (Link type: Symmetric link, Neighbor address: 10.1.1.2) src = 10.1.1.1
49
    |<------|   HELLO (Link type: Symmetric link, Neighbor address: 10.1.1.1) src = 10.1.1.2
47
    |<------|   HELLO (Link type: Symmetric link, Neighbor address: 10.1.1.1) src = 10.1.1.2
50
   \endverbatim 
48
   \endverbatim
51
 */
49
 */
52
class HelloRegressionTest : public TestCase
50
class HelloRegressionTest : public TestCase
53
{
51
{
54
public:
52
public:
55
  HelloRegressionTest (); 
53
  HelloRegressionTest ();
56
  ~HelloRegressionTest ();
54
  ~HelloRegressionTest ();
57
private:
55
private:
58
  /// Total simulation time
56
  /// Total simulation time
(-)a/src/olsr/test/olsr-header-test-suite.cc (-6 / +11 lines)
 Lines 24-30    Link Here 
24
24
25
using namespace ns3;
25
using namespace ns3;
26
26
27
class OlsrEmfTestCase : public TestCase {
27
class OlsrEmfTestCase : public TestCase
28
{
28
public:
29
public:
29
  OlsrEmfTestCase ();
30
  OlsrEmfTestCase ();
30
  virtual void DoRun (void);
31
  virtual void DoRun (void);
 Lines 47-53    Link Here 
47
}
48
}
48
49
49
50
50
class OlsrMidTestCase : public TestCase {
51
class OlsrMidTestCase : public TestCase
52
{
51
public:
53
public:
52
  OlsrMidTestCase ();
54
  OlsrMidTestCase ();
53
  virtual void DoRun (void);
55
  virtual void DoRun (void);
 Lines 153-159    Link Here 
153
}
155
}
154
156
155
157
156
class OlsrHelloTestCase : public TestCase {
158
class OlsrHelloTestCase : public TestCase
159
{
157
public:
160
public:
158
  OlsrHelloTestCase ();
161
  OlsrHelloTestCase ();
159
  virtual void DoRun (void);
162
  virtual void DoRun (void);
 Lines 213-219    Link Here 
213
216
214
}
217
}
215
218
216
class OlsrTcTestCase : public TestCase {
219
class OlsrTcTestCase : public TestCase
220
{
217
public:
221
public:
218
  OlsrTcTestCase ();
222
  OlsrTcTestCase ();
219
  virtual void DoRun (void);
223
  virtual void DoRun (void);
 Lines 251-257    Link Here 
251
255
252
}
256
}
253
257
254
class OlsrHnaTestCase : public TestCase {
258
class OlsrHnaTestCase : public TestCase
259
{
255
public:
260
public:
256
  OlsrHnaTestCase ();
261
  OlsrHnaTestCase ();
257
  virtual void DoRun (void);
262
  virtual void DoRun (void);
 Lines 302-308    Link Here 
302
  OlsrTestSuite ();
307
  OlsrTestSuite ();
303
} g_olsrTestSuite;
308
} g_olsrTestSuite;
304
309
305
OlsrTestSuite::OlsrTestSuite()
310
OlsrTestSuite::OlsrTestSuite ()
306
  : TestSuite ("routing-olsr-header", UNIT)
311
  : TestSuite ("routing-olsr-header", UNIT)
307
{
312
{
308
  AddTestCase (new OlsrHnaTestCase (), TestCase::QUICK);
313
  AddTestCase (new OlsrHnaTestCase (), TestCase::QUICK);
(-)a/src/olsr/test/olsr-routing-protocol-test-suite.cc (-12 / +12 lines)
 Lines 1-6    Link Here 
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
2
/*
3
 * Copyright (c) 2004 Francisco J. Ros 
3
 * Copyright (c) 2004 Francisco J. Ros
4
 * Copyright (c) 2007 INESC Porto
4
 * Copyright (c) 2007 INESC Porto
5
 *
5
 *
6
 * This program is free software; you can redistribute it and/or modify
6
 * This program is free software; you can redistribute it and/or modify
 Lines 41-53    Link Here 
41
using namespace olsr;
41
using namespace olsr;
42
42
43
/// Testcase for MPR computation mechanism
43
/// Testcase for MPR computation mechanism
44
class OlsrMprTestCase : public TestCase {
44
class OlsrMprTestCase : public TestCase
45
{
45
public:
46
public:
46
  OlsrMprTestCase ();
47
  OlsrMprTestCase ();
47
  ~OlsrMprTestCase ();
48
  ~OlsrMprTestCase ();
48
  /// \brief Run test case
49
  /// \brief Run test case
49
  virtual void DoRun (void);
50
  virtual void DoRun (void);
50
  ;
51
};
51
};
52
52
53
53
 Lines 63-72    Link Here 
63
{
63
{
64
  Ptr<RoutingProtocol> protocol = CreateObject<RoutingProtocol> ();
64
  Ptr<RoutingProtocol> protocol = CreateObject<RoutingProtocol> ();
65
  protocol->m_mainAddress = Ipv4Address ("10.0.0.1");
65
  protocol->m_mainAddress = Ipv4Address ("10.0.0.1");
66
  OlsrState & state = protocol->m_state; 
66
  OlsrState & state = protocol->m_state;
67
 
67
68
  /*
68
  /*
69
   *  1 -- 2 
69
   *  1 -- 2
70
   *  |    |
70
   *  |    |
71
   *  3 -- 4
71
   *  3 -- 4
72
   *
72
   *
 Lines 78-84    Link Here 
78
  neigbor.neighborMainAddr = Ipv4Address ("10.0.0.2");
78
  neigbor.neighborMainAddr = Ipv4Address ("10.0.0.2");
79
  protocol->m_state.InsertNeighborTuple (neigbor);
79
  protocol->m_state.InsertNeighborTuple (neigbor);
80
  neigbor.neighborMainAddr = Ipv4Address ("10.0.0.3");
80
  neigbor.neighborMainAddr = Ipv4Address ("10.0.0.3");
81
  protocol->m_state.InsertNeighborTuple (neigbor); 
81
  protocol->m_state.InsertNeighborTuple (neigbor);
82
  TwoHopNeighborTuple tuple;
82
  TwoHopNeighborTuple tuple;
83
  tuple.expirationTime = Seconds (3600);
83
  tuple.expirationTime = Seconds (3600);
84
  tuple.neighborMainAddr = Ipv4Address ("10.0.0.2");
84
  tuple.neighborMainAddr = Ipv4Address ("10.0.0.2");
 Lines 91-97    Link Here 
91
  protocol->MprComputation ();
91
  protocol->MprComputation ();
92
  NS_TEST_EXPECT_MSG_EQ (state.GetMprSet ().size (), 1, "An only address must be chosen.");
92
  NS_TEST_EXPECT_MSG_EQ (state.GetMprSet ().size (), 1, "An only address must be chosen.");
93
  /*
93
  /*
94
   *  1 -- 2 -- 5 
94
   *  1 -- 2 -- 5
95
   *  |    |
95
   *  |    |
96
   *  3 -- 4
96
   *  3 -- 4
97
   *
97
   *
 Lines 106-112    Link Here 
106
  NS_TEST_EXPECT_MSG_EQ (mpr.size (), 1, "An only address must be chosen.");
106
  NS_TEST_EXPECT_MSG_EQ (mpr.size (), 1, "An only address must be chosen.");
107
  NS_TEST_EXPECT_MSG_EQ ((mpr.find ("10.0.0.2") != mpr.end ()), true, "Node 1 must select node 2 as MPR");
107
  NS_TEST_EXPECT_MSG_EQ ((mpr.find ("10.0.0.2") != mpr.end ()), true, "Node 1 must select node 2 as MPR");
108
  /*
108
  /*
109
   *  1 -- 2 -- 5 
109
   *  1 -- 2 -- 5
110
   *  |    |
110
   *  |    |
111
   *  3 -- 4
111
   *  3 -- 4
112
   *  |
112
   *  |
 Lines 126-132    Link Here 
126
  /*
126
  /*
127
   *  7 (OLSR_WILL_ALWAYS)
127
   *  7 (OLSR_WILL_ALWAYS)
128
   *  |
128
   *  |
129
   *  1 -- 2 -- 5 
129
   *  1 -- 2 -- 5
130
   *  |    |
130
   *  |    |
131
   *  3 -- 4
131
   *  3 -- 4
132
   *  |
132
   *  |
 Lines 145-151    Link Here 
145
  /*
145
  /*
146
   *                7 <- WILL_ALWAYS
146
   *                7 <- WILL_ALWAYS
147
   *                |
147
   *                |
148
   *      9 -- 8 -- 1 -- 2 -- 5 
148
   *      9 -- 8 -- 1 -- 2 -- 5
149
   *                |    |
149
   *                |    |
150
   *           ^    3 -- 4
150
   *           ^    3 -- 4
151
   *           |    |
151
   *           |    |
 Lines 173-179    Link Here 
173
  OlsrProtocolTestSuite ();
173
  OlsrProtocolTestSuite ();
174
} g_olsrProtocolTestSuite;
174
} g_olsrProtocolTestSuite;
175
175
176
OlsrProtocolTestSuite::OlsrProtocolTestSuite()
176
OlsrProtocolTestSuite::OlsrProtocolTestSuite ()
177
  : TestSuite ("routing-olsr", UNIT)
177
  : TestSuite ("routing-olsr", UNIT)
178
{
178
{
179
  AddTestCase (new OlsrMprTestCase (), TestCase::QUICK);
179
  AddTestCase (new OlsrMprTestCase (), TestCase::QUICK);
(-)a/src/olsr/test/regression-test-suite.cc (-1 / +1 lines)
 Lines 28-34    Link Here 
28
class RegressionTestSuite : public TestSuite
28
class RegressionTestSuite : public TestSuite
29
{
29
{
30
public:
30
public:
31
  RegressionTestSuite () : TestSuite ("routing-olsr-regression", SYSTEM) 
31
  RegressionTestSuite () : TestSuite ("routing-olsr-regression", SYSTEM)
32
  {
32
  {
33
    SetDataDir (NS_TEST_SOURCEDIR);
33
    SetDataDir (NS_TEST_SOURCEDIR);
34
    AddTestCase (new HelloRegressionTest, TestCase::QUICK);
34
    AddTestCase (new HelloRegressionTest, TestCase::QUICK);
(-)a/src/olsr/test/tc-regression-test.cc (-11 / +9 lines)
 Lines 38-56    Link Here 
38
#include "ns3/simple-net-device-helper.h"
38
#include "ns3/simple-net-device-helper.h"
39
#include "ns3/simple-net-device.h"
39
#include "ns3/simple-net-device.h"
40
40
41
namespace ns3
41
namespace ns3 {
42
{
42
namespace olsr {
43
namespace olsr
44
{
45
43
46
TcRegressionTest::TcRegressionTest() : 
44
TcRegressionTest::TcRegressionTest () :
47
  TestCase ("Test OLSR Topology Control message generation"),
45
  TestCase ("Test OLSR Topology Control message generation"),
48
  m_time (Seconds (20)),
46
  m_time (Seconds (20)),
49
  m_countA (0), m_countB (0), m_countC (0)
47
  m_countA (0), m_countB (0), m_countC (0)
50
{
48
{
51
}
49
}
52
50
53
TcRegressionTest::~TcRegressionTest()
51
TcRegressionTest::~TcRegressionTest ()
54
{
52
{
55
}
53
}
56
54
 Lines 185-191    Link Here 
185
          NS_TEST_EXPECT_MSG_EQ (hello.linkMessages[1].neighborInterfaceAddresses[0], Ipv4Address ("10.1.1.1"), int(m_countA) << " - Neighbor.");
183
          NS_TEST_EXPECT_MSG_EQ (hello.linkMessages[1].neighborInterfaceAddresses[0], Ipv4Address ("10.1.1.1"), int(m_countA) << " - Neighbor.");
186
        }
184
        }
187
    }
185
    }
188
  m_countA ++;
186
  m_countA++;
189
}
187
}
190
188
191
void
189
void
 Lines 207-214    Link Here 
207
  receivedPacketProbe->RemoveHeader (msgHdr);
205
  receivedPacketProbe->RemoveHeader (msgHdr);
208
  const olsr::MessageHeader::Hello &hello = msgHdr.GetHello ();
206
  const olsr::MessageHeader::Hello &hello = msgHdr.GetHello ();
209
207
210
  if (m_countB == 0 || m_countB == 2 || m_countB == 5 || m_countB == 6 || m_countB == 8 ||
208
  if (m_countB == 0 || m_countB == 2 || m_countB == 5 || m_countB == 6 || m_countB == 8
211
      m_countB == 10 || m_countB == 13 || m_countB == 15 || m_countB == 17 || m_countB == 19)
209
      || m_countB == 10 || m_countB == 13 || m_countB == 15 || m_countB == 17 || m_countB == 19)
212
    {
210
    {
213
      NS_TEST_EXPECT_MSG_EQ (msgHdr.GetOriginatorAddress (), Ipv4Address ("10.1.1.3"), "Originator address.");
211
      NS_TEST_EXPECT_MSG_EQ (msgHdr.GetOriginatorAddress (), Ipv4Address ("10.1.1.3"), "Originator address.");
214
    }
212
    }
 Lines 240-246    Link Here 
240
      NS_TEST_EXPECT_MSG_EQ (hello.linkMessages[0].neighborInterfaceAddresses[0], Ipv4Address ("10.1.1.2"), int(m_countC) << " - Neighbor.");
238
      NS_TEST_EXPECT_MSG_EQ (hello.linkMessages[0].neighborInterfaceAddresses[0], Ipv4Address ("10.1.1.2"), int(m_countC) << " - Neighbor.");
241
    }
239
    }
242
240
243
  m_countB ++;
241
  m_countB++;
244
}
242
}
245
243
246
// Note: this is identical to ReceivePktProbeA, but the packet counter needs to be different.
244
// Note: this is identical to ReceivePktProbeA, but the packet counter needs to be different.
 Lines 308-314    Link Here 
308
          NS_TEST_EXPECT_MSG_EQ (hello.linkMessages[1].neighborInterfaceAddresses[0], Ipv4Address ("10.1.1.1"), int(m_countC) << " - Neighbor.");
306
          NS_TEST_EXPECT_MSG_EQ (hello.linkMessages[1].neighborInterfaceAddresses[0], Ipv4Address ("10.1.1.1"), int(m_countC) << " - Neighbor.");
309
        }
307
        }
310
    }
308
    }
311
  m_countC ++;
309
  m_countC++;
312
}
310
}
313
311
314
}
312
}
(-)a/src/olsr/test/tc-regression-test.h (-9 / +7 lines)
 Lines 27-43    Link Here 
27
#include "ns3/ipv4-raw-socket-impl.h"
27
#include "ns3/ipv4-raw-socket-impl.h"
28
#include "ns3/node-container.h"
28
#include "ns3/node-container.h"
29
29
30
namespace ns3
30
namespace ns3 {
31
{
31
namespace olsr {
32
namespace olsr
33
{
34
/**
32
/**
35
 * \ingroup olsr
33
 * \ingroup olsr
36
 * \brief Less trivial test of OLSR Topology Control message generation
34
 * \brief Less trivial test of OLSR Topology Control message generation
37
 * 
35
 *
38
 * This test simulates 3 Wi-Fi stations with chain topology and runs OLSR without any extra traffic.
36
 * This test simulates 3 Wi-Fi stations with chain topology and runs OLSR without any extra traffic.
39
 * It is expected that only second station will send TC messages.
37
 * It is expected that only second station will send TC messages.
40
 * 
38
 *
41
 * Expected trace (20 seconds, note random b-cast jitter):
39
 * Expected trace (20 seconds, note random b-cast jitter):
42
   \verbatim
40
   \verbatim
43
         1       2       3
41
         1       2       3
 Lines 72-84    Link Here 
72
  <------|------>|       |              HELLO (Link Type: MPR Link, Neighbor: 10.1.1.2) src = 10.1.1.1
70
  <------|------>|       |              HELLO (Link Type: MPR Link, Neighbor: 10.1.1.2) src = 10.1.1.1
73
         |       |<------|------>       HELLO (Link Type: MPR Link, Neighbor: 10.1.1.2) src = 10.1.1.3
71
         |       |<------|------>       HELLO (Link Type: MPR Link, Neighbor: 10.1.1.2) src = 10.1.1.3
74
         |<------|------>|              HELLO (Link Type: Symmetric, Neighbor: 10.1.1.3; Link Type: Symmetric, Neighbor: 10.1.1.1) src = 10.1.1.2
72
         |<------|------>|              HELLO (Link Type: Symmetric, Neighbor: 10.1.1.3; Link Type: Symmetric, Neighbor: 10.1.1.1) src = 10.1.1.2
75
   \endverbatim 
73
   \endverbatim
76
 */
74
 */
77
class TcRegressionTest : public TestCase
75
class TcRegressionTest : public TestCase
78
{
76
{
79
public:
77
public:
80
  TcRegressionTest(); 
78
  TcRegressionTest ();
81
  ~TcRegressionTest();
79
  ~TcRegressionTest ();
82
private:
80
private:
83
  /// Total simulation time
81
  /// Total simulation time
84
  const Time m_time;
82
  const Time m_time;

Return to bug 938