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

(-)a/src/core/model/test.cc (+13 lines)
 Lines 21-26    Link Here 
21
#include "abort.h"
21
#include "abort.h"
22
#include <math.h>
22
#include <math.h>
23
23
24
#include "ns3/simulator.h"
25
24
// Set to true to enable a segmentation fault upon a test case macro test 
26
// Set to true to enable a segmentation fault upon a test case macro test 
25
// failing (for debugging purposes)
27
// failing (for debugging purposes)
26
bool gBreakOnFailure = false;
28
bool gBreakOnFailure = false;
 Lines 395-405    Link Here 
395
void 
397
void 
396
TestCase::DoSetup (void)
398
TestCase::DoSetup (void)
397
{
399
{
400
  /*
401
   * Ensure a clean execution environment
402
   */
403
  Simulator::Destroy();
398
}
404
}
399
405
400
void 
406
void 
401
TestCase::DoTeardown (void)
407
TestCase::DoTeardown (void)
402
{
408
{
409
  /*
410
   *   Most tests will destroy their simulators when successful,
411
   * but on failure, they tend to leave the simulator alive.
412
   *   This can be a problem for subsequent test runs, so we
413
   * must destroy the simulator on TestCase teardown just in case.
414
   */
415
  Simulator::Destroy();
403
}
416
}
404
417
405
TestSuite::TestSuite (std::string name, TestType type)
418
TestSuite::TestSuite (std::string name, TestType type)
(-)a/src/energy/test/rv-battery-model-test.cc (-4 / +8 lines)
 Lines 107-112    Link Here 
107
  // Itsy battery
107
  // Itsy battery
108
  m_alpha = 35220;
108
  m_alpha = 35220;
109
  m_beta = 0.637;
109
  m_beta = 0.637;
110
  
111
  // create load profiles for variable load test
112
  CreateLoadProfiles ();
110
}
113
}
111
114
112
BatteryLifetimeTest::~BatteryLifetimeTest ()
115
BatteryLifetimeTest::~BatteryLifetimeTest ()
 Lines 642-647    Link Here 
642
{
645
{
643
  NS_LOG_DEBUG ("Constant load run.");
646
  NS_LOG_DEBUG ("Constant load run.");
644
647
648
  // set constant load test parameters
649
  m_alpha = 35220;
650
  m_beta = 0.637;
651
645
  // 640mA
652
  // 640mA
646
  NS_TEST_ASSERT_MSG_EQ (ConstantLoadTest (0.640, Seconds (2844.0)), false,  "Problems with constant load test (640mA).");
653
  NS_TEST_ASSERT_MSG_EQ (ConstantLoadTest (0.640, Seconds (2844.0)), false,  "Problems with constant load test (640mA).");
647
  // 320mA
654
  // 320mA
 Lines 653-661    Link Here 
653
  // 32mA
660
  // 32mA
654
  NS_TEST_ASSERT_MSG_EQ (ConstantLoadTest (0.032, Seconds (65580.0)), false,  "Problems with constant load test (32).");
661
  NS_TEST_ASSERT_MSG_EQ (ConstantLoadTest (0.032, Seconds (65580.0)), false,  "Problems with constant load test (32).");
655
662
656
  // create load profiles for variable load test
657
  CreateLoadProfiles ();
658
659
  // variable load with Itsy battery
663
  // variable load with Itsy battery
660
  NS_LOG_DEBUG ("\n\nItsy");
664
  NS_LOG_DEBUG ("\n\nItsy");
661
  m_alpha = 35220;
665
  m_alpha = 35220;
 Lines 759-765    Link Here 
759
763
760
  NS_LOG_DEBUG ("Expected lifetime = " << expLifetime.GetSeconds () << "s");
764
  NS_LOG_DEBUG ("Expected lifetime = " << expLifetime.GetSeconds () << "s");
761
  NS_LOG_DEBUG ("Actual lifetime = " << actualLifetime.GetSeconds () << "s");
765
  NS_LOG_DEBUG ("Actual lifetime = " << actualLifetime.GetSeconds () << "s");
762
766
  
763
  NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL (actualLifetime, expLifetime, "Incorrect lifetime!");
767
  NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL (actualLifetime, expLifetime, "Incorrect lifetime!");
764
  /*
768
  /*
765
  NS_TEST_ASSERT_MSG_EQ_TOL_RETURNS_BOOL (actualLifetime.GetSeconds () / 60,
769
  NS_TEST_ASSERT_MSG_EQ_TOL_RETURNS_BOOL (actualLifetime.GetSeconds () / 60,
(-)a/src/energy/test/basic-energy-model-test.cc (-14 / +34 lines)
 Lines 217-222    Link Here 
217
217
218
private:
218
private:
219
  void DoRun (void);
219
  void DoRun (void);
220
  void DoSetup (void);
221
  void DoTeardown (void);
220
222
221
  /**
223
  /**
222
   * Callback invoked when energy is drained from source.
224
   * Callback invoked when energy is drained from source.
 Lines 238-248    Link Here 
238
  double m_simTimeS;        // maximum simulation time, in seconds
240
  double m_simTimeS;        // maximum simulation time, in seconds
239
  double m_timeStepS;       // simulation time step size, in seconds
241
  double m_timeStepS;       // simulation time step size, in seconds
240
  double m_updateIntervalS; // update interval of each device model
242
  double m_updateIntervalS; // update interval of each device model
243
  std::string m_phyMode;
241
244
242
};
245
};
243
246
244
BasicEnergyDepletionTest::BasicEnergyDepletionTest ()
247
BasicEnergyDepletionTest::BasicEnergyDepletionTest ()
245
  : TestCase ("Basic energy model energy depletion test case")
248
  : TestCase ("Basic energy model energy depletion test case")
249
  , m_phyMode ("DsssRate1Mbps")
246
{
250
{
247
  m_numOfNodes = 10;
251
  m_numOfNodes = 10;
248
  m_callbackCount = 0;
252
  m_callbackCount = 0;
 Lines 256-261    Link Here 
256
}
260
}
257
261
258
void
262
void
263
BasicEnergyDepletionTest::DoSetup (void)
264
{
265
  TestCase::DoSetup ();
266
267
  // disable fragmentation for frames below 2200 bytes
268
  Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold",
269
                      StringValue ("2200"));
270
  // turn off RTS/CTS for frames below 2200 bytes
271
  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold",
272
                      StringValue ("2200"));
273
  // Fix non-unicast data rate to be the same as that of unicast
274
  Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",
275
                      StringValue (m_phyMode));
276
}
277
278
void
279
BasicEnergyDepletionTest::DoTeardown (void)
280
{
281
  // Restore defaults
282
  std::string invalidWifiMode ("Invalid-WifiMode");
283
  Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2346"));
284
  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("2346"));
285
  Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode", StringValue (invalidWifiMode));
286
  
287
  TestCase::DoTeardown ();
288
}
289
290
void
259
BasicEnergyDepletionTest::DoRun (void)
291
BasicEnergyDepletionTest::DoRun (void)
260
{
292
{
261
  /*
293
  /*
 Lines 287-304    Link Here 
287
  NodeContainer c;
319
  NodeContainer c;
288
  c.Create (m_numOfNodes);
320
  c.Create (m_numOfNodes);
289
321
290
  std::string phyMode ("DsssRate1Mbps");
291
292
  // disable fragmentation for frames below 2200 bytes
293
  Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold",
294
                      StringValue ("2200"));
295
  // turn off RTS/CTS for frames below 2200 bytes
296
  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold",
297
                      StringValue ("2200"));
298
  // Fix non-unicast data rate to be the same as that of unicast
299
  Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",
300
                      StringValue (phyMode));
301
302
  // install YansWifiPhy
322
  // install YansWifiPhy
303
  WifiHelper wifi;
323
  WifiHelper wifi;
304
  wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
324
  wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
 Lines 319-326    Link Here 
319
  // Add a non-QoS upper MAC, and disable rate control
339
  // Add a non-QoS upper MAC, and disable rate control
320
  NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
340
  NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
321
  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
341
  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
322
                                "DataMode", StringValue (phyMode),
342
                                "DataMode", StringValue (m_phyMode),
323
                                "ControlMode", StringValue (phyMode));
343
                                "ControlMode", StringValue (m_phyMode));
324
  // Set it to ad-hoc mode
344
  // Set it to ad-hoc mode
325
  wifiMac.SetType ("ns3::AdhocWifiMac");
345
  wifiMac.SetType ("ns3::AdhocWifiMac");
326
  NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, c);
346
  NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, c);
(-)a/src/energy/test/rv-battery-model-test.cc (-30 / +44 lines)
 Lines 57-69    Link Here 
57
  void CreateLoadProfiles (void);
57
  void CreateLoadProfiles (void);
58
58
59
  /**
59
  /**
60
   * \returns False if no error occurs.
61
   *
62
   * Runs test.
60
   * Runs test.
63
   */
61
   */
64
  void DoRun (void);
62
  void DoRun (void);
65
63
66
  /**
64
  /**
65
   * Sets up test configuration
66
   */
67
  void DoSetup (void);
68
69
  /**
70
   * Restores environment after test runs
71
   */
72
  void DoTeardown (void);
73
74
  /**
67
   * \param load Load value, in Amperes (A).
75
   * \param load Load value, in Amperes (A).
68
   * \param expLifetime Expected lifetime.
76
   * \param expLifetime Expected lifetime.
69
   * \return False if no error occurs.
77
   * \return False if no error occurs.
 Lines 99-108    Link Here 
99
  std::vector<LoadProfile> m_loadProfiles;
107
  std::vector<LoadProfile> m_loadProfiles;
100
  double m_alpha;
108
  double m_alpha;
101
  double m_beta;
109
  double m_beta;
110
  std::string m_phyMode;
102
};
111
};
103
112
104
BatteryLifetimeTest::BatteryLifetimeTest ()
113
BatteryLifetimeTest::BatteryLifetimeTest ()
105
  : TestCase ("RV battery model battery lifetime test case.")
114
  : TestCase ("RV battery model battery lifetime test case.")
115
  , m_phyMode ("DsssRate1Mbps")
106
{
116
{
107
  // Itsy battery
117
  // Itsy battery
108
  m_alpha = 35220;
118
  m_alpha = 35220;
 Lines 641-646    Link Here 
641
}
651
}
642
652
643
void
653
void
654
BatteryLifetimeTest::DoSetup (void)
655
{
656
  TestCase::DoSetup ();
657
658
  // disable fragmentation for frames below 2200 bytes
659
  Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold",
660
                      StringValue ("2200"));
661
  // turn off RTS/CTS for frames below 2200 bytes
662
  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold",
663
                      StringValue ("2200"));
664
  // Fix non-unicast data rate to be the same as that of unicast
665
  Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",
666
                      StringValue (m_phyMode));
667
}
668
669
void
670
BatteryLifetimeTest::DoTeardown (void)
671
{
672
  // Restore defaults
673
  std::string invalidWifiMode ("Invalid-WifiMode");
674
  Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2346"));
675
  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("2346"));
676
  Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode", StringValue (invalidWifiMode));
677
  
678
  TestCase::DoTeardown ();
679
}
680
681
void
644
BatteryLifetimeTest::DoRun (void)
682
BatteryLifetimeTest::DoRun (void)
645
{
683
{
646
  NS_LOG_DEBUG ("Constant load run.");
684
  NS_LOG_DEBUG ("Constant load run.");
 Lines 700-717    Link Here 
700
  NodeContainer c;
738
  NodeContainer c;
701
  c.Create (1);
739
  c.Create (1);
702
740
703
  std::string phyMode ("DsssRate1Mbps");
704
705
  // disable fragmentation for frames below 2200 bytes
706
  Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold",
707
                      StringValue ("2200"));
708
  // turn off RTS/CTS for frames below 2200 bytes
709
  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold",
710
                      StringValue ("2200"));
711
  // Fix non-unicast data rate to be the same as that of unicast
712
  Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",
713
                      StringValue (phyMode));
714
715
  // install YansWifiPhy
741
  // install YansWifiPhy
716
  WifiHelper wifi;
742
  WifiHelper wifi;
717
  wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
743
  wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
 Lines 732-739    Link Here 
732
  // Add a non-QoS upper MAC, and disable rate control
758
  // Add a non-QoS upper MAC, and disable rate control
733
  NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
759
  NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
734
  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
760
  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
735
                                "DataMode", StringValue (phyMode),
761
                                "DataMode", StringValue (m_phyMode),
736
                                "ControlMode", StringValue (phyMode));
762
                                "ControlMode", StringValue (m_phyMode));
737
  // Set it to ad-hoc mode
763
  // Set it to ad-hoc mode
738
  wifiMac.SetType ("ns3::AdhocWifiMac");
764
  wifiMac.SetType ("ns3::AdhocWifiMac");
739
  NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, c);
765
  NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, c);
 Lines 787-804    Link Here 
787
  NodeContainer c;
813
  NodeContainer c;
788
  c.Create (1);
814
  c.Create (1);
789
815
790
  std::string phyMode ("DsssRate1Mbps");
791
792
  // disable fragmentation for frames below 2200 bytes
793
  Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold",
794
                      StringValue ("2200"));
795
  // turn off RTS/CTS for frames below 2200 bytes
796
  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold",
797
                      StringValue ("2200"));
798
  // Fix non-unicast data rate to be the same as that of unicast
799
  Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",
800
                      StringValue (phyMode));
801
802
  // install YansWifiPhy
816
  // install YansWifiPhy
803
  WifiHelper wifi;
817
  WifiHelper wifi;
804
  wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
818
  wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
 Lines 819-826    Link Here 
819
  // Add a non-QoS upper MAC, and disable rate control
833
  // Add a non-QoS upper MAC, and disable rate control
820
  NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
834
  NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
821
  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
835
  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
822
                                "DataMode", StringValue (phyMode),
836
                                "DataMode", StringValue (m_phyMode),
823
                                "ControlMode", StringValue (phyMode));
837
                                "ControlMode", StringValue (m_phyMode));
824
  // Set it to ad-hoc mode
838
  // Set it to ad-hoc mode
825
  wifiMac.SetType ("ns3::AdhocWifiMac");
839
  wifiMac.SetType ("ns3::AdhocWifiMac");
826
  NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, c);
840
  NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, c);
(-)a/src/mobility/test/ns2-mobility-helper-test-suite.cc (+1 lines)
 Lines 204-209    Link Here 
204
  
204
  
205
  void DoSetup ()
205
  void DoSetup ()
206
  {
206
  {
207
    Simulator::Destroy();
207
    CreateNodes ();
208
    CreateNodes ();
208
  }
209
  }
209
  
210
  
(-)a/src/olsr/test/bug780-test.cc (-5 / +22 lines)
 Lines 75-80    Link Here 
75
}
75
}
76
76
77
void
77
void
78
Bug780Test::DoSetup ()
79
{
80
  TestCase::DoSetup ();
81
82
  //sending one packets per sec
83
  // Fix non-unicast data rate to be the same as that of unicast
84
  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold",
85
                      StringValue ("400"));
86
}
87
88
void
89
Bug780Test::DoTeardown ()
90
{
91
  //sending one packets per sec
92
  // Fix non-unicast data rate to be the same as that of unicast
93
  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold",
94
                      StringValue ("2346"));
95
  
96
  TestCase::DoTeardown ();
97
}
98
99
void
78
Bug780Test::DoRun ()
100
Bug780Test::DoRun ()
79
{
101
{
80
  SeedManager::SetSeed (123);
102
  SeedManager::SetSeed (123);
 Lines 97-107    Link Here 
97
  double SimTime = 200.0;
119
  double SimTime = 200.0;
98
  std::string phyMode ("DsssRate1Mbps");
120
  std::string phyMode ("DsssRate1Mbps");
99
121
100
  //sending one packets per sec
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;
122
  NodeContainer adhocNodes;
106
  adhocNodes.Create (nWifis);
123
  adhocNodes.Create (nWifis);
107
124
(-)a/src/olsr/test/bug780-test.h (+2 lines)
 Lines 42-47    Link Here 
42
  void CheckResults ();
42
  void CheckResults ();
43
  /// Go
43
  /// Go
44
  void DoRun ();
44
  void DoRun ();
45
  void DoSetup ();
46
  void DoTeardown ();
45
};
47
};
46
48
47
}
49
}
(-)a/src/propagation/test/propagation-loss-model-test-suite.cc (-4 / +81 lines)
 Lines 42-47    Link Here 
42
42
43
private:
43
private:
44
  virtual void DoRun (void);
44
  virtual void DoRun (void);
45
  virtual void DoSetup (void);
46
  virtual void DoTeardown (void);
45
47
46
  typedef struct {
48
  typedef struct {
47
    Vector m_position;
49
    Vector m_position;
 Lines 63-76    Link Here 
63
}
65
}
64
66
65
void
67
void
66
FriisPropagationLossModelTestCase::DoRun (void)
68
FriisPropagationLossModelTestCase::DoSetup (void)
67
{
69
{
70
  TestCase::DoSetup ();
71
68
  // The ns-3 testing manual gives more background on the values selected
72
  // The ns-3 testing manual gives more background on the values selected
69
  // for this test.  First, set a few defaults. 
73
  // for this test.  First, set a few defaults. 
70
74
71
  // wavelength at 2.4 GHz is 0.125m
75
  // wavelength at 2.4 GHz is 0.125m
72
  Config::SetDefault ("ns3::FriisPropagationLossModel::Lambda", DoubleValue (0.125));
76
  Config::SetDefault ("ns3::FriisPropagationLossModel::Lambda", DoubleValue (0.125));
73
  Config::SetDefault ("ns3::FriisPropagationLossModel::SystemLoss", DoubleValue (1.0));
77
  Config::SetDefault ("ns3::FriisPropagationLossModel::SystemLoss", DoubleValue (1.0));
78
}
79
80
void
81
FriisPropagationLossModelTestCase::DoTeardown (void)
82
{
83
  // Restore defaults
84
  Config::SetDefault ("ns3::FriisPropagationLossModel::Lambda", DoubleValue (0.0582524));
85
  Config::SetDefault ("ns3::FriisPropagationLossModel::SystemLoss", DoubleValue (1.0));
86
87
  TestCase::DoTeardown ();
88
}
89
90
void
91
FriisPropagationLossModelTestCase::DoRun (void)
92
{
93
  // The ns-3 testing manual gives more background on the values selected
94
  // for this test.
74
95
75
  // Select a reference transmit power
96
  // Select a reference transmit power
76
  // Pt = 10^(17.0206/10)/10^3 = .05035702 W
97
  // Pt = 10^(17.0206/10)/10^3 = .05035702 W
 Lines 139-144    Link Here 
139
160
140
private:
161
private:
141
  virtual void DoRun (void);
162
  virtual void DoRun (void);
163
  virtual void DoSetup (void);
164
  virtual void DoTeardown (void);
142
165
143
  typedef struct
166
  typedef struct
144
  {
167
  {
 Lines 162-176    Link Here 
162
}
185
}
163
186
164
void
187
void
165
TwoRayGroundPropagationLossModelTestCase::DoRun (void)
188
TwoRayGroundPropagationLossModelTestCase::DoSetup (void)
166
{
189
{
190
  TestCase::DoSetup ();
191
167
  // wavelength at 2.4 GHz is 0.125m
192
  // wavelength at 2.4 GHz is 0.125m
168
  Config::SetDefault ("ns3::TwoRayGroundPropagationLossModel::Lambda", DoubleValue (0.125));
193
  Config::SetDefault ("ns3::TwoRayGroundPropagationLossModel::Lambda", DoubleValue (0.125));
169
  Config::SetDefault ("ns3::TwoRayGroundPropagationLossModel::SystemLoss", DoubleValue (1.0));
194
  Config::SetDefault ("ns3::TwoRayGroundPropagationLossModel::SystemLoss", DoubleValue (1.0));
170
195
171
  // set antenna height to 1.5m above z coordinate
196
  // set antenna height to 1.5m above z coordinate
172
  Config::SetDefault ("ns3::TwoRayGroundPropagationLossModel::HeightAboveZ", DoubleValue (1.5));
197
  Config::SetDefault ("ns3::TwoRayGroundPropagationLossModel::HeightAboveZ", DoubleValue (1.5));
198
}
173
199
200
void
201
TwoRayGroundPropagationLossModelTestCase::DoTeardown (void)
202
{
203
  TestCase::DoTeardown ();
204
205
  // Restore defaults
206
  Config::SetDefault ("ns3::TwoRayGroundPropagationLossModel::Lambda", DoubleValue (0.0582524));
207
  Config::SetDefault ("ns3::TwoRayGroundPropagationLossModel::SystemLoss", DoubleValue (1.0));
208
  Config::SetDefault ("ns3::TwoRayGroundPropagationLossModel::HeightAboveZ", DoubleValue (0.0));
209
}
210
211
void
212
TwoRayGroundPropagationLossModelTestCase::DoRun (void)
213
{
174
  // Select a reference transmit power of 17.0206 dBm
214
  // Select a reference transmit power of 17.0206 dBm
175
  // Pt = 10^(17.0206/10)/10^3 = .05035702 W
215
  // Pt = 10^(17.0206/10)/10^3 = .05035702 W
176
  double txPowerW = 0.05035702;
216
  double txPowerW = 0.05035702;
 Lines 267-272    Link Here 
267
307
268
private:
308
private:
269
  virtual void DoRun (void);
309
  virtual void DoRun (void);
310
  virtual void DoSetup (void);
311
  virtual void DoTeardown (void);
270
312
271
  typedef struct {
313
  typedef struct {
272
    Vector m_position;
314
    Vector m_position;
 Lines 288-299    Link Here 
288
}
330
}
289
331
290
void
332
void
291
LogDistancePropagationLossModelTestCase::DoRun (void)
333
LogDistancePropagationLossModelTestCase::DoSetup (void)
292
{
334
{
335
  TestCase::DoSetup ();
336
293
  // reference loss at 2.4 GHz is 40.045997
337
  // reference loss at 2.4 GHz is 40.045997
294
  Config::SetDefault ("ns3::LogDistancePropagationLossModel::ReferenceLoss", DoubleValue (40.045997));
338
  Config::SetDefault ("ns3::LogDistancePropagationLossModel::ReferenceLoss", DoubleValue (40.045997));
295
  Config::SetDefault ("ns3::LogDistancePropagationLossModel::Exponent", DoubleValue (3));
339
  Config::SetDefault ("ns3::LogDistancePropagationLossModel::Exponent", DoubleValue (3));
340
}
296
341
342
void
343
LogDistancePropagationLossModelTestCase::DoTeardown (void)
344
{
345
  // Restore defaults
346
  Config::SetDefault ("ns3::LogDistancePropagationLossModel::ReferenceLoss", DoubleValue (46.6777));
347
  Config::SetDefault ("ns3::LogDistancePropagationLossModel::Exponent", DoubleValue (3));
348
349
  TestCase::DoTeardown ();
350
}
351
352
void
353
LogDistancePropagationLossModelTestCase::DoRun (void)
354
{
297
  // Select a reference transmit power
355
  // Select a reference transmit power
298
  // Pt = 10^(17.0206/10)/10^3 = .05035702 W
356
  // Pt = 10^(17.0206/10)/10^3 = .05035702 W
299
  double txPowerW = 0.05035702;
357
  double txPowerW = 0.05035702;
 Lines 402-407    Link Here 
402
460
403
private:
461
private:
404
  virtual void DoRun (void);
462
  virtual void DoRun (void);
463
  virtual void DoSetup (void);
464
  virtual void DoTeardown (void);
405
};
465
};
406
466
407
RangePropagationLossModelTestCase::RangePropagationLossModelTestCase ()
467
RangePropagationLossModelTestCase::RangePropagationLossModelTestCase ()
 Lines 414-422    Link Here 
414
}
474
}
415
475
416
void
476
void
477
RangePropagationLossModelTestCase::DoSetup (void)
478
{
479
  TestCase::DoSetup ();
480
  
481
  // Set testcase parameters
482
  Config::SetDefault ("ns3::RangePropagationLossModel::MaxRange", DoubleValue (127.2));
483
}
484
485
void
486
RangePropagationLossModelTestCase::DoTeardown (void)
487
{
488
  // Restore defaults
489
  Config::SetDefault ("ns3::RangePropagationLossModel::MaxRange", DoubleValue (250.0));
490
  
491
  TestCase::DoTeardown ();
492
}
493
494
void
417
RangePropagationLossModelTestCase::DoRun (void)
495
RangePropagationLossModelTestCase::DoRun (void)
418
{
496
{
419
  Config::SetDefault ("ns3::RangePropagationLossModel::MaxRange", DoubleValue (127.2));
420
  Ptr<MobilityModel> a = CreateObject<ConstantPositionMobilityModel> (); 
497
  Ptr<MobilityModel> a = CreateObject<ConstantPositionMobilityModel> (); 
421
  a->SetPosition (Vector (0,0,0));
498
  a->SetPosition (Vector (0,0,0));
422
  Ptr<MobilityModel> b = CreateObject<ConstantPositionMobilityModel> (); 
499
  Ptr<MobilityModel> b = CreateObject<ConstantPositionMobilityModel> (); 
(-)a/src/test/csma-system-test-suite.cc (-6 / +25 lines)
 Lines 165-170    Link Here 
165
165
166
private:
166
private:
167
  virtual void DoRun (void);
167
  virtual void DoRun (void);
168
  virtual void DoSetup (void);
169
  virtual void DoTeardown (void);
170
  
168
  void SinkRxNode1 (Ptr<const Packet> p, const Address &ad);
171
  void SinkRxNode1 (Ptr<const Packet> p, const Address &ad);
169
  void SinkRxNode2 (Ptr<const Packet> p, const Address &ad);
172
  void SinkRxNode2 (Ptr<const Packet> p, const Address &ad);
170
  void DropEvent (Ptr<const Packet> p);
173
  void DropEvent (Ptr<const Packet> p);
 Lines 201-206    Link Here 
201
  m_drops++;
204
  m_drops++;
202
}
205
}
203
206
207
208
void
209
CsmaBroadcastTestCase::DoSetup ()
210
{
211
  TestCase::DoSetup();
212
213
  //
214
  // Set up default values for the simulation.
215
  //
216
  // Select DIX/Ethernet II-style encapsulation (no LLC/Snap header)
217
  Config::SetDefault ("ns3::CsmaNetDevice::EncapsulationMode", StringValue ("Dix"));
218
}
219
220
void
221
CsmaBroadcastTestCase::DoTeardown ()
222
{
223
  // Restore defaults
224
  // NOTE: don't, Dix is the default
225
  
226
  TestCase::DoTeardown ();
227
}
228
204
//
229
//
205
// Example of the sending of a datagram to a broadcast address
230
// Example of the sending of a datagram to a broadcast address
206
//
231
//
 Lines 333-344    Link Here 
333
void
358
void
334
CsmaMulticastTestCase::DoRun (void)
359
CsmaMulticastTestCase::DoRun (void)
335
{
360
{
336
  //
337
  // Set up default values for the simulation.
338
  //
339
  // Select DIX/Ethernet II-style encapsulation (no LLC/Snap header)
340
  Config::SetDefault ("ns3::CsmaNetDevice::EncapsulationMode", StringValue ("Dix"));
341
342
  NodeContainer c;
361
  NodeContainer c;
343
  c.Create (5);
362
  c.Create (5);
344
  // We will later want two subcontainers of these nodes, for the two LANs
363
  // We will later want two subcontainers of these nodes, for the two LANs
(-)a/src/test/global-routing-test-suite.cc (-4 / +23 lines)
 Lines 55-61    Link Here 
55
private:
55
private:
56
  void SinkRx (std::string path, Ptr<const Packet> p, const Address &address);
56
  void SinkRx (std::string path, Ptr<const Packet> p, const Address &address);
57
  void HandleRead (Ptr<Socket>);
57
  void HandleRead (Ptr<Socket>);
58
  
58
  virtual void DoRun (void);
59
  virtual void DoRun (void);
60
  virtual void DoSetup (void);
61
  virtual void DoTeardown (void);
62
  
59
  int m_count;
63
  int m_count;
60
  std::vector<uint8_t> m_firstInterface;
64
  std::vector<uint8_t> m_firstInterface;
61
  std::vector<uint8_t> m_secondInterface;
65
  std::vector<uint8_t> m_secondInterface;
 Lines 118-123    Link Here 
118
    }
122
    }
119
}
123
}
120
124
125
void
126
DynamicGlobalRoutingTestCase::DoSetup ()
127
{
128
  TestCase::DoSetup();
129
130
  // The below value configures the default behavior of global routing.
131
  // By default, it is disabled.  To respond to interface events, set to true
132
  Config::SetDefault ("ns3::Ipv4GlobalRouting::RespondToInterfaceEvents", BooleanValue (true));
133
}
134
135
void
136
DynamicGlobalRoutingTestCase::DoTeardown ()
137
{
138
  // By default, it is disabled. Restore it.
139
  Config::SetDefault ("ns3::Ipv4GlobalRouting::RespondToInterfaceEvents", BooleanValue (false));
140
  
141
  TestCase::DoTeardown();
142
}
143
121
// Test derived from examples/routing/dynamic-global-routing.cc
144
// Test derived from examples/routing/dynamic-global-routing.cc
122
//
145
//
123
// Network topology
146
// Network topology
 Lines 140-149    Link Here 
140
void
163
void
141
DynamicGlobalRoutingTestCase::DoRun (void)
164
DynamicGlobalRoutingTestCase::DoRun (void)
142
{
165
{
143
  // The below value configures the default behavior of global routing.
144
  // By default, it is disabled.  To respond to interface events, set to true
145
  Config::SetDefault ("ns3::Ipv4GlobalRouting::RespondToInterfaceEvents", BooleanValue (true));
146
147
  NodeContainer c;
166
  NodeContainer c;
148
  c.Create (7);
167
  c.Create (7);
149
  NodeContainer n0n2 = NodeContainer (c.Get (0), c.Get (2));
168
  NodeContainer n0n2 = NodeContainer (c.Get (0), c.Get (2));
(-)a/src/test/ns3tcp/ns3tcp-cwnd-test-suite.cc (-3 / +21 lines)
 Lines 384-389    Link Here 
384
384
385
private:
385
private:
386
  virtual void DoRun (void);
386
  virtual void DoRun (void);
387
  virtual void DoSetup (void);
388
  virtual void DoTeardown (void);
389
  
387
  bool m_writeResults;
390
  bool m_writeResults;
388
391
389
  class CwndEvent {
392
  class CwndEvent {
 Lines 419-429    Link Here 
419
}
422
}
420
423
421
void
424
void
425
Ns3TcpCwndTestCase2::DoSetup (void)
426
{
427
  TestCase::DoSetup ();
428
  
429
  // Set up some default values for the simulation.
430
  Config::SetDefault ("ns3::DropTailQueue::MaxPackets", UintegerValue (4));
431
}
432
433
void
434
Ns3TcpCwndTestCase2::DoTeardown (void)
435
{
436
  // Restore defaults
437
  Config::SetDefault ("ns3::DropTailQueue::MaxPackets", UintegerValue (100));
438
  
439
  TestCase::DoTeardown ();
440
}
441
442
void
422
Ns3TcpCwndTestCase2::DoRun (void)
443
Ns3TcpCwndTestCase2::DoRun (void)
423
{
444
{
424
  // Set up some default values for the simulation.
425
  Config::SetDefault ("ns3::DropTailQueue::MaxPackets", UintegerValue (4));
426
427
  NodeContainer n0n1;
445
  NodeContainer n0n1;
428
  n0n1.Create (2);
446
  n0n1.Create (2);
429
447
(-)a/src/test/ns3tcp/ns3tcp-loss-test-suite.cc (-37 / +73 lines)
 Lines 115-120    Link Here 
115
void
115
void
116
Ns3TcpLossTestCase::DoSetup (void)
116
Ns3TcpLossTestCase::DoSetup (void)
117
{
117
{
118
  Simulator::Destroy();
119
  
120
  // Enable packet metadata
121
  Packet::EnablePrinting ();  
122
118
  //
123
  //
119
  // We expect there to be a file called ns3tcp-state-response-vectors.pcap in
124
  // We expect there to be a file called ns3tcp-state-response-vectors.pcap in
120
  // response-vectors/ of this directory
125
  // response-vectors/ of this directory
 Lines 133-144    Link Here 
133
      m_pcapFile.Open (m_pcapFilename, std::ios::in|std::ios::binary);
138
      m_pcapFile.Open (m_pcapFilename, std::ios::in|std::ios::binary);
134
      NS_ABORT_MSG_UNLESS (m_pcapFile.GetDataLinkType () == PCAP_LINK_TYPE, "Wrong response vectors in directory");
139
      NS_ABORT_MSG_UNLESS (m_pcapFile.GetDataLinkType () == PCAP_LINK_TYPE, "Wrong response vectors in directory");
135
    }
140
    }
141
142
  // Config
143
  std::ostringstream tcpModel;
144
  tcpModel << "ns3::Tcp" << m_tcpModel;
145
  Config::SetDefault ("ns3::TcpL4Protocol::SocketType", StringValue (tcpModel.str ()));
146
  Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (1000));
147
  Config::SetDefault ("ns3::TcpSocket::DelAckCount", UintegerValue (1));
148
149
  // Logging
150
  if (m_writeLogging)
151
    {
152
      LogComponentEnableAll (LOG_PREFIX_FUNC);
153
      LogComponentEnable ("TcpLossResponse", LOG_LEVEL_ALL);
154
      LogComponentEnable ("ErrorModel", LOG_LEVEL_DEBUG);
155
      LogComponentEnable ("TcpLossResponse", LOG_LEVEL_ALL);
156
      LogComponentEnable ("TcpNewReno", LOG_LEVEL_INFO);
157
      LogComponentEnable ("TcpReno", LOG_LEVEL_INFO);
158
      LogComponentEnable ("TcpTahoe", LOG_LEVEL_INFO);
159
      LogComponentEnable ("TcpSocketBase", LOG_LEVEL_INFO);
160
    }
161
136
}
162
}
137
163
138
void
164
void
139
Ns3TcpLossTestCase::DoTeardown (void)
165
Ns3TcpLossTestCase::DoTeardown (void)
140
{
166
{
167
  // Restore Config
168
  std::string tcpModel ("ns3::TcpNewReno");
169
  Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (536));
170
  Config::SetDefault ("ns3::TcpSocket::DelAckCount", UintegerValue (2));
171
172
  // Restore Logging
173
  if (m_writeLogging)
174
    {
175
      LogComponentDisableAll (LOG_PREFIX_FUNC);
176
      LogComponentDisable ("TcpLossResponse", LOG_LEVEL_ALL);
177
      LogComponentDisable ("ErrorModel", LOG_LEVEL_DEBUG);
178
      LogComponentDisable ("TcpLossResponse", LOG_LEVEL_ALL);
179
      LogComponentDisable ("TcpNewReno", LOG_LEVEL_INFO);
180
      LogComponentDisable ("TcpReno", LOG_LEVEL_INFO);
181
      LogComponentDisable ("TcpTahoe", LOG_LEVEL_INFO);
182
      LogComponentDisable ("TcpSocketBase", LOG_LEVEL_INFO);
183
    }
184
141
  m_pcapFile.Close ();
185
  m_pcapFile.Close ();
186
  
187
  // Enable packet metadata
188
  Packet::DisablePrinting ();  
189
  
190
  Simulator::Destroy();
142
}
191
}
143
192
144
void
193
void
 Lines 182-203    Link Here 
182
      // file and see if it still does the right thing.
231
      // file and see if it still does the right thing.
183
      //
232
      //
184
      uint8_t expected[PCAP_SNAPLEN];
233
      uint8_t expected[PCAP_SNAPLEN];
185
      uint32_t tsSec, tsUsec, inclLen, origLen, readLen;
234
      uint32_t tsSec=0, tsUsec=0, inclLen=0, origLen=0, readLen=0;
186
      m_pcapFile.Read (expected, sizeof(expected), tsSec, tsUsec, inclLen, origLen, readLen);
235
      m_pcapFile.Read (expected, sizeof(expected), tsSec, tsUsec, inclLen, origLen, readLen);
187
236
188
      uint8_t *actual = new uint8_t[readLen];
237
      if (readLen != 0 && origLen != 0) 
189
      p->CopyData (actual, readLen);
238
        {
239
          uint8_t *actual = new uint8_t[readLen];
240
          p->CopyData (actual, readLen);
190
241
191
      uint32_t result = memcmp (actual, expected, readLen);
242
          uint32_t result = memcmp (actual, expected, readLen);
192
243
193
      delete [] actual;
244
          delete [] actual;
194
245
195
      //
246
          //
196
      // Avoid streams of errors -- only report the first.
247
          // Avoid streams of errors -- only report the first.
197
      //
248
          //
198
      if (GetErrorStatus () == false)
249
          if (GetErrorStatus () == false)
250
            {
251
              NS_TEST_EXPECT_MSG_EQ (result, 0, "Expected data comparison error");
252
            }
253
        }
254
      else if (GetErrorStatus () == false)
199
        {
255
        {
200
          NS_TEST_EXPECT_MSG_EQ (result, 0, "Expected data comparison error");
256
          NS_TEST_EXPECT_MSG_GT (readLen, 0, "Unexpected packet error");
201
        }
257
        }
202
    }
258
    }
203
}
259
}
 Lines 282-306    Link Here 
282
  // Example corresponding to simulations in the paper "Simulation-based
338
  // Example corresponding to simulations in the paper "Simulation-based
283
  // Comparisons of Tahoe, Reno, and SACK TCP 
339
  // Comparisons of Tahoe, Reno, and SACK TCP 
284
340
285
  std::ostringstream tcpModel;
286
  tcpModel << "ns3::Tcp" << m_tcpModel;
287
  Config::SetDefault ("ns3::TcpL4Protocol::SocketType", 
288
                      StringValue (tcpModel.str ()));
289
  Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (1000));
290
  Config::SetDefault ("ns3::TcpSocket::DelAckCount", UintegerValue (1));
291
292
  if (m_writeLogging)
293
    {
294
      LogComponentEnableAll (LOG_PREFIX_FUNC);
295
      LogComponentEnable ("TcpLossResponse", LOG_LEVEL_ALL);
296
      LogComponentEnable ("ErrorModel", LOG_LEVEL_DEBUG);
297
      LogComponentEnable ("TcpLossResponse", LOG_LEVEL_ALL);
298
      LogComponentEnable ("TcpNewReno", LOG_LEVEL_INFO);
299
      LogComponentEnable ("TcpReno", LOG_LEVEL_INFO);
300
      LogComponentEnable ("TcpTahoe", LOG_LEVEL_INFO);
301
      LogComponentEnable ("TcpSocketBase", LOG_LEVEL_INFO);
302
    }
303
304
  ////////////////////////////////////////////////////////
341
  ////////////////////////////////////////////////////////
305
  // Topology construction
342
  // Topology construction
306
  //
343
  //
 Lines 359-371    Link Here 
359
                          ipInterfs.GetAddress (1), 
396
                          ipInterfs.GetAddress (1), 
360
                          servPort);
397
                          servPort);
361
398
362
  Config::Connect ("/NodeList/0/$ns3::Ipv4L3Protocol/Tx",
363
                   MakeCallback (&Ns3TcpLossTestCase::Ipv4L3Tx, this));
364
365
  Config::ConnectWithoutContext
366
    ("/NodeList/0/$ns3::TcpL4Protocol/SocketList/0/CongestionWindow",
367
    MakeCallback (&Ns3TcpLossTestCase::CwndTracer, this));
368
369
  ////////////////////////////////////////////////////////
399
  ////////////////////////////////////////////////////////
370
  // Set up loss model at node k1
400
  // Set up loss model at node k1
371
  //
401
  //
 Lines 403-408    Link Here 
403
  pem->SetList (sampleList);
433
  pem->SetList (sampleList);
404
  dev1.Get (1)->SetAttribute ("ReceiveErrorModel", PointerValue (pem));
434
  dev1.Get (1)->SetAttribute ("ReceiveErrorModel", PointerValue (pem));
405
435
436
  Config::Connect ("/NodeList/0/$ns3::Ipv4L3Protocol/Tx",
437
                   MakeCallback (&Ns3TcpLossTestCase::Ipv4L3Tx, this));
438
439
  Config::ConnectWithoutContext
440
    ("/NodeList/0/$ns3::TcpL4Protocol/SocketList/0/CongestionWindow",
441
    MakeCallback (&Ns3TcpLossTestCase::CwndTracer, this));
442
406
  // One can toggle the comment for the following line on or off to see the
443
  // One can toggle the comment for the following line on or off to see the
407
  // effects of finite send buffer modelling.  One can also change the size of
444
  // effects of finite send buffer modelling.  One can also change the size of
408
  // that buffer.
445
  // that buffer.
 Lines 442-448    Link Here 
442
Ns3TcpLossTestSuite::Ns3TcpLossTestSuite ()
479
Ns3TcpLossTestSuite::Ns3TcpLossTestSuite ()
443
  : TestSuite ("ns3-tcp-loss", SYSTEM)
480
  : TestSuite ("ns3-tcp-loss", SYSTEM)
444
{
481
{
445
  Packet::EnablePrinting ();  // Enable packet metadata for all test cases
446
  AddTestCase (new Ns3TcpLossTestCase ("Tahoe", 0));
482
  AddTestCase (new Ns3TcpLossTestCase ("Tahoe", 0));
447
  AddTestCase (new Ns3TcpLossTestCase ("Tahoe", 1));
483
  AddTestCase (new Ns3TcpLossTestCase ("Tahoe", 1));
448
  AddTestCase (new Ns3TcpLossTestCase ("Tahoe", 2));
484
  AddTestCase (new Ns3TcpLossTestCase ("Tahoe", 2));
(-)a/src/test/ns3tcp/ns3tcp-socket-test-suite.cc (-2 / +19 lines)
 Lines 158-163    Link Here 
158
158
159
private:
159
private:
160
  virtual void DoRun (void);
160
  virtual void DoRun (void);
161
  virtual void DoSetup (void);
162
  virtual void DoTeardown (void);
163
161
  bool m_writeResults;
164
  bool m_writeResults;
162
165
163
  void SinkRx (std::string path, Ptr<const Packet> p, const Address &address);
166
  void SinkRx (std::string path, Ptr<const Packet> p, const Address &address);
 Lines 179-184    Link Here 
179
}
182
}
180
183
181
void
184
void
185
Ns3TcpSocketTestCase2::DoSetup (void)
186
{
187
  TestCase::DoSetup ();
188
  Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (1000));
189
}
190
191
void
192
Ns3TcpSocketTestCase2::DoTeardown (void)
193
{
194
  // Restore defaults
195
  Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (536));
196
  
197
  TestCase::DoTeardown ();
198
}
199
200
void
182
Ns3TcpSocketTestCase2::DoRun (void)
201
Ns3TcpSocketTestCase2::DoRun (void)
183
{
202
{
184
  uint16_t sinkPort = 50000;
203
  uint16_t sinkPort = 50000;
 Lines 189-196    Link Here 
189
  Time writerStopTimeObj = Seconds (writerStopTime);
208
  Time writerStopTimeObj = Seconds (writerStopTime);
190
  Time simStopTimeObj= Seconds (simStopTime);
209
  Time simStopTimeObj= Seconds (simStopTime);
191
210
192
  Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (1000));
193
194
  NodeContainer nodes;
211
  NodeContainer nodes;
195
  nodes.Create (2);
212
  nodes.Create (2);
196
  Ptr<Node> n0 = nodes.Get (0);
213
  Ptr<Node> n0 = nodes.Get (0);
(-)a/src/test/ns3tcp/ns3tcp-state-test-suite.cc (-37 / +71 lines)
 Lines 110-115    Link Here 
110
void
110
void
111
Ns3TcpStateTestCase::DoSetup (void)
111
Ns3TcpStateTestCase::DoSetup (void)
112
{
112
{
113
  Simulator::Destroy();
114
115
  // Enable packet metadata
116
  Packet::EnablePrinting ();  
117
  
113
  //
118
  //
114
  // We expect there to be a file called ns3tcp-state-response-vectors.pcap in
119
  // We expect there to be a file called ns3tcp-state-response-vectors.pcap in
115
  // response-vectors/ of this directory
120
  // response-vectors/ of this directory
 Lines 128-139    Link Here 
128
      m_pcapFile.Open (m_pcapFilename, std::ios::in|std::ios::binary);
133
      m_pcapFile.Open (m_pcapFilename, std::ios::in|std::ios::binary);
129
      NS_ABORT_MSG_UNLESS (m_pcapFile.GetDataLinkType () == PCAP_LINK_TYPE, "Wrong response vectors in directory");
134
      NS_ABORT_MSG_UNLESS (m_pcapFile.GetDataLinkType () == PCAP_LINK_TYPE, "Wrong response vectors in directory");
130
    }
135
    }
136
  
137
  // Config
138
  std::string tcpModel ("ns3::TcpNewReno");
139
  Config::SetDefault ("ns3::TcpL4Protocol::SocketType", StringValue (tcpModel));
140
  Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (1000));
141
  Config::SetDefault ("ns3::TcpSocket::DelAckCount", UintegerValue (1));
142
  Config::SetDefault ("ns3::DropTailQueue::MaxPackets", UintegerValue (20));
143
144
  // Logging  
145
  if (m_writeLogging)
146
    {
147
      LogComponentEnableAll (LOG_PREFIX_FUNC);
148
      LogComponentEnable ("TcpTestCases", LOG_LEVEL_ALL);
149
      LogComponentEnable ("ErrorModel", LOG_LEVEL_DEBUG);
150
      LogComponentEnable ("TcpTestCases", LOG_LEVEL_ALL);
151
      LogComponentEnable ("TcpNewReno", LOG_LEVEL_INFO);
152
      LogComponentEnable ("TcpReno", LOG_LEVEL_INFO);
153
      LogComponentEnable ("TcpTahoe", LOG_LEVEL_INFO);
154
      LogComponentEnable ("TcpSocketBase", LOG_LEVEL_INFO);
155
    }
131
}
156
}
132
157
133
void
158
void
134
Ns3TcpStateTestCase::DoTeardown (void)
159
Ns3TcpStateTestCase::DoTeardown (void)
135
{
160
{
161
  // Restore Logging
162
  if (m_writeLogging)
163
    {
164
      LogComponentDisableAll (LOG_PREFIX_FUNC);
165
      LogComponentDisable ("TcpTestCases", LOG_LEVEL_ALL);
166
      LogComponentDisable ("ErrorModel", LOG_LEVEL_DEBUG);
167
      LogComponentDisable ("TcpTestCases", LOG_LEVEL_ALL);
168
      LogComponentDisable ("TcpNewReno", LOG_LEVEL_INFO);
169
      LogComponentDisable ("TcpReno", LOG_LEVEL_INFO);
170
      LogComponentDisable ("TcpTahoe", LOG_LEVEL_INFO);
171
      LogComponentDisable ("TcpSocketBase", LOG_LEVEL_INFO);
172
    }
173
  
174
  // Restore config to usual defaults
175
  Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (536));
176
  Config::SetDefault ("ns3::TcpSocket::DelAckCount", UintegerValue (2));
177
  Config::SetDefault ("ns3::DropTailQueue::MaxPackets", UintegerValue (100));
178
  // No need to restore ns3::TcpL4Protocol::SocketType, ns3::TcpNewReno is already the default
179
136
  m_pcapFile.Close ();
180
  m_pcapFile.Close ();
181
182
  // Enable packet metadata
183
  Packet::DisablePrinting ();  
184
185
  Simulator::Destroy();
137
}
186
}
138
187
139
void
188
void
 Lines 177-198    Link Here 
177
      // file and see if it still does the right thing.
226
      // file and see if it still does the right thing.
178
      //
227
      //
179
      uint8_t expected[PCAP_SNAPLEN];
228
      uint8_t expected[PCAP_SNAPLEN];
180
      uint32_t tsSec, tsUsec, inclLen, origLen, readLen;
229
      uint32_t tsSec=0, tsUsec=0, inclLen=0, origLen=0, readLen=0;
181
      m_pcapFile.Read (expected, sizeof(expected), tsSec, tsUsec, inclLen, origLen, readLen);
230
      m_pcapFile.Read (expected, sizeof(expected), tsSec, tsUsec, inclLen, origLen, readLen);
231
      
232
      if (readLen != 0 && origLen != 0) 
233
        {
234
          uint8_t *actual = new uint8_t[readLen];
235
          p->CopyData (actual, readLen);
182
236
183
      uint8_t *actual = new uint8_t[readLen];
237
          uint32_t result = memcmp (actual, expected, readLen);
184
      p->CopyData (actual, readLen);
185
238
186
      uint32_t result = memcmp (actual, expected, readLen);
239
          delete [] actual;
187
240
188
      delete [] actual;
241
          //
189
242
          // Avoid streams of errors -- only report the first.
190
      //
243
          //
191
      // Avoid streams of errors -- only report the first.
244
          if (GetErrorStatus () == false)
192
      //
245
            {
193
      if (GetErrorStatus () == false)
246
              NS_TEST_EXPECT_MSG_EQ (result, 0, "Expected data comparison error");
247
            }
248
        }
249
      else if (GetErrorStatus () == false)
194
        {
250
        {
195
          NS_TEST_EXPECT_MSG_EQ (result, 0, "Expected data comparison error");
251
          NS_TEST_EXPECT_MSG_GT (readLen, 0, "Unexpected packet error");
196
        }
252
        }
197
    }
253
    }
198
}
254
}
 Lines 266-294    Link Here 
266
  //           10Mb/s, 0.1ms      10Mb/s, 0.1ms
322
  //           10Mb/s, 0.1ms      10Mb/s, 0.1ms
267
  //       n0-----------------n1-----------------n2
323
  //       n0-----------------n1-----------------n2
268
324
269
  std::string tcpModel ("ns3::TcpNewReno");
270
271
  Config::SetDefault ("ns3::TcpL4Protocol::SocketType", StringValue (tcpModel));
272
  Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (1000));
273
  Config::SetDefault ("ns3::TcpSocket::DelAckCount", UintegerValue (1));
274
  Config::SetDefault ("ns3::DropTailQueue::MaxPackets", UintegerValue (20));
275
276
  if (m_writeLogging)
277
    {
278
      LogComponentEnableAll (LOG_PREFIX_FUNC);
279
      LogComponentEnable ("TcpTestCases", LOG_LEVEL_ALL);
280
      LogComponentEnable ("ErrorModel", LOG_LEVEL_DEBUG);
281
      LogComponentEnable ("TcpTestCases", LOG_LEVEL_ALL);
282
      LogComponentEnable ("TcpNewReno", LOG_LEVEL_INFO);
283
      LogComponentEnable ("TcpReno", LOG_LEVEL_INFO);
284
      LogComponentEnable ("TcpTahoe", LOG_LEVEL_INFO);
285
      LogComponentEnable ("TcpSocketBase", LOG_LEVEL_INFO);
286
    }
287
288
  ////////////////////////////////////////////////////////
325
  ////////////////////////////////////////////////////////
289
  // Topology construction
326
  // Topology construction
290
  //
327
  //
291
328
  
292
  // Create three nodes
329
  // Create three nodes
293
  NodeContainer n0n1;
330
  NodeContainer n0n1;
294
  n0n1.Create (2);
331
  n0n1.Create (2);
 Lines 338-346    Link Here 
338
  Simulator::ScheduleNow (&Ns3TcpStateTestCase::StartFlow, this, 
375
  Simulator::ScheduleNow (&Ns3TcpStateTestCase::StartFlow, this, 
339
                          localSocket, ipInterfs.GetAddress (1), servPort);
376
                          localSocket, ipInterfs.GetAddress (1), servPort);
340
377
341
  Config::Connect ("/NodeList/0/$ns3::Ipv4L3Protocol/Tx",
342
                   MakeCallback (&Ns3TcpStateTestCase::Ipv4L3Tx, this));
343
344
  ////////////////////////////////////////////////////////
378
  ////////////////////////////////////////////////////////
345
  // Set up different test cases: Lost model at node n1, different file size
379
  // Set up different test cases: Lost model at node n1, different file size
346
  //
380
  //
 Lines 411-416    Link Here 
411
  errN1->SetList (dropListN1);
445
  errN1->SetList (dropListN1);
412
  dev1.Get (0)->SetAttribute ("ReceiveErrorModel", PointerValue (errN1));
446
  dev1.Get (0)->SetAttribute ("ReceiveErrorModel", PointerValue (errN1));
413
447
448
  Config::Connect ("/NodeList/0/$ns3::Ipv4L3Protocol/Tx",
449
                   MakeCallback (&Ns3TcpStateTestCase::Ipv4L3Tx, this));
450
414
  std::ostringstream oss;
451
  std::ostringstream oss;
415
  oss << "tcp-state" << m_testCase << "-test-case";
452
  oss << "tcp-state" << m_testCase << "-test-case";
416
  if (m_writeResults)
453
  if (m_writeResults)
 Lines 434-441    Link Here 
434
  Simulator::Stop (Seconds (1000));
471
  Simulator::Stop (Seconds (1000));
435
  Simulator::Run ();
472
  Simulator::Run ();
436
  Simulator::Destroy ();
473
  Simulator::Destroy ();
437
438
439
}
474
}
440
475
441
class Ns3TcpStateTestSuite : public TestSuite
476
class Ns3TcpStateTestSuite : public TestSuite
 Lines 447-453    Link Here 
447
Ns3TcpStateTestSuite::Ns3TcpStateTestSuite ()
482
Ns3TcpStateTestSuite::Ns3TcpStateTestSuite ()
448
  : TestSuite ("ns3-tcp-state", SYSTEM)
483
  : TestSuite ("ns3-tcp-state", SYSTEM)
449
{
484
{
450
  Packet::EnablePrinting ();  // Enable packet metadata for all test cases
451
  AddTestCase (new Ns3TcpStateTestCase (0));
485
  AddTestCase (new Ns3TcpStateTestCase (0));
452
  AddTestCase (new Ns3TcpStateTestCase (1));
486
  AddTestCase (new Ns3TcpStateTestCase (1));
453
  AddTestCase (new Ns3TcpStateTestCase (2));
487
  AddTestCase (new Ns3TcpStateTestCase (2));
(-)a/src/test/ns3wifi/wifi-interference-test-suite.cc (-13 / +34 lines)
 Lines 57-62    Link Here 
57
57
58
private:
58
private:
59
  virtual void DoRun (void);
59
  virtual void DoRun (void);
60
  virtual void DoSetup (void);
61
  virtual void DoTeardown (void);
62
  
60
  void ReceivePacket (Ptr<Socket> socket);
63
  void ReceivePacket (Ptr<Socket> socket);
61
  static void GenerateTraffic (Ptr<Socket> socket, uint32_t pktSize, uint32_t pktCount, Time pktInterval);
64
  static void GenerateTraffic (Ptr<Socket> socket, uint32_t pktSize, uint32_t pktCount, Time pktInterval);
62
  void PrintEndSync (std::string context, uint32_t dataRate, double snr, double per);
65
  void PrintEndSync (std::string context, uint32_t dataRate, double snr, double per);
 Lines 65-75    Link Here 
65
  double m_PER;
68
  double m_PER;
66
  double m_SNR;
69
  double m_SNR;
67
  uint32_t m_DataRate;
70
  uint32_t m_DataRate;
71
  
72
  std::string m_phyMode;
68
};
73
};
69
74
70
// Add some help text to this case to describe what it is intended to test
75
// Add some help text to this case to describe what it is intended to test
71
WifiInterferenceTestCase::WifiInterferenceTestCase  ()
76
WifiInterferenceTestCase::WifiInterferenceTestCase  ()
72
  : TestCase ("Test interference calculation when interfering frame exactly overlaps intended frame")
77
  : TestCase ("Test interference calculation when interfering frame exactly overlaps intended frame")
78
  , m_phyMode ("DsssRate1Mbps")
73
{
79
{
74
}
80
}
75
81
 Lines 77-82    Link Here 
77
{
83
{
78
}
84
}
79
85
86
void
87
WifiInterferenceTestCase::DoSetup ()
88
{
89
  TestCase::DoSetup ();
90
  
91
  // disable fragmentation for frames below 2200 bytes
92
  Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2200"));
93
  // turn off RTS/CTS for frames below 2200 bytes
94
  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("2200"));
95
  // Fix non-unicast data rate to be the same as that of unicast
96
  Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode", StringValue (m_phyMode));
97
}
98
99
void
100
WifiInterferenceTestCase::DoTeardown ()
101
{
102
  // Restore default configuration
103
  std::string invalidWifiMode ("Invalid-WifiMode");
104
  Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2346"));
105
  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("2346"));
106
  Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode", StringValue (invalidWifiMode));
107
  
108
  TestCase::DoTeardown ();
109
}
110
80
void 
111
void 
81
WifiInterferenceTestCase::ReceivePacket (Ptr<Socket> socket)
112
WifiInterferenceTestCase::ReceivePacket (Ptr<Socket> socket)
82
{
113
{
 Lines 131-144    Link Here 
131
  // Convert to time object
162
  // Convert to time object
132
  Time interPacketInterval = Seconds (interval);
163
  Time interPacketInterval = Seconds (interval);
133
164
134
  // disable fragmentation for frames below 2200 bytes
135
  Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2200"));
136
  // turn off RTS/CTS for frames below 2200 bytes
137
  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("2200"));
138
  // Fix non-unicast data rate to be the same as that of unicast
139
  Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode", 
140
                      StringValue (phyMode));
141
142
  NodeContainer c;
165
  NodeContainer c;
143
  c.Create (3);
166
  c.Create (3);
144
167
 Lines 232-239    Link Here 
232
void
255
void
233
WifiInterferenceTestCase::DoRun (void)
256
WifiInterferenceTestCase::DoRun (void)
234
{
257
{
235
236
  std::string phyMode ("DsssRate1Mbps");
237
  double Prss = -90;  // -dBm
258
  double Prss = -90;  // -dBm
238
  double Irss = -90;  // -dBm
259
  double Irss = -90;  // -dBm
239
  double delta = 0;  // microseconds
260
  double delta = 0;  // microseconds
 Lines 246-262    Link Here 
246
  // Compute the packet error rate (PER) when delta=0 microseconds.  This
267
  // Compute the packet error rate (PER) when delta=0 microseconds.  This
247
  // means that the interferer arrives at exactly the same time as the
268
  // means that the interferer arrives at exactly the same time as the
248
  // intended packet
269
  // intended packet
249
  PER = WifiSimpleInterference (phyMode,Prss,Irss,delta,PpacketSize,IpacketSize,verbose,internet);
270
  PER = WifiSimpleInterference (m_phyMode,Prss,Irss,delta,PpacketSize,IpacketSize,verbose,internet);
250
271
251
  // Now rerun this test case and compute the PER when the delta time between
272
  // Now rerun this test case and compute the PER when the delta time between
252
  // arrival of the intended frame and interferer is 1 microsecond.
273
  // arrival of the intended frame and interferer is 1 microsecond.
253
  delta = 1;
274
  delta = 1;
254
  PER1 = WifiSimpleInterference (phyMode,Prss,Irss,delta,PpacketSize,IpacketSize,verbose,internet);
275
  PER1 = WifiSimpleInterference (m_phyMode,Prss,Irss,delta,PpacketSize,IpacketSize,verbose,internet);
255
276
256
  // Now rerun this test case and compute the PER when the delta time between
277
  // Now rerun this test case and compute the PER when the delta time between
257
  // arrival of the intended frame and interferer is 2 microseconds.
278
  // arrival of the intended frame and interferer is 2 microseconds.
258
  delta = 2;
279
  delta = 2;
259
  PER2 = WifiSimpleInterference (phyMode,Prss,Irss,delta,PpacketSize,IpacketSize,verbose,internet);
280
  PER2 = WifiSimpleInterference (m_phyMode,Prss,Irss,delta,PpacketSize,IpacketSize,verbose,internet);
260
281
261
  double PERDiff1 = PER - PER1;
282
  double PERDiff1 = PER - PER1;
262
283
(-)a/src/aodv/test/bug-772.cc (+1 lines)
 Lines 74-79    Link Here 
74
Bug772ChainTest::DoRun ()
74
Bug772ChainTest::DoRun ()
75
{
75
{
76
  SeedManager::SetSeed (12345);
76
  SeedManager::SetSeed (12345);
77
  Config::SetDefault ("ns3::ArpCache::AliveTimeout", TimeValue (Seconds (1)));
77
78
78
  CreateNodes ();
79
  CreateNodes ();
79
  CreateDevices ();
80
  CreateDevices ();
(-)a/src/core/model/test.cc (+8 lines)
 Lines 22-27    Link Here 
22
#include <math.h>
22
#include <math.h>
23
23
24
#include "ns3/simulator.h"
24
#include "ns3/simulator.h"
25
#include "ns3/config.h"
25
26
26
// Set to true to enable a segmentation fault upon a test case macro test 
27
// Set to true to enable a segmentation fault upon a test case macro test 
27
// failing (for debugging purposes)
28
// failing (for debugging purposes)
 Lines 414-419    Link Here 
414
   * must destroy the simulator on TestCase teardown just in case.
415
   * must destroy the simulator on TestCase teardown just in case.
415
   */
416
   */
416
  Simulator::Destroy();
417
  Simulator::Destroy();
418
  
419
  /**
420
   *   Some tests will change default configuration settings. In
421
   * those cases, a full configuration reset is the only way to get
422
   * back to a reproducible state.
423
   */
424
  Config::Reset ();
417
}
425
}
418
426
419
TestSuite::TestSuite (std::string name, TestType type)
427
TestSuite::TestSuite (std::string name, TestType type)
(-)a/src/core/test/names-test-suite.cc (+14 lines)
 Lines 87-92    Link Here 
87
BasicAddTestCase::DoTeardown (void)
87
BasicAddTestCase::DoTeardown (void)
88
{
88
{
89
  Names::Clear ();
89
  Names::Clear ();
90
  TestCase::DoTeardown ();
90
}
91
}
91
92
92
void
93
void
 Lines 153-158    Link Here 
153
StringContextAddTestCase::DoTeardown (void)
154
StringContextAddTestCase::DoTeardown (void)
154
{
155
{
155
  Names::Clear ();
156
  Names::Clear ();
157
  TestCase::DoTeardown ();
156
}
158
}
157
159
158
void
160
void
 Lines 216-221    Link Here 
216
FullyQualifiedAddTestCase::DoTeardown (void)
218
FullyQualifiedAddTestCase::DoTeardown (void)
217
{
219
{
218
  Names::Clear ();
220
  Names::Clear ();
221
  TestCase::DoTeardown ();
219
}
222
}
220
223
221
void
224
void
 Lines 282-287    Link Here 
282
RelativeAddTestCase::DoTeardown (void)
285
RelativeAddTestCase::DoTeardown (void)
283
{
286
{
284
  Names::Clear ();
287
  Names::Clear ();
288
  TestCase::DoTeardown ();
285
}
289
}
286
290
287
void
291
void
 Lines 347-352    Link Here 
347
BasicRenameTestCase::DoTeardown (void)
351
BasicRenameTestCase::DoTeardown (void)
348
{
352
{
349
  Names::Clear ();
353
  Names::Clear ();
354
  TestCase::DoTeardown ();
350
}
355
}
351
356
352
void
357
void
 Lines 407-412    Link Here 
407
StringContextRenameTestCase::DoTeardown (void)
412
StringContextRenameTestCase::DoTeardown (void)
408
{
413
{
409
  Names::Clear ();
414
  Names::Clear ();
415
  TestCase::DoTeardown ();
410
}
416
}
411
417
412
void
418
void
 Lines 467-472    Link Here 
467
FullyQualifiedRenameTestCase::DoTeardown (void)
473
FullyQualifiedRenameTestCase::DoTeardown (void)
468
{
474
{
469
  Names::Clear ();
475
  Names::Clear ();
476
  TestCase::DoTeardown ();
470
}
477
}
471
478
472
void
479
void
 Lines 527-532    Link Here 
527
RelativeRenameTestCase::DoTeardown (void)
534
RelativeRenameTestCase::DoTeardown (void)
528
{
535
{
529
  Names::Clear ();
536
  Names::Clear ();
537
  TestCase::DoTeardown ();
530
}
538
}
531
539
532
void
540
void
 Lines 587-592    Link Here 
587
FindPathTestCase::DoTeardown (void)
595
FindPathTestCase::DoTeardown (void)
588
{
596
{
589
  Names::Clear ();
597
  Names::Clear ();
598
  TestCase::DoTeardown ();
590
}
599
}
591
600
592
void
601
void
 Lines 641-646    Link Here 
641
BasicFindTestCase::DoTeardown (void)
650
BasicFindTestCase::DoTeardown (void)
642
{
651
{
643
  Names::Clear ();
652
  Names::Clear ();
653
  TestCase::DoTeardown ();
644
}
654
}
645
655
646
void
656
void
 Lines 703-708    Link Here 
703
StringContextFindTestCase::DoTeardown (void)
713
StringContextFindTestCase::DoTeardown (void)
704
{
714
{
705
  Names::Clear ();
715
  Names::Clear ();
716
  TestCase::DoTeardown ();
706
}
717
}
707
718
708
void
719
void
 Lines 765-770    Link Here 
765
FullyQualifiedFindTestCase::DoTeardown (void)
776
FullyQualifiedFindTestCase::DoTeardown (void)
766
{
777
{
767
  Names::Clear ();
778
  Names::Clear ();
779
  TestCase::DoTeardown ();
768
}
780
}
769
781
770
void
782
void
 Lines 827-832    Link Here 
827
RelativeFindTestCase::DoTeardown (void)
839
RelativeFindTestCase::DoTeardown (void)
828
{
840
{
829
  Names::Clear ();
841
  Names::Clear ();
842
  TestCase::DoTeardown ();
830
}
843
}
831
844
832
void
845
void
 Lines 887-892    Link Here 
887
AlternateFindTestCase::DoTeardown (void)
900
AlternateFindTestCase::DoTeardown (void)
888
{
901
{
889
  Names::Clear ();
902
  Names::Clear ();
903
  TestCase::DoTeardown ();
890
}
904
}
891
905
892
void
906
void
(-)a/src/core/test/time-test-suite.cc (+1 lines)
 Lines 76-81    Link Here 
76
TimeSimpleTestCase::DoTeardown (void)
76
TimeSimpleTestCase::DoTeardown (void)
77
{
77
{
78
  Time::SetResolution (m_originalResolution);
78
  Time::SetResolution (m_originalResolution);
79
  TestCase::DoTeardown ();
79
}
80
}
80
81
81
static class TimeTestSuite : public TestSuite
82
static class TimeTestSuite : public TestSuite
(-)a/src/core/test/timer-test-suite.cc (+1 lines)
 Lines 215-220    Link Here 
215
{
215
{
216
  Simulator::Run ();
216
  Simulator::Run ();
217
  Simulator::Destroy ();
217
  Simulator::Destroy ();
218
  TestCase::DoTeardown ();
218
}
219
}
219
220
220
static class TimerTestSuite : public TestSuite
221
static class TimerTestSuite : public TestSuite
(-)a/src/energy/test/basic-energy-model-test.cc (-13 lines)
 Lines 218-224    Link Here 
218
private:
218
private:
219
  void DoRun (void);
219
  void DoRun (void);
220
  void DoSetup (void);
220
  void DoSetup (void);
221
  void DoTeardown (void);
222
221
223
  /**
222
  /**
224
   * Callback invoked when energy is drained from source.
223
   * Callback invoked when energy is drained from source.
 Lines 276-293    Link Here 
276
}
275
}
277
276
278
void
277
void
279
BasicEnergyDepletionTest::DoTeardown (void)
280
{
281
  // Restore defaults
282
  std::string invalidWifiMode ("Invalid-WifiMode");
283
  Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2346"));
284
  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("2346"));
285
  Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode", StringValue (invalidWifiMode));
286
  
287
  TestCase::DoTeardown ();
288
}
289
290
void
291
BasicEnergyDepletionTest::DoRun (void)
278
BasicEnergyDepletionTest::DoRun (void)
292
{
279
{
293
  /*
280
  /*
(-)a/src/energy/test/rv-battery-model-test.cc (-17 lines)
 Lines 67-77    Link Here 
67
  void DoSetup (void);
67
  void DoSetup (void);
68
68
69
  /**
69
  /**
70
   * Restores environment after test runs
71
   */
72
  void DoTeardown (void);
73
74
  /**
75
   * \param load Load value, in Amperes (A).
70
   * \param load Load value, in Amperes (A).
76
   * \param expLifetime Expected lifetime.
71
   * \param expLifetime Expected lifetime.
77
   * \return False if no error occurs.
72
   * \return False if no error occurs.
 Lines 667-684    Link Here 
667
}
662
}
668
663
669
void
664
void
670
BatteryLifetimeTest::DoTeardown (void)
671
{
672
  // Restore defaults
673
  std::string invalidWifiMode ("Invalid-WifiMode");
674
  Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2346"));
675
  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("2346"));
676
  Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode", StringValue (invalidWifiMode));
677
  
678
  TestCase::DoTeardown ();
679
}
680
681
void
682
BatteryLifetimeTest::DoRun (void)
665
BatteryLifetimeTest::DoRun (void)
683
{
666
{
684
  NS_LOG_DEBUG ("Constant load run.");
667
  NS_LOG_DEBUG ("Constant load run.");
(-)a/src/internet/test/ipv4-address-generator-test-suite.cc (-3 / +5 lines)
 Lines 38-43    Link Here 
38
NetworkNumberAllocatorTestCase::DoTeardown (void)
38
NetworkNumberAllocatorTestCase::DoTeardown (void)
39
{
39
{
40
  Ipv4AddressGenerator::Reset ();
40
  Ipv4AddressGenerator::Reset ();
41
  TestCase::DoTeardown ();
41
}
42
}
42
void
43
void
43
NetworkNumberAllocatorTestCase::DoRun (void)
44
NetworkNumberAllocatorTestCase::DoRun (void)
 Lines 117-123    Link Here 
117
AddressAllocatorTestCase::DoTeardown (void)
118
AddressAllocatorTestCase::DoTeardown (void)
118
{
119
{
119
  Ipv4AddressGenerator::Reset ();
120
  Ipv4AddressGenerator::Reset ();
120
  Simulator::Destroy ();
121
  TestCase::DoTeardown ();
121
}
122
}
122
123
123
124
 Lines 138-144    Link Here 
138
NetworkAndAddressTestCase::DoTeardown (void)
139
NetworkAndAddressTestCase::DoTeardown (void)
139
{
140
{
140
  Ipv4AddressGenerator::Reset ();
141
  Ipv4AddressGenerator::Reset ();
141
  Simulator::Destroy ();
142
  TestCase::DoTeardown ();
142
}
143
}
143
144
144
void
145
void
 Lines 202-207    Link Here 
202
ExampleAddressGeneratorTestCase::DoTeardown (void)
203
ExampleAddressGeneratorTestCase::DoTeardown (void)
203
{
204
{
204
  Ipv4AddressGenerator::Reset ();
205
  Ipv4AddressGenerator::Reset ();
206
  TestCase::DoTeardown ();
205
}
207
}
206
208
207
void
209
void
 Lines 254-260    Link Here 
254
AddressCollisionTestCase::DoTeardown (void)
256
AddressCollisionTestCase::DoTeardown (void)
255
{
257
{
256
  Ipv4AddressGenerator::Reset ();
258
  Ipv4AddressGenerator::Reset ();
257
  Simulator::Destroy ();
259
  TestCase::DoTeardown ();
258
}
260
}
259
void
261
void
260
AddressCollisionTestCase::DoRun (void)
262
AddressCollisionTestCase::DoRun (void)
(-)a/src/internet/test/ipv4-address-helper-test-suite.cc (-3 / +3 lines)
 Lines 41-47    Link Here 
41
NetworkAllocatorHelperTestCase::DoTeardown (void)
41
NetworkAllocatorHelperTestCase::DoTeardown (void)
42
{
42
{
43
  Ipv4AddressGenerator::Reset ();
43
  Ipv4AddressGenerator::Reset ();
44
  Simulator::Destroy ();
44
  TestCase::DoTeardown ();
45
}
45
}
46
void
46
void
47
NetworkAllocatorHelperTestCase::DoRun (void)
47
NetworkAllocatorHelperTestCase::DoRun (void)
 Lines 87-93    Link Here 
87
AddressAllocatorHelperTestCase::DoTeardown (void)
87
AddressAllocatorHelperTestCase::DoTeardown (void)
88
{
88
{
89
  Ipv4AddressGenerator::Reset ();
89
  Ipv4AddressGenerator::Reset ();
90
  Simulator::Destroy ();
90
  TestCase::DoTeardown ();
91
}
91
}
92
92
93
void
93
void
 Lines 176-182    Link Here 
176
ResetAllocatorHelperTestCase::DoTeardown (void)
176
ResetAllocatorHelperTestCase::DoTeardown (void)
177
{
177
{
178
  Ipv4AddressGenerator::Reset ();
178
  Ipv4AddressGenerator::Reset ();
179
  Simulator::Destroy ();
179
  TestCase::DoTeardown ();
180
}
180
}
181
181
182
static class Ipv4AddressHelperTestSuite : public TestSuite
182
static class Ipv4AddressHelperTestSuite : public TestSuite
(-)a/src/internet/test/tcp-test.cc (-1 / +1 lines)
 Lines 160-166    Link Here 
160
  delete [] m_sourceTxPayload;
160
  delete [] m_sourceTxPayload;
161
  delete [] m_sourceRxPayload;
161
  delete [] m_sourceRxPayload;
162
  delete [] m_serverRxPayload;
162
  delete [] m_serverRxPayload;
163
  Simulator::Destroy ();
163
  TestCase::DoTeardown ();
164
}
164
}
165
165
166
void
166
void
(-)a/src/mobility/test/ns2-mobility-helper-test-suite.cc (-1 / +1 lines)
 Lines 212-218    Link Here 
212
  {
212
  {
213
    Names::Clear ();
213
    Names::Clear ();
214
    std::remove (m_traceFile.c_str ());
214
    std::remove (m_traceFile.c_str ());
215
    Simulator::Destroy ();
215
    TestCase::DoTeardown ();
216
  }
216
  }
217
  
217
  
218
  /// Go
218
  /// Go
(-)a/src/mobility/test/steady-state-random-waypoint-mobility-model-test.cc (+1 lines)
 Lines 47-52    Link Here 
47
SteadyStateRandomWaypointTest::DoTeardown (void)
47
SteadyStateRandomWaypointTest::DoTeardown (void)
48
{
48
{
49
  mobilityStack.clear();
49
  mobilityStack.clear();
50
  TestCase::DoTeardown();
50
}
51
}
51
52
52
void
53
void
(-)a/src/mobility/test/waypoint-mobility-model-test.cc (+1 lines)
 Lines 57-62    Link Here 
57
{
57
{
58
  mobilityStack.clear();
58
  mobilityStack.clear();
59
  waypoints.clear();
59
  waypoints.clear();
60
  TestCase::DoTeardown();
60
}
61
}
61
62
62
void
63
void
(-)a/src/network/test/pcap-file-test-suite.cc (+6 lines)
 Lines 114-119    Link Here 
114
WriteModeCreateTestCase::DoTeardown (void)
114
WriteModeCreateTestCase::DoTeardown (void)
115
{
115
{
116
  remove (m_testFilename.c_str ());
116
  remove (m_testFilename.c_str ());
117
  TestCase::DoTeardown ();
117
}
118
}
118
119
119
void
120
void
 Lines 226-231    Link Here 
226
ReadModeCreateTestCase::DoTeardown (void)
227
ReadModeCreateTestCase::DoTeardown (void)
227
{
228
{
228
  remove (m_testFilename.c_str ());
229
  remove (m_testFilename.c_str ());
230
  TestCase::DoTeardown ();
229
}
231
}
230
232
231
void
233
void
 Lines 332-337    Link Here 
332
AppendModeCreateTestCase::DoTeardown (void)
334
AppendModeCreateTestCase::DoTeardown (void)
333
{
335
{
334
  remove (m_testFilename.c_str ());
336
  remove (m_testFilename.c_str ());
337
  TestCase::DoTeardown ();
335
}
338
}
336
339
337
void
340
void
 Lines 438-443    Link Here 
438
FileHeaderTestCase::DoTeardown (void)
441
FileHeaderTestCase::DoTeardown (void)
439
{
442
{
440
  remove (m_testFilename.c_str ());
443
  remove (m_testFilename.c_str ());
444
  TestCase::DoTeardown ();
441
}
445
}
442
446
443
void
447
void
 Lines 675-680    Link Here 
675
RecordHeaderTestCase::DoTeardown (void)
679
RecordHeaderTestCase::DoTeardown (void)
676
{
680
{
677
  remove (m_testFilename.c_str ());
681
  remove (m_testFilename.c_str ());
682
  TestCase::DoTeardown ();
678
}
683
}
679
684
680
void
685
void
 Lines 972-977    Link Here 
972
void
977
void
973
ReadFileTestCase::DoTeardown (void)
978
ReadFileTestCase::DoTeardown (void)
974
{
979
{
980
  TestCase::DoTeardown ();
975
}
981
}
976
982
977
const uint32_t N_KNOWN_PACKETS = 6;
983
const uint32_t N_KNOWN_PACKETS = 6;
(-)a/src/olsr/test/bug780-test.cc (-11 lines)
 Lines 86-102    Link Here 
86
}
86
}
87
87
88
void
88
void
89
Bug780Test::DoTeardown ()
90
{
91
  //sending one packets per sec
92
  // Fix non-unicast data rate to be the same as that of unicast
93
  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold",
94
                      StringValue ("2346"));
95
  
96
  TestCase::DoTeardown ();
97
}
98
99
void
100
Bug780Test::DoRun ()
89
Bug780Test::DoRun ()
101
{
90
{
102
  SeedManager::SetSeed (123);
91
  SeedManager::SetSeed (123);
(-)a/src/olsr/test/bug780-test.h (-1 lines)
 Lines 43-49    Link Here 
43
  /// Go
43
  /// Go
44
  void DoRun ();
44
  void DoRun ();
45
  void DoSetup ();
45
  void DoSetup ();
46
  void DoTeardown ();
47
};
46
};
48
47
49
}
48
}
(-)a/src/propagation/test/propagation-loss-model-test-suite.cc (-44 lines)
 Lines 43-49    Link Here 
43
private:
43
private:
44
  virtual void DoRun (void);
44
  virtual void DoRun (void);
45
  virtual void DoSetup (void);
45
  virtual void DoSetup (void);
46
  virtual void DoTeardown (void);
47
46
48
  typedef struct {
47
  typedef struct {
49
    Vector m_position;
48
    Vector m_position;
 Lines 78-93    Link Here 
78
}
77
}
79
78
80
void
79
void
81
FriisPropagationLossModelTestCase::DoTeardown (void)
82
{
83
  // Restore defaults
84
  Config::SetDefault ("ns3::FriisPropagationLossModel::Lambda", DoubleValue (0.0582524));
85
  Config::SetDefault ("ns3::FriisPropagationLossModel::SystemLoss", DoubleValue (1.0));
86
87
  TestCase::DoTeardown ();
88
}
89
90
void
91
FriisPropagationLossModelTestCase::DoRun (void)
80
FriisPropagationLossModelTestCase::DoRun (void)
92
{
81
{
93
  // The ns-3 testing manual gives more background on the values selected
82
  // The ns-3 testing manual gives more background on the values selected
 Lines 161-167    Link Here 
161
private:
150
private:
162
  virtual void DoRun (void);
151
  virtual void DoRun (void);
163
  virtual void DoSetup (void);
152
  virtual void DoSetup (void);
164
  virtual void DoTeardown (void);
165
153
166
  typedef struct
154
  typedef struct
167
  {
155
  {
 Lines 198-214    Link Here 
198
}
186
}
199
187
200
void
188
void
201
TwoRayGroundPropagationLossModelTestCase::DoTeardown (void)
202
{
203
  TestCase::DoTeardown ();
204
205
  // Restore defaults
206
  Config::SetDefault ("ns3::TwoRayGroundPropagationLossModel::Lambda", DoubleValue (0.0582524));
207
  Config::SetDefault ("ns3::TwoRayGroundPropagationLossModel::SystemLoss", DoubleValue (1.0));
208
  Config::SetDefault ("ns3::TwoRayGroundPropagationLossModel::HeightAboveZ", DoubleValue (0.0));
209
}
210
211
void
212
TwoRayGroundPropagationLossModelTestCase::DoRun (void)
189
TwoRayGroundPropagationLossModelTestCase::DoRun (void)
213
{
190
{
214
  // Select a reference transmit power of 17.0206 dBm
191
  // Select a reference transmit power of 17.0206 dBm
 Lines 308-314    Link Here 
308
private:
285
private:
309
  virtual void DoRun (void);
286
  virtual void DoRun (void);
310
  virtual void DoSetup (void);
287
  virtual void DoSetup (void);
311
  virtual void DoTeardown (void);
312
288
313
  typedef struct {
289
  typedef struct {
314
    Vector m_position;
290
    Vector m_position;
 Lines 340-355    Link Here 
340
}
316
}
341
317
342
void
318
void
343
LogDistancePropagationLossModelTestCase::DoTeardown (void)
344
{
345
  // Restore defaults
346
  Config::SetDefault ("ns3::LogDistancePropagationLossModel::ReferenceLoss", DoubleValue (46.6777));
347
  Config::SetDefault ("ns3::LogDistancePropagationLossModel::Exponent", DoubleValue (3));
348
349
  TestCase::DoTeardown ();
350
}
351
352
void
353
LogDistancePropagationLossModelTestCase::DoRun (void)
319
LogDistancePropagationLossModelTestCase::DoRun (void)
354
{
320
{
355
  // Select a reference transmit power
321
  // Select a reference transmit power
 Lines 461-467    Link Here 
461
private:
427
private:
462
  virtual void DoRun (void);
428
  virtual void DoRun (void);
463
  virtual void DoSetup (void);
429
  virtual void DoSetup (void);
464
  virtual void DoTeardown (void);
465
};
430
};
466
431
467
RangePropagationLossModelTestCase::RangePropagationLossModelTestCase ()
432
RangePropagationLossModelTestCase::RangePropagationLossModelTestCase ()
 Lines 483-497    Link Here 
483
}
448
}
484
449
485
void
450
void
486
RangePropagationLossModelTestCase::DoTeardown (void)
487
{
488
  // Restore defaults
489
  Config::SetDefault ("ns3::RangePropagationLossModel::MaxRange", DoubleValue (250.0));
490
  
491
  TestCase::DoTeardown ();
492
}
493
494
void
495
RangePropagationLossModelTestCase::DoRun (void)
451
RangePropagationLossModelTestCase::DoRun (void)
496
{
452
{
497
  Ptr<MobilityModel> a = CreateObject<ConstantPositionMobilityModel> (); 
453
  Ptr<MobilityModel> a = CreateObject<ConstantPositionMobilityModel> (); 
(-)a/src/test/csma-system-test-suite.cc (-10 lines)
 Lines 166-172    Link Here 
166
private:
166
private:
167
  virtual void DoRun (void);
167
  virtual void DoRun (void);
168
  virtual void DoSetup (void);
168
  virtual void DoSetup (void);
169
  virtual void DoTeardown (void);
170
  
169
  
171
  void SinkRxNode1 (Ptr<const Packet> p, const Address &ad);
170
  void SinkRxNode1 (Ptr<const Packet> p, const Address &ad);
172
  void SinkRxNode2 (Ptr<const Packet> p, const Address &ad);
171
  void SinkRxNode2 (Ptr<const Packet> p, const Address &ad);
 Lines 217-231    Link Here 
217
  Config::SetDefault ("ns3::CsmaNetDevice::EncapsulationMode", StringValue ("Dix"));
216
  Config::SetDefault ("ns3::CsmaNetDevice::EncapsulationMode", StringValue ("Dix"));
218
}
217
}
219
218
220
void
221
CsmaBroadcastTestCase::DoTeardown ()
222
{
223
  // Restore defaults
224
  // NOTE: don't, Dix is the default
225
  
226
  TestCase::DoTeardown ();
227
}
228
229
//
219
//
230
// Example of the sending of a datagram to a broadcast address
220
// Example of the sending of a datagram to a broadcast address
231
//
221
//
(-)a/src/test/error-model-test-suite.cc (+3 lines)
 Lines 81-86    Link Here 
81
  // Set some arbitrary deterministic values
81
  // Set some arbitrary deterministic values
82
  SeedManager::SetSeed (7);
82
  SeedManager::SetSeed (7);
83
  SeedManager::SetRun (5);
83
  SeedManager::SetRun (5);
84
  
85
  m_count = 0;
86
  m_drops = 0;
84
87
85
  Ptr<Node> a = CreateObject<Node> ();
88
  Ptr<Node> a = CreateObject<Node> ();
86
  Ptr<Node> b = CreateObject<Node> ();
89
  Ptr<Node> b = CreateObject<Node> ();
(-)a/src/test/global-routing-test-suite.cc (-10 lines)
 Lines 58-64    Link Here 
58
  
58
  
59
  virtual void DoRun (void);
59
  virtual void DoRun (void);
60
  virtual void DoSetup (void);
60
  virtual void DoSetup (void);
61
  virtual void DoTeardown (void);
62
  
61
  
63
  int m_count;
62
  int m_count;
64
  std::vector<uint8_t> m_firstInterface;
63
  std::vector<uint8_t> m_firstInterface;
 Lines 132-146    Link Here 
132
  Config::SetDefault ("ns3::Ipv4GlobalRouting::RespondToInterfaceEvents", BooleanValue (true));
131
  Config::SetDefault ("ns3::Ipv4GlobalRouting::RespondToInterfaceEvents", BooleanValue (true));
133
}
132
}
134
133
135
void
136
DynamicGlobalRoutingTestCase::DoTeardown ()
137
{
138
  // By default, it is disabled. Restore it.
139
  Config::SetDefault ("ns3::Ipv4GlobalRouting::RespondToInterfaceEvents", BooleanValue (false));
140
  
141
  TestCase::DoTeardown();
142
}
143
144
// Test derived from examples/routing/dynamic-global-routing.cc
134
// Test derived from examples/routing/dynamic-global-routing.cc
145
//
135
//
146
// Network topology
136
// Network topology
(-)a/src/test/ns3tcp/ns3tcp-cwnd-test-suite.cc (-10 lines)
 Lines 385-391    Link Here 
385
private:
385
private:
386
  virtual void DoRun (void);
386
  virtual void DoRun (void);
387
  virtual void DoSetup (void);
387
  virtual void DoSetup (void);
388
  virtual void DoTeardown (void);
389
  
388
  
390
  bool m_writeResults;
389
  bool m_writeResults;
391
390
 Lines 431-445    Link Here 
431
}
430
}
432
431
433
void
432
void
434
Ns3TcpCwndTestCase2::DoTeardown (void)
435
{
436
  // Restore defaults
437
  Config::SetDefault ("ns3::DropTailQueue::MaxPackets", UintegerValue (100));
438
  
439
  TestCase::DoTeardown ();
440
}
441
442
void
443
Ns3TcpCwndTestCase2::DoRun (void)
433
Ns3TcpCwndTestCase2::DoRun (void)
444
{
434
{
445
  NodeContainer n0n1;
435
  NodeContainer n0n1;
(-)a/src/test/ns3tcp/ns3tcp-interop-test-suite.cc (+1 lines)
 Lines 128-133    Link Here 
128
Ns3TcpInteroperabilityTestCase::DoTeardown (void)
128
Ns3TcpInteroperabilityTestCase::DoTeardown (void)
129
{
129
{
130
  m_pcapFile.Close ();
130
  m_pcapFile.Close ();
131
  TestCase::DoTeardown ();
131
}
132
}
132
133
133
void
134
void
(-)a/src/test/ns3tcp/ns3tcp-loss-test-suite.cc (-6 / +1 lines)
 Lines 164-174    Link Here 
164
void
164
void
165
Ns3TcpLossTestCase::DoTeardown (void)
165
Ns3TcpLossTestCase::DoTeardown (void)
166
{
166
{
167
  // Restore Config
168
  std::string tcpModel ("ns3::TcpNewReno");
169
  Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (536));
170
  Config::SetDefault ("ns3::TcpSocket::DelAckCount", UintegerValue (2));
171
172
  // Restore Logging
167
  // Restore Logging
173
  if (m_writeLogging)
168
  if (m_writeLogging)
174
    {
169
    {
 Lines 187-193    Link Here 
187
  // Enable packet metadata
182
  // Enable packet metadata
188
  Packet::DisablePrinting ();  
183
  Packet::DisablePrinting ();  
189
  
184
  
190
  Simulator::Destroy();
185
  TestCase::DoTeardown ();
191
}
186
}
192
187
193
void
188
void
(-)a/src/test/ns3tcp/ns3tcp-socket-test-suite.cc (-10 lines)
 Lines 159-165    Link Here 
159
private:
159
private:
160
  virtual void DoRun (void);
160
  virtual void DoRun (void);
161
  virtual void DoSetup (void);
161
  virtual void DoSetup (void);
162
  virtual void DoTeardown (void);
163
162
164
  bool m_writeResults;
163
  bool m_writeResults;
165
164
 Lines 189-203    Link Here 
189
}
188
}
190
189
191
void
190
void
192
Ns3TcpSocketTestCase2::DoTeardown (void)
193
{
194
  // Restore defaults
195
  Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (536));
196
  
197
  TestCase::DoTeardown ();
198
}
199
200
void
201
Ns3TcpSocketTestCase2::DoRun (void)
191
Ns3TcpSocketTestCase2::DoRun (void)
202
{
192
{
203
  uint16_t sinkPort = 50000;
193
  uint16_t sinkPort = 50000;
(-)a/src/test/ns3tcp/ns3tcp-state-test-suite.cc (-7 / +1 lines)
 Lines 171-188    Link Here 
171
      LogComponentDisable ("TcpSocketBase", LOG_LEVEL_INFO);
171
      LogComponentDisable ("TcpSocketBase", LOG_LEVEL_INFO);
172
    }
172
    }
173
  
173
  
174
  // Restore config to usual defaults
175
  Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (536));
176
  Config::SetDefault ("ns3::TcpSocket::DelAckCount", UintegerValue (2));
177
  Config::SetDefault ("ns3::DropTailQueue::MaxPackets", UintegerValue (100));
178
  // No need to restore ns3::TcpL4Protocol::SocketType, ns3::TcpNewReno is already the default
179
180
  m_pcapFile.Close ();
174
  m_pcapFile.Close ();
181
175
182
  // Enable packet metadata
176
  // Enable packet metadata
183
  Packet::DisablePrinting ();  
177
  Packet::DisablePrinting ();  
184
178
185
  Simulator::Destroy();
179
  TestCase::DoTeardown ();
186
}
180
}
187
181
188
void
182
void
(-)a/src/test/ns3wifi/wifi-interference-test-suite.cc (-13 lines)
 Lines 58-64    Link Here 
58
private:
58
private:
59
  virtual void DoRun (void);
59
  virtual void DoRun (void);
60
  virtual void DoSetup (void);
60
  virtual void DoSetup (void);
61
  virtual void DoTeardown (void);
62
  
61
  
63
  void ReceivePacket (Ptr<Socket> socket);
62
  void ReceivePacket (Ptr<Socket> socket);
64
  static void GenerateTraffic (Ptr<Socket> socket, uint32_t pktSize, uint32_t pktCount, Time pktInterval);
63
  static void GenerateTraffic (Ptr<Socket> socket, uint32_t pktSize, uint32_t pktCount, Time pktInterval);
 Lines 96-113    Link Here 
96
  Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode", StringValue (m_phyMode));
95
  Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode", StringValue (m_phyMode));
97
}
96
}
98
97
99
void
100
WifiInterferenceTestCase::DoTeardown ()
101
{
102
  // Restore default configuration
103
  std::string invalidWifiMode ("Invalid-WifiMode");
104
  Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2346"));
105
  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("2346"));
106
  Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode", StringValue (invalidWifiMode));
107
  
108
  TestCase::DoTeardown ();
109
}
110
111
void 
98
void 
112
WifiInterferenceTestCase::ReceivePacket (Ptr<Socket> socket)
99
WifiInterferenceTestCase::ReceivePacket (Ptr<Socket> socket)
113
{
100
{
114
* TestSuite: DoSetup and DoTeardown save/restore RNG state, to isolate test suites
101
* TestSuite: DoSetup and DoTeardown save/restore RNG state, to isolate test suites
115
 - NOTE: it should be done per-case, not per-suite, but some test cases in some suites depend on RNG state set by previous cases.
102
 - NOTE: it should be done per-case, not per-suite, but some test cases in some suites depend on RNG state set by previous cases.
(-)a/src/aodv/test/aodv-regression.cc (-1 / +8 lines)
 Lines 67-72    Link Here 
67
    // Ping loopback test case
67
    // Ping loopback test case
68
    AddTestCase (new LoopbackTestCase ());
68
    AddTestCase (new LoopbackTestCase ());
69
  }
69
  }
70
  
71
  virtual void DoSetup (void)
72
  {
73
    TestSuite::DoSetup();
74
    
75
    // Set a reproducible random seed
76
    SeedManager::SetSeed(12345);
77
  }
70
} g_aodvRegressionTestSuite;
78
} g_aodvRegressionTestSuite;
71
 
79
 
72
80
 Lines 92-98    Link Here 
92
void
100
void
93
ChainRegressionTest::DoRun ()
101
ChainRegressionTest::DoRun ()
94
{
102
{
95
  SeedManager::SetSeed (12345);
96
  Config::SetDefault ("ns3::ArpCache::AliveTimeout", TimeValue (m_arpAliveTimeout));
103
  Config::SetDefault ("ns3::ArpCache::AliveTimeout", TimeValue (m_arpAliveTimeout));
97
104
98
  CreateNodes ();
105
  CreateNodes ();
(-)a/src/core/model/test.cc (+16 lines)
 Lines 681-686    Link Here 
681
void 
681
void 
682
TestSuite::DoSetup (void)
682
TestSuite::DoSetup (void)
683
{
683
{
684
  /* 
685
   * Preserve global RNG state (RngStream contains process-wide side effects)
686
   */
687
  m_rngRunBackup = SeedManager::GetRun();
688
  m_rngSeedBackup = SeedManager::GetSeed();
689
  
690
  /*
691
   * Reset RNG state (in case the testing framework changed it somehow between runs)
692
   */
693
  SeedManager::SetRun(m_rngRunBackup);
694
  SeedManager::SetSeed(m_rngSeedBackup);
684
}
695
}
685
696
686
void
697
void
 Lines 719-724    Link Here 
719
void 
730
void 
720
TestSuite::DoTeardown (void)
731
TestSuite::DoTeardown (void)
721
{
732
{
733
  /* 
734
   * Restore global RNG state
735
   */
736
  SeedManager::SetRun(m_rngRunBackup);
737
  SeedManager::SetSeed(m_rngSeedBackup);
722
}
738
}
723
739
724
class TestRunnerImpl
740
class TestRunnerImpl
(-)a/src/core/model/test.h (+10 lines)
 Lines 29-34    Link Here 
29
#include <stdint.h>
29
#include <stdint.h>
30
30
31
#include "ns3/system-wall-clock-ms.h"
31
#include "ns3/system-wall-clock-ms.h"
32
#include "ns3/random-variable.h"
32
33
33
extern bool gBreakOnFailure;
34
extern bool gBreakOnFailure;
34
35
 Lines 1276-1281    Link Here 
1276
  bool m_error;
1277
  bool m_error;
1277
  TestType m_type;
1278
  TestType m_type;
1278
1279
1280
  // Backup of process-wide RNG state
1281
  // FIXME: This *should* be done per-testcase, but current test cases
1282
  //    depend have cases where they depend on RNG state resulting from
1283
  //    previous runs within a TestSuite (like routing-aodv-regression),
1284
  //    so in order not to break them, we do not reset RNG state between
1285
  //    test cases, only between tests suites.
1286
  uint32_t m_rngSeedBackup;
1287
  uint32_t m_rngRunBackup;
1288
1279
  typedef std::vector<TestCase *> TestCaseVector_t;
1289
  typedef std::vector<TestCase *> TestCaseVector_t;
1280
  TestCaseVector_t m_tests;
1290
  TestCaseVector_t m_tests;
1281
};
1291
};
1282
- fix TestSuite::DoSetup() to explicitly clear configuration before running - just in case
1292
- fix TestSuite::DoSetup() to explicitly clear configuration before running - just in case
(-)a/src/core/model/test.cc (+5 lines)
 Lines 681-686    Link Here 
681
void 
681
void 
682
TestSuite::DoSetup (void)
682
TestSuite::DoSetup (void)
683
{
683
{
684
  /*
685
   * Ensure repeatable state, reset all configuration settings to their defaults
686
   */
687
  Config::Reset ();
688
  
684
  /* 
689
  /* 
685
   * Preserve global RNG state (RngStream contains process-wide side effects)
690
   * Preserve global RNG state (RngStream contains process-wide side effects)
686
   */
691
   */
687
* The test framework now assures repeatable conditions within test cases, by:
692
* The test framework now assures repeatable conditions within test cases, by:
688
  - Destroying the simulator at base TestCase::DoTeardown/Setup
693
  - Destroying the simulator at base TestCase::DoTeardown/Setup
689
  - Resetting configuration (attribute defaults and global values) at
694
  - Resetting configuration (attribute defaults and global values) at
690
    various points (TestCase::DoTeardown, TestSuite::DoSetup)
695
    various points (TestCase::DoTeardown, TestSuite::DoSetup)
691
  - Saving/Restoring the RNG state at TestSuite::DoSetup/Teardown
696
  - Saving/Restoring the RNG state at TestSuite::DoSetup/Teardown
692
    (I tried per TestCase, but some test cases depend on RNG state
697
    (I tried per TestCase, but some test cases depend on RNG state
693
    set by previous test cases, sorting that out would have been
698
    set by previous test cases, sorting that out would have been
694
    a LOT more work)
699
    a LOT more work)
(-)a/src/aodv/test/aodv-regression.cc (-1 / +8 lines)
 Lines 67-72    Link Here 
67
    // Ping loopback test case
67
    // Ping loopback test case
68
    AddTestCase (new LoopbackTestCase ());
68
    AddTestCase (new LoopbackTestCase ());
69
  }
69
  }
70
  
71
  virtual void DoSetup (void)
72
  {
73
    TestSuite::DoSetup();
74
    
75
    // Set a reproducible random seed
76
    SeedManager::SetSeed(12345);
77
  }
70
} g_aodvRegressionTestSuite;
78
} g_aodvRegressionTestSuite;
71
 
79
 
72
80
 Lines 92-98    Link Here 
92
void
100
void
93
ChainRegressionTest::DoRun ()
101
ChainRegressionTest::DoRun ()
94
{
102
{
95
  SeedManager::SetSeed (12345);
96
  Config::SetDefault ("ns3::ArpCache::AliveTimeout", TimeValue (m_arpAliveTimeout));
103
  Config::SetDefault ("ns3::ArpCache::AliveTimeout", TimeValue (m_arpAliveTimeout));
97
104
98
  CreateNodes ();
105
  CreateNodes ();
(-)a/src/aodv/test/bug-772.cc (+1 lines)
 Lines 74-79    Link Here 
74
Bug772ChainTest::DoRun ()
74
Bug772ChainTest::DoRun ()
75
{
75
{
76
  SeedManager::SetSeed (12345);
76
  SeedManager::SetSeed (12345);
77
  Config::SetDefault ("ns3::ArpCache::AliveTimeout", TimeValue (Seconds (1)));
77
78
78
  CreateNodes ();
79
  CreateNodes ();
79
  CreateDevices ();
80
  CreateDevices ();
(-)a/src/core/model/test.cc (+42 lines)
 Lines 21-26    Link Here 
21
#include "abort.h"
21
#include "abort.h"
22
#include <math.h>
22
#include <math.h>
23
23
24
#include "ns3/simulator.h"
25
#include "ns3/config.h"
26
24
// Set to true to enable a segmentation fault upon a test case macro test 
27
// Set to true to enable a segmentation fault upon a test case macro test 
25
// failing (for debugging purposes)
28
// failing (for debugging purposes)
26
bool gBreakOnFailure = false;
29
bool gBreakOnFailure = false;
 Lines 395-405    Link Here 
395
void 
398
void 
396
TestCase::DoSetup (void)
399
TestCase::DoSetup (void)
397
{
400
{
401
  /*
402
   * Ensure a clean execution environment
403
   */
404
  Simulator::Destroy();
398
}
405
}
399
406
400
void 
407
void 
401
TestCase::DoTeardown (void)
408
TestCase::DoTeardown (void)
402
{
409
{
410
  /*
411
   *   Most tests will destroy their simulators when successful,
412
   * but on failure, they tend to leave the simulator alive.
413
   *   This can be a problem for subsequent test runs, so we
414
   * must destroy the simulator on TestCase teardown just in case.
415
   */
416
  Simulator::Destroy();
417
  
418
  /**
419
   *   Some tests will change default configuration settings. In
420
   * those cases, a full configuration reset is the only way to get
421
   * back to a reproducible state.
422
   */
423
  Config::Reset ();
403
}
424
}
404
425
405
TestSuite::TestSuite (std::string name, TestType type)
426
TestSuite::TestSuite (std::string name, TestType type)
 Lines 659-664    Link Here 
659
void 
680
void 
660
TestSuite::DoSetup (void)
681
TestSuite::DoSetup (void)
661
{
682
{
683
  /*
684
   * Ensure repeatable state, reset all configuration settings to their defaults
685
   */
686
  Config::Reset ();
687
  
688
  /* 
689
   * Preserve global RNG state (RngStream contains process-wide side effects)
690
   */
691
  m_rngRunBackup = SeedManager::GetRun();
692
  m_rngSeedBackup = SeedManager::GetSeed();
693
  
694
  /*
695
   * Reset RNG state (in case the testing framework changed it somehow between runs)
696
   */
697
  SeedManager::SetRun(m_rngRunBackup);
698
  SeedManager::SetSeed(m_rngSeedBackup);
662
}
699
}
663
700
664
void
701
void
 Lines 697-702    Link Here 
697
void 
734
void 
698
TestSuite::DoTeardown (void)
735
TestSuite::DoTeardown (void)
699
{
736
{
737
  /* 
738
   * Restore global RNG state
739
   */
740
  SeedManager::SetRun(m_rngRunBackup);
741
  SeedManager::SetSeed(m_rngSeedBackup);
700
}
742
}
701
743
702
class TestRunnerImpl
744
class TestRunnerImpl
(-)a/src/core/model/test.h (+10 lines)
 Lines 29-34    Link Here 
29
#include <stdint.h>
29
#include <stdint.h>
30
30
31
#include "ns3/system-wall-clock-ms.h"
31
#include "ns3/system-wall-clock-ms.h"
32
#include "ns3/random-variable.h"
32
33
33
extern bool gBreakOnFailure;
34
extern bool gBreakOnFailure;
34
35
 Lines 1276-1281    Link Here 
1276
  bool m_error;
1277
  bool m_error;
1277
  TestType m_type;
1278
  TestType m_type;
1278
1279
1280
  // Backup of process-wide RNG state
1281
  // FIXME: This *should* be done per-testcase, but current test cases
1282
  //    depend have cases where they depend on RNG state resulting from
1283
  //    previous runs within a TestSuite (like routing-aodv-regression),
1284
  //    so in order not to break them, we do not reset RNG state between
1285
  //    test cases, only between tests suites.
1286
  uint32_t m_rngSeedBackup;
1287
  uint32_t m_rngRunBackup;
1288
1279
  typedef std::vector<TestCase *> TestCaseVector_t;
1289
  typedef std::vector<TestCase *> TestCaseVector_t;
1280
  TestCaseVector_t m_tests;
1290
  TestCaseVector_t m_tests;
1281
};
1291
};
(-)a/src/core/test/names-test-suite.cc (+14 lines)
 Lines 87-92    Link Here 
87
BasicAddTestCase::DoTeardown (void)
87
BasicAddTestCase::DoTeardown (void)
88
{
88
{
89
  Names::Clear ();
89
  Names::Clear ();
90
  TestCase::DoTeardown ();
90
}
91
}
91
92
92
void
93
void
 Lines 153-158    Link Here 
153
StringContextAddTestCase::DoTeardown (void)
154
StringContextAddTestCase::DoTeardown (void)
154
{
155
{
155
  Names::Clear ();
156
  Names::Clear ();
157
  TestCase::DoTeardown ();
156
}
158
}
157
159
158
void
160
void
 Lines 216-221    Link Here 
216
FullyQualifiedAddTestCase::DoTeardown (void)
218
FullyQualifiedAddTestCase::DoTeardown (void)
217
{
219
{
218
  Names::Clear ();
220
  Names::Clear ();
221
  TestCase::DoTeardown ();
219
}
222
}
220
223
221
void
224
void
 Lines 282-287    Link Here 
282
RelativeAddTestCase::DoTeardown (void)
285
RelativeAddTestCase::DoTeardown (void)
283
{
286
{
284
  Names::Clear ();
287
  Names::Clear ();
288
  TestCase::DoTeardown ();
285
}
289
}
286
290
287
void
291
void
 Lines 347-352    Link Here 
347
BasicRenameTestCase::DoTeardown (void)
351
BasicRenameTestCase::DoTeardown (void)
348
{
352
{
349
  Names::Clear ();
353
  Names::Clear ();
354
  TestCase::DoTeardown ();
350
}
355
}
351
356
352
void
357
void
 Lines 407-412    Link Here 
407
StringContextRenameTestCase::DoTeardown (void)
412
StringContextRenameTestCase::DoTeardown (void)
408
{
413
{
409
  Names::Clear ();
414
  Names::Clear ();
415
  TestCase::DoTeardown ();
410
}
416
}
411
417
412
void
418
void
 Lines 467-472    Link Here 
467
FullyQualifiedRenameTestCase::DoTeardown (void)
473
FullyQualifiedRenameTestCase::DoTeardown (void)
468
{
474
{
469
  Names::Clear ();
475
  Names::Clear ();
476
  TestCase::DoTeardown ();
470
}
477
}
471
478
472
void
479
void
 Lines 527-532    Link Here 
527
RelativeRenameTestCase::DoTeardown (void)
534
RelativeRenameTestCase::DoTeardown (void)
528
{
535
{
529
  Names::Clear ();
536
  Names::Clear ();
537
  TestCase::DoTeardown ();
530
}
538
}
531
539
532
void
540
void
 Lines 587-592    Link Here 
587
FindPathTestCase::DoTeardown (void)
595
FindPathTestCase::DoTeardown (void)
588
{
596
{
589
  Names::Clear ();
597
  Names::Clear ();
598
  TestCase::DoTeardown ();
590
}
599
}
591
600
592
void
601
void
 Lines 641-646    Link Here 
641
BasicFindTestCase::DoTeardown (void)
650
BasicFindTestCase::DoTeardown (void)
642
{
651
{
643
  Names::Clear ();
652
  Names::Clear ();
653
  TestCase::DoTeardown ();
644
}
654
}
645
655
646
void
656
void
 Lines 703-708    Link Here 
703
StringContextFindTestCase::DoTeardown (void)
713
StringContextFindTestCase::DoTeardown (void)
704
{
714
{
705
  Names::Clear ();
715
  Names::Clear ();
716
  TestCase::DoTeardown ();
706
}
717
}
707
718
708
void
719
void
 Lines 765-770    Link Here 
765
FullyQualifiedFindTestCase::DoTeardown (void)
776
FullyQualifiedFindTestCase::DoTeardown (void)
766
{
777
{
767
  Names::Clear ();
778
  Names::Clear ();
779
  TestCase::DoTeardown ();
768
}
780
}
769
781
770
void
782
void
 Lines 827-832    Link Here 
827
RelativeFindTestCase::DoTeardown (void)
839
RelativeFindTestCase::DoTeardown (void)
828
{
840
{
829
  Names::Clear ();
841
  Names::Clear ();
842
  TestCase::DoTeardown ();
830
}
843
}
831
844
832
void
845
void
 Lines 887-892    Link Here 
887
AlternateFindTestCase::DoTeardown (void)
900
AlternateFindTestCase::DoTeardown (void)
888
{
901
{
889
  Names::Clear ();
902
  Names::Clear ();
903
  TestCase::DoTeardown ();
890
}
904
}
891
905
892
void
906
void
(-)a/src/core/test/time-test-suite.cc (+1 lines)
 Lines 76-81    Link Here 
76
TimeSimpleTestCase::DoTeardown (void)
76
TimeSimpleTestCase::DoTeardown (void)
77
{
77
{
78
  Time::SetResolution (m_originalResolution);
78
  Time::SetResolution (m_originalResolution);
79
  TestCase::DoTeardown ();
79
}
80
}
80
81
81
static class TimeTestSuite : public TestSuite
82
static class TimeTestSuite : public TestSuite
(-)a/src/core/test/timer-test-suite.cc (+1 lines)
 Lines 215-220    Link Here 
215
{
215
{
216
  Simulator::Run ();
216
  Simulator::Run ();
217
  Simulator::Destroy ();
217
  Simulator::Destroy ();
218
  TestCase::DoTeardown ();
218
}
219
}
219
220
220
static class TimerTestSuite : public TestSuite
221
static class TimerTestSuite : public TestSuite
(-)a/src/energy/test/basic-energy-model-test.cc (-14 / +21 lines)
 Lines 217-222    Link Here 
217
217
218
private:
218
private:
219
  void DoRun (void);
219
  void DoRun (void);
220
  void DoSetup (void);
220
221
221
  /**
222
  /**
222
   * Callback invoked when energy is drained from source.
223
   * Callback invoked when energy is drained from source.
 Lines 238-248    Link Here 
238
  double m_simTimeS;        // maximum simulation time, in seconds
239
  double m_simTimeS;        // maximum simulation time, in seconds
239
  double m_timeStepS;       // simulation time step size, in seconds
240
  double m_timeStepS;       // simulation time step size, in seconds
240
  double m_updateIntervalS; // update interval of each device model
241
  double m_updateIntervalS; // update interval of each device model
242
  std::string m_phyMode;
241
243
242
};
244
};
243
245
244
BasicEnergyDepletionTest::BasicEnergyDepletionTest ()
246
BasicEnergyDepletionTest::BasicEnergyDepletionTest ()
245
  : TestCase ("Basic energy model energy depletion test case")
247
  : TestCase ("Basic energy model energy depletion test case")
248
  , m_phyMode ("DsssRate1Mbps")
246
{
249
{
247
  m_numOfNodes = 10;
250
  m_numOfNodes = 10;
248
  m_callbackCount = 0;
251
  m_callbackCount = 0;
 Lines 256-261    Link Here 
256
}
259
}
257
260
258
void
261
void
262
BasicEnergyDepletionTest::DoSetup (void)
263
{
264
  TestCase::DoSetup ();
265
266
  // disable fragmentation for frames below 2200 bytes
267
  Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold",
268
                      StringValue ("2200"));
269
  // turn off RTS/CTS for frames below 2200 bytes
270
  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold",
271
                      StringValue ("2200"));
272
  // Fix non-unicast data rate to be the same as that of unicast
273
  Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",
274
                      StringValue (m_phyMode));
275
}
276
277
void
259
BasicEnergyDepletionTest::DoRun (void)
278
BasicEnergyDepletionTest::DoRun (void)
260
{
279
{
261
  /*
280
  /*
 Lines 287-304    Link Here 
287
  NodeContainer c;
306
  NodeContainer c;
288
  c.Create (m_numOfNodes);
307
  c.Create (m_numOfNodes);
289
308
290
  std::string phyMode ("DsssRate1Mbps");
291
292
  // disable fragmentation for frames below 2200 bytes
293
  Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold",
294
                      StringValue ("2200"));
295
  // turn off RTS/CTS for frames below 2200 bytes
296
  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold",
297
                      StringValue ("2200"));
298
  // Fix non-unicast data rate to be the same as that of unicast
299
  Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",
300
                      StringValue (phyMode));
301
302
  // install YansWifiPhy
309
  // install YansWifiPhy
303
  WifiHelper wifi;
310
  WifiHelper wifi;
304
  wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
311
  wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
 Lines 319-326    Link Here 
319
  // Add a non-QoS upper MAC, and disable rate control
326
  // Add a non-QoS upper MAC, and disable rate control
320
  NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
327
  NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
321
  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
328
  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
322
                                "DataMode", StringValue (phyMode),
329
                                "DataMode", StringValue (m_phyMode),
323
                                "ControlMode", StringValue (phyMode));
330
                                "ControlMode", StringValue (m_phyMode));
324
  // Set it to ad-hoc mode
331
  // Set it to ad-hoc mode
325
  wifiMac.SetType ("ns3::AdhocWifiMac");
332
  wifiMac.SetType ("ns3::AdhocWifiMac");
326
  NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, c);
333
  NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, c);
(-)a/src/energy/test/rv-battery-model-test.cc (-34 / +35 lines)
 Lines 57-69    Link Here 
57
  void CreateLoadProfiles (void);
57
  void CreateLoadProfiles (void);
58
58
59
  /**
59
  /**
60
   * \returns False if no error occurs.
61
   *
62
   * Runs test.
60
   * Runs test.
63
   */
61
   */
64
  void DoRun (void);
62
  void DoRun (void);
65
63
66
  /**
64
  /**
65
   * Sets up test configuration
66
   */
67
  void DoSetup (void);
68
69
  /**
67
   * \param load Load value, in Amperes (A).
70
   * \param load Load value, in Amperes (A).
68
   * \param expLifetime Expected lifetime.
71
   * \param expLifetime Expected lifetime.
69
   * \return False if no error occurs.
72
   * \return False if no error occurs.
 Lines 99-112    Link Here 
99
  std::vector<LoadProfile> m_loadProfiles;
102
  std::vector<LoadProfile> m_loadProfiles;
100
  double m_alpha;
103
  double m_alpha;
101
  double m_beta;
104
  double m_beta;
105
  std::string m_phyMode;
102
};
106
};
103
107
104
BatteryLifetimeTest::BatteryLifetimeTest ()
108
BatteryLifetimeTest::BatteryLifetimeTest ()
105
  : TestCase ("RV battery model battery lifetime test case.")
109
  : TestCase ("RV battery model battery lifetime test case.")
110
  , m_phyMode ("DsssRate1Mbps")
106
{
111
{
107
  // Itsy battery
112
  // Itsy battery
108
  m_alpha = 35220;
113
  m_alpha = 35220;
109
  m_beta = 0.637;
114
  m_beta = 0.637;
115
  
116
  // create load profiles for variable load test
117
  CreateLoadProfiles ();
110
}
118
}
111
119
112
BatteryLifetimeTest::~BatteryLifetimeTest ()
120
BatteryLifetimeTest::~BatteryLifetimeTest ()
 Lines 638-647    Link Here 
638
}
646
}
639
647
640
void
648
void
649
BatteryLifetimeTest::DoSetup (void)
650
{
651
  TestCase::DoSetup ();
652
653
  // disable fragmentation for frames below 2200 bytes
654
  Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold",
655
                      StringValue ("2200"));
656
  // turn off RTS/CTS for frames below 2200 bytes
657
  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold",
658
                      StringValue ("2200"));
659
  // Fix non-unicast data rate to be the same as that of unicast
660
  Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",
661
                      StringValue (m_phyMode));
662
}
663
664
void
641
BatteryLifetimeTest::DoRun (void)
665
BatteryLifetimeTest::DoRun (void)
642
{
666
{
643
  NS_LOG_DEBUG ("Constant load run.");
667
  NS_LOG_DEBUG ("Constant load run.");
644
668
669
  // set constant load test parameters
670
  m_alpha = 35220;
671
  m_beta = 0.637;
672
645
  // 640mA
673
  // 640mA
646
  NS_TEST_ASSERT_MSG_EQ (ConstantLoadTest (0.640, Seconds (2844.0)), false,  "Problems with constant load test (640mA).");
674
  NS_TEST_ASSERT_MSG_EQ (ConstantLoadTest (0.640, Seconds (2844.0)), false,  "Problems with constant load test (640mA).");
647
  // 320mA
675
  // 320mA
 Lines 653-661    Link Here 
653
  // 32mA
681
  // 32mA
654
  NS_TEST_ASSERT_MSG_EQ (ConstantLoadTest (0.032, Seconds (65580.0)), false,  "Problems with constant load test (32).");
682
  NS_TEST_ASSERT_MSG_EQ (ConstantLoadTest (0.032, Seconds (65580.0)), false,  "Problems with constant load test (32).");
655
683
656
  // create load profiles for variable load test
657
  CreateLoadProfiles ();
658
659
  // variable load with Itsy battery
684
  // variable load with Itsy battery
660
  NS_LOG_DEBUG ("\n\nItsy");
685
  NS_LOG_DEBUG ("\n\nItsy");
661
  m_alpha = 35220;
686
  m_alpha = 35220;
 Lines 696-713    Link Here 
696
  NodeContainer c;
721
  NodeContainer c;
697
  c.Create (1);
722
  c.Create (1);
698
723
699
  std::string phyMode ("DsssRate1Mbps");
700
701
  // disable fragmentation for frames below 2200 bytes
702
  Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold",
703
                      StringValue ("2200"));
704
  // turn off RTS/CTS for frames below 2200 bytes
705
  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold",
706
                      StringValue ("2200"));
707
  // Fix non-unicast data rate to be the same as that of unicast
708
  Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",
709
                      StringValue (phyMode));
710
711
  // install YansWifiPhy
724
  // install YansWifiPhy
712
  WifiHelper wifi;
725
  WifiHelper wifi;
713
  wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
726
  wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
 Lines 728-735    Link Here 
728
  // Add a non-QoS upper MAC, and disable rate control
741
  // Add a non-QoS upper MAC, and disable rate control
729
  NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
742
  NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
730
  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
743
  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
731
                                "DataMode", StringValue (phyMode),
744
                                "DataMode", StringValue (m_phyMode),
732
                                "ControlMode", StringValue (phyMode));
745
                                "ControlMode", StringValue (m_phyMode));
733
  // Set it to ad-hoc mode
746
  // Set it to ad-hoc mode
734
  wifiMac.SetType ("ns3::AdhocWifiMac");
747
  wifiMac.SetType ("ns3::AdhocWifiMac");
735
  NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, c);
748
  NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, c);
 Lines 759-765    Link Here 
759
772
760
  NS_LOG_DEBUG ("Expected lifetime = " << expLifetime.GetSeconds () << "s");
773
  NS_LOG_DEBUG ("Expected lifetime = " << expLifetime.GetSeconds () << "s");
761
  NS_LOG_DEBUG ("Actual lifetime = " << actualLifetime.GetSeconds () << "s");
774
  NS_LOG_DEBUG ("Actual lifetime = " << actualLifetime.GetSeconds () << "s");
762
775
  
763
  NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL (actualLifetime, expLifetime, "Incorrect lifetime!");
776
  NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL (actualLifetime, expLifetime, "Incorrect lifetime!");
764
  /*
777
  /*
765
  NS_TEST_ASSERT_MSG_EQ_TOL_RETURNS_BOOL (actualLifetime.GetSeconds () / 60,
778
  NS_TEST_ASSERT_MSG_EQ_TOL_RETURNS_BOOL (actualLifetime.GetSeconds () / 60,
 Lines 783-800    Link Here 
783
  NodeContainer c;
796
  NodeContainer c;
784
  c.Create (1);
797
  c.Create (1);
785
798
786
  std::string phyMode ("DsssRate1Mbps");
787
788
  // disable fragmentation for frames below 2200 bytes
789
  Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold",
790
                      StringValue ("2200"));
791
  // turn off RTS/CTS for frames below 2200 bytes
792
  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold",
793
                      StringValue ("2200"));
794
  // Fix non-unicast data rate to be the same as that of unicast
795
  Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",
796
                      StringValue (phyMode));
797
798
  // install YansWifiPhy
799
  // install YansWifiPhy
799
  WifiHelper wifi;
800
  WifiHelper wifi;
800
  wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
801
  wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
 Lines 815-822    Link Here 
815
  // Add a non-QoS upper MAC, and disable rate control
816
  // Add a non-QoS upper MAC, and disable rate control
816
  NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
817
  NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
817
  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
818
  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
818
                                "DataMode", StringValue (phyMode),
819
                                "DataMode", StringValue (m_phyMode),
819
                                "ControlMode", StringValue (phyMode));
820
                                "ControlMode", StringValue (m_phyMode));
820
  // Set it to ad-hoc mode
821
  // Set it to ad-hoc mode
821
  wifiMac.SetType ("ns3::AdhocWifiMac");
822
  wifiMac.SetType ("ns3::AdhocWifiMac");
822
  NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, c);
823
  NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, c);
(-)a/src/internet/test/ipv4-address-generator-test-suite.cc (-3 / +5 lines)
 Lines 38-43    Link Here 
38
NetworkNumberAllocatorTestCase::DoTeardown (void)
38
NetworkNumberAllocatorTestCase::DoTeardown (void)
39
{
39
{
40
  Ipv4AddressGenerator::Reset ();
40
  Ipv4AddressGenerator::Reset ();
41
  TestCase::DoTeardown ();
41
}
42
}
42
void
43
void
43
NetworkNumberAllocatorTestCase::DoRun (void)
44
NetworkNumberAllocatorTestCase::DoRun (void)
 Lines 117-123    Link Here 
117
AddressAllocatorTestCase::DoTeardown (void)
118
AddressAllocatorTestCase::DoTeardown (void)
118
{
119
{
119
  Ipv4AddressGenerator::Reset ();
120
  Ipv4AddressGenerator::Reset ();
120
  Simulator::Destroy ();
121
  TestCase::DoTeardown ();
121
}
122
}
122
123
123
124
 Lines 138-144    Link Here 
138
NetworkAndAddressTestCase::DoTeardown (void)
139
NetworkAndAddressTestCase::DoTeardown (void)
139
{
140
{
140
  Ipv4AddressGenerator::Reset ();
141
  Ipv4AddressGenerator::Reset ();
141
  Simulator::Destroy ();
142
  TestCase::DoTeardown ();
142
}
143
}
143
144
144
void
145
void
 Lines 202-207    Link Here 
202
ExampleAddressGeneratorTestCase::DoTeardown (void)
203
ExampleAddressGeneratorTestCase::DoTeardown (void)
203
{
204
{
204
  Ipv4AddressGenerator::Reset ();
205
  Ipv4AddressGenerator::Reset ();
206
  TestCase::DoTeardown ();
205
}
207
}
206
208
207
void
209
void
 Lines 254-260    Link Here 
254
AddressCollisionTestCase::DoTeardown (void)
256
AddressCollisionTestCase::DoTeardown (void)
255
{
257
{
256
  Ipv4AddressGenerator::Reset ();
258
  Ipv4AddressGenerator::Reset ();
257
  Simulator::Destroy ();
259
  TestCase::DoTeardown ();
258
}
260
}
259
void
261
void
260
AddressCollisionTestCase::DoRun (void)
262
AddressCollisionTestCase::DoRun (void)
(-)a/src/internet/test/ipv4-address-helper-test-suite.cc (-3 / +3 lines)
 Lines 41-47    Link Here 
41
NetworkAllocatorHelperTestCase::DoTeardown (void)
41
NetworkAllocatorHelperTestCase::DoTeardown (void)
42
{
42
{
43
  Ipv4AddressGenerator::Reset ();
43
  Ipv4AddressGenerator::Reset ();
44
  Simulator::Destroy ();
44
  TestCase::DoTeardown ();
45
}
45
}
46
void
46
void
47
NetworkAllocatorHelperTestCase::DoRun (void)
47
NetworkAllocatorHelperTestCase::DoRun (void)
 Lines 87-93    Link Here 
87
AddressAllocatorHelperTestCase::DoTeardown (void)
87
AddressAllocatorHelperTestCase::DoTeardown (void)
88
{
88
{
89
  Ipv4AddressGenerator::Reset ();
89
  Ipv4AddressGenerator::Reset ();
90
  Simulator::Destroy ();
90
  TestCase::DoTeardown ();
91
}
91
}
92
92
93
void
93
void
 Lines 176-182    Link Here 
176
ResetAllocatorHelperTestCase::DoTeardown (void)
176
ResetAllocatorHelperTestCase::DoTeardown (void)
177
{
177
{
178
  Ipv4AddressGenerator::Reset ();
178
  Ipv4AddressGenerator::Reset ();
179
  Simulator::Destroy ();
179
  TestCase::DoTeardown ();
180
}
180
}
181
181
182
static class Ipv4AddressHelperTestSuite : public TestSuite
182
static class Ipv4AddressHelperTestSuite : public TestSuite
(-)a/src/internet/test/tcp-test.cc (-1 / +1 lines)
 Lines 160-166    Link Here 
160
  delete [] m_sourceTxPayload;
160
  delete [] m_sourceTxPayload;
161
  delete [] m_sourceRxPayload;
161
  delete [] m_sourceRxPayload;
162
  delete [] m_serverRxPayload;
162
  delete [] m_serverRxPayload;
163
  Simulator::Destroy ();
163
  TestCase::DoTeardown ();
164
}
164
}
165
165
166
void
166
void
(-)a/src/mobility/test/ns2-mobility-helper-test-suite.cc (-1 / +2 lines)
 Lines 204-209    Link Here 
204
  
204
  
205
  void DoSetup ()
205
  void DoSetup ()
206
  {
206
  {
207
    Simulator::Destroy();
207
    CreateNodes ();
208
    CreateNodes ();
208
  }
209
  }
209
  
210
  
 Lines 211-217    Link Here 
211
  {
212
  {
212
    Names::Clear ();
213
    Names::Clear ();
213
    std::remove (m_traceFile.c_str ());
214
    std::remove (m_traceFile.c_str ());
214
    Simulator::Destroy ();
215
    TestCase::DoTeardown ();
215
  }
216
  }
216
  
217
  
217
  /// Go
218
  /// Go
(-)a/src/mobility/test/steady-state-random-waypoint-mobility-model-test.cc (+1 lines)
 Lines 47-52    Link Here 
47
SteadyStateRandomWaypointTest::DoTeardown (void)
47
SteadyStateRandomWaypointTest::DoTeardown (void)
48
{
48
{
49
  mobilityStack.clear();
49
  mobilityStack.clear();
50
  TestCase::DoTeardown();
50
}
51
}
51
52
52
void
53
void
(-)a/src/mobility/test/waypoint-mobility-model-test.cc (+1 lines)
 Lines 57-62    Link Here 
57
{
57
{
58
  mobilityStack.clear();
58
  mobilityStack.clear();
59
  waypoints.clear();
59
  waypoints.clear();
60
  TestCase::DoTeardown();
60
}
61
}
61
62
62
void
63
void
(-)a/src/network/test/pcap-file-test-suite.cc (+6 lines)
 Lines 114-119    Link Here 
114
WriteModeCreateTestCase::DoTeardown (void)
114
WriteModeCreateTestCase::DoTeardown (void)
115
{
115
{
116
  remove (m_testFilename.c_str ());
116
  remove (m_testFilename.c_str ());
117
  TestCase::DoTeardown ();
117
}
118
}
118
119
119
void
120
void
 Lines 226-231    Link Here 
226
ReadModeCreateTestCase::DoTeardown (void)
227
ReadModeCreateTestCase::DoTeardown (void)
227
{
228
{
228
  remove (m_testFilename.c_str ());
229
  remove (m_testFilename.c_str ());
230
  TestCase::DoTeardown ();
229
}
231
}
230
232
231
void
233
void
 Lines 332-337    Link Here 
332
AppendModeCreateTestCase::DoTeardown (void)
334
AppendModeCreateTestCase::DoTeardown (void)
333
{
335
{
334
  remove (m_testFilename.c_str ());
336
  remove (m_testFilename.c_str ());
337
  TestCase::DoTeardown ();
335
}
338
}
336
339
337
void
340
void
 Lines 438-443    Link Here 
438
FileHeaderTestCase::DoTeardown (void)
441
FileHeaderTestCase::DoTeardown (void)
439
{
442
{
440
  remove (m_testFilename.c_str ());
443
  remove (m_testFilename.c_str ());
444
  TestCase::DoTeardown ();
441
}
445
}
442
446
443
void
447
void
 Lines 675-680    Link Here 
675
RecordHeaderTestCase::DoTeardown (void)
679
RecordHeaderTestCase::DoTeardown (void)
676
{
680
{
677
  remove (m_testFilename.c_str ());
681
  remove (m_testFilename.c_str ());
682
  TestCase::DoTeardown ();
678
}
683
}
679
684
680
void
685
void
 Lines 972-977    Link Here 
972
void
977
void
973
ReadFileTestCase::DoTeardown (void)
978
ReadFileTestCase::DoTeardown (void)
974
{
979
{
980
  TestCase::DoTeardown ();
975
}
981
}
976
982
977
const uint32_t N_KNOWN_PACKETS = 6;
983
const uint32_t N_KNOWN_PACKETS = 6;
(-)a/src/olsr/test/bug780-test.cc (-5 / +11 lines)
 Lines 75-80    Link Here 
75
}
75
}
76
76
77
void
77
void
78
Bug780Test::DoSetup ()
79
{
80
  TestCase::DoSetup ();
81
82
  //sending one packets per sec
83
  // Fix non-unicast data rate to be the same as that of unicast
84
  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold",
85
                      StringValue ("400"));
86
}
87
88
void
78
Bug780Test::DoRun ()
89
Bug780Test::DoRun ()
79
{
90
{
80
  SeedManager::SetSeed (123);
91
  SeedManager::SetSeed (123);
 Lines 97-107    Link Here 
97
  double SimTime = 200.0;
108
  double SimTime = 200.0;
98
  std::string phyMode ("DsssRate1Mbps");
109
  std::string phyMode ("DsssRate1Mbps");
99
110
100
  //sending one packets per sec
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;
111
  NodeContainer adhocNodes;
106
  adhocNodes.Create (nWifis);
112
  adhocNodes.Create (nWifis);
107
113
(-)a/src/olsr/test/bug780-test.h (+1 lines)
 Lines 43-48    Link Here 
43
  void CheckResults ();
43
  void CheckResults ();
44
  /// Go
44
  /// Go
45
  void DoRun ();
45
  void DoRun ();
46
  void DoSetup ();
46
};
47
};
47
48
48
}
49
}
(-)a/src/propagation/test/propagation-loss-model-test-suite.cc (-4 / +37 lines)
 Lines 42-47    Link Here 
42
42
43
private:
43
private:
44
  virtual void DoRun (void);
44
  virtual void DoRun (void);
45
  virtual void DoSetup (void);
45
46
46
  typedef struct {
47
  typedef struct {
47
    Vector m_position;
48
    Vector m_position;
 Lines 63-76    Link Here 
63
}
64
}
64
65
65
void
66
void
66
FriisPropagationLossModelTestCase::DoRun (void)
67
FriisPropagationLossModelTestCase::DoSetup (void)
67
{
68
{
69
  TestCase::DoSetup ();
70
68
  // The ns-3 testing manual gives more background on the values selected
71
  // The ns-3 testing manual gives more background on the values selected
69
  // for this test.  First, set a few defaults. 
72
  // for this test.  First, set a few defaults. 
70
73
71
  // wavelength at 2.4 GHz is 0.125m
74
  // wavelength at 2.4 GHz is 0.125m
72
  Config::SetDefault ("ns3::FriisPropagationLossModel::Lambda", DoubleValue (0.125));
75
  Config::SetDefault ("ns3::FriisPropagationLossModel::Lambda", DoubleValue (0.125));
73
  Config::SetDefault ("ns3::FriisPropagationLossModel::SystemLoss", DoubleValue (1.0));
76
  Config::SetDefault ("ns3::FriisPropagationLossModel::SystemLoss", DoubleValue (1.0));
77
}
78
79
void
80
FriisPropagationLossModelTestCase::DoRun (void)
81
{
82
  // The ns-3 testing manual gives more background on the values selected
83
  // for this test.
74
84
75
  // Select a reference transmit power
85
  // Select a reference transmit power
76
  // Pt = 10^(17.0206/10)/10^3 = .05035702 W
86
  // Pt = 10^(17.0206/10)/10^3 = .05035702 W
 Lines 139-144    Link Here 
139
149
140
private:
150
private:
141
  virtual void DoRun (void);
151
  virtual void DoRun (void);
152
  virtual void DoSetup (void);
142
153
143
  typedef struct
154
  typedef struct
144
  {
155
  {
 Lines 162-176    Link Here 
162
}
173
}
163
174
164
void
175
void
165
TwoRayGroundPropagationLossModelTestCase::DoRun (void)
176
TwoRayGroundPropagationLossModelTestCase::DoSetup (void)
166
{
177
{
178
  TestCase::DoSetup ();
179
167
  // wavelength at 2.4 GHz is 0.125m
180
  // wavelength at 2.4 GHz is 0.125m
168
  Config::SetDefault ("ns3::TwoRayGroundPropagationLossModel::Lambda", DoubleValue (0.125));
181
  Config::SetDefault ("ns3::TwoRayGroundPropagationLossModel::Lambda", DoubleValue (0.125));
169
  Config::SetDefault ("ns3::TwoRayGroundPropagationLossModel::SystemLoss", DoubleValue (1.0));
182
  Config::SetDefault ("ns3::TwoRayGroundPropagationLossModel::SystemLoss", DoubleValue (1.0));
170
183
171
  // set antenna height to 1.5m above z coordinate
184
  // set antenna height to 1.5m above z coordinate
172
  Config::SetDefault ("ns3::TwoRayGroundPropagationLossModel::HeightAboveZ", DoubleValue (1.5));
185
  Config::SetDefault ("ns3::TwoRayGroundPropagationLossModel::HeightAboveZ", DoubleValue (1.5));
186
}
173
187
188
void
189
TwoRayGroundPropagationLossModelTestCase::DoRun (void)
190
{
174
  // Select a reference transmit power of 17.0206 dBm
191
  // Select a reference transmit power of 17.0206 dBm
175
  // Pt = 10^(17.0206/10)/10^3 = .05035702 W
192
  // Pt = 10^(17.0206/10)/10^3 = .05035702 W
176
  double txPowerW = 0.05035702;
193
  double txPowerW = 0.05035702;
 Lines 267-272    Link Here 
267
284
268
private:
285
private:
269
  virtual void DoRun (void);
286
  virtual void DoRun (void);
287
  virtual void DoSetup (void);
270
288
271
  typedef struct {
289
  typedef struct {
272
    Vector m_position;
290
    Vector m_position;
 Lines 288-299    Link Here 
288
}
306
}
289
307
290
void
308
void
291
LogDistancePropagationLossModelTestCase::DoRun (void)
309
LogDistancePropagationLossModelTestCase::DoSetup (void)
292
{
310
{
311
  TestCase::DoSetup ();
312
293
  // reference loss at 2.4 GHz is 40.045997
313
  // reference loss at 2.4 GHz is 40.045997
294
  Config::SetDefault ("ns3::LogDistancePropagationLossModel::ReferenceLoss", DoubleValue (40.045997));
314
  Config::SetDefault ("ns3::LogDistancePropagationLossModel::ReferenceLoss", DoubleValue (40.045997));
295
  Config::SetDefault ("ns3::LogDistancePropagationLossModel::Exponent", DoubleValue (3));
315
  Config::SetDefault ("ns3::LogDistancePropagationLossModel::Exponent", DoubleValue (3));
316
}
296
317
318
void
319
LogDistancePropagationLossModelTestCase::DoRun (void)
320
{
297
  // Select a reference transmit power
321
  // Select a reference transmit power
298
  // Pt = 10^(17.0206/10)/10^3 = .05035702 W
322
  // Pt = 10^(17.0206/10)/10^3 = .05035702 W
299
  double txPowerW = 0.05035702;
323
  double txPowerW = 0.05035702;
 Lines 402-407    Link Here 
402
426
403
private:
427
private:
404
  virtual void DoRun (void);
428
  virtual void DoRun (void);
429
  virtual void DoSetup (void);
405
};
430
};
406
431
407
RangePropagationLossModelTestCase::RangePropagationLossModelTestCase ()
432
RangePropagationLossModelTestCase::RangePropagationLossModelTestCase ()
 Lines 414-422    Link Here 
414
}
439
}
415
440
416
void
441
void
442
RangePropagationLossModelTestCase::DoSetup (void)
443
{
444
  TestCase::DoSetup ();
445
  
446
  // Set testcase parameters
447
  Config::SetDefault ("ns3::RangePropagationLossModel::MaxRange", DoubleValue (127.2));
448
}
449
450
void
417
RangePropagationLossModelTestCase::DoRun (void)
451
RangePropagationLossModelTestCase::DoRun (void)
418
{
452
{
419
  Config::SetDefault ("ns3::RangePropagationLossModel::MaxRange", DoubleValue (127.2));
420
  Ptr<MobilityModel> a = CreateObject<ConstantPositionMobilityModel> (); 
453
  Ptr<MobilityModel> a = CreateObject<ConstantPositionMobilityModel> (); 
421
  a->SetPosition (Vector (0,0,0));
454
  a->SetPosition (Vector (0,0,0));
422
  Ptr<MobilityModel> b = CreateObject<ConstantPositionMobilityModel> (); 
455
  Ptr<MobilityModel> b = CreateObject<ConstantPositionMobilityModel> (); 
(-)a/src/test/csma-system-test-suite.cc (-6 / +15 lines)
 Lines 165-170    Link Here 
165
165
166
private:
166
private:
167
  virtual void DoRun (void);
167
  virtual void DoRun (void);
168
  virtual void DoSetup (void);
169
  
168
  void SinkRxNode1 (Ptr<const Packet> p, const Address &ad);
170
  void SinkRxNode1 (Ptr<const Packet> p, const Address &ad);
169
  void SinkRxNode2 (Ptr<const Packet> p, const Address &ad);
171
  void SinkRxNode2 (Ptr<const Packet> p, const Address &ad);
170
  void DropEvent (Ptr<const Packet> p);
172
  void DropEvent (Ptr<const Packet> p);
 Lines 201-206    Link Here 
201
  m_drops++;
203
  m_drops++;
202
}
204
}
203
205
206
207
void
208
CsmaBroadcastTestCase::DoSetup ()
209
{
210
  TestCase::DoSetup();
211
212
  //
213
  // Set up default values for the simulation.
214
  //
215
  // Select DIX/Ethernet II-style encapsulation (no LLC/Snap header)
216
  Config::SetDefault ("ns3::CsmaNetDevice::EncapsulationMode", StringValue ("Dix"));
217
}
218
204
//
219
//
205
// Example of the sending of a datagram to a broadcast address
220
// Example of the sending of a datagram to a broadcast address
206
//
221
//
 Lines 333-344    Link Here 
333
void
348
void
334
CsmaMulticastTestCase::DoRun (void)
349
CsmaMulticastTestCase::DoRun (void)
335
{
350
{
336
  //
337
  // Set up default values for the simulation.
338
  //
339
  // Select DIX/Ethernet II-style encapsulation (no LLC/Snap header)
340
  Config::SetDefault ("ns3::CsmaNetDevice::EncapsulationMode", StringValue ("Dix"));
341
342
  NodeContainer c;
351
  NodeContainer c;
343
  c.Create (5);
352
  c.Create (5);
344
  // We will later want two subcontainers of these nodes, for the two LANs
353
  // We will later want two subcontainers of these nodes, for the two LANs
(-)a/src/test/error-model-test-suite.cc (+3 lines)
 Lines 81-86    Link Here 
81
  // Set some arbitrary deterministic values
81
  // Set some arbitrary deterministic values
82
  SeedManager::SetSeed (7);
82
  SeedManager::SetSeed (7);
83
  SeedManager::SetRun (5);
83
  SeedManager::SetRun (5);
84
  
85
  m_count = 0;
86
  m_drops = 0;
84
87
85
  Ptr<Node> a = CreateObject<Node> ();
88
  Ptr<Node> a = CreateObject<Node> ();
86
  Ptr<Node> b = CreateObject<Node> ();
89
  Ptr<Node> b = CreateObject<Node> ();
(-)a/src/test/global-routing-test-suite.cc (-4 / +13 lines)
 Lines 55-61    Link Here 
55
private:
55
private:
56
  void SinkRx (std::string path, Ptr<const Packet> p, const Address &address);
56
  void SinkRx (std::string path, Ptr<const Packet> p, const Address &address);
57
  void HandleRead (Ptr<Socket>);
57
  void HandleRead (Ptr<Socket>);
58
  
58
  virtual void DoRun (void);
59
  virtual void DoRun (void);
60
  virtual void DoSetup (void);
61
  
59
  int m_count;
62
  int m_count;
60
  std::vector<uint8_t> m_firstInterface;
63
  std::vector<uint8_t> m_firstInterface;
61
  std::vector<uint8_t> m_secondInterface;
64
  std::vector<uint8_t> m_secondInterface;
 Lines 118-123    Link Here 
118
    }
121
    }
119
}
122
}
120
123
124
void
125
DynamicGlobalRoutingTestCase::DoSetup ()
126
{
127
  TestCase::DoSetup();
128
129
  // The below value configures the default behavior of global routing.
130
  // By default, it is disabled.  To respond to interface events, set to true
131
  Config::SetDefault ("ns3::Ipv4GlobalRouting::RespondToInterfaceEvents", BooleanValue (true));
132
}
133
121
// Test derived from examples/routing/dynamic-global-routing.cc
134
// Test derived from examples/routing/dynamic-global-routing.cc
122
//
135
//
123
// Network topology
136
// Network topology
 Lines 140-149    Link Here 
140
void
153
void
141
DynamicGlobalRoutingTestCase::DoRun (void)
154
DynamicGlobalRoutingTestCase::DoRun (void)
142
{
155
{
143
  // The below value configures the default behavior of global routing.
144
  // By default, it is disabled.  To respond to interface events, set to true
145
  Config::SetDefault ("ns3::Ipv4GlobalRouting::RespondToInterfaceEvents", BooleanValue (true));
146
147
  NodeContainer c;
156
  NodeContainer c;
148
  c.Create (7);
157
  c.Create (7);
149
  NodeContainer n0n2 = NodeContainer (c.Get (0), c.Get (2));
158
  NodeContainer n0n2 = NodeContainer (c.Get (0), c.Get (2));
(-)a/src/test/ns3tcp/ns3tcp-cwnd-test-suite.cc (-3 / +11 lines)
 Lines 384-389    Link Here 
384
384
385
private:
385
private:
386
  virtual void DoRun (void);
386
  virtual void DoRun (void);
387
  virtual void DoSetup (void);
388
  
387
  bool m_writeResults;
389
  bool m_writeResults;
388
390
389
  class CwndEvent {
391
  class CwndEvent {
 Lines 419-429    Link Here 
419
}
421
}
420
422
421
void
423
void
424
Ns3TcpCwndTestCase2::DoSetup (void)
425
{
426
  TestCase::DoSetup ();
427
  
428
  // Set up some default values for the simulation.
429
  Config::SetDefault ("ns3::DropTailQueue::MaxPackets", UintegerValue (4));
430
}
431
432
void
422
Ns3TcpCwndTestCase2::DoRun (void)
433
Ns3TcpCwndTestCase2::DoRun (void)
423
{
434
{
424
  // Set up some default values for the simulation.
425
  Config::SetDefault ("ns3::DropTailQueue::MaxPackets", UintegerValue (4));
426
427
  NodeContainer n0n1;
435
  NodeContainer n0n1;
428
  n0n1.Create (2);
436
  n0n1.Create (2);
429
437
(-)a/src/test/ns3tcp/ns3tcp-interop-test-suite.cc (+1 lines)
 Lines 128-133    Link Here 
128
Ns3TcpInteroperabilityTestCase::DoTeardown (void)
128
Ns3TcpInteroperabilityTestCase::DoTeardown (void)
129
{
129
{
130
  m_pcapFile.Close ();
130
  m_pcapFile.Close ();
131
  TestCase::DoTeardown ();
131
}
132
}
132
133
133
void
134
void
(-)a/src/test/ns3tcp/ns3tcp-loss-test-suite.cc (-37 / +68 lines)
 Lines 115-120    Link Here 
115
void
115
void
116
Ns3TcpLossTestCase::DoSetup (void)
116
Ns3TcpLossTestCase::DoSetup (void)
117
{
117
{
118
  Simulator::Destroy();
119
  
120
  // Enable packet metadata
121
  Packet::EnablePrinting ();  
122
118
  //
123
  //
119
  // We expect there to be a file called ns3tcp-state-response-vectors.pcap in
124
  // We expect there to be a file called ns3tcp-state-response-vectors.pcap in
120
  // response-vectors/ of this directory
125
  // response-vectors/ of this directory
 Lines 133-144    Link Here 
133
      m_pcapFile.Open (m_pcapFilename, std::ios::in|std::ios::binary);
138
      m_pcapFile.Open (m_pcapFilename, std::ios::in|std::ios::binary);
134
      NS_ABORT_MSG_UNLESS (m_pcapFile.GetDataLinkType () == PCAP_LINK_TYPE, "Wrong response vectors in directory");
139
      NS_ABORT_MSG_UNLESS (m_pcapFile.GetDataLinkType () == PCAP_LINK_TYPE, "Wrong response vectors in directory");
135
    }
140
    }
141
142
  // Config
143
  std::ostringstream tcpModel;
144
  tcpModel << "ns3::Tcp" << m_tcpModel;
145
  Config::SetDefault ("ns3::TcpL4Protocol::SocketType", StringValue (tcpModel.str ()));
146
  Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (1000));
147
  Config::SetDefault ("ns3::TcpSocket::DelAckCount", UintegerValue (1));
148
149
  // Logging
150
  if (m_writeLogging)
151
    {
152
      LogComponentEnableAll (LOG_PREFIX_FUNC);
153
      LogComponentEnable ("TcpLossResponse", LOG_LEVEL_ALL);
154
      LogComponentEnable ("ErrorModel", LOG_LEVEL_DEBUG);
155
      LogComponentEnable ("TcpLossResponse", LOG_LEVEL_ALL);
156
      LogComponentEnable ("TcpNewReno", LOG_LEVEL_INFO);
157
      LogComponentEnable ("TcpReno", LOG_LEVEL_INFO);
158
      LogComponentEnable ("TcpTahoe", LOG_LEVEL_INFO);
159
      LogComponentEnable ("TcpSocketBase", LOG_LEVEL_INFO);
160
    }
161
136
}
162
}
137
163
138
void
164
void
139
Ns3TcpLossTestCase::DoTeardown (void)
165
Ns3TcpLossTestCase::DoTeardown (void)
140
{
166
{
167
  // Restore Logging
168
  if (m_writeLogging)
169
    {
170
      LogComponentDisableAll (LOG_PREFIX_FUNC);
171
      LogComponentDisable ("TcpLossResponse", LOG_LEVEL_ALL);
172
      LogComponentDisable ("ErrorModel", LOG_LEVEL_DEBUG);
173
      LogComponentDisable ("TcpLossResponse", LOG_LEVEL_ALL);
174
      LogComponentDisable ("TcpNewReno", LOG_LEVEL_INFO);
175
      LogComponentDisable ("TcpReno", LOG_LEVEL_INFO);
176
      LogComponentDisable ("TcpTahoe", LOG_LEVEL_INFO);
177
      LogComponentDisable ("TcpSocketBase", LOG_LEVEL_INFO);
178
    }
179
141
  m_pcapFile.Close ();
180
  m_pcapFile.Close ();
181
  
182
  // Enable packet metadata
183
  Packet::DisablePrinting ();  
184
  
185
  TestCase::DoTeardown ();
142
}
186
}
143
187
144
void
188
void
 Lines 182-203    Link Here 
182
      // file and see if it still does the right thing.
226
      // file and see if it still does the right thing.
183
      //
227
      //
184
      uint8_t expected[PCAP_SNAPLEN];
228
      uint8_t expected[PCAP_SNAPLEN];
185
      uint32_t tsSec, tsUsec, inclLen, origLen, readLen;
229
      uint32_t tsSec=0, tsUsec=0, inclLen=0, origLen=0, readLen=0;
186
      m_pcapFile.Read (expected, sizeof(expected), tsSec, tsUsec, inclLen, origLen, readLen);
230
      m_pcapFile.Read (expected, sizeof(expected), tsSec, tsUsec, inclLen, origLen, readLen);
187
231
188
      uint8_t *actual = new uint8_t[readLen];
232
      if (readLen != 0 && origLen != 0) 
189
      p->CopyData (actual, readLen);
233
        {
234
          uint8_t *actual = new uint8_t[readLen];
235
          p->CopyData (actual, readLen);
190
236
191
      uint32_t result = memcmp (actual, expected, readLen);
237
          uint32_t result = memcmp (actual, expected, readLen);
192
238
193
      delete [] actual;
239
          delete [] actual;
194
240
195
      //
241
          //
196
      // Avoid streams of errors -- only report the first.
242
          // Avoid streams of errors -- only report the first.
197
      //
243
          //
198
      if (GetErrorStatus () == false)
244
          if (GetErrorStatus () == false)
245
            {
246
              NS_TEST_EXPECT_MSG_EQ (result, 0, "Expected data comparison error");
247
            }
248
        }
249
      else if (GetErrorStatus () == false)
199
        {
250
        {
200
          NS_TEST_EXPECT_MSG_EQ (result, 0, "Expected data comparison error");
251
          NS_TEST_EXPECT_MSG_GT (readLen, 0, "Unexpected packet error");
201
        }
252
        }
202
    }
253
    }
203
}
254
}
 Lines 282-306    Link Here 
282
  // Example corresponding to simulations in the paper "Simulation-based
333
  // Example corresponding to simulations in the paper "Simulation-based
283
  // Comparisons of Tahoe, Reno, and SACK TCP 
334
  // Comparisons of Tahoe, Reno, and SACK TCP 
284
335
285
  std::ostringstream tcpModel;
286
  tcpModel << "ns3::Tcp" << m_tcpModel;
287
  Config::SetDefault ("ns3::TcpL4Protocol::SocketType", 
288
                      StringValue (tcpModel.str ()));
289
  Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (1000));
290
  Config::SetDefault ("ns3::TcpSocket::DelAckCount", UintegerValue (1));
291
292
  if (m_writeLogging)
293
    {
294
      LogComponentEnableAll (LOG_PREFIX_FUNC);
295
      LogComponentEnable ("TcpLossResponse", LOG_LEVEL_ALL);
296
      LogComponentEnable ("ErrorModel", LOG_LEVEL_DEBUG);
297
      LogComponentEnable ("TcpLossResponse", LOG_LEVEL_ALL);
298
      LogComponentEnable ("TcpNewReno", LOG_LEVEL_INFO);
299
      LogComponentEnable ("TcpReno", LOG_LEVEL_INFO);
300
      LogComponentEnable ("TcpTahoe", LOG_LEVEL_INFO);
301
      LogComponentEnable ("TcpSocketBase", LOG_LEVEL_INFO);
302
    }
303
304
  ////////////////////////////////////////////////////////
336
  ////////////////////////////////////////////////////////
305
  // Topology construction
337
  // Topology construction
306
  //
338
  //
 Lines 359-371    Link Here 
359
                          ipInterfs.GetAddress (1), 
391
                          ipInterfs.GetAddress (1), 
360
                          servPort);
392
                          servPort);
361
393
362
  Config::Connect ("/NodeList/0/$ns3::Ipv4L3Protocol/Tx",
363
                   MakeCallback (&Ns3TcpLossTestCase::Ipv4L3Tx, this));
364
365
  Config::ConnectWithoutContext
366
    ("/NodeList/0/$ns3::TcpL4Protocol/SocketList/0/CongestionWindow",
367
    MakeCallback (&Ns3TcpLossTestCase::CwndTracer, this));
368
369
  ////////////////////////////////////////////////////////
394
  ////////////////////////////////////////////////////////
370
  // Set up loss model at node k1
395
  // Set up loss model at node k1
371
  //
396
  //
 Lines 403-408    Link Here 
403
  pem->SetList (sampleList);
428
  pem->SetList (sampleList);
404
  dev1.Get (1)->SetAttribute ("ReceiveErrorModel", PointerValue (pem));
429
  dev1.Get (1)->SetAttribute ("ReceiveErrorModel", PointerValue (pem));
405
430
431
  Config::Connect ("/NodeList/0/$ns3::Ipv4L3Protocol/Tx",
432
                   MakeCallback (&Ns3TcpLossTestCase::Ipv4L3Tx, this));
433
434
  Config::ConnectWithoutContext
435
    ("/NodeList/0/$ns3::TcpL4Protocol/SocketList/0/CongestionWindow",
436
    MakeCallback (&Ns3TcpLossTestCase::CwndTracer, this));
437
406
  // One can toggle the comment for the following line on or off to see the
438
  // One can toggle the comment for the following line on or off to see the
407
  // effects of finite send buffer modelling.  One can also change the size of
439
  // effects of finite send buffer modelling.  One can also change the size of
408
  // that buffer.
440
  // that buffer.
 Lines 442-448    Link Here 
442
Ns3TcpLossTestSuite::Ns3TcpLossTestSuite ()
474
Ns3TcpLossTestSuite::Ns3TcpLossTestSuite ()
443
  : TestSuite ("ns3-tcp-loss", SYSTEM)
475
  : TestSuite ("ns3-tcp-loss", SYSTEM)
444
{
476
{
445
  Packet::EnablePrinting ();  // Enable packet metadata for all test cases
446
  AddTestCase (new Ns3TcpLossTestCase ("Tahoe", 0));
477
  AddTestCase (new Ns3TcpLossTestCase ("Tahoe", 0));
447
  AddTestCase (new Ns3TcpLossTestCase ("Tahoe", 1));
478
  AddTestCase (new Ns3TcpLossTestCase ("Tahoe", 1));
448
  AddTestCase (new Ns3TcpLossTestCase ("Tahoe", 2));
479
  AddTestCase (new Ns3TcpLossTestCase ("Tahoe", 2));
(-)a/src/test/ns3tcp/ns3tcp-socket-test-suite.cc (-2 / +9 lines)
 Lines 158-163    Link Here 
158
158
159
private:
159
private:
160
  virtual void DoRun (void);
160
  virtual void DoRun (void);
161
  virtual void DoSetup (void);
162
161
  bool m_writeResults;
163
  bool m_writeResults;
162
164
163
  void SinkRx (std::string path, Ptr<const Packet> p, const Address &address);
165
  void SinkRx (std::string path, Ptr<const Packet> p, const Address &address);
 Lines 179-184    Link Here 
179
}
181
}
180
182
181
void
183
void
184
Ns3TcpSocketTestCase2::DoSetup (void)
185
{
186
  TestCase::DoSetup ();
187
  Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (1000));
188
}
189
190
void
182
Ns3TcpSocketTestCase2::DoRun (void)
191
Ns3TcpSocketTestCase2::DoRun (void)
183
{
192
{
184
  uint16_t sinkPort = 50000;
193
  uint16_t sinkPort = 50000;
 Lines 189-196    Link Here 
189
  Time writerStopTimeObj = Seconds (writerStopTime);
198
  Time writerStopTimeObj = Seconds (writerStopTime);
190
  Time simStopTimeObj= Seconds (simStopTime);
199
  Time simStopTimeObj= Seconds (simStopTime);
191
200
192
  Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (1000));
193
194
  NodeContainer nodes;
201
  NodeContainer nodes;
195
  nodes.Create (2);
202
  nodes.Create (2);
196
  Ptr<Node> n0 = nodes.Get (0);
203
  Ptr<Node> n0 = nodes.Get (0);
(-)a/src/test/ns3tcp/ns3tcp-state-test-suite.cc (-37 / +65 lines)
 Lines 110-115    Link Here 
110
void
110
void
111
Ns3TcpStateTestCase::DoSetup (void)
111
Ns3TcpStateTestCase::DoSetup (void)
112
{
112
{
113
  Simulator::Destroy();
114
115
  // Enable packet metadata
116
  Packet::EnablePrinting ();  
117
  
113
  //
118
  //
114
  // We expect there to be a file called ns3tcp-state-response-vectors.pcap in
119
  // We expect there to be a file called ns3tcp-state-response-vectors.pcap in
115
  // response-vectors/ of this directory
120
  // response-vectors/ of this directory
 Lines 128-139    Link Here 
128
      m_pcapFile.Open (m_pcapFilename, std::ios::in|std::ios::binary);
133
      m_pcapFile.Open (m_pcapFilename, std::ios::in|std::ios::binary);
129
      NS_ABORT_MSG_UNLESS (m_pcapFile.GetDataLinkType () == PCAP_LINK_TYPE, "Wrong response vectors in directory");
134
      NS_ABORT_MSG_UNLESS (m_pcapFile.GetDataLinkType () == PCAP_LINK_TYPE, "Wrong response vectors in directory");
130
    }
135
    }
136
  
137
  // Config
138
  std::string tcpModel ("ns3::TcpNewReno");
139
  Config::SetDefault ("ns3::TcpL4Protocol::SocketType", StringValue (tcpModel));
140
  Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (1000));
141
  Config::SetDefault ("ns3::TcpSocket::DelAckCount", UintegerValue (1));
142
  Config::SetDefault ("ns3::DropTailQueue::MaxPackets", UintegerValue (20));
143
144
  // Logging  
145
  if (m_writeLogging)
146
    {
147
      LogComponentEnableAll (LOG_PREFIX_FUNC);
148
      LogComponentEnable ("TcpTestCases", LOG_LEVEL_ALL);
149
      LogComponentEnable ("ErrorModel", LOG_LEVEL_DEBUG);
150
      LogComponentEnable ("TcpTestCases", LOG_LEVEL_ALL);
151
      LogComponentEnable ("TcpNewReno", LOG_LEVEL_INFO);
152
      LogComponentEnable ("TcpReno", LOG_LEVEL_INFO);
153
      LogComponentEnable ("TcpTahoe", LOG_LEVEL_INFO);
154
      LogComponentEnable ("TcpSocketBase", LOG_LEVEL_INFO);
155
    }
131
}
156
}
132
157
133
void
158
void
134
Ns3TcpStateTestCase::DoTeardown (void)
159
Ns3TcpStateTestCase::DoTeardown (void)
135
{
160
{
161
  // Restore Logging
162
  if (m_writeLogging)
163
    {
164
      LogComponentDisableAll (LOG_PREFIX_FUNC);
165
      LogComponentDisable ("TcpTestCases", LOG_LEVEL_ALL);
166
      LogComponentDisable ("ErrorModel", LOG_LEVEL_DEBUG);
167
      LogComponentDisable ("TcpTestCases", LOG_LEVEL_ALL);
168
      LogComponentDisable ("TcpNewReno", LOG_LEVEL_INFO);
169
      LogComponentDisable ("TcpReno", LOG_LEVEL_INFO);
170
      LogComponentDisable ("TcpTahoe", LOG_LEVEL_INFO);
171
      LogComponentDisable ("TcpSocketBase", LOG_LEVEL_INFO);
172
    }
173
  
136
  m_pcapFile.Close ();
174
  m_pcapFile.Close ();
175
176
  // Enable packet metadata
177
  Packet::DisablePrinting ();  
178
179
  TestCase::DoTeardown ();
137
}
180
}
138
181
139
void
182
void
 Lines 177-198    Link Here 
177
      // file and see if it still does the right thing.
220
      // file and see if it still does the right thing.
178
      //
221
      //
179
      uint8_t expected[PCAP_SNAPLEN];
222
      uint8_t expected[PCAP_SNAPLEN];
180
      uint32_t tsSec, tsUsec, inclLen, origLen, readLen;
223
      uint32_t tsSec=0, tsUsec=0, inclLen=0, origLen=0, readLen=0;
181
      m_pcapFile.Read (expected, sizeof(expected), tsSec, tsUsec, inclLen, origLen, readLen);
224
      m_pcapFile.Read (expected, sizeof(expected), tsSec, tsUsec, inclLen, origLen, readLen);
225
      
226
      if (readLen != 0 && origLen != 0) 
227
        {
228
          uint8_t *actual = new uint8_t[readLen];
229
          p->CopyData (actual, readLen);
182
230
183
      uint8_t *actual = new uint8_t[readLen];
231
          uint32_t result = memcmp (actual, expected, readLen);
184
      p->CopyData (actual, readLen);
185
232
186
      uint32_t result = memcmp (actual, expected, readLen);
233
          delete [] actual;
187
234
188
      delete [] actual;
235
          //
189
236
          // Avoid streams of errors -- only report the first.
190
      //
237
          //
191
      // Avoid streams of errors -- only report the first.
238
          if (GetErrorStatus () == false)
192
      //
239
            {
193
      if (GetErrorStatus () == false)
240
              NS_TEST_EXPECT_MSG_EQ (result, 0, "Expected data comparison error");
241
            }
242
        }
243
      else if (GetErrorStatus () == false)
194
        {
244
        {
195
          NS_TEST_EXPECT_MSG_EQ (result, 0, "Expected data comparison error");
245
          NS_TEST_EXPECT_MSG_GT (readLen, 0, "Unexpected packet error");
196
        }
246
        }
197
    }
247
    }
198
}
248
}
 Lines 266-294    Link Here 
266
  //           10Mb/s, 0.1ms      10Mb/s, 0.1ms
316
  //           10Mb/s, 0.1ms      10Mb/s, 0.1ms
267
  //       n0-----------------n1-----------------n2
317
  //       n0-----------------n1-----------------n2
268
318
269
  std::string tcpModel ("ns3::TcpNewReno");
270
271
  Config::SetDefault ("ns3::TcpL4Protocol::SocketType", StringValue (tcpModel));
272
  Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (1000));
273
  Config::SetDefault ("ns3::TcpSocket::DelAckCount", UintegerValue (1));
274
  Config::SetDefault ("ns3::DropTailQueue::MaxPackets", UintegerValue (20));
275
276
  if (m_writeLogging)
277
    {
278
      LogComponentEnableAll (LOG_PREFIX_FUNC);
279
      LogComponentEnable ("TcpTestCases", LOG_LEVEL_ALL);
280
      LogComponentEnable ("ErrorModel", LOG_LEVEL_DEBUG);
281
      LogComponentEnable ("TcpTestCases", LOG_LEVEL_ALL);
282
      LogComponentEnable ("TcpNewReno", LOG_LEVEL_INFO);
283
      LogComponentEnable ("TcpReno", LOG_LEVEL_INFO);
284
      LogComponentEnable ("TcpTahoe", LOG_LEVEL_INFO);
285
      LogComponentEnable ("TcpSocketBase", LOG_LEVEL_INFO);
286
    }
287
288
  ////////////////////////////////////////////////////////
319
  ////////////////////////////////////////////////////////
289
  // Topology construction
320
  // Topology construction
290
  //
321
  //
291
322
  
292
  // Create three nodes
323
  // Create three nodes
293
  NodeContainer n0n1;
324
  NodeContainer n0n1;
294
  n0n1.Create (2);
325
  n0n1.Create (2);
 Lines 338-346    Link Here 
338
  Simulator::ScheduleNow (&Ns3TcpStateTestCase::StartFlow, this, 
369
  Simulator::ScheduleNow (&Ns3TcpStateTestCase::StartFlow, this, 
339
                          localSocket, ipInterfs.GetAddress (1), servPort);
370
                          localSocket, ipInterfs.GetAddress (1), servPort);
340
371
341
  Config::Connect ("/NodeList/0/$ns3::Ipv4L3Protocol/Tx",
342
                   MakeCallback (&Ns3TcpStateTestCase::Ipv4L3Tx, this));
343
344
  ////////////////////////////////////////////////////////
372
  ////////////////////////////////////////////////////////
345
  // Set up different test cases: Lost model at node n1, different file size
373
  // Set up different test cases: Lost model at node n1, different file size
346
  //
374
  //
 Lines 411-416    Link Here 
411
  errN1->SetList (dropListN1);
439
  errN1->SetList (dropListN1);
412
  dev1.Get (0)->SetAttribute ("ReceiveErrorModel", PointerValue (errN1));
440
  dev1.Get (0)->SetAttribute ("ReceiveErrorModel", PointerValue (errN1));
413
441
442
  Config::Connect ("/NodeList/0/$ns3::Ipv4L3Protocol/Tx",
443
                   MakeCallback (&Ns3TcpStateTestCase::Ipv4L3Tx, this));
444
414
  std::ostringstream oss;
445
  std::ostringstream oss;
415
  oss << "tcp-state" << m_testCase << "-test-case";
446
  oss << "tcp-state" << m_testCase << "-test-case";
416
  if (m_writeResults)
447
  if (m_writeResults)
 Lines 434-441    Link Here 
434
  Simulator::Stop (Seconds (1000));
465
  Simulator::Stop (Seconds (1000));
435
  Simulator::Run ();
466
  Simulator::Run ();
436
  Simulator::Destroy ();
467
  Simulator::Destroy ();
437
438
439
}
468
}
440
469
441
class Ns3TcpStateTestSuite : public TestSuite
470
class Ns3TcpStateTestSuite : public TestSuite
 Lines 447-453    Link Here 
447
Ns3TcpStateTestSuite::Ns3TcpStateTestSuite ()
476
Ns3TcpStateTestSuite::Ns3TcpStateTestSuite ()
448
  : TestSuite ("ns3-tcp-state", SYSTEM)
477
  : TestSuite ("ns3-tcp-state", SYSTEM)
449
{
478
{
450
  Packet::EnablePrinting ();  // Enable packet metadata for all test cases
451
  AddTestCase (new Ns3TcpStateTestCase (0));
479
  AddTestCase (new Ns3TcpStateTestCase (0));
452
  AddTestCase (new Ns3TcpStateTestCase (1));
480
  AddTestCase (new Ns3TcpStateTestCase (1));
453
  AddTestCase (new Ns3TcpStateTestCase (2));
481
  AddTestCase (new Ns3TcpStateTestCase (2));
(-)a/src/test/ns3wifi/wifi-interference-test-suite.cc (-13 / +21 lines)
 Lines 57-62    Link Here 
57
57
58
private:
58
private:
59
  virtual void DoRun (void);
59
  virtual void DoRun (void);
60
  virtual void DoSetup (void);
61
  
60
  void ReceivePacket (Ptr<Socket> socket);
62
  void ReceivePacket (Ptr<Socket> socket);
61
  static void GenerateTraffic (Ptr<Socket> socket, uint32_t pktSize, uint32_t pktCount, Time pktInterval);
63
  static void GenerateTraffic (Ptr<Socket> socket, uint32_t pktSize, uint32_t pktCount, Time pktInterval);
62
  void PrintEndSync (std::string context, uint32_t dataRate, double snr, double per);
64
  void PrintEndSync (std::string context, uint32_t dataRate, double snr, double per);
 Lines 65-75    Link Here 
65
  double m_PER;
67
  double m_PER;
66
  double m_SNR;
68
  double m_SNR;
67
  uint32_t m_DataRate;
69
  uint32_t m_DataRate;
70
  
71
  std::string m_phyMode;
68
};
72
};
69
73
70
// Add some help text to this case to describe what it is intended to test
74
// Add some help text to this case to describe what it is intended to test
71
WifiInterferenceTestCase::WifiInterferenceTestCase  ()
75
WifiInterferenceTestCase::WifiInterferenceTestCase  ()
72
  : TestCase ("Test interference calculation when interfering frame exactly overlaps intended frame")
76
  : TestCase ("Test interference calculation when interfering frame exactly overlaps intended frame")
77
  , m_phyMode ("DsssRate1Mbps")
73
{
78
{
74
}
79
}
75
80
 Lines 77-82    Link Here 
77
{
82
{
78
}
83
}
79
84
85
void
86
WifiInterferenceTestCase::DoSetup ()
87
{
88
  TestCase::DoSetup ();
89
  
90
  // disable fragmentation for frames below 2200 bytes
91
  Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2200"));
92
  // turn off RTS/CTS for frames below 2200 bytes
93
  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("2200"));
94
  // Fix non-unicast data rate to be the same as that of unicast
95
  Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode", StringValue (m_phyMode));
96
}
97
80
void 
98
void 
81
WifiInterferenceTestCase::ReceivePacket (Ptr<Socket> socket)
99
WifiInterferenceTestCase::ReceivePacket (Ptr<Socket> socket)
82
{
100
{
 Lines 131-144    Link Here 
131
  // Convert to time object
149
  // Convert to time object
132
  Time interPacketInterval = Seconds (interval);
150
  Time interPacketInterval = Seconds (interval);
133
151
134
  // disable fragmentation for frames below 2200 bytes
135
  Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2200"));
136
  // turn off RTS/CTS for frames below 2200 bytes
137
  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("2200"));
138
  // Fix non-unicast data rate to be the same as that of unicast
139
  Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode", 
140
                      StringValue (phyMode));
141
142
  NodeContainer c;
152
  NodeContainer c;
143
  c.Create (3);
153
  c.Create (3);
144
154
 Lines 232-239    Link Here 
232
void
242
void
233
WifiInterferenceTestCase::DoRun (void)
243
WifiInterferenceTestCase::DoRun (void)
234
{
244
{
235
236
  std::string phyMode ("DsssRate1Mbps");
237
  double Prss = -90;  // -dBm
245
  double Prss = -90;  // -dBm
238
  double Irss = -90;  // -dBm
246
  double Irss = -90;  // -dBm
239
  double delta = 0;  // microseconds
247
  double delta = 0;  // microseconds
 Lines 246-262    Link Here 
246
  // Compute the packet error rate (PER) when delta=0 microseconds.  This
254
  // Compute the packet error rate (PER) when delta=0 microseconds.  This
247
  // means that the interferer arrives at exactly the same time as the
255
  // means that the interferer arrives at exactly the same time as the
248
  // intended packet
256
  // intended packet
249
  PER = WifiSimpleInterference (phyMode,Prss,Irss,delta,PpacketSize,IpacketSize,verbose,internet);
257
  PER = WifiSimpleInterference (m_phyMode,Prss,Irss,delta,PpacketSize,IpacketSize,verbose,internet);
250
258
251
  // Now rerun this test case and compute the PER when the delta time between
259
  // Now rerun this test case and compute the PER when the delta time between
252
  // arrival of the intended frame and interferer is 1 microsecond.
260
  // arrival of the intended frame and interferer is 1 microsecond.
253
  delta = 1;
261
  delta = 1;
254
  PER1 = WifiSimpleInterference (phyMode,Prss,Irss,delta,PpacketSize,IpacketSize,verbose,internet);
262
  PER1 = WifiSimpleInterference (m_phyMode,Prss,Irss,delta,PpacketSize,IpacketSize,verbose,internet);
255
263
256
  // Now rerun this test case and compute the PER when the delta time between
264
  // Now rerun this test case and compute the PER when the delta time between
257
  // arrival of the intended frame and interferer is 2 microseconds.
265
  // arrival of the intended frame and interferer is 2 microseconds.
258
  delta = 2;
266
  delta = 2;
259
  PER2 = WifiSimpleInterference (phyMode,Prss,Irss,delta,PpacketSize,IpacketSize,verbose,internet);
267
  PER2 = WifiSimpleInterference (m_phyMode,Prss,Irss,delta,PpacketSize,IpacketSize,verbose,internet);
260
268
261
  double PERDiff1 = PER - PER1;
269
  double PERDiff1 = PER - PER1;
262
270
263
* The test framework now assures repeatable conditions within test cases, by:
271
* The test framework now assures repeatable conditions within test cases, by:
264
  - Destroying the simulator at base TestCase::DoTeardown/Setup
272
  - Destroying the simulator at base TestCase::DoTeardown/Setup
265
  - Resetting configuration (attribute defaults and global values) at
273
  - Resetting configuration (attribute defaults and global values) at
266
    various points (TestCase::DoTeardown, TestSuite::DoSetup)
274
    various points (TestCase::DoTeardown, TestSuite::DoSetup)
267
  - Saving/Restoring the RNG state at TestSuite::DoSetup/Teardown
275
  - Saving/Restoring the RNG state at TestSuite::DoSetup/Teardown
268
    (I tried per TestCase, but some test cases depend on RNG state
276
    (I tried per TestCase, but some test cases depend on RNG state
269
    set by previous test cases, sorting that out would have been
277
    set by previous test cases, sorting that out would have been
270
    a LOT more work)
278
    a LOT more work)
(-)a/src/aodv/test/aodv-regression.cc (-1 / +8 lines)
 Lines 67-72    Link Here 
67
    // Ping loopback test case
67
    // Ping loopback test case
68
    AddTestCase (new LoopbackTestCase ());
68
    AddTestCase (new LoopbackTestCase ());
69
  }
69
  }
70
  
71
  virtual void DoSetup (void)
72
  {
73
    TestSuite::DoSetup();
74
    
75
    // Set a reproducible random seed
76
    SeedManager::SetSeed(12345);
77
  }
70
} g_aodvRegressionTestSuite;
78
} g_aodvRegressionTestSuite;
71
 
79
 
72
80
 Lines 92-98    Link Here 
92
void
100
void
93
ChainRegressionTest::DoRun ()
101
ChainRegressionTest::DoRun ()
94
{
102
{
95
  SeedManager::SetSeed (12345);
96
  Config::SetDefault ("ns3::ArpCache::AliveTimeout", TimeValue (m_arpAliveTimeout));
103
  Config::SetDefault ("ns3::ArpCache::AliveTimeout", TimeValue (m_arpAliveTimeout));
97
104
98
  CreateNodes ();
105
  CreateNodes ();
(-)a/src/aodv/test/bug-772.cc (+1 lines)
 Lines 74-79    Link Here 
74
Bug772ChainTest::DoRun ()
74
Bug772ChainTest::DoRun ()
75
{
75
{
76
  SeedManager::SetSeed (12345);
76
  SeedManager::SetSeed (12345);
77
  Config::SetDefault ("ns3::ArpCache::AliveTimeout", TimeValue (Seconds (1)));
77
78
78
  CreateNodes ();
79
  CreateNodes ();
79
  CreateDevices ();
80
  CreateDevices ();
(-)a/src/core/model/test.cc (+42 lines)
 Lines 21-26    Link Here 
21
#include "abort.h"
21
#include "abort.h"
22
#include <math.h>
22
#include <math.h>
23
23
24
#include "ns3/simulator.h"
25
#include "ns3/config.h"
26
24
// Set to true to enable a segmentation fault upon a test case macro test 
27
// Set to true to enable a segmentation fault upon a test case macro test 
25
// failing (for debugging purposes)
28
// failing (for debugging purposes)
26
bool gBreakOnFailure = false;
29
bool gBreakOnFailure = false;
 Lines 395-405    Link Here 
395
void 
398
void 
396
TestCase::DoSetup (void)
399
TestCase::DoSetup (void)
397
{
400
{
401
  /*
402
   * Ensure a clean execution environment
403
   */
404
  Simulator::Destroy();
398
}
405
}
399
406
400
void 
407
void 
401
TestCase::DoTeardown (void)
408
TestCase::DoTeardown (void)
402
{
409
{
410
  /*
411
   *   Most tests will destroy their simulators when successful,
412
   * but on failure, they tend to leave the simulator alive.
413
   *   This can be a problem for subsequent test runs, so we
414
   * must destroy the simulator on TestCase teardown just in case.
415
   */
416
  Simulator::Destroy();
417
  
418
  /**
419
   *   Some tests will change default configuration settings. In
420
   * those cases, a full configuration reset is the only way to get
421
   * back to a reproducible state.
422
   */
423
  Config::Reset ();
403
}
424
}
404
425
405
TestSuite::TestSuite (std::string name, TestType type)
426
TestSuite::TestSuite (std::string name, TestType type)
 Lines 659-664    Link Here 
659
void 
680
void 
660
TestSuite::DoSetup (void)
681
TestSuite::DoSetup (void)
661
{
682
{
683
  /*
684
   * Ensure repeatable state, reset all configuration settings to their defaults
685
   */
686
  Config::Reset ();
687
  
688
  /* 
689
   * Preserve global RNG state (RngStream contains process-wide side effects)
690
   */
691
  m_rngRunBackup = SeedManager::GetRun();
692
  m_rngSeedBackup = SeedManager::GetSeed();
693
  
694
  /*
695
   * Reset RNG state (in case the testing framework changed it somehow between runs)
696
   */
697
  SeedManager::SetRun(m_rngRunBackup);
698
  SeedManager::SetSeed(m_rngSeedBackup);
662
}
699
}
663
700
664
void
701
void
 Lines 697-702    Link Here 
697
void 
734
void 
698
TestSuite::DoTeardown (void)
735
TestSuite::DoTeardown (void)
699
{
736
{
737
  /* 
738
   * Restore global RNG state
739
   */
740
  SeedManager::SetRun(m_rngRunBackup);
741
  SeedManager::SetSeed(m_rngSeedBackup);
700
}
742
}
701
743
702
class TestRunnerImpl
744
class TestRunnerImpl
(-)a/src/core/model/test.h (+10 lines)
 Lines 29-34    Link Here 
29
#include <stdint.h>
29
#include <stdint.h>
30
30
31
#include "ns3/system-wall-clock-ms.h"
31
#include "ns3/system-wall-clock-ms.h"
32
#include "ns3/random-variable.h"
32
33
33
extern bool gBreakOnFailure;
34
extern bool gBreakOnFailure;
34
35
 Lines 1276-1281    Link Here 
1276
  bool m_error;
1277
  bool m_error;
1277
  TestType m_type;
1278
  TestType m_type;
1278
1279
1280
  // Backup of process-wide RNG state
1281
  // FIXME: This *should* be done per-testcase, but current test cases
1282
  //    depend have cases where they depend on RNG state resulting from
1283
  //    previous runs within a TestSuite (like routing-aodv-regression),
1284
  //    so in order not to break them, we do not reset RNG state between
1285
  //    test cases, only between tests suites.
1286
  uint32_t m_rngSeedBackup;
1287
  uint32_t m_rngRunBackup;
1288
1279
  typedef std::vector<TestCase *> TestCaseVector_t;
1289
  typedef std::vector<TestCase *> TestCaseVector_t;
1280
  TestCaseVector_t m_tests;
1290
  TestCaseVector_t m_tests;
1281
};
1291
};
(-)a/src/core/test/names-test-suite.cc (+14 lines)
 Lines 87-92    Link Here 
87
BasicAddTestCase::DoTeardown (void)
87
BasicAddTestCase::DoTeardown (void)
88
{
88
{
89
  Names::Clear ();
89
  Names::Clear ();
90
  TestCase::DoTeardown ();
90
}
91
}
91
92
92
void
93
void
 Lines 153-158    Link Here 
153
StringContextAddTestCase::DoTeardown (void)
154
StringContextAddTestCase::DoTeardown (void)
154
{
155
{
155
  Names::Clear ();
156
  Names::Clear ();
157
  TestCase::DoTeardown ();
156
}
158
}
157
159
158
void
160
void
 Lines 216-221    Link Here 
216
FullyQualifiedAddTestCase::DoTeardown (void)
218
FullyQualifiedAddTestCase::DoTeardown (void)
217
{
219
{
218
  Names::Clear ();
220
  Names::Clear ();
221
  TestCase::DoTeardown ();
219
}
222
}
220
223
221
void
224
void
 Lines 282-287    Link Here 
282
RelativeAddTestCase::DoTeardown (void)
285
RelativeAddTestCase::DoTeardown (void)
283
{
286
{
284
  Names::Clear ();
287
  Names::Clear ();
288
  TestCase::DoTeardown ();
285
}
289
}
286
290
287
void
291
void
 Lines 347-352    Link Here 
347
BasicRenameTestCase::DoTeardown (void)
351
BasicRenameTestCase::DoTeardown (void)
348
{
352
{
349
  Names::Clear ();
353
  Names::Clear ();
354
  TestCase::DoTeardown ();
350
}
355
}
351
356
352
void
357
void
 Lines 407-412    Link Here 
407
StringContextRenameTestCase::DoTeardown (void)
412
StringContextRenameTestCase::DoTeardown (void)
408
{
413
{
409
  Names::Clear ();
414
  Names::Clear ();
415
  TestCase::DoTeardown ();
410
}
416
}
411
417
412
void
418
void
 Lines 467-472    Link Here 
467
FullyQualifiedRenameTestCase::DoTeardown (void)
473
FullyQualifiedRenameTestCase::DoTeardown (void)
468
{
474
{
469
  Names::Clear ();
475
  Names::Clear ();
476
  TestCase::DoTeardown ();
470
}
477
}
471
478
472
void
479
void
 Lines 527-532    Link Here 
527
RelativeRenameTestCase::DoTeardown (void)
534
RelativeRenameTestCase::DoTeardown (void)
528
{
535
{
529
  Names::Clear ();
536
  Names::Clear ();
537
  TestCase::DoTeardown ();
530
}
538
}
531
539
532
void
540
void
 Lines 587-592    Link Here 
587
FindPathTestCase::DoTeardown (void)
595
FindPathTestCase::DoTeardown (void)
588
{
596
{
589
  Names::Clear ();
597
  Names::Clear ();
598
  TestCase::DoTeardown ();
590
}
599
}
591
600
592
void
601
void
 Lines 641-646    Link Here 
641
BasicFindTestCase::DoTeardown (void)
650
BasicFindTestCase::DoTeardown (void)
642
{
651
{
643
  Names::Clear ();
652
  Names::Clear ();
653
  TestCase::DoTeardown ();
644
}
654
}
645
655
646
void
656
void
 Lines 703-708    Link Here 
703
StringContextFindTestCase::DoTeardown (void)
713
StringContextFindTestCase::DoTeardown (void)
704
{
714
{
705
  Names::Clear ();
715
  Names::Clear ();
716
  TestCase::DoTeardown ();
706
}
717
}
707
718
708
void
719
void
 Lines 765-770    Link Here 
765
FullyQualifiedFindTestCase::DoTeardown (void)
776
FullyQualifiedFindTestCase::DoTeardown (void)
766
{
777
{
767
  Names::Clear ();
778
  Names::Clear ();
779
  TestCase::DoTeardown ();
768
}
780
}
769
781
770
void
782
void
 Lines 827-832    Link Here 
827
RelativeFindTestCase::DoTeardown (void)
839
RelativeFindTestCase::DoTeardown (void)
828
{
840
{
829
  Names::Clear ();
841
  Names::Clear ();
842
  TestCase::DoTeardown ();
830
}
843
}
831
844
832
void
845
void
 Lines 887-892    Link Here 
887
AlternateFindTestCase::DoTeardown (void)
900
AlternateFindTestCase::DoTeardown (void)
888
{
901
{
889
  Names::Clear ();
902
  Names::Clear ();
903
  TestCase::DoTeardown ();
890
}
904
}
891
905
892
void
906
void
(-)a/src/core/test/time-test-suite.cc (+1 lines)
 Lines 76-81    Link Here 
76
TimeSimpleTestCase::DoTeardown (void)
76
TimeSimpleTestCase::DoTeardown (void)
77
{
77
{
78
  Time::SetResolution (m_originalResolution);
78
  Time::SetResolution (m_originalResolution);
79
  TestCase::DoTeardown ();
79
}
80
}
80
81
81
static class TimeTestSuite : public TestSuite
82
static class TimeTestSuite : public TestSuite
(-)a/src/core/test/timer-test-suite.cc (+1 lines)
 Lines 215-220    Link Here 
215
{
215
{
216
  Simulator::Run ();
216
  Simulator::Run ();
217
  Simulator::Destroy ();
217
  Simulator::Destroy ();
218
  TestCase::DoTeardown ();
218
}
219
}
219
220
220
static class TimerTestSuite : public TestSuite
221
static class TimerTestSuite : public TestSuite
(-)a/src/energy/test/basic-energy-model-test.cc (-14 / +21 lines)
 Lines 217-222    Link Here 
217
217
218
private:
218
private:
219
  void DoRun (void);
219
  void DoRun (void);
220
  void DoSetup (void);
220
221
221
  /**
222
  /**
222
   * Callback invoked when energy is drained from source.
223
   * Callback invoked when energy is drained from source.
 Lines 238-248    Link Here 
238
  double m_simTimeS;        // maximum simulation time, in seconds
239
  double m_simTimeS;        // maximum simulation time, in seconds
239
  double m_timeStepS;       // simulation time step size, in seconds
240
  double m_timeStepS;       // simulation time step size, in seconds
240
  double m_updateIntervalS; // update interval of each device model
241
  double m_updateIntervalS; // update interval of each device model
242
  std::string m_phyMode;
241
243
242
};
244
};
243
245
244
BasicEnergyDepletionTest::BasicEnergyDepletionTest ()
246
BasicEnergyDepletionTest::BasicEnergyDepletionTest ()
245
  : TestCase ("Basic energy model energy depletion test case")
247
  : TestCase ("Basic energy model energy depletion test case")
248
  , m_phyMode ("DsssRate1Mbps")
246
{
249
{
247
  m_numOfNodes = 10;
250
  m_numOfNodes = 10;
248
  m_callbackCount = 0;
251
  m_callbackCount = 0;
 Lines 256-261    Link Here 
256
}
259
}
257
260
258
void
261
void
262
BasicEnergyDepletionTest::DoSetup (void)
263
{
264
  TestCase::DoSetup ();
265
266
  // disable fragmentation for frames below 2200 bytes
267
  Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold",
268
                      StringValue ("2200"));
269
  // turn off RTS/CTS for frames below 2200 bytes
270
  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold",
271
                      StringValue ("2200"));
272
  // Fix non-unicast data rate to be the same as that of unicast
273
  Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",
274
                      StringValue (m_phyMode));
275
}
276
277
void
259
BasicEnergyDepletionTest::DoRun (void)
278
BasicEnergyDepletionTest::DoRun (void)
260
{
279
{
261
  /*
280
  /*
 Lines 287-304    Link Here 
287
  NodeContainer c;
306
  NodeContainer c;
288
  c.Create (m_numOfNodes);
307
  c.Create (m_numOfNodes);
289
308
290
  std::string phyMode ("DsssRate1Mbps");
291
292
  // disable fragmentation for frames below 2200 bytes
293
  Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold",
294
                      StringValue ("2200"));
295
  // turn off RTS/CTS for frames below 2200 bytes
296
  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold",
297
                      StringValue ("2200"));
298
  // Fix non-unicast data rate to be the same as that of unicast
299
  Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",
300
                      StringValue (phyMode));
301
302
  // install YansWifiPhy
309
  // install YansWifiPhy
303
  WifiHelper wifi;
310
  WifiHelper wifi;
304
  wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
311
  wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
 Lines 319-326    Link Here 
319
  // Add a non-QoS upper MAC, and disable rate control
326
  // Add a non-QoS upper MAC, and disable rate control
320
  NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
327
  NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
321
  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
328
  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
322
                                "DataMode", StringValue (phyMode),
329
                                "DataMode", StringValue (m_phyMode),
323
                                "ControlMode", StringValue (phyMode));
330
                                "ControlMode", StringValue (m_phyMode));
324
  // Set it to ad-hoc mode
331
  // Set it to ad-hoc mode
325
  wifiMac.SetType ("ns3::AdhocWifiMac");
332
  wifiMac.SetType ("ns3::AdhocWifiMac");
326
  NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, c);
333
  NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, c);
(-)a/src/energy/test/rv-battery-model-test.cc (-34 / +35 lines)
 Lines 57-69    Link Here 
57
  void CreateLoadProfiles (void);
57
  void CreateLoadProfiles (void);
58
58
59
  /**
59
  /**
60
   * \returns False if no error occurs.
61
   *
62
   * Runs test.
60
   * Runs test.
63
   */
61
   */
64
  void DoRun (void);
62
  void DoRun (void);
65
63
66
  /**
64
  /**
65
   * Sets up test configuration
66
   */
67
  void DoSetup (void);
68
69
  /**
67
   * \param load Load value, in Amperes (A).
70
   * \param load Load value, in Amperes (A).
68
   * \param expLifetime Expected lifetime.
71
   * \param expLifetime Expected lifetime.
69
   * \return False if no error occurs.
72
   * \return False if no error occurs.
 Lines 99-112    Link Here 
99
  std::vector<LoadProfile> m_loadProfiles;
102
  std::vector<LoadProfile> m_loadProfiles;
100
  double m_alpha;
103
  double m_alpha;
101
  double m_beta;
104
  double m_beta;
105
  std::string m_phyMode;
102
};
106
};
103
107
104
BatteryLifetimeTest::BatteryLifetimeTest ()
108
BatteryLifetimeTest::BatteryLifetimeTest ()
105
  : TestCase ("RV battery model battery lifetime test case.")
109
  : TestCase ("RV battery model battery lifetime test case.")
110
  , m_phyMode ("DsssRate1Mbps")
106
{
111
{
107
  // Itsy battery
112
  // Itsy battery
108
  m_alpha = 35220;
113
  m_alpha = 35220;
109
  m_beta = 0.637;
114
  m_beta = 0.637;
115
  
116
  // create load profiles for variable load test
117
  CreateLoadProfiles ();
110
}
118
}
111
119
112
BatteryLifetimeTest::~BatteryLifetimeTest ()
120
BatteryLifetimeTest::~BatteryLifetimeTest ()
 Lines 638-647    Link Here 
638
}
646
}
639
647
640
void
648
void
649
BatteryLifetimeTest::DoSetup (void)
650
{
651
  TestCase::DoSetup ();
652
653
  // disable fragmentation for frames below 2200 bytes
654
  Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold",
655
                      StringValue ("2200"));
656
  // turn off RTS/CTS for frames below 2200 bytes
657
  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold",
658
                      StringValue ("2200"));
659
  // Fix non-unicast data rate to be the same as that of unicast
660
  Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",
661
                      StringValue (m_phyMode));
662
}
663
664
void
641
BatteryLifetimeTest::DoRun (void)
665
BatteryLifetimeTest::DoRun (void)
642
{
666
{
643
  NS_LOG_DEBUG ("Constant load run.");
667
  NS_LOG_DEBUG ("Constant load run.");
644
668
669
  // set constant load test parameters
670
  m_alpha = 35220;
671
  m_beta = 0.637;
672
645
  // 640mA
673
  // 640mA
646
  NS_TEST_ASSERT_MSG_EQ (ConstantLoadTest (0.640, Seconds (2844.0)), false,  "Problems with constant load test (640mA).");
674
  NS_TEST_ASSERT_MSG_EQ (ConstantLoadTest (0.640, Seconds (2844.0)), false,  "Problems with constant load test (640mA).");
647
  // 320mA
675
  // 320mA
 Lines 653-661    Link Here 
653
  // 32mA
681
  // 32mA
654
  NS_TEST_ASSERT_MSG_EQ (ConstantLoadTest (0.032, Seconds (65580.0)), false,  "Problems with constant load test (32).");
682
  NS_TEST_ASSERT_MSG_EQ (ConstantLoadTest (0.032, Seconds (65580.0)), false,  "Problems with constant load test (32).");
655
683
656
  // create load profiles for variable load test
657
  CreateLoadProfiles ();
658
659
  // variable load with Itsy battery
684
  // variable load with Itsy battery
660
  NS_LOG_DEBUG ("\n\nItsy");
685
  NS_LOG_DEBUG ("\n\nItsy");
661
  m_alpha = 35220;
686
  m_alpha = 35220;
 Lines 696-713    Link Here 
696
  NodeContainer c;
721
  NodeContainer c;
697
  c.Create (1);
722
  c.Create (1);
698
723
699
  std::string phyMode ("DsssRate1Mbps");
700
701
  // disable fragmentation for frames below 2200 bytes
702
  Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold",
703
                      StringValue ("2200"));
704
  // turn off RTS/CTS for frames below 2200 bytes
705
  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold",
706
                      StringValue ("2200"));
707
  // Fix non-unicast data rate to be the same as that of unicast
708
  Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",
709
                      StringValue (phyMode));
710
711
  // install YansWifiPhy
724
  // install YansWifiPhy
712
  WifiHelper wifi;
725
  WifiHelper wifi;
713
  wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
726
  wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
 Lines 728-735    Link Here 
728
  // Add a non-QoS upper MAC, and disable rate control
741
  // Add a non-QoS upper MAC, and disable rate control
729
  NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
742
  NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
730
  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
743
  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
731
                                "DataMode", StringValue (phyMode),
744
                                "DataMode", StringValue (m_phyMode),
732
                                "ControlMode", StringValue (phyMode));
745
                                "ControlMode", StringValue (m_phyMode));
733
  // Set it to ad-hoc mode
746
  // Set it to ad-hoc mode
734
  wifiMac.SetType ("ns3::AdhocWifiMac");
747
  wifiMac.SetType ("ns3::AdhocWifiMac");
735
  NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, c);
748
  NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, c);
 Lines 759-765    Link Here 
759
772
760
  NS_LOG_DEBUG ("Expected lifetime = " << expLifetime.GetSeconds () << "s");
773
  NS_LOG_DEBUG ("Expected lifetime = " << expLifetime.GetSeconds () << "s");
761
  NS_LOG_DEBUG ("Actual lifetime = " << actualLifetime.GetSeconds () << "s");
774
  NS_LOG_DEBUG ("Actual lifetime = " << actualLifetime.GetSeconds () << "s");
762
775
  
763
  NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL (actualLifetime, expLifetime, "Incorrect lifetime!");
776
  NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL (actualLifetime, expLifetime, "Incorrect lifetime!");
764
  /*
777
  /*
765
  NS_TEST_ASSERT_MSG_EQ_TOL_RETURNS_BOOL (actualLifetime.GetSeconds () / 60,
778
  NS_TEST_ASSERT_MSG_EQ_TOL_RETURNS_BOOL (actualLifetime.GetSeconds () / 60,
 Lines 783-800    Link Here 
783
  NodeContainer c;
796
  NodeContainer c;
784
  c.Create (1);
797
  c.Create (1);
785
798
786
  std::string phyMode ("DsssRate1Mbps");
787
788
  // disable fragmentation for frames below 2200 bytes
789
  Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold",
790
                      StringValue ("2200"));
791
  // turn off RTS/CTS for frames below 2200 bytes
792
  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold",
793
                      StringValue ("2200"));
794
  // Fix non-unicast data rate to be the same as that of unicast
795
  Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",
796
                      StringValue (phyMode));
797
798
  // install YansWifiPhy
799
  // install YansWifiPhy
799
  WifiHelper wifi;
800
  WifiHelper wifi;
800
  wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
801
  wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
 Lines 815-822    Link Here 
815
  // Add a non-QoS upper MAC, and disable rate control
816
  // Add a non-QoS upper MAC, and disable rate control
816
  NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
817
  NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
817
  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
818
  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
818
                                "DataMode", StringValue (phyMode),
819
                                "DataMode", StringValue (m_phyMode),
819
                                "ControlMode", StringValue (phyMode));
820
                                "ControlMode", StringValue (m_phyMode));
820
  // Set it to ad-hoc mode
821
  // Set it to ad-hoc mode
821
  wifiMac.SetType ("ns3::AdhocWifiMac");
822
  wifiMac.SetType ("ns3::AdhocWifiMac");
822
  NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, c);
823
  NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, c);
(-)a/src/internet/test/ipv4-address-generator-test-suite.cc (-3 / +5 lines)
 Lines 38-43    Link Here 
38
NetworkNumberAllocatorTestCase::DoTeardown (void)
38
NetworkNumberAllocatorTestCase::DoTeardown (void)
39
{
39
{
40
  Ipv4AddressGenerator::Reset ();
40
  Ipv4AddressGenerator::Reset ();
41
  TestCase::DoTeardown ();
41
}
42
}
42
void
43
void
43
NetworkNumberAllocatorTestCase::DoRun (void)
44
NetworkNumberAllocatorTestCase::DoRun (void)
 Lines 117-123    Link Here 
117
AddressAllocatorTestCase::DoTeardown (void)
118
AddressAllocatorTestCase::DoTeardown (void)
118
{
119
{
119
  Ipv4AddressGenerator::Reset ();
120
  Ipv4AddressGenerator::Reset ();
120
  Simulator::Destroy ();
121
  TestCase::DoTeardown ();
121
}
122
}
122
123
123
124
 Lines 138-144    Link Here 
138
NetworkAndAddressTestCase::DoTeardown (void)
139
NetworkAndAddressTestCase::DoTeardown (void)
139
{
140
{
140
  Ipv4AddressGenerator::Reset ();
141
  Ipv4AddressGenerator::Reset ();
141
  Simulator::Destroy ();
142
  TestCase::DoTeardown ();
142
}
143
}
143
144
144
void
145
void
 Lines 202-207    Link Here 
202
ExampleAddressGeneratorTestCase::DoTeardown (void)
203
ExampleAddressGeneratorTestCase::DoTeardown (void)
203
{
204
{
204
  Ipv4AddressGenerator::Reset ();
205
  Ipv4AddressGenerator::Reset ();
206
  TestCase::DoTeardown ();
205
}
207
}
206
208
207
void
209
void
 Lines 254-260    Link Here 
254
AddressCollisionTestCase::DoTeardown (void)
256
AddressCollisionTestCase::DoTeardown (void)
255
{
257
{
256
  Ipv4AddressGenerator::Reset ();
258
  Ipv4AddressGenerator::Reset ();
257
  Simulator::Destroy ();
259
  TestCase::DoTeardown ();
258
}
260
}
259
void
261
void
260
AddressCollisionTestCase::DoRun (void)
262
AddressCollisionTestCase::DoRun (void)
(-)a/src/internet/test/ipv4-address-helper-test-suite.cc (-3 / +3 lines)
 Lines 41-47    Link Here 
41
NetworkAllocatorHelperTestCase::DoTeardown (void)
41
NetworkAllocatorHelperTestCase::DoTeardown (void)
42
{
42
{
43
  Ipv4AddressGenerator::Reset ();
43
  Ipv4AddressGenerator::Reset ();
44
  Simulator::Destroy ();
44
  TestCase::DoTeardown ();
45
}
45
}
46
void
46
void
47
NetworkAllocatorHelperTestCase::DoRun (void)
47
NetworkAllocatorHelperTestCase::DoRun (void)
 Lines 87-93    Link Here 
87
AddressAllocatorHelperTestCase::DoTeardown (void)
87
AddressAllocatorHelperTestCase::DoTeardown (void)
88
{
88
{
89
  Ipv4AddressGenerator::Reset ();
89
  Ipv4AddressGenerator::Reset ();
90
  Simulator::Destroy ();
90
  TestCase::DoTeardown ();
91
}
91
}
92
92
93
void
93
void
 Lines 176-182    Link Here 
176
ResetAllocatorHelperTestCase::DoTeardown (void)
176
ResetAllocatorHelperTestCase::DoTeardown (void)
177
{
177
{
178
  Ipv4AddressGenerator::Reset ();
178
  Ipv4AddressGenerator::Reset ();
179
  Simulator::Destroy ();
179
  TestCase::DoTeardown ();
180
}
180
}
181
181
182
static class Ipv4AddressHelperTestSuite : public TestSuite
182
static class Ipv4AddressHelperTestSuite : public TestSuite
(-)a/src/internet/test/tcp-test.cc (-1 / +1 lines)
 Lines 160-166    Link Here 
160
  delete [] m_sourceTxPayload;
160
  delete [] m_sourceTxPayload;
161
  delete [] m_sourceRxPayload;
161
  delete [] m_sourceRxPayload;
162
  delete [] m_serverRxPayload;
162
  delete [] m_serverRxPayload;
163
  Simulator::Destroy ();
163
  TestCase::DoTeardown ();
164
}
164
}
165
165
166
void
166
void
(-)a/src/mobility/test/ns2-mobility-helper-test-suite.cc (-1 / +2 lines)
 Lines 204-209    Link Here 
204
  
204
  
205
  void DoSetup ()
205
  void DoSetup ()
206
  {
206
  {
207
    Simulator::Destroy();
207
    CreateNodes ();
208
    CreateNodes ();
208
  }
209
  }
209
  
210
  
 Lines 211-217    Link Here 
211
  {
212
  {
212
    Names::Clear ();
213
    Names::Clear ();
213
    std::remove (m_traceFile.c_str ());
214
    std::remove (m_traceFile.c_str ());
214
    Simulator::Destroy ();
215
    TestCase::DoTeardown ();
215
  }
216
  }
216
  
217
  
217
  /// Go
218
  /// Go
(-)a/src/mobility/test/steady-state-random-waypoint-mobility-model-test.cc (+1 lines)
 Lines 47-52    Link Here 
47
SteadyStateRandomWaypointTest::DoTeardown (void)
47
SteadyStateRandomWaypointTest::DoTeardown (void)
48
{
48
{
49
  mobilityStack.clear();
49
  mobilityStack.clear();
50
  TestCase::DoTeardown();
50
}
51
}
51
52
52
void
53
void
(-)a/src/mobility/test/waypoint-mobility-model-test.cc (+1 lines)
 Lines 57-62    Link Here 
57
{
57
{
58
  mobilityStack.clear();
58
  mobilityStack.clear();
59
  waypoints.clear();
59
  waypoints.clear();
60
  TestCase::DoTeardown();
60
}
61
}
61
62
62
void
63
void
(-)a/src/network/test/pcap-file-test-suite.cc (+6 lines)
 Lines 114-119    Link Here 
114
WriteModeCreateTestCase::DoTeardown (void)
114
WriteModeCreateTestCase::DoTeardown (void)
115
{
115
{
116
  remove (m_testFilename.c_str ());
116
  remove (m_testFilename.c_str ());
117
  TestCase::DoTeardown ();
117
}
118
}
118
119
119
void
120
void
 Lines 226-231    Link Here 
226
ReadModeCreateTestCase::DoTeardown (void)
227
ReadModeCreateTestCase::DoTeardown (void)
227
{
228
{
228
  remove (m_testFilename.c_str ());
229
  remove (m_testFilename.c_str ());
230
  TestCase::DoTeardown ();
229
}
231
}
230
232
231
void
233
void
 Lines 332-337    Link Here 
332
AppendModeCreateTestCase::DoTeardown (void)
334
AppendModeCreateTestCase::DoTeardown (void)
333
{
335
{
334
  remove (m_testFilename.c_str ());
336
  remove (m_testFilename.c_str ());
337
  TestCase::DoTeardown ();
335
}
338
}
336
339
337
void
340
void
 Lines 438-443    Link Here 
438
FileHeaderTestCase::DoTeardown (void)
441
FileHeaderTestCase::DoTeardown (void)
439
{
442
{
440
  remove (m_testFilename.c_str ());
443
  remove (m_testFilename.c_str ());
444
  TestCase::DoTeardown ();
441
}
445
}
442
446
443
void
447
void
 Lines 675-680    Link Here 
675
RecordHeaderTestCase::DoTeardown (void)
679
RecordHeaderTestCase::DoTeardown (void)
676
{
680
{
677
  remove (m_testFilename.c_str ());
681
  remove (m_testFilename.c_str ());
682
  TestCase::DoTeardown ();
678
}
683
}
679
684
680
void
685
void
 Lines 972-977    Link Here 
972
void
977
void
973
ReadFileTestCase::DoTeardown (void)
978
ReadFileTestCase::DoTeardown (void)
974
{
979
{
980
  TestCase::DoTeardown ();
975
}
981
}
976
982
977
const uint32_t N_KNOWN_PACKETS = 6;
983
const uint32_t N_KNOWN_PACKETS = 6;
(-)a/src/olsr/test/bug780-test.cc (-5 / +11 lines)
 Lines 75-80    Link Here 
75
}
75
}
76
76
77
void
77
void
78
Bug780Test::DoSetup ()
79
{
80
  TestCase::DoSetup ();
81
82
  //sending one packets per sec
83
  // Fix non-unicast data rate to be the same as that of unicast
84
  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold",
85
                      StringValue ("400"));
86
}
87
88
void
78
Bug780Test::DoRun ()
89
Bug780Test::DoRun ()
79
{
90
{
80
  SeedManager::SetSeed (123);
91
  SeedManager::SetSeed (123);
 Lines 97-107    Link Here 
97
  double SimTime = 200.0;
108
  double SimTime = 200.0;
98
  std::string phyMode ("DsssRate1Mbps");
109
  std::string phyMode ("DsssRate1Mbps");
99
110
100
  //sending one packets per sec
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;
111
  NodeContainer adhocNodes;
106
  adhocNodes.Create (nWifis);
112
  adhocNodes.Create (nWifis);
107
113
(-)a/src/olsr/test/bug780-test.h (+1 lines)
 Lines 43-48    Link Here 
43
  void CheckResults ();
43
  void CheckResults ();
44
  /// Go
44
  /// Go
45
  void DoRun ();
45
  void DoRun ();
46
  void DoSetup ();
46
};
47
};
47
48
48
}
49
}
(-)a/src/propagation/test/propagation-loss-model-test-suite.cc (-4 / +37 lines)
 Lines 42-47    Link Here 
42
42
43
private:
43
private:
44
  virtual void DoRun (void);
44
  virtual void DoRun (void);
45
  virtual void DoSetup (void);
45
46
46
  typedef struct {
47
  typedef struct {
47
    Vector m_position;
48
    Vector m_position;
 Lines 63-76    Link Here 
63
}
64
}
64
65
65
void
66
void
66
FriisPropagationLossModelTestCase::DoRun (void)
67
FriisPropagationLossModelTestCase::DoSetup (void)
67
{
68
{
69
  TestCase::DoSetup ();
70
68
  // The ns-3 testing manual gives more background on the values selected
71
  // The ns-3 testing manual gives more background on the values selected
69
  // for this test.  First, set a few defaults. 
72
  // for this test.  First, set a few defaults. 
70
73
71
  // wavelength at 2.4 GHz is 0.125m
74
  // wavelength at 2.4 GHz is 0.125m
72
  Config::SetDefault ("ns3::FriisPropagationLossModel::Lambda", DoubleValue (0.125));
75
  Config::SetDefault ("ns3::FriisPropagationLossModel::Lambda", DoubleValue (0.125));
73
  Config::SetDefault ("ns3::FriisPropagationLossModel::SystemLoss", DoubleValue (1.0));
76
  Config::SetDefault ("ns3::FriisPropagationLossModel::SystemLoss", DoubleValue (1.0));
77
}
78
79
void
80
FriisPropagationLossModelTestCase::DoRun (void)
81
{
82
  // The ns-3 testing manual gives more background on the values selected
83
  // for this test.
74
84
75
  // Select a reference transmit power
85
  // Select a reference transmit power
76
  // Pt = 10^(17.0206/10)/10^3 = .05035702 W
86
  // Pt = 10^(17.0206/10)/10^3 = .05035702 W
 Lines 139-144    Link Here 
139
149
140
private:
150
private:
141
  virtual void DoRun (void);
151
  virtual void DoRun (void);
152
  virtual void DoSetup (void);
142
153
143
  typedef struct
154
  typedef struct
144
  {
155
  {
 Lines 162-176    Link Here 
162
}
173
}
163
174
164
void
175
void
165
TwoRayGroundPropagationLossModelTestCase::DoRun (void)
176
TwoRayGroundPropagationLossModelTestCase::DoSetup (void)
166
{
177
{
178
  TestCase::DoSetup ();
179
167
  // wavelength at 2.4 GHz is 0.125m
180
  // wavelength at 2.4 GHz is 0.125m
168
  Config::SetDefault ("ns3::TwoRayGroundPropagationLossModel::Lambda", DoubleValue (0.125));
181
  Config::SetDefault ("ns3::TwoRayGroundPropagationLossModel::Lambda", DoubleValue (0.125));
169
  Config::SetDefault ("ns3::TwoRayGroundPropagationLossModel::SystemLoss", DoubleValue (1.0));
182
  Config::SetDefault ("ns3::TwoRayGroundPropagationLossModel::SystemLoss", DoubleValue (1.0));
170
183
171
  // set antenna height to 1.5m above z coordinate
184
  // set antenna height to 1.5m above z coordinate
172
  Config::SetDefault ("ns3::TwoRayGroundPropagationLossModel::HeightAboveZ", DoubleValue (1.5));
185
  Config::SetDefault ("ns3::TwoRayGroundPropagationLossModel::HeightAboveZ", DoubleValue (1.5));
186
}
173
187
188
void
189
TwoRayGroundPropagationLossModelTestCase::DoRun (void)
190
{
174
  // Select a reference transmit power of 17.0206 dBm
191
  // Select a reference transmit power of 17.0206 dBm
175
  // Pt = 10^(17.0206/10)/10^3 = .05035702 W
192
  // Pt = 10^(17.0206/10)/10^3 = .05035702 W
176
  double txPowerW = 0.05035702;
193
  double txPowerW = 0.05035702;
 Lines 267-272    Link Here 
267
284
268
private:
285
private:
269
  virtual void DoRun (void);
286
  virtual void DoRun (void);
287
  virtual void DoSetup (void);
270
288
271
  typedef struct {
289
  typedef struct {
272
    Vector m_position;
290
    Vector m_position;
 Lines 288-299    Link Here 
288
}
306
}
289
307
290
void
308
void
291
LogDistancePropagationLossModelTestCase::DoRun (void)
309
LogDistancePropagationLossModelTestCase::DoSetup (void)
292
{
310
{
311
  TestCase::DoSetup ();
312
293
  // reference loss at 2.4 GHz is 40.045997
313
  // reference loss at 2.4 GHz is 40.045997
294
  Config::SetDefault ("ns3::LogDistancePropagationLossModel::ReferenceLoss", DoubleValue (40.045997));
314
  Config::SetDefault ("ns3::LogDistancePropagationLossModel::ReferenceLoss", DoubleValue (40.045997));
295
  Config::SetDefault ("ns3::LogDistancePropagationLossModel::Exponent", DoubleValue (3));
315
  Config::SetDefault ("ns3::LogDistancePropagationLossModel::Exponent", DoubleValue (3));
316
}
296
317
318
void
319
LogDistancePropagationLossModelTestCase::DoRun (void)
320
{
297
  // Select a reference transmit power
321
  // Select a reference transmit power
298
  // Pt = 10^(17.0206/10)/10^3 = .05035702 W
322
  // Pt = 10^(17.0206/10)/10^3 = .05035702 W
299
  double txPowerW = 0.05035702;
323
  double txPowerW = 0.05035702;
 Lines 402-407    Link Here 
402
426
403
private:
427
private:
404
  virtual void DoRun (void);
428
  virtual void DoRun (void);
429
  virtual void DoSetup (void);
405
};
430
};
406
431
407
RangePropagationLossModelTestCase::RangePropagationLossModelTestCase ()
432
RangePropagationLossModelTestCase::RangePropagationLossModelTestCase ()
 Lines 414-422    Link Here 
414
}
439
}
415
440
416
void
441
void
442
RangePropagationLossModelTestCase::DoSetup (void)
443
{
444
  TestCase::DoSetup ();
445
  
446
  // Set testcase parameters
447
  Config::SetDefault ("ns3::RangePropagationLossModel::MaxRange", DoubleValue (127.2));
448
}
449
450
void
417
RangePropagationLossModelTestCase::DoRun (void)
451
RangePropagationLossModelTestCase::DoRun (void)
418
{
452
{
419
  Config::SetDefault ("ns3::RangePropagationLossModel::MaxRange", DoubleValue (127.2));
420
  Ptr<MobilityModel> a = CreateObject<ConstantPositionMobilityModel> (); 
453
  Ptr<MobilityModel> a = CreateObject<ConstantPositionMobilityModel> (); 
421
  a->SetPosition (Vector (0,0,0));
454
  a->SetPosition (Vector (0,0,0));
422
  Ptr<MobilityModel> b = CreateObject<ConstantPositionMobilityModel> (); 
455
  Ptr<MobilityModel> b = CreateObject<ConstantPositionMobilityModel> (); 
(-)a/src/test/csma-system-test-suite.cc (-6 / +15 lines)
 Lines 165-170    Link Here 
165
165
166
private:
166
private:
167
  virtual void DoRun (void);
167
  virtual void DoRun (void);
168
  virtual void DoSetup (void);
169
  
168
  void SinkRxNode1 (Ptr<const Packet> p, const Address &ad);
170
  void SinkRxNode1 (Ptr<const Packet> p, const Address &ad);
169
  void SinkRxNode2 (Ptr<const Packet> p, const Address &ad);
171
  void SinkRxNode2 (Ptr<const Packet> p, const Address &ad);
170
  void DropEvent (Ptr<const Packet> p);
172
  void DropEvent (Ptr<const Packet> p);
 Lines 201-206    Link Here 
201
  m_drops++;
203
  m_drops++;
202
}
204
}
203
205
206
207
void
208
CsmaBroadcastTestCase::DoSetup ()
209
{
210
  TestCase::DoSetup();
211
212
  //
213
  // Set up default values for the simulation.
214
  //
215
  // Select DIX/Ethernet II-style encapsulation (no LLC/Snap header)
216
  Config::SetDefault ("ns3::CsmaNetDevice::EncapsulationMode", StringValue ("Dix"));
217
}
218
204
//
219
//
205
// Example of the sending of a datagram to a broadcast address
220
// Example of the sending of a datagram to a broadcast address
206
//
221
//
 Lines 333-344    Link Here 
333
void
348
void
334
CsmaMulticastTestCase::DoRun (void)
349
CsmaMulticastTestCase::DoRun (void)
335
{
350
{
336
  //
337
  // Set up default values for the simulation.
338
  //
339
  // Select DIX/Ethernet II-style encapsulation (no LLC/Snap header)
340
  Config::SetDefault ("ns3::CsmaNetDevice::EncapsulationMode", StringValue ("Dix"));
341
342
  NodeContainer c;
351
  NodeContainer c;
343
  c.Create (5);
352
  c.Create (5);
344
  // We will later want two subcontainers of these nodes, for the two LANs
353
  // We will later want two subcontainers of these nodes, for the two LANs
(-)a/src/test/error-model-test-suite.cc (+3 lines)
 Lines 81-86    Link Here 
81
  // Set some arbitrary deterministic values
81
  // Set some arbitrary deterministic values
82
  SeedManager::SetSeed (7);
82
  SeedManager::SetSeed (7);
83
  SeedManager::SetRun (5);
83
  SeedManager::SetRun (5);
84
  
85
  m_count = 0;
86
  m_drops = 0;
84
87
85
  Ptr<Node> a = CreateObject<Node> ();
88
  Ptr<Node> a = CreateObject<Node> ();
86
  Ptr<Node> b = CreateObject<Node> ();
89
  Ptr<Node> b = CreateObject<Node> ();
(-)a/src/test/global-routing-test-suite.cc (-4 / +13 lines)
 Lines 55-61    Link Here 
55
private:
55
private:
56
  void SinkRx (std::string path, Ptr<const Packet> p, const Address &address);
56
  void SinkRx (std::string path, Ptr<const Packet> p, const Address &address);
57
  void HandleRead (Ptr<Socket>);
57
  void HandleRead (Ptr<Socket>);
58
  
58
  virtual void DoRun (void);
59
  virtual void DoRun (void);
60
  virtual void DoSetup (void);
61
  
59
  int m_count;
62
  int m_count;
60
  std::vector<uint8_t> m_firstInterface;
63
  std::vector<uint8_t> m_firstInterface;
61
  std::vector<uint8_t> m_secondInterface;
64
  std::vector<uint8_t> m_secondInterface;
 Lines 118-123    Link Here 
118
    }
121
    }
119
}
122
}
120
123
124
void
125
DynamicGlobalRoutingTestCase::DoSetup ()
126
{
127
  TestCase::DoSetup();
128
129
  // The below value configures the default behavior of global routing.
130
  // By default, it is disabled.  To respond to interface events, set to true
131
  Config::SetDefault ("ns3::Ipv4GlobalRouting::RespondToInterfaceEvents", BooleanValue (true));
132
}
133
121
// Test derived from examples/routing/dynamic-global-routing.cc
134
// Test derived from examples/routing/dynamic-global-routing.cc
122
//
135
//
123
// Network topology
136
// Network topology
 Lines 140-149    Link Here 
140
void
153
void
141
DynamicGlobalRoutingTestCase::DoRun (void)
154
DynamicGlobalRoutingTestCase::DoRun (void)
142
{
155
{
143
  // The below value configures the default behavior of global routing.
144
  // By default, it is disabled.  To respond to interface events, set to true
145
  Config::SetDefault ("ns3::Ipv4GlobalRouting::RespondToInterfaceEvents", BooleanValue (true));
146
147
  NodeContainer c;
156
  NodeContainer c;
148
  c.Create (7);
157
  c.Create (7);
149
  NodeContainer n0n2 = NodeContainer (c.Get (0), c.Get (2));
158
  NodeContainer n0n2 = NodeContainer (c.Get (0), c.Get (2));
(-)a/src/test/ns3tcp/ns3tcp-cwnd-test-suite.cc (-3 / +11 lines)
 Lines 384-389    Link Here 
384
384
385
private:
385
private:
386
  virtual void DoRun (void);
386
  virtual void DoRun (void);
387
  virtual void DoSetup (void);
388
  
387
  bool m_writeResults;
389
  bool m_writeResults;
388
390
389
  class CwndEvent {
391
  class CwndEvent {
 Lines 419-429    Link Here 
419
}
421
}
420
422
421
void
423
void
424
Ns3TcpCwndTestCase2::DoSetup (void)
425
{
426
  TestCase::DoSetup ();
427
  
428
  // Set up some default values for the simulation.
429
  Config::SetDefault ("ns3::DropTailQueue::MaxPackets", UintegerValue (4));
430
}
431
432
void
422
Ns3TcpCwndTestCase2::DoRun (void)
433
Ns3TcpCwndTestCase2::DoRun (void)
423
{
434
{
424
  // Set up some default values for the simulation.
425
  Config::SetDefault ("ns3::DropTailQueue::MaxPackets", UintegerValue (4));
426
427
  NodeContainer n0n1;
435
  NodeContainer n0n1;
428
  n0n1.Create (2);
436
  n0n1.Create (2);
429
437
(-)a/src/test/ns3tcp/ns3tcp-interop-test-suite.cc (+1 lines)
 Lines 128-133    Link Here 
128
Ns3TcpInteroperabilityTestCase::DoTeardown (void)
128
Ns3TcpInteroperabilityTestCase::DoTeardown (void)
129
{
129
{
130
  m_pcapFile.Close ();
130
  m_pcapFile.Close ();
131
  TestCase::DoTeardown ();
131
}
132
}
132
133
133
void
134
void
(-)a/src/test/ns3tcp/ns3tcp-loss-test-suite.cc (-37 / +68 lines)
 Lines 115-120    Link Here 
115
void
115
void
116
Ns3TcpLossTestCase::DoSetup (void)
116
Ns3TcpLossTestCase::DoSetup (void)
117
{
117
{
118
  Simulator::Destroy();
119
  
120
  // Enable packet metadata
121
  Packet::EnablePrinting ();  
122
118
  //
123
  //
119
  // We expect there to be a file called ns3tcp-state-response-vectors.pcap in
124
  // We expect there to be a file called ns3tcp-state-response-vectors.pcap in
120
  // response-vectors/ of this directory
125
  // response-vectors/ of this directory
 Lines 133-144    Link Here 
133
      m_pcapFile.Open (m_pcapFilename, std::ios::in|std::ios::binary);
138
      m_pcapFile.Open (m_pcapFilename, std::ios::in|std::ios::binary);
134
      NS_ABORT_MSG_UNLESS (m_pcapFile.GetDataLinkType () == PCAP_LINK_TYPE, "Wrong response vectors in directory");
139
      NS_ABORT_MSG_UNLESS (m_pcapFile.GetDataLinkType () == PCAP_LINK_TYPE, "Wrong response vectors in directory");
135
    }
140
    }
141
142
  // Config
143
  std::ostringstream tcpModel;
144
  tcpModel << "ns3::Tcp" << m_tcpModel;
145
  Config::SetDefault ("ns3::TcpL4Protocol::SocketType", StringValue (tcpModel.str ()));
146
  Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (1000));
147
  Config::SetDefault ("ns3::TcpSocket::DelAckCount", UintegerValue (1));
148
149
  // Logging
150
  if (m_writeLogging)
151
    {
152
      LogComponentEnableAll (LOG_PREFIX_FUNC);
153
      LogComponentEnable ("TcpLossResponse", LOG_LEVEL_ALL);
154
      LogComponentEnable ("ErrorModel", LOG_LEVEL_DEBUG);
155
      LogComponentEnable ("TcpLossResponse", LOG_LEVEL_ALL);
156
      LogComponentEnable ("TcpNewReno", LOG_LEVEL_INFO);
157
      LogComponentEnable ("TcpReno", LOG_LEVEL_INFO);
158
      LogComponentEnable ("TcpTahoe", LOG_LEVEL_INFO);
159
      LogComponentEnable ("TcpSocketBase", LOG_LEVEL_INFO);
160
    }
161
136
}
162
}
137
163
138
void
164
void
139
Ns3TcpLossTestCase::DoTeardown (void)
165
Ns3TcpLossTestCase::DoTeardown (void)
140
{
166
{
167
  // Restore Logging
168
  if (m_writeLogging)
169
    {
170
      LogComponentDisableAll (LOG_PREFIX_FUNC);
171
      LogComponentDisable ("TcpLossResponse", LOG_LEVEL_ALL);
172
      LogComponentDisable ("ErrorModel", LOG_LEVEL_DEBUG);
173
      LogComponentDisable ("TcpLossResponse", LOG_LEVEL_ALL);
174
      LogComponentDisable ("TcpNewReno", LOG_LEVEL_INFO);
175
      LogComponentDisable ("TcpReno", LOG_LEVEL_INFO);
176
      LogComponentDisable ("TcpTahoe", LOG_LEVEL_INFO);
177
      LogComponentDisable ("TcpSocketBase", LOG_LEVEL_INFO);
178
    }
179
141
  m_pcapFile.Close ();
180
  m_pcapFile.Close ();
181
  
182
  // Enable packet metadata
183
  Packet::DisablePrinting ();  
184
  
185
  TestCase::DoTeardown ();
142
}
186
}
143
187
144
void
188
void
 Lines 182-203    Link Here 
182
      // file and see if it still does the right thing.
226
      // file and see if it still does the right thing.
183
      //
227
      //
184
      uint8_t expected[PCAP_SNAPLEN];
228
      uint8_t expected[PCAP_SNAPLEN];
185
      uint32_t tsSec, tsUsec, inclLen, origLen, readLen;
229
      uint32_t tsSec=0, tsUsec=0, inclLen=0, origLen=0, readLen=0;
186
      m_pcapFile.Read (expected, sizeof(expected), tsSec, tsUsec, inclLen, origLen, readLen);
230
      m_pcapFile.Read (expected, sizeof(expected), tsSec, tsUsec, inclLen, origLen, readLen);
187
231
188
      uint8_t *actual = new uint8_t[readLen];
232
      if (readLen != 0 && origLen != 0) 
189
      p->CopyData (actual, readLen);
233
        {
234
          uint8_t *actual = new uint8_t[readLen];
235
          p->CopyData (actual, readLen);
190
236
191
      uint32_t result = memcmp (actual, expected, readLen);
237
          uint32_t result = memcmp (actual, expected, readLen);
192
238
193
      delete [] actual;
239
          delete [] actual;
194
240
195
      //
241
          //
196
      // Avoid streams of errors -- only report the first.
242
          // Avoid streams of errors -- only report the first.
197
      //
243
          //
198
      if (GetErrorStatus () == false)
244
          if (GetErrorStatus () == false)
245
            {
246
              NS_TEST_EXPECT_MSG_EQ (result, 0, "Expected data comparison error");
247
            }
248
        }
249
      else if (GetErrorStatus () == false)
199
        {
250
        {
200
          NS_TEST_EXPECT_MSG_EQ (result, 0, "Expected data comparison error");
251
          NS_TEST_EXPECT_MSG_GT (readLen, 0, "Unexpected packet error");
201
        }
252
        }
202
    }
253
    }
203
}
254
}
 Lines 282-306    Link Here 
282
  // Example corresponding to simulations in the paper "Simulation-based
333
  // Example corresponding to simulations in the paper "Simulation-based
283
  // Comparisons of Tahoe, Reno, and SACK TCP 
334
  // Comparisons of Tahoe, Reno, and SACK TCP 
284
335
285
  std::ostringstream tcpModel;
286
  tcpModel << "ns3::Tcp" << m_tcpModel;
287
  Config::SetDefault ("ns3::TcpL4Protocol::SocketType", 
288
                      StringValue (tcpModel.str ()));
289
  Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (1000));
290
  Config::SetDefault ("ns3::TcpSocket::DelAckCount", UintegerValue (1));
291
292
  if (m_writeLogging)
293
    {
294
      LogComponentEnableAll (LOG_PREFIX_FUNC);
295
      LogComponentEnable ("TcpLossResponse", LOG_LEVEL_ALL);
296
      LogComponentEnable ("ErrorModel", LOG_LEVEL_DEBUG);
297
      LogComponentEnable ("TcpLossResponse", LOG_LEVEL_ALL);
298
      LogComponentEnable ("TcpNewReno", LOG_LEVEL_INFO);
299
      LogComponentEnable ("TcpReno", LOG_LEVEL_INFO);
300
      LogComponentEnable ("TcpTahoe", LOG_LEVEL_INFO);
301
      LogComponentEnable ("TcpSocketBase", LOG_LEVEL_INFO);
302
    }
303
304
  ////////////////////////////////////////////////////////
336
  ////////////////////////////////////////////////////////
305
  // Topology construction
337
  // Topology construction
306
  //
338
  //
 Lines 359-371    Link Here 
359
                          ipInterfs.GetAddress (1), 
391
                          ipInterfs.GetAddress (1), 
360
                          servPort);
392
                          servPort);
361
393
362
  Config::Connect ("/NodeList/0/$ns3::Ipv4L3Protocol/Tx",
363
                   MakeCallback (&Ns3TcpLossTestCase::Ipv4L3Tx, this));
364
365
  Config::ConnectWithoutContext
366
    ("/NodeList/0/$ns3::TcpL4Protocol/SocketList/0/CongestionWindow",
367
    MakeCallback (&Ns3TcpLossTestCase::CwndTracer, this));
368
369
  ////////////////////////////////////////////////////////
394
  ////////////////////////////////////////////////////////
370
  // Set up loss model at node k1
395
  // Set up loss model at node k1
371
  //
396
  //
 Lines 403-408    Link Here 
403
  pem->SetList (sampleList);
428
  pem->SetList (sampleList);
404
  dev1.Get (1)->SetAttribute ("ReceiveErrorModel", PointerValue (pem));
429
  dev1.Get (1)->SetAttribute ("ReceiveErrorModel", PointerValue (pem));
405
430
431
  Config::Connect ("/NodeList/0/$ns3::Ipv4L3Protocol/Tx",
432
                   MakeCallback (&Ns3TcpLossTestCase::Ipv4L3Tx, this));
433
434
  Config::ConnectWithoutContext
435
    ("/NodeList/0/$ns3::TcpL4Protocol/SocketList/0/CongestionWindow",
436
    MakeCallback (&Ns3TcpLossTestCase::CwndTracer, this));
437
406
  // One can toggle the comment for the following line on or off to see the
438
  // One can toggle the comment for the following line on or off to see the
407
  // effects of finite send buffer modelling.  One can also change the size of
439
  // effects of finite send buffer modelling.  One can also change the size of
408
  // that buffer.
440
  // that buffer.
 Lines 442-448    Link Here 
442
Ns3TcpLossTestSuite::Ns3TcpLossTestSuite ()
474
Ns3TcpLossTestSuite::Ns3TcpLossTestSuite ()
443
  : TestSuite ("ns3-tcp-loss", SYSTEM)
475
  : TestSuite ("ns3-tcp-loss", SYSTEM)
444
{
476
{
445
  Packet::EnablePrinting ();  // Enable packet metadata for all test cases
446
  AddTestCase (new Ns3TcpLossTestCase ("Tahoe", 0));
477
  AddTestCase (new Ns3TcpLossTestCase ("Tahoe", 0));
447
  AddTestCase (new Ns3TcpLossTestCase ("Tahoe", 1));
478
  AddTestCase (new Ns3TcpLossTestCase ("Tahoe", 1));
448
  AddTestCase (new Ns3TcpLossTestCase ("Tahoe", 2));
479
  AddTestCase (new Ns3TcpLossTestCase ("Tahoe", 2));
(-)a/src/test/ns3tcp/ns3tcp-socket-test-suite.cc (-2 / +9 lines)
 Lines 158-163    Link Here 
158
158
159
private:
159
private:
160
  virtual void DoRun (void);
160
  virtual void DoRun (void);
161
  virtual void DoSetup (void);
162
161
  bool m_writeResults;
163
  bool m_writeResults;
162
164
163
  void SinkRx (std::string path, Ptr<const Packet> p, const Address &address);
165
  void SinkRx (std::string path, Ptr<const Packet> p, const Address &address);
 Lines 179-184    Link Here 
179
}
181
}
180
182
181
void
183
void
184
Ns3TcpSocketTestCase2::DoSetup (void)
185
{
186
  TestCase::DoSetup ();
187
  Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (1000));
188
}
189
190
void
182
Ns3TcpSocketTestCase2::DoRun (void)
191
Ns3TcpSocketTestCase2::DoRun (void)
183
{
192
{
184
  uint16_t sinkPort = 50000;
193
  uint16_t sinkPort = 50000;
 Lines 189-196    Link Here 
189
  Time writerStopTimeObj = Seconds (writerStopTime);
198
  Time writerStopTimeObj = Seconds (writerStopTime);
190
  Time simStopTimeObj= Seconds (simStopTime);
199
  Time simStopTimeObj= Seconds (simStopTime);
191
200
192
  Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (1000));
193
194
  NodeContainer nodes;
201
  NodeContainer nodes;
195
  nodes.Create (2);
202
  nodes.Create (2);
196
  Ptr<Node> n0 = nodes.Get (0);
203
  Ptr<Node> n0 = nodes.Get (0);
(-)a/src/test/ns3tcp/ns3tcp-state-test-suite.cc (-37 / +65 lines)
 Lines 110-115    Link Here 
110
void
110
void
111
Ns3TcpStateTestCase::DoSetup (void)
111
Ns3TcpStateTestCase::DoSetup (void)
112
{
112
{
113
  Simulator::Destroy();
114
115
  // Enable packet metadata
116
  Packet::EnablePrinting ();  
117
  
113
  //
118
  //
114
  // We expect there to be a file called ns3tcp-state-response-vectors.pcap in
119
  // We expect there to be a file called ns3tcp-state-response-vectors.pcap in
115
  // response-vectors/ of this directory
120
  // response-vectors/ of this directory
 Lines 128-139    Link Here 
128
      m_pcapFile.Open (m_pcapFilename, std::ios::in|std::ios::binary);
133
      m_pcapFile.Open (m_pcapFilename, std::ios::in|std::ios::binary);
129
      NS_ABORT_MSG_UNLESS (m_pcapFile.GetDataLinkType () == PCAP_LINK_TYPE, "Wrong response vectors in directory");
134
      NS_ABORT_MSG_UNLESS (m_pcapFile.GetDataLinkType () == PCAP_LINK_TYPE, "Wrong response vectors in directory");
130
    }
135
    }
136
  
137
  // Config
138
  std::string tcpModel ("ns3::TcpNewReno");
139
  Config::SetDefault ("ns3::TcpL4Protocol::SocketType", StringValue (tcpModel));
140
  Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (1000));
141
  Config::SetDefault ("ns3::TcpSocket::DelAckCount", UintegerValue (1));
142
  Config::SetDefault ("ns3::DropTailQueue::MaxPackets", UintegerValue (20));
143
144
  // Logging  
145
  if (m_writeLogging)
146
    {
147
      LogComponentEnableAll (LOG_PREFIX_FUNC);
148
      LogComponentEnable ("TcpTestCases", LOG_LEVEL_ALL);
149
      LogComponentEnable ("ErrorModel", LOG_LEVEL_DEBUG);
150
      LogComponentEnable ("TcpTestCases", LOG_LEVEL_ALL);
151
      LogComponentEnable ("TcpNewReno", LOG_LEVEL_INFO);
152
      LogComponentEnable ("TcpReno", LOG_LEVEL_INFO);
153
      LogComponentEnable ("TcpTahoe", LOG_LEVEL_INFO);
154
      LogComponentEnable ("TcpSocketBase", LOG_LEVEL_INFO);
155
    }
131
}
156
}
132
157
133
void
158
void
134
Ns3TcpStateTestCase::DoTeardown (void)
159
Ns3TcpStateTestCase::DoTeardown (void)
135
{
160
{
161
  // Restore Logging
162
  if (m_writeLogging)
163
    {
164
      LogComponentDisableAll (LOG_PREFIX_FUNC);
165
      LogComponentDisable ("TcpTestCases", LOG_LEVEL_ALL);
166
      LogComponentDisable ("ErrorModel", LOG_LEVEL_DEBUG);
167
      LogComponentDisable ("TcpTestCases", LOG_LEVEL_ALL);
168
      LogComponentDisable ("TcpNewReno", LOG_LEVEL_INFO);
169
      LogComponentDisable ("TcpReno", LOG_LEVEL_INFO);
170
      LogComponentDisable ("TcpTahoe", LOG_LEVEL_INFO);
171
      LogComponentDisable ("TcpSocketBase", LOG_LEVEL_INFO);
172
    }
173
  
136
  m_pcapFile.Close ();
174
  m_pcapFile.Close ();
175
176
  // Enable packet metadata
177
  Packet::DisablePrinting ();  
178
179
  TestCase::DoTeardown ();
137
}
180
}
138
181
139
void
182
void
 Lines 177-198    Link Here 
177
      // file and see if it still does the right thing.
220
      // file and see if it still does the right thing.
178
      //
221
      //
179
      uint8_t expected[PCAP_SNAPLEN];
222
      uint8_t expected[PCAP_SNAPLEN];
180
      uint32_t tsSec, tsUsec, inclLen, origLen, readLen;
223
      uint32_t tsSec=0, tsUsec=0, inclLen=0, origLen=0, readLen=0;
181
      m_pcapFile.Read (expected, sizeof(expected), tsSec, tsUsec, inclLen, origLen, readLen);
224
      m_pcapFile.Read (expected, sizeof(expected), tsSec, tsUsec, inclLen, origLen, readLen);
225
      
226
      if (readLen != 0 && origLen != 0) 
227
        {
228
          uint8_t *actual = new uint8_t[readLen];
229
          p->CopyData (actual, readLen);
182
230
183
      uint8_t *actual = new uint8_t[readLen];
231
          uint32_t result = memcmp (actual, expected, readLen);
184
      p->CopyData (actual, readLen);
185
232
186
      uint32_t result = memcmp (actual, expected, readLen);
233
          delete [] actual;
187
234
188
      delete [] actual;
235
          //
189
236
          // Avoid streams of errors -- only report the first.
190
      //
237
          //
191
      // Avoid streams of errors -- only report the first.
238
          if (GetErrorStatus () == false)
192
      //
239
            {
193
      if (GetErrorStatus () == false)
240
              NS_TEST_EXPECT_MSG_EQ (result, 0, "Expected data comparison error");
241
            }
242
        }
243
      else if (GetErrorStatus () == false)
194
        {
244
        {
195
          NS_TEST_EXPECT_MSG_EQ (result, 0, "Expected data comparison error");
245
          NS_TEST_EXPECT_MSG_GT (readLen, 0, "Unexpected packet error");
196
        }
246
        }
197
    }
247
    }
198
}
248
}
 Lines 266-294    Link Here 
266
  //           10Mb/s, 0.1ms      10Mb/s, 0.1ms
316
  //           10Mb/s, 0.1ms      10Mb/s, 0.1ms
267
  //       n0-----------------n1-----------------n2
317
  //       n0-----------------n1-----------------n2
268
318
269
  std::string tcpModel ("ns3::TcpNewReno");
270
271
  Config::SetDefault ("ns3::TcpL4Protocol::SocketType", StringValue (tcpModel));
272
  Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (1000));
273
  Config::SetDefault ("ns3::TcpSocket::DelAckCount", UintegerValue (1));
274
  Config::SetDefault ("ns3::DropTailQueue::MaxPackets", UintegerValue (20));
275
276
  if (m_writeLogging)
277
    {
278
      LogComponentEnableAll (LOG_PREFIX_FUNC);
279
      LogComponentEnable ("TcpTestCases", LOG_LEVEL_ALL);
280
      LogComponentEnable ("ErrorModel", LOG_LEVEL_DEBUG);
281
      LogComponentEnable ("TcpTestCases", LOG_LEVEL_ALL);
282
      LogComponentEnable ("TcpNewReno", LOG_LEVEL_INFO);
283
      LogComponentEnable ("TcpReno", LOG_LEVEL_INFO);
284
      LogComponentEnable ("TcpTahoe", LOG_LEVEL_INFO);
285
      LogComponentEnable ("TcpSocketBase", LOG_LEVEL_INFO);
286
    }
287
288
  ////////////////////////////////////////////////////////
319
  ////////////////////////////////////////////////////////
289
  // Topology construction
320
  // Topology construction
290
  //
321
  //
291
322
  
292
  // Create three nodes
323
  // Create three nodes
293
  NodeContainer n0n1;
324
  NodeContainer n0n1;
294
  n0n1.Create (2);
325
  n0n1.Create (2);
 Lines 338-346    Link Here 
338
  Simulator::ScheduleNow (&Ns3TcpStateTestCase::StartFlow, this, 
369
  Simulator::ScheduleNow (&Ns3TcpStateTestCase::StartFlow, this, 
339
                          localSocket, ipInterfs.GetAddress (1), servPort);
370
                          localSocket, ipInterfs.GetAddress (1), servPort);
340
371
341
  Config::Connect ("/NodeList/0/$ns3::Ipv4L3Protocol/Tx",
342
                   MakeCallback (&Ns3TcpStateTestCase::Ipv4L3Tx, this));
343
344
  ////////////////////////////////////////////////////////
372
  ////////////////////////////////////////////////////////
345
  // Set up different test cases: Lost model at node n1, different file size
373
  // Set up different test cases: Lost model at node n1, different file size
346
  //
374
  //
 Lines 411-416    Link Here 
411
  errN1->SetList (dropListN1);
439
  errN1->SetList (dropListN1);
412
  dev1.Get (0)->SetAttribute ("ReceiveErrorModel", PointerValue (errN1));
440
  dev1.Get (0)->SetAttribute ("ReceiveErrorModel", PointerValue (errN1));
413
441
442
  Config::Connect ("/NodeList/0/$ns3::Ipv4L3Protocol/Tx",
443
                   MakeCallback (&Ns3TcpStateTestCase::Ipv4L3Tx, this));
444
414
  std::ostringstream oss;
445
  std::ostringstream oss;
415
  oss << "tcp-state" << m_testCase << "-test-case";
446
  oss << "tcp-state" << m_testCase << "-test-case";
416
  if (m_writeResults)
447
  if (m_writeResults)
 Lines 434-441    Link Here 
434
  Simulator::Stop (Seconds (1000));
465
  Simulator::Stop (Seconds (1000));
435
  Simulator::Run ();
466
  Simulator::Run ();
436
  Simulator::Destroy ();
467
  Simulator::Destroy ();
437
438
439
}
468
}
440
469
441
class Ns3TcpStateTestSuite : public TestSuite
470
class Ns3TcpStateTestSuite : public TestSuite
 Lines 447-453    Link Here 
447
Ns3TcpStateTestSuite::Ns3TcpStateTestSuite ()
476
Ns3TcpStateTestSuite::Ns3TcpStateTestSuite ()
448
  : TestSuite ("ns3-tcp-state", SYSTEM)
477
  : TestSuite ("ns3-tcp-state", SYSTEM)
449
{
478
{
450
  Packet::EnablePrinting ();  // Enable packet metadata for all test cases
451
  AddTestCase (new Ns3TcpStateTestCase (0));
479
  AddTestCase (new Ns3TcpStateTestCase (0));
452
  AddTestCase (new Ns3TcpStateTestCase (1));
480
  AddTestCase (new Ns3TcpStateTestCase (1));
453
  AddTestCase (new Ns3TcpStateTestCase (2));
481
  AddTestCase (new Ns3TcpStateTestCase (2));
(-)a/src/test/ns3wifi/wifi-interference-test-suite.cc (-13 / +21 lines)
 Lines 57-62    Link Here 
57
57
58
private:
58
private:
59
  virtual void DoRun (void);
59
  virtual void DoRun (void);
60
  virtual void DoSetup (void);
61
  
60
  void ReceivePacket (Ptr<Socket> socket);
62
  void ReceivePacket (Ptr<Socket> socket);
61
  static void GenerateTraffic (Ptr<Socket> socket, uint32_t pktSize, uint32_t pktCount, Time pktInterval);
63
  static void GenerateTraffic (Ptr<Socket> socket, uint32_t pktSize, uint32_t pktCount, Time pktInterval);
62
  void PrintEndSync (std::string context, uint32_t dataRate, double snr, double per);
64
  void PrintEndSync (std::string context, uint32_t dataRate, double snr, double per);
 Lines 65-75    Link Here 
65
  double m_PER;
67
  double m_PER;
66
  double m_SNR;
68
  double m_SNR;
67
  uint32_t m_DataRate;
69
  uint32_t m_DataRate;
70
  
71
  std::string m_phyMode;
68
};
72
};
69
73
70
// Add some help text to this case to describe what it is intended to test
74
// Add some help text to this case to describe what it is intended to test
71
WifiInterferenceTestCase::WifiInterferenceTestCase  ()
75
WifiInterferenceTestCase::WifiInterferenceTestCase  ()
72
  : TestCase ("Test interference calculation when interfering frame exactly overlaps intended frame")
76
  : TestCase ("Test interference calculation when interfering frame exactly overlaps intended frame")
77
  , m_phyMode ("DsssRate1Mbps")
73
{
78
{
74
}
79
}
75
80
 Lines 77-82    Link Here 
77
{
82
{
78
}
83
}
79
84
85
void
86
WifiInterferenceTestCase::DoSetup ()
87
{
88
  TestCase::DoSetup ();
89
  
90
  // disable fragmentation for frames below 2200 bytes
91
  Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2200"));
92
  // turn off RTS/CTS for frames below 2200 bytes
93
  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("2200"));
94
  // Fix non-unicast data rate to be the same as that of unicast
95
  Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode", StringValue (m_phyMode));
96
}
97
80
void 
98
void 
81
WifiInterferenceTestCase::ReceivePacket (Ptr<Socket> socket)
99
WifiInterferenceTestCase::ReceivePacket (Ptr<Socket> socket)
82
{
100
{
 Lines 131-144    Link Here 
131
  // Convert to time object
149
  // Convert to time object
132
  Time interPacketInterval = Seconds (interval);
150
  Time interPacketInterval = Seconds (interval);
133
151
134
  // disable fragmentation for frames below 2200 bytes
135
  Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2200"));
136
  // turn off RTS/CTS for frames below 2200 bytes
137
  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("2200"));
138
  // Fix non-unicast data rate to be the same as that of unicast
139
  Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode", 
140
                      StringValue (phyMode));
141
142
  NodeContainer c;
152
  NodeContainer c;
143
  c.Create (3);
153
  c.Create (3);
144
154
 Lines 232-239    Link Here 
232
void
242
void
233
WifiInterferenceTestCase::DoRun (void)
243
WifiInterferenceTestCase::DoRun (void)
234
{
244
{
235
236
  std::string phyMode ("DsssRate1Mbps");
237
  double Prss = -90;  // -dBm
245
  double Prss = -90;  // -dBm
238
  double Irss = -90;  // -dBm
246
  double Irss = -90;  // -dBm
239
  double delta = 0;  // microseconds
247
  double delta = 0;  // microseconds
 Lines 246-262    Link Here 
246
  // Compute the packet error rate (PER) when delta=0 microseconds.  This
254
  // Compute the packet error rate (PER) when delta=0 microseconds.  This
247
  // means that the interferer arrives at exactly the same time as the
255
  // means that the interferer arrives at exactly the same time as the
248
  // intended packet
256
  // intended packet
249
  PER = WifiSimpleInterference (phyMode,Prss,Irss,delta,PpacketSize,IpacketSize,verbose,internet);
257
  PER = WifiSimpleInterference (m_phyMode,Prss,Irss,delta,PpacketSize,IpacketSize,verbose,internet);
250
258
251
  // Now rerun this test case and compute the PER when the delta time between
259
  // Now rerun this test case and compute the PER when the delta time between
252
  // arrival of the intended frame and interferer is 1 microsecond.
260
  // arrival of the intended frame and interferer is 1 microsecond.
253
  delta = 1;
261
  delta = 1;
254
  PER1 = WifiSimpleInterference (phyMode,Prss,Irss,delta,PpacketSize,IpacketSize,verbose,internet);
262
  PER1 = WifiSimpleInterference (m_phyMode,Prss,Irss,delta,PpacketSize,IpacketSize,verbose,internet);
255
263
256
  // Now rerun this test case and compute the PER when the delta time between
264
  // Now rerun this test case and compute the PER when the delta time between
257
  // arrival of the intended frame and interferer is 2 microseconds.
265
  // arrival of the intended frame and interferer is 2 microseconds.
258
  delta = 2;
266
  delta = 2;
259
  PER2 = WifiSimpleInterference (phyMode,Prss,Irss,delta,PpacketSize,IpacketSize,verbose,internet);
267
  PER2 = WifiSimpleInterference (m_phyMode,Prss,Irss,delta,PpacketSize,IpacketSize,verbose,internet);
260
268
261
  double PERDiff1 = PER - PER1;
269
  double PERDiff1 = PER - PER1;
262
270
(-)a/src/core/model/test.h (-1 / +1 lines)
 Lines 754-760    Link Here 
754
          actualStream << actual;                                                                          \
754
          actualStream << actual;                                                                          \
755
          std::ostringstream limitStream;                                                                  \
755
          std::ostringstream limitStream;                                                                  \
756
          limitStream << limit;                                                                            \
756
          limitStream << limit;                                                                            \
757
          ReporTesttFailure (std::string (# actual) + " (actual) > " + std::string (# limit) + " (limit)",   \
757
          ReportTestFailure (std::string (# actual) + " (actual) > " + std::string (# limit) + " (limit)",   \
758
                             actualStream.str (), limitStream.str (), msgStream.str (), file, line);           \
758
                             actualStream.str (), limitStream.str (), msgStream.str (), file, line);           \
759
        }                                                                                                  \
759
        }                                                                                                  \
760
    } while (false)
760
    } while (false)

Return to bug 1192