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

(-)a/src/olsr/test/bug780-test.cc (-114 / +82 lines)
 Lines 21-52    Link Here 
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
24
#include <fstream>
25
#include <iostream>
26
27
#include "ns3/test.h"
24
#include "ns3/test.h"
28
#include "ns3/olsr-helper.h"
25
#include "ns3/olsr-helper.h"
29
#include "ns3/ipv4-list-routing-helper.h"
26
#include "ns3/ipv4-list-routing-helper.h"
30
#include "ns3/wifi-helper.h"
31
#include "ns3/yans-wifi-helper.h"
32
#include "ns3/nqos-wifi-mac-helper.h"
33
#include "ns3/constant-velocity-mobility-model.h"
34
#include "ns3/mobility-helper.h"
35
#include "ns3/olsr-routing-protocol.h"
27
#include "ns3/olsr-routing-protocol.h"
36
#include "ns3/internet-stack-helper.h"
28
#include "ns3/internet-stack-helper.h"
37
#include "ns3/log.h"
29
#include "ns3/log.h"
38
#include "ns3/config.h"
39
#include "ns3/double.h"
30
#include "ns3/double.h"
31
#include "ns3/uinteger.h"
40
#include "ns3/string.h"
32
#include "ns3/string.h"
41
#include "ns3/boolean.h"
33
#include "ns3/boolean.h"
42
#include "ns3/ipv4-address-helper.h"
34
#include "ns3/ipv4-address-helper.h"
43
#include "ns3/ipv4-interface-container.h"
35
#include "ns3/ipv4-interface-container.h"
44
#include "ns3/internet-stack-helper.h"
36
#include "ns3/internet-stack-helper.h"
45
#include "ns3/v4ping-helper.h"
46
#include "ns3/pcap-file.h"
47
#include "ns3/pcap-test.h"
48
#include "ns3/rng-seed-manager.h"
37
#include "ns3/rng-seed-manager.h"
49
38
#include "ns3/simple-net-device-helper.h"
39
#include "ns3/simple-net-device.h"
40
#include "ns3/icmpv4.h"
50
#include "bug780-test.h"
41
#include "bug780-test.h"
51
42
52
namespace ns3
43
namespace ns3
 Lines 54-73    Link Here 
54
namespace olsr
45
namespace olsr
55
{
46
{
56
47
57
const char * const Bug780Test::PREFIX = "bug780";
58
59
static void
60
SetVelocity (Ptr<Node> node, Vector vel)
61
{
62
  Ptr<ConstantVelocityMobilityModel> mobility =
63
    node->GetObject<ConstantVelocityMobilityModel> ();
64
  mobility->SetVelocity (vel);
65
}
66
67
68
Bug780Test::Bug780Test() : 
48
Bug780Test::Bug780Test() : 
69
  TestCase ("Test OLSR bug 780"),
49
  TestCase ("Test OLSR bug 780"),
70
  m_time (Seconds (200.0))
50
  m_time (Seconds (200.0)), m_seq (0), m_recvCount (0)
71
{
51
{
72
}
52
}
73
53
 Lines 84-201    Link Here 
84
64
85
  Simulator::Stop (m_time);
65
  Simulator::Stop (m_time);
86
  Simulator::Run ();
66
  Simulator::Run ();
67
68
  NS_TEST_EXPECT_MSG_EQ (m_recvCount, 192, "192 out of 200 ping received.");
69
87
  Simulator::Destroy ();
70
  Simulator::Destroy ();
88
89
  CheckResults ();  
90
}
71
}
91
72
92
void
73
void
93
Bug780Test::CreateNodes (void)
74
Bug780Test::CreateNodes (void)
94
{
75
{
95
  int nWifis = 3;
76
  NodeContainer c;
96
  double SimTime = 200.0;
77
  c.Create (3);
97
  std::string phyMode ("DsssRate1Mbps");
98
  int64_t streamsUsed = 0;
99
78
100
  //sending one packets per sec
79
  // install TCP/IP & OLSR
101
  // Fix non-unicast data rate to be the same as that of unicast
102
  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold",
103
                      StringValue ("400"));
104
105
  NodeContainer adhocNodes;
106
  adhocNodes.Create (nWifis);
107
108
  WifiHelper wifi;
109
  YansWifiPhyHelper wifiPhy =  YansWifiPhyHelper::Default ();
110
  YansWifiChannelHelper wifiChannel;
111
  wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
112
  wifiChannel.AddPropagationLoss ("ns3::FriisPropagationLossModel");
113
  Ptr<YansWifiChannel> chan = wifiChannel.Create ();
114
  wifiPhy.SetChannel (chan);
115
116
  // Add a non-QoS upper mac, and disable rate control
117
  NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
118
  wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
119
  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
120
                                "DataMode",StringValue (phyMode),
121
                                "ControlMode",StringValue (phyMode));
122
123
  //set the tx range to 300
124
  wifiPhy.Set ("TxPowerStart",DoubleValue (-0.1615));
125
  wifiPhy.Set ("TxPowerEnd", DoubleValue (-0.1615));
126
127
  // Set it to adhoc mode
128
  wifiMac.SetType ("ns3::AdhocWifiMac");
129
  NetDeviceContainer adhocDevices = wifi.Install (wifiPhy, wifiMac, adhocNodes);
130
131
  // Assign fixed stream numbers to wifi and channel random variables
132
  streamsUsed += wifi.AssignStreams (adhocDevices, streamsUsed);
133
  // Assign 6 streams per Wifi device
134
  NS_TEST_ASSERT_MSG_EQ (streamsUsed, (adhocDevices.GetN () * 6), "Stream assignment mismatch");
135
  streamsUsed += wifiChannel.AssignStreams (chan, streamsUsed);
136
  // Assign 0 additional streams per channel for this configuration 
137
  NS_TEST_ASSERT_MSG_EQ (streamsUsed, (adhocDevices.GetN () * 6), "Stream assignment mismatch");
138
139
  OlsrHelper olsr;
80
  OlsrHelper olsr;
140
141
  InternetStackHelper internet;
81
  InternetStackHelper internet;
142
  internet.SetRoutingHelper (olsr);
82
  internet.SetRoutingHelper (olsr);
143
  internet.Install (adhocNodes);
83
  internet.Install (c);
144
  // Assign 3 streams per node to internet stack for this configuration
84
  int64_t streamsUsed = olsr.AssignStreams (c, 0);
145
  streamsUsed += internet.AssignStreams (adhocNodes, streamsUsed);
85
  NS_TEST_EXPECT_MSG_EQ (streamsUsed, 3, "Should have assigned 3 streams");
146
  NS_TEST_ASSERT_MSG_EQ (streamsUsed, (adhocDevices.GetN () * 6) + (adhocNodes.GetN () * 3), "Stream assignment mismatch");
86
147
  // Olsr uses one additional stream per wifi device for this configuration
87
  // create channel & devices
148
  streamsUsed += olsr.AssignStreams (adhocNodes, 0);
88
  SimpleNetDeviceHelper simpleNetHelper;
149
  NS_TEST_ASSERT_MSG_EQ (streamsUsed, ((adhocDevices.GetN () * 6) + (adhocDevices.GetN () * 3) + nWifis), "Should have assigned 3 streams");
89
  simpleNetHelper.SetDeviceAttribute ("DataRate", StringValue ("10Mbps"));
90
  simpleNetHelper.SetChannelAttribute ("Delay", StringValue ("2ms"));
91
  NetDeviceContainer nd = simpleNetHelper.Install (c);
150
92
151
  Ipv4AddressHelper addressAdhoc;
93
  Ipv4AddressHelper addressAdhoc;
152
  addressAdhoc.SetBase ("10.1.1.0", "255.255.255.0");
94
  addressAdhoc.SetBase ("10.1.1.0", "255.255.255.0");
153
  Ipv4InterfaceContainer adhocInterfaces;
95
  Ipv4InterfaceContainer adhocInterfaces;
154
  adhocInterfaces = addressAdhoc.Assign (adhocDevices);
96
  adhocInterfaces = addressAdhoc.Assign (nd);
155
97
156
  MobilityHelper mobilityAdhoc;
98
  // Blacklist some devices (equivalent to Wireless out of range)
99
  Ptr<SimpleNetDevice> nd0 = DynamicCast<SimpleNetDevice> (nd.Get (0));
100
  Ptr<SimpleNetDevice> nd2 = DynamicCast<SimpleNetDevice> (nd.Get (2));
101
  Ptr<SimpleChannel> ch = DynamicCast<SimpleChannel> (nd.Get (0)->GetChannel ());
157
102
158
  Ptr<ListPositionAllocator> positionAlloc_Adhoc =
103
  Simulator::Schedule (Seconds (100.0), &SimpleChannel::BlackList, ch, nd0, nd2);
159
    CreateObject<ListPositionAllocator>();
104
  Simulator::Schedule (Seconds (100.0), &SimpleChannel::BlackList, ch, nd2, nd0);
160
  double distance = 0.0;
161
  for (uint32_t i = 0; i <= adhocNodes.GetN (); i++)
162
    {
163
      positionAlloc_Adhoc->Add (Vector (distance,0.0,0.0));
164
      distance += 250.0;
165
    }
166
105
167
  mobilityAdhoc.SetMobilityModel ("ns3::ConstantVelocityMobilityModel");
106
  // 3. Setup ping
168
  mobilityAdhoc.SetPositionAllocator (positionAlloc_Adhoc);
107
  m_socket = Socket::CreateSocket (c.Get (0), TypeId::LookupByName ("ns3::Ipv4RawSocketFactory"));
169
  mobilityAdhoc.Install (adhocNodes);
108
  m_socket->SetAttribute ("Protocol", UintegerValue (1)); // icmp
109
  m_socket->SetRecvCallback (MakeCallback (&Bug780Test::Receive, this));
110
  InetSocketAddress src = InetSocketAddress (Ipv4Address::GetAny (), 0);
111
  m_socket->Bind (src);
112
  InetSocketAddress dst = InetSocketAddress (adhocInterfaces.GetAddress (2), 0);
113
  m_socket->Connect (dst);
170
114
171
  //At 50 sec node 3 moves towards node 2
115
  SendPing ();
172
  Simulator::Schedule (Seconds (50.0), &SetVelocity, adhocNodes.Get (2),Vector (-5.0,0.0,0.0));
173
  //AT 100 sec set node 3 with zero velocity
174
  Simulator::Schedule (Seconds (100.0), &SetVelocity, adhocNodes.Get (2),Vector (0.0,0.0,0.0));
175
  //Move node2 away from node 3
176
  Simulator::Schedule (Seconds (100.0), &SetVelocity, adhocNodes.Get (1),Vector (5.0,0.0,0.0));
177
  //AT 150 sec set node 2 with zero velocity
178
  Simulator::Schedule (Seconds (150.0), &SetVelocity, adhocNodes.Get (1), Vector (0.0,0.0,0.0));
179
180
181
  // Ping 10.1.1.1 -> 10.1.1.2
182
  V4PingHelper ping (adhocInterfaces.GetAddress (1));
183
  ping.SetAttribute ("Verbose", BooleanValue (true));
184
185
  ApplicationContainer p = ping.Install (adhocNodes.Get (0));
186
  p.Start (Seconds (50));
187
  p.Stop (Seconds (SimTime) - Seconds (0.001));
188
189
  // pcap
190
  wifiPhy.EnablePcapAll (CreateTempDirFilename (PREFIX));
191
}
116
}
192
117
193
void
118
void
194
Bug780Test::CheckResults ()
119
Bug780Test::SendPing ()
195
{
120
{
196
  for (uint32_t i = 0; i < 2; ++i)
121
  if (Simulator::Now () >= m_time)
197
    {
122
    {
198
      NS_PCAP_TEST_EXPECT_EQ (PREFIX << "-" << i << "-0.pcap");
123
      return;
124
    }
125
126
  Ptr<Packet> p = Create<Packet> ();
127
  Icmpv4Echo echo;
128
  echo.SetSequenceNumber (m_seq);
129
  m_seq++;
130
  echo.SetIdentifier (0);
131
132
  Ptr<Packet> dataPacket = Create<Packet> (56);
133
  echo.SetData (dataPacket);
134
  p->AddHeader (echo);
135
  Icmpv4Header header;
136
  header.SetType (Icmpv4Header::ECHO);
137
  header.SetCode (0);
138
  if (Node::ChecksumEnabled ())
139
    {
140
      header.EnableChecksum ();
141
    }
142
  p->AddHeader (header);
143
  m_socket->Send (p, 0);
144
  Simulator::Schedule (Seconds (1), &Bug780Test::SendPing, this);
145
}
146
147
void
148
Bug780Test::Receive (Ptr<Socket> socket)
149
{
150
  while (m_socket->GetRxAvailable () > 0)
151
    {
152
      Address from;
153
      Ptr<Packet> p = m_socket->RecvFrom (0xffffffff, 0, from);
154
155
      NS_ASSERT (InetSocketAddress::IsMatchingType (from));
156
      InetSocketAddress realFrom = InetSocketAddress::ConvertFrom (from);
157
      NS_ASSERT (realFrom.GetPort () == 1); // protocol should be icmp.
158
      Ipv4Header ipv4;
159
      p->RemoveHeader (ipv4);
160
      NS_ASSERT (ipv4.GetProtocol () == 1); // protocol should be icmp.
161
      Icmpv4Header icmp;
162
      p->RemoveHeader (icmp);
163
      if (icmp.GetType () == Icmpv4Header::ECHO_REPLY)
164
        {
165
          m_recvCount ++;
166
        }
199
    }
167
    }
200
}
168
}
201
169
(-)a/src/olsr/test/bug780-test.h (-4 / +11 lines)
 Lines 34-49    Link Here 
34
  Bug780Test (); 
34
  Bug780Test (); 
35
  ~Bug780Test ();
35
  ~Bug780Test ();
36
private:
36
private:
37
  /// Unique PCAP files prefix for this test
38
  static const char * const PREFIX;
39
  /// Total simulation time
37
  /// Total simulation time
40
  const Time m_time;
38
  const Time m_time;
41
  /// Create & configure test network
39
  /// Create & configure test network
42
  void CreateNodes ();
40
  void CreateNodes ();
43
  /// Compare traces with reference ones
44
  void CheckResults ();
45
  /// Go
41
  /// Go
46
  void DoRun ();
42
  void DoRun ();
43
  /// Send one ping
44
  void SendPing ();
45
  /// Receive echo reply
46
  /// \param socket the socket
47
  void Receive (Ptr<Socket> socket);
48
  /// Socket
49
  Ptr<Socket> m_socket;
50
  /// Sequence number
51
  uint16_t m_seq;
52
  /// Received ECHO Reply counter
53
  uint16_t m_recvCount;
47
};
54
};
48
55
49
}
56
}
(-)a/src/olsr/test/hello-regression-test.cc (-18 / +117 lines)
 Lines 18-23    Link Here 
18
 * Authors: Pavel Boyko <boyko@iitp.ru>
18
 * Authors: Pavel Boyko <boyko@iitp.ru>
19
 */
19
 */
20
20
21
#include <vector>
21
#include "hello-regression-test.h"
22
#include "hello-regression-test.h"
22
#include "ns3/simulator.h"
23
#include "ns3/simulator.h"
23
#include "ns3/random-variable-stream.h"
24
#include "ns3/random-variable-stream.h"
 Lines 25-48    Link Here 
25
#include "ns3/double.h"
26
#include "ns3/double.h"
26
#include "ns3/uinteger.h"
27
#include "ns3/uinteger.h"
27
#include "ns3/string.h"
28
#include "ns3/string.h"
28
#include "ns3/pcap-file.h"
29
#include "ns3/olsr-helper.h"
29
#include "ns3/olsr-helper.h"
30
#include "ns3/internet-stack-helper.h"
30
#include "ns3/internet-stack-helper.h"
31
#include "ns3/point-to-point-helper.h"
31
#include "ns3/simple-net-device-helper.h"
32
#include "ns3/ipv4-address-helper.h"
32
#include "ns3/ipv4-address-helper.h"
33
#include "ns3/abort.h"
33
#include "ns3/abort.h"
34
#include "ns3/pcap-test.h"
34
#include "ns3/socket-factory.h"
35
#include "ns3/ipv4-raw-socket-factory.h"
36
#include "ns3/udp-l4-protocol.h"
37
#include "ns3/udp-header.h"
38
#include "ns3/olsr-header.h"
35
39
36
namespace ns3
40
namespace ns3
37
{
41
{
38
namespace olsr
42
namespace olsr
39
{
43
{
40
44
41
const char * const HelloRegressionTest::PREFIX = "olsr-hello-regression-test";
42
43
HelloRegressionTest::HelloRegressionTest() : 
45
HelloRegressionTest::HelloRegressionTest() : 
44
  TestCase ("Test OLSR Hello messages generation"),
46
  TestCase ("Test OLSR Hello messages generation"),
45
  m_time (Seconds (5))
47
  m_time (Seconds (5)), m_countA (0), m_countB (0)
46
{
48
{
47
}
49
}
48
50
 Lines 59-67    Link Here 
59
61
60
  Simulator::Stop (m_time);
62
  Simulator::Stop (m_time);
61
  Simulator::Run ();
63
  Simulator::Run ();
64
65
  m_rxSocketA = 0;
66
  m_rxSocketB = 0;
62
  Simulator::Destroy ();
67
  Simulator::Destroy ();
63
64
  CheckResults ();
65
}
68
}
66
69
67
void
70
void
 Lines 78-103    Link Here 
78
  // Assign OLSR RVs to specific streams
81
  // Assign OLSR RVs to specific streams
79
  int64_t streamsUsed = olsr.AssignStreams (c, 0);
82
  int64_t streamsUsed = olsr.AssignStreams (c, 0);
80
  NS_TEST_ASSERT_MSG_EQ (streamsUsed, 2, "Should have assigned 2 streams");
83
  NS_TEST_ASSERT_MSG_EQ (streamsUsed, 2, "Should have assigned 2 streams");
81
  // create p2p channel & devices
84
  // create channel & devices
82
  PointToPointHelper p2p;
85
  SimpleNetDeviceHelper simpleNetHelper;
83
  p2p.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
86
  simpleNetHelper.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
84
  p2p.SetChannelAttribute ("Delay", StringValue ("2ms"));
87
  simpleNetHelper.SetChannelAttribute ("Delay", StringValue ("2ms"));
85
  NetDeviceContainer nd = p2p.Install (c);
88
  NetDeviceContainer nd = simpleNetHelper.Install (c);
86
  // setup IP addresses
89
  // setup IP addresses
87
  Ipv4AddressHelper ipv4;
90
  Ipv4AddressHelper ipv4;
88
  ipv4.SetBase ("10.1.1.0", "255.255.255.0");
91
  ipv4.SetBase ("10.1.1.0", "255.255.255.0");
89
  ipv4.Assign (nd);
92
  ipv4.Assign (nd);
90
  // setup PCAP traces
93
91
  p2p.EnablePcapAll (CreateTempDirFilename (PREFIX));
94
  // Create the sockets
95
  Ptr<SocketFactory> rxSocketFactoryA = c.Get (0)->GetObject<Ipv4RawSocketFactory> ();
96
  m_rxSocketA = DynamicCast<Ipv4RawSocketImpl> (rxSocketFactoryA->CreateSocket ());
97
  m_rxSocketA->SetProtocol (UdpL4Protocol::PROT_NUMBER);
98
  m_rxSocketA->SetRecvCallback (MakeCallback (&HelloRegressionTest::ReceivePktProbeA, this));
99
100
  Ptr<SocketFactory> rxSocketFactoryB = c.Get (1)->GetObject<Ipv4RawSocketFactory> ();
101
  m_rxSocketB = DynamicCast<Ipv4RawSocketImpl> (rxSocketFactoryB->CreateSocket ());
102
  m_rxSocketB->SetProtocol (UdpL4Protocol::PROT_NUMBER);
103
  m_rxSocketB->SetRecvCallback (MakeCallback (&HelloRegressionTest::ReceivePktProbeB, this));
92
}
104
}
93
105
94
void
106
void
95
HelloRegressionTest::CheckResults ()
107
HelloRegressionTest::ReceivePktProbeA (Ptr<Socket> socket)
96
{
108
{
97
  for (uint32_t i = 0; i < 2; ++i)
109
  uint32_t availableData;
110
  availableData = socket->GetRxAvailable ();
111
  Ptr<Packet> receivedPacketProbe = socket->Recv (std::numeric_limits<uint32_t>::max (), 0);
112
  NS_ASSERT (availableData == receivedPacketProbe->GetSize ());
113
114
  Ipv4Header ipHdr;
115
  receivedPacketProbe->RemoveHeader (ipHdr);
116
  UdpHeader udpHdr;
117
  receivedPacketProbe->RemoveHeader (udpHdr);
118
  PacketHeader pktHdr;
119
  receivedPacketProbe->RemoveHeader (pktHdr);
120
  MessageHeader msgHdr;
121
  receivedPacketProbe->RemoveHeader (msgHdr);
122
123
  const olsr::MessageHeader::Hello &hello = msgHdr.GetHello ();
124
  NS_TEST_EXPECT_MSG_EQ (msgHdr.GetOriginatorAddress (), Ipv4Address ("10.1.1.2"), "Originator address.");
125
126
  if (m_countA == 0)
98
    {
127
    {
99
      NS_PCAP_TEST_EXPECT_EQ (PREFIX << "-" << i << "-1.pcap");
128
      NS_TEST_EXPECT_MSG_EQ (hello.linkMessages.size (), 0, "No Link messages on the first Hello.");
100
    }
129
    }
130
  else
131
    {
132
      NS_TEST_EXPECT_MSG_EQ (hello.linkMessages.size (), 1, "One Link message on the second and third Hello.");
133
    }
134
135
  std::vector<olsr::MessageHeader::Hello::LinkMessage>::const_iterator iter;
136
  for (iter = hello.linkMessages.begin (); iter != hello.linkMessages.end (); iter ++)
137
    {
138
      if (m_countA == 1)
139
        {
140
          NS_TEST_EXPECT_MSG_EQ (iter->linkCode, 1, "Asymmetric link on second Hello.");
141
        }
142
      else
143
        {
144
          NS_TEST_EXPECT_MSG_EQ (iter->linkCode, 6, "Symmetric link on second Hello.");
145
        }
146
147
      NS_TEST_EXPECT_MSG_EQ (iter->neighborInterfaceAddresses.size (), 1, "Only one neighbor.");
148
      NS_TEST_EXPECT_MSG_EQ (iter->neighborInterfaceAddresses[0], Ipv4Address ("10.1.1.1"), "Only one neighbor.");
149
    }
150
151
  m_countA ++;
152
}
153
154
void
155
HelloRegressionTest::ReceivePktProbeB (Ptr<Socket> socket)
156
{
157
  uint32_t availableData;
158
  availableData = socket->GetRxAvailable ();
159
  Ptr<Packet> receivedPacketProbe = socket->Recv (std::numeric_limits<uint32_t>::max (), 0);
160
  NS_ASSERT (availableData == receivedPacketProbe->GetSize ());
161
162
  Ipv4Header ipHdr;
163
  receivedPacketProbe->RemoveHeader (ipHdr);
164
  UdpHeader udpHdr;
165
  receivedPacketProbe->RemoveHeader (udpHdr);
166
  PacketHeader pktHdr;
167
  receivedPacketProbe->RemoveHeader (pktHdr);
168
  MessageHeader msgHdr;
169
  receivedPacketProbe->RemoveHeader (msgHdr);
170
171
  const olsr::MessageHeader::Hello &hello = msgHdr.GetHello ();
172
  NS_TEST_EXPECT_MSG_EQ (msgHdr.GetOriginatorAddress (), Ipv4Address ("10.1.1.1"), "Originator address.");
173
174
  if (m_countA == 0)
175
    {
176
      NS_TEST_EXPECT_MSG_EQ (hello.linkMessages.size (), 0, "No Link messages on the first Hello.");
177
    }
178
  else
179
    {
180
      NS_TEST_EXPECT_MSG_EQ (hello.linkMessages.size (), 1, "One Link message on the second and third Hello.");
181
    }
182
183
  std::vector<olsr::MessageHeader::Hello::LinkMessage>::const_iterator iter;
184
  for (iter = hello.linkMessages.begin (); iter != hello.linkMessages.end (); iter ++)
185
    {
186
      if (m_countA == 1)
187
        {
188
          NS_TEST_EXPECT_MSG_EQ (iter->linkCode, 1, "Asymmetric link on second Hello.");
189
        }
190
      else
191
        {
192
          NS_TEST_EXPECT_MSG_EQ (iter->linkCode, 6, "Symmetric link on second Hello.");
193
        }
194
195
      NS_TEST_EXPECT_MSG_EQ (iter->neighborInterfaceAddresses.size (), 1, "Only one neighbor.");
196
      NS_TEST_EXPECT_MSG_EQ (iter->neighborInterfaceAddresses[0], Ipv4Address ("10.1.1.2"), "Only one neighbor.");
197
    }
198
199
  m_countB ++;
101
}
200
}
102
201
103
}
202
}
(-)a/src/olsr/test/hello-regression-test.h (-4 / +15 lines)
 Lines 23-28    Link Here 
23
23
24
#include "ns3/test.h"
24
#include "ns3/test.h"
25
#include "ns3/nstime.h"
25
#include "ns3/nstime.h"
26
#include "ns3/socket.h"
27
#include "ns3/ipv4-raw-socket-impl.h"
26
#include "ns3/node-container.h"
28
#include "ns3/node-container.h"
27
29
28
namespace ns3
30
namespace ns3
 Lines 53-68    Link Here 
53
  HelloRegressionTest (); 
55
  HelloRegressionTest (); 
54
  ~HelloRegressionTest ();
56
  ~HelloRegressionTest ();
55
private:
57
private:
56
  /// Unique PCAP files prefix for this test
57
  static const char * const PREFIX;
58
  /// Total simulation time
58
  /// Total simulation time
59
  const Time m_time;
59
  const Time m_time;
60
  /// Create & configure test network
60
  /// Create & configure test network
61
  void CreateNodes ();
61
  void CreateNodes ();
62
  /// Compare traces with reference ones
63
  void CheckResults ();
64
  /// Go
62
  /// Go
65
  void DoRun ();
63
  void DoRun ();
64
65
  /// Receive raw data on node A
66
  void ReceivePktProbeA (Ptr<Socket> socket);
67
  /// Packet counter on node A
68
  uint8_t m_countA;
69
  /// Receiving socket on node A
70
  Ptr<Ipv4RawSocketImpl> m_rxSocketA;
71
  /// Receive raw data on node B
72
  void ReceivePktProbeB (Ptr<Socket> socket);
73
  /// Packet counter on node B
74
  uint8_t m_countB;
75
  /// Receiving socket on node B
76
  Ptr<Ipv4RawSocketImpl> m_rxSocketB;
66
};
77
};
67
78
68
}
79
}
(-)a/src/olsr/test/tc-regression-test.cc (-41 / +225 lines)
 Lines 26-53    Link Here 
26
#include "ns3/double.h"
26
#include "ns3/double.h"
27
#include "ns3/uinteger.h"
27
#include "ns3/uinteger.h"
28
#include "ns3/string.h"
28
#include "ns3/string.h"
29
#include "ns3/pcap-test.h"
30
#include "ns3/pcap-file.h"
31
#include "ns3/olsr-helper.h"
29
#include "ns3/olsr-helper.h"
32
#include "ns3/internet-stack-helper.h"
30
#include "ns3/internet-stack-helper.h"
33
#include "ns3/point-to-point-helper.h"
34
#include "ns3/ipv4-address-helper.h"
31
#include "ns3/ipv4-address-helper.h"
35
#include "ns3/abort.h"
32
#include "ns3/abort.h"
36
#include "ns3/yans-wifi-helper.h"
33
#include "ns3/socket-factory.h"
37
#include "ns3/mobility-helper.h"
34
#include "ns3/ipv4-raw-socket-factory.h"
38
#include "ns3/nqos-wifi-mac-helper.h"
35
#include "ns3/udp-l4-protocol.h"
36
#include "ns3/udp-header.h"
37
#include "ns3/olsr-header.h"
38
#include "ns3/simple-net-device-helper.h"
39
#include "ns3/simple-net-device.h"
39
40
40
namespace ns3
41
namespace ns3
41
{
42
{
42
namespace olsr
43
namespace olsr
43
{
44
{
44
45
45
const char * const TcRegressionTest::PREFIX = "olsr-tc-regression-test";
46
47
TcRegressionTest::TcRegressionTest() : 
46
TcRegressionTest::TcRegressionTest() : 
48
  TestCase ("Test OLSR Topology Control message generation"),
47
  TestCase ("Test OLSR Topology Control message generation"),
49
  m_time (Seconds (20)),
48
  m_time (Seconds (20)),
50
  m_step (120)
49
  m_countA (0), m_countB (0), m_countC (0)
51
{
50
{
52
}
51
}
53
52
 Lines 64-72    Link Here 
64
63
65
  Simulator::Stop (m_time);
64
  Simulator::Stop (m_time);
66
  Simulator::Run ();
65
  Simulator::Run ();
66
67
  m_rxSocketA = 0;
68
  m_rxSocketB = 0;
69
  m_rxSocketC = 0;
67
  Simulator::Destroy ();
70
  Simulator::Destroy ();
68
69
  CheckResults ();
70
}
71
}
71
72
72
void
73
void
 Lines 76-130    Link Here 
76
  NodeContainer c;
77
  NodeContainer c;
77
  c.Create (3);
78
  c.Create (3);
78
79
79
  // place nodes in the chain
80
  MobilityHelper mobility;
81
  mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
82
                                 "MinX", DoubleValue (0.0),
83
                                 "MinY", DoubleValue (0.0),
84
                                 "DeltaX", DoubleValue (m_step),
85
                                 "DeltaY", DoubleValue (0),
86
                                 "GridWidth", UintegerValue (3),
87
                                 "LayoutType", StringValue ("RowFirst"));
88
  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
89
  mobility.Install (c);
90
91
  // install TCP/IP & OLSR
80
  // install TCP/IP & OLSR
92
  OlsrHelper olsr;
81
  OlsrHelper olsr;
93
  InternetStackHelper internet;
82
  InternetStackHelper internet;
94
  internet.SetRoutingHelper (olsr);
83
  internet.SetRoutingHelper (olsr);
95
  internet.Install (c);
84
  internet.Install (c);
96
  int64_t streamsUsed = olsr.AssignStreams (c, 0);
85
  int64_t streamsUsed = olsr.AssignStreams (c, 0);
97
  NS_TEST_EXPECT_MSG_EQ (streamsUsed, 3, "Should have assigned 2 streams");
86
  NS_TEST_EXPECT_MSG_EQ (streamsUsed, 3, "Should have assigned 3 streams");
98
87
99
  // create wifi channel & devices
88
  // create channel & devices
100
  NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
89
  SimpleNetDeviceHelper simpleNetHelper;
101
  wifiMac.SetType ("ns3::AdhocWifiMac");
90
  simpleNetHelper.SetDeviceAttribute ("DataRate", StringValue ("10Mbps"));
102
  YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
91
  simpleNetHelper.SetChannelAttribute ("Delay", StringValue ("2ms"));
103
  YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
92
  NetDeviceContainer nd = simpleNetHelper.Install (c);
104
  wifiPhy.SetChannel (wifiChannel.Create ());
93
105
  // This test suite output was originally based on YansErrorRateModel 
94
  // Blacklist some devices (equivalent to Wireless out of range)
106
  wifiPhy.SetErrorRateModel ("ns3::YansErrorRateModel");
95
  Ptr<SimpleNetDevice> nd0 = DynamicCast<SimpleNetDevice> (nd.Get (0));
107
  WifiHelper wifi = WifiHelper::Default ();
96
  Ptr<SimpleNetDevice> nd2 = DynamicCast<SimpleNetDevice> (nd.Get (2));
108
  wifi.SetStandard (WIFI_PHY_STANDARD_80211a);
97
  Ptr<SimpleChannel> ch = DynamicCast<SimpleChannel> (nd.Get (0)->GetChannel ());
109
  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode", StringValue ("OfdmRate6Mbps"), "RtsCtsThreshold", StringValue ("2200"));
98
  ch->BlackList (nd0, nd2);
110
  NetDeviceContainer nd = wifi.Install (wifiPhy, wifiMac, c); 
99
  ch->BlackList (nd2, nd0);
111
100
112
  // setup IP addresses
101
  // setup IP addresses
113
  Ipv4AddressHelper ipv4;
102
  Ipv4AddressHelper ipv4;
114
  ipv4.SetBase ("10.1.1.0", "255.255.255.0");
103
  ipv4.SetBase ("10.1.1.0", "255.255.255.0");
115
  ipv4.Assign (nd);
104
  ipv4.Assign (nd);
116
105
117
  // setup PCAP traces
106
  // Create the sockets
118
  wifiPhy.EnablePcapAll (CreateTempDirFilename(PREFIX));
107
  Ptr<SocketFactory> rxSocketFactoryA = c.Get (0)->GetObject<Ipv4RawSocketFactory> ();
108
  m_rxSocketA = DynamicCast<Ipv4RawSocketImpl> (rxSocketFactoryA->CreateSocket ());
109
  m_rxSocketA->SetProtocol (UdpL4Protocol::PROT_NUMBER);
110
  m_rxSocketA->SetRecvCallback (MakeCallback (&TcRegressionTest::ReceivePktProbeA, this));
111
112
  Ptr<SocketFactory> rxSocketFactoryB = c.Get (1)->GetObject<Ipv4RawSocketFactory> ();
113
  m_rxSocketB = DynamicCast<Ipv4RawSocketImpl> (rxSocketFactoryB->CreateSocket ());
114
  m_rxSocketB->SetProtocol (UdpL4Protocol::PROT_NUMBER);
115
  m_rxSocketB->SetRecvCallback (MakeCallback (&TcRegressionTest::ReceivePktProbeB, this));
116
117
  Ptr<SocketFactory> rxSocketFactoryC = c.Get (2)->GetObject<Ipv4RawSocketFactory> ();
118
  m_rxSocketC = DynamicCast<Ipv4RawSocketImpl> (rxSocketFactoryC->CreateSocket ());
119
  m_rxSocketC->SetProtocol (UdpL4Protocol::PROT_NUMBER);
120
  m_rxSocketC->SetRecvCallback (MakeCallback (&TcRegressionTest::ReceivePktProbeC, this));
121
}
122
123
// Note: this is identical to ReceivePktProbeC, but the packet counter needs to be different.
124
void
125
TcRegressionTest::ReceivePktProbeA (Ptr<Socket> socket)
126
{
127
  uint32_t availableData;
128
  availableData = socket->GetRxAvailable ();
129
  Ptr<Packet> receivedPacketProbe = socket->Recv (std::numeric_limits<uint32_t>::max (), 0);
130
  NS_ASSERT (availableData == receivedPacketProbe->GetSize ());
131
132
  Ipv4Header ipHdr;
133
  receivedPacketProbe->RemoveHeader (ipHdr);
134
  UdpHeader udpHdr;
135
  receivedPacketProbe->RemoveHeader (udpHdr);
136
  PacketHeader pktHdr;
137
  receivedPacketProbe->RemoveHeader (pktHdr);
138
139
  if (m_countA == 0)
140
    {
141
      MessageHeader msgHdr;
142
      receivedPacketProbe->RemoveHeader (msgHdr);
143
      const olsr::MessageHeader::Hello &hello = msgHdr.GetHello ();
144
      NS_TEST_EXPECT_MSG_EQ (msgHdr.GetOriginatorAddress (), Ipv4Address ("10.1.1.2"), "Originator address.");
145
      NS_TEST_EXPECT_MSG_EQ (hello.linkMessages.size (), 0, "0 - Hello, No messages.");
146
    }
147
  else if (m_countA == 1)
148
    {
149
      MessageHeader msgHdr;
150
      receivedPacketProbe->RemoveHeader (msgHdr);
151
      NS_TEST_EXPECT_MSG_EQ (msgHdr.GetOriginatorAddress (), Ipv4Address ("10.1.1.2"), "Originator address.");
152
      const olsr::MessageHeader::Hello &hello = msgHdr.GetHello ();
153
      NS_TEST_EXPECT_MSG_EQ (hello.linkMessages.size (), 2, "1 - Hello, one message.");
154
      NS_TEST_EXPECT_MSG_EQ (hello.linkMessages[0].linkCode, 1, "1 - Asymmetric Link.");
155
      NS_TEST_EXPECT_MSG_EQ (hello.linkMessages[0].neighborInterfaceAddresses.size (), 1, "1 - Neighbor.");
156
      NS_TEST_EXPECT_MSG_EQ (hello.linkMessages[0].neighborInterfaceAddresses[0], Ipv4Address ("10.1.1.3"), "1 - Neighbor.");
157
      NS_TEST_EXPECT_MSG_EQ (hello.linkMessages[1].linkCode, 1, "1 - Asymmetric Link.");
158
      NS_TEST_EXPECT_MSG_EQ (hello.linkMessages[1].neighborInterfaceAddresses.size (), 1, "1 - Neighbor.");
159
      NS_TEST_EXPECT_MSG_EQ (hello.linkMessages[1].neighborInterfaceAddresses[0], Ipv4Address ("10.1.1.1"), "1 - Neighbor.");
160
    }
161
  else
162
    {
163
      if (m_countA == 5 || m_countA == 8)
164
        {
165
          MessageHeader msgHdr;
166
          receivedPacketProbe->RemoveHeader (msgHdr);
167
          const olsr::MessageHeader::Tc &tc = msgHdr.GetTc ();
168
          NS_TEST_EXPECT_MSG_EQ (msgHdr.GetOriginatorAddress (), Ipv4Address ("10.1.1.2"), "Originator address.");
169
          NS_TEST_EXPECT_MSG_EQ (tc.neighborAddresses.size (), 2, int(m_countA) << " - TC, one message.");
170
          NS_TEST_EXPECT_MSG_EQ (tc.neighborAddresses[0], Ipv4Address ("10.1.1.3"), int(m_countA) << " - Neighbor.");
171
          NS_TEST_EXPECT_MSG_EQ (tc.neighborAddresses[1], Ipv4Address ("10.1.1.1"), int(m_countA) << " - Neighbor.");
172
        }
173
      if (m_countA != 8)
174
        {
175
          MessageHeader msgHdr;
176
          receivedPacketProbe->RemoveHeader (msgHdr);
177
          NS_TEST_EXPECT_MSG_EQ (msgHdr.GetOriginatorAddress (), Ipv4Address ("10.1.1.2"), "Originator address.");
178
          const olsr::MessageHeader::Hello &hello = msgHdr.GetHello ();
179
          NS_TEST_EXPECT_MSG_EQ (hello.linkMessages.size (), 2, int(m_countA) << " - Hello, one message.");
180
          NS_TEST_EXPECT_MSG_EQ (hello.linkMessages[0].linkCode, 6, int(m_countA) << " - Symmetric Link.");
181
          NS_TEST_EXPECT_MSG_EQ (hello.linkMessages[0].neighborInterfaceAddresses.size (), 1, int(m_countA) << " - Neighbor.");
182
          NS_TEST_EXPECT_MSG_EQ (hello.linkMessages[0].neighborInterfaceAddresses[0], Ipv4Address ("10.1.1.3"), int(m_countA) << " - Neighbor.");
183
          NS_TEST_EXPECT_MSG_EQ (hello.linkMessages[1].linkCode, 6, int(m_countA) << " - Symmetric Link.");
184
          NS_TEST_EXPECT_MSG_EQ (hello.linkMessages[1].neighborInterfaceAddresses.size (), 1, int(m_countA) << " - Neighbor.");
185
          NS_TEST_EXPECT_MSG_EQ (hello.linkMessages[1].neighborInterfaceAddresses[0], Ipv4Address ("10.1.1.1"), int(m_countA) << " - Neighbor.");
186
        }
187
    }
188
  m_countA ++;
119
}
189
}
120
190
121
void
191
void
122
TcRegressionTest::CheckResults ()
192
TcRegressionTest::ReceivePktProbeB (Ptr<Socket> socket)
123
{
193
{
124
  for (uint32_t i = 0; i < 3; ++i)
194
  uint32_t availableData;
195
  availableData = socket->GetRxAvailable ();
196
  Ptr<Packet> receivedPacketProbe = socket->Recv (std::numeric_limits<uint32_t>::max (), 0);
197
  NS_ASSERT (availableData == receivedPacketProbe->GetSize ());
198
199
  Ipv4Header ipHdr;
200
  receivedPacketProbe->RemoveHeader (ipHdr);
201
  UdpHeader udpHdr;
202
  receivedPacketProbe->RemoveHeader (udpHdr);
203
  PacketHeader pktHdr;
204
  receivedPacketProbe->RemoveHeader (pktHdr);
205
206
  MessageHeader msgHdr;
207
  receivedPacketProbe->RemoveHeader (msgHdr);
208
  const olsr::MessageHeader::Hello &hello = msgHdr.GetHello ();
209
210
  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)
125
    {
212
    {
126
      NS_PCAP_TEST_EXPECT_EQ (PREFIX << "-" << i << "-1.pcap");
213
      NS_TEST_EXPECT_MSG_EQ (msgHdr.GetOriginatorAddress (), Ipv4Address ("10.1.1.3"), "Originator address.");
127
    }
214
    }
215
  else
216
    {
217
      NS_TEST_EXPECT_MSG_EQ (msgHdr.GetOriginatorAddress (), Ipv4Address ("10.1.1.1"), "Originator address.");
218
    }
219
220
  if (m_countB == 0 || m_countB == 1)
221
    {
222
      NS_TEST_EXPECT_MSG_EQ (hello.linkMessages.size (), 0, int(m_countC) << " - Hello, links announced.");
223
    }
224
  else
225
    {
226
      NS_TEST_EXPECT_MSG_EQ (hello.linkMessages.size (), 1, int(m_countC) << " - Hello, links announced.");
227
      if (m_countB == 2 || m_countB == 3)
228
        {
229
          NS_TEST_EXPECT_MSG_EQ (hello.linkMessages[0].linkCode, 1, int(m_countC) << " - Asymmetric Link.");
230
        }
231
      else if (m_countB == 4 || m_countB == 5)
232
        {
233
          NS_TEST_EXPECT_MSG_EQ (hello.linkMessages[0].linkCode, 6, int(m_countC) << " - Symmetric Link.");
234
        }
235
      else
236
        {
237
          NS_TEST_EXPECT_MSG_EQ (hello.linkMessages[0].linkCode, 10, int(m_countC) << " - MPR Link.");
238
        }
239
240
      NS_TEST_EXPECT_MSG_EQ (hello.linkMessages[0].neighborInterfaceAddresses[0], Ipv4Address ("10.1.1.2"), int(m_countC) << " - Neighbor.");
241
    }
242
243
  m_countB ++;
244
}
245
246
// Note: this is identical to ReceivePktProbeA, but the packet counter needs to be different.
247
void
248
TcRegressionTest::ReceivePktProbeC (Ptr<Socket> socket)
249
{
250
  uint32_t availableData;
251
  availableData = socket->GetRxAvailable ();
252
  Ptr<Packet> receivedPacketProbe = socket->Recv (std::numeric_limits<uint32_t>::max (), 0);
253
  NS_ASSERT (availableData == receivedPacketProbe->GetSize ());
254
255
  Ipv4Header ipHdr;
256
  receivedPacketProbe->RemoveHeader (ipHdr);
257
  UdpHeader udpHdr;
258
  receivedPacketProbe->RemoveHeader (udpHdr);
259
  PacketHeader pktHdr;
260
  receivedPacketProbe->RemoveHeader (pktHdr);
261
262
  if (m_countC == 0)
263
    {
264
      MessageHeader msgHdr;
265
      receivedPacketProbe->RemoveHeader (msgHdr);
266
      const olsr::MessageHeader::Hello &hello = msgHdr.GetHello ();
267
      NS_TEST_EXPECT_MSG_EQ (msgHdr.GetOriginatorAddress (), Ipv4Address ("10.1.1.2"), "Originator address.");
268
      NS_TEST_EXPECT_MSG_EQ (hello.linkMessages.size (), 0, "0 - Hello, No messages.");
269
    }
270
  else if (m_countC == 1)
271
    {
272
      MessageHeader msgHdr;
273
      receivedPacketProbe->RemoveHeader (msgHdr);
274
      NS_TEST_EXPECT_MSG_EQ (msgHdr.GetOriginatorAddress (), Ipv4Address ("10.1.1.2"), "Originator address.");
275
      const olsr::MessageHeader::Hello &hello = msgHdr.GetHello ();
276
      NS_TEST_EXPECT_MSG_EQ (hello.linkMessages.size (), 2, "1 - Hello, one message.");
277
      NS_TEST_EXPECT_MSG_EQ (hello.linkMessages[0].linkCode, 1, "1 - Asymmetric Link.");
278
      NS_TEST_EXPECT_MSG_EQ (hello.linkMessages[0].neighborInterfaceAddresses.size (), 1, "1 - Neighbor.");
279
      NS_TEST_EXPECT_MSG_EQ (hello.linkMessages[0].neighborInterfaceAddresses[0], Ipv4Address ("10.1.1.3"), "1 - Neighbor.");
280
      NS_TEST_EXPECT_MSG_EQ (hello.linkMessages[1].linkCode, 1, "1 - Asymmetric Link.");
281
      NS_TEST_EXPECT_MSG_EQ (hello.linkMessages[1].neighborInterfaceAddresses.size (), 1, "1 - Neighbor.");
282
      NS_TEST_EXPECT_MSG_EQ (hello.linkMessages[1].neighborInterfaceAddresses[0], Ipv4Address ("10.1.1.1"), "1 - Neighbor.");
283
    }
284
  else
285
    {
286
      if (m_countC == 5 || m_countC == 8)
287
        {
288
          MessageHeader msgHdr;
289
          receivedPacketProbe->RemoveHeader (msgHdr);
290
          const olsr::MessageHeader::Tc &tc = msgHdr.GetTc ();
291
          NS_TEST_EXPECT_MSG_EQ (msgHdr.GetOriginatorAddress (), Ipv4Address ("10.1.1.2"), "Originator address.");
292
          NS_TEST_EXPECT_MSG_EQ (tc.neighborAddresses.size (), 2, int(m_countC) << " - TC, one message.");
293
          NS_TEST_EXPECT_MSG_EQ (tc.neighborAddresses[0], Ipv4Address ("10.1.1.3"), int(m_countC) << " - Neighbor.");
294
          NS_TEST_EXPECT_MSG_EQ (tc.neighborAddresses[1], Ipv4Address ("10.1.1.1"), int(m_countC) << " - Neighbor.");
295
        }
296
      if (m_countC != 8)
297
        {
298
          MessageHeader msgHdr;
299
          receivedPacketProbe->RemoveHeader (msgHdr);
300
          NS_TEST_EXPECT_MSG_EQ (msgHdr.GetOriginatorAddress (), Ipv4Address ("10.1.1.2"), "Originator address.");
301
          const olsr::MessageHeader::Hello &hello = msgHdr.GetHello ();
302
          NS_TEST_EXPECT_MSG_EQ (hello.linkMessages.size (), 2, int(m_countC) << " - Hello, one message.");
303
          NS_TEST_EXPECT_MSG_EQ (hello.linkMessages[0].linkCode, 6, int(m_countC) << " - Symmetric Link.");
304
          NS_TEST_EXPECT_MSG_EQ (hello.linkMessages[0].neighborInterfaceAddresses.size (), 1, int(m_countC) << " - Neighbor.");
305
          NS_TEST_EXPECT_MSG_EQ (hello.linkMessages[0].neighborInterfaceAddresses[0], Ipv4Address ("10.1.1.3"), int(m_countC) << " - Neighbor.");
306
          NS_TEST_EXPECT_MSG_EQ (hello.linkMessages[1].linkCode, 6, int(m_countC) << " - Symmetric Link.");
307
          NS_TEST_EXPECT_MSG_EQ (hello.linkMessages[1].neighborInterfaceAddresses.size (), 1, int(m_countC) << " - Neighbor.");
308
          NS_TEST_EXPECT_MSG_EQ (hello.linkMessages[1].neighborInterfaceAddresses[0], Ipv4Address ("10.1.1.1"), int(m_countC) << " - Neighbor.");
309
        }
310
    }
311
  m_countC ++;
128
}
312
}
129
313
130
}
314
}
(-)a/src/olsr/test/tc-regression-test.h (-7 / +25 lines)
 Lines 23-28    Link Here 
23
23
24
#include "ns3/test.h"
24
#include "ns3/test.h"
25
#include "ns3/nstime.h"
25
#include "ns3/nstime.h"
26
#include "ns3/socket.h"
27
#include "ns3/ipv4-raw-socket-impl.h"
26
#include "ns3/node-container.h"
28
#include "ns3/node-container.h"
27
29
28
namespace ns3
30
namespace ns3
 Lines 33-39    Link Here 
33
 * \ingroup olsr
35
 * \ingroup olsr
34
 * \brief Less trivial test of OLSR Topology Control message generation
36
 * \brief Less trivial test of OLSR Topology Control message generation
35
 * 
37
 * 
36
 * This test creates 3 WiFi stations with chain topology and runs OLSR without any extra traffic. 
38
 * This test simulates 3 Wi-Fi stations with chain topology and runs OLSR without any extra traffic.
37
 * It is expected that only second station will send TC messages.
39
 * It is expected that only second station will send TC messages.
38
 * 
40
 * 
39
 * Expected trace (20 seconds, note random b-cast jitter):
41
 * Expected trace (20 seconds, note random b-cast jitter):
 Lines 78-95    Link Here 
78
  TcRegressionTest(); 
80
  TcRegressionTest(); 
79
  ~TcRegressionTest();
81
  ~TcRegressionTest();
80
private:
82
private:
81
  /// Unique PCAP files prefix for this test
82
  static const char * const PREFIX;
83
  /// Total simulation time
83
  /// Total simulation time
84
  const Time m_time;
84
  const Time m_time;
85
  /// Distance between nodes in meters, 0.8 of RX range is recommended
86
  const double m_step;
87
  /// Create & configure test network
85
  /// Create & configure test network
88
  void CreateNodes ();
86
  void CreateNodes ();
89
  /// Compare traces with reference ones
90
  void CheckResults ();
91
  /// Go
87
  /// Go
92
  void DoRun ();
88
  void DoRun ();
89
90
  /// Receive raw data on node A
91
  void ReceivePktProbeA (Ptr<Socket> socket);
92
  /// Packet counter on node A
93
  uint8_t m_countA;
94
  /// Receiving socket on node A
95
  Ptr<Ipv4RawSocketImpl> m_rxSocketA;
96
97
  /// Receive raw data on node B
98
  void ReceivePktProbeB (Ptr<Socket> socket);
99
  /// Packet counter on node B
100
  uint8_t m_countB;
101
  /// Receiving socket on node B
102
  Ptr<Ipv4RawSocketImpl> m_rxSocketB;
103
104
  /// Receive raw data on node C
105
  void ReceivePktProbeC (Ptr<Socket> socket);
106
  /// Packet counter on node C
107
  uint8_t m_countC;
108
  /// Receiving socket on node C
109
  Ptr<Ipv4RawSocketImpl> m_rxSocketC;
110
93
};
111
};
94
112
95
}
113
}
(-)a/src/olsr/wscript (-1 / +1 lines)
 Lines 1-7    Link Here 
1
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
1
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
2
2
3
def build(bld):
3
def build(bld):
4
    module = bld.create_ns3_module('olsr', ['internet', 'config-store', 'point-to-point', 'wifi', 'applications'])
4
    module = bld.create_ns3_module('olsr', ['internet'])
5
    module.includes = '.'
5
    module.includes = '.'
6
    module.source = [
6
    module.source = [
7
        'model/olsr-header.cc',
7
        'model/olsr-header.cc',

Return to bug 1941