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

(-)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/config.cc (+5 lines)
 Lines 603-608    Link Here 
603
{
603
{
604
  return GlobalValue::BindFailSafe (name, value);
604
  return GlobalValue::BindFailSafe (name, value);
605
}
605
}
606
void Reset ()
607
{
608
  AttributeList::GetGlobal ()->Reset ();
609
  GlobalValue::ResetAll ();
610
}
606
void ConnectWithoutContext (std::string path, const CallbackBase &cb)
611
void ConnectWithoutContext (std::string path, const CallbackBase &cb)
607
{
612
{
608
  Singleton<ConfigImpl>::Get ()->ConnectWithoutContext (path, cb);
613
  Singleton<ConfigImpl>::Get ()->ConnectWithoutContext (path, cb);
(-)a/src/core/model/config.h (+5 lines)
 Lines 110-115    Link Here 
110
 * This function undoes the work of Config::ConnectWithContext.
110
 * This function undoes the work of Config::ConnectWithContext.
111
 */
111
 */
112
void Disconnect (std::string path, const CallbackBase &cb);
112
void Disconnect (std::string path, const CallbackBase &cb);
113
/**
114
 * This method resets the effect of all SetDefault, SetDefaultFailSafe,
115
 * SetGlobal, and SetGlobalFailSafe calls.
116
 */
117
void Reset ();
113
118
114
/**
119
/**
115
 * \brief hold a set of objects which match a specific search string.
120
 * \brief hold a set of objects which match a specific search string.
(-)a/src/core/model/global-value.cc (-4 / +18 lines)
 Lines 49-54    Link Here 
49
void
49
void
50
GlobalValue::InitializeFromEnv (void)
50
GlobalValue::InitializeFromEnv (void)
51
{
51
{
52
  m_value = m_initialValue->Copy ();
52
#ifdef HAVE_GETENV
53
#ifdef HAVE_GETENV
53
  char *envVar = getenv ("NS_GLOBAL_VALUE");
54
  char *envVar = getenv ("NS_GLOBAL_VALUE");
54
  if (envVar == 0)
55
  if (envVar == 0)
 Lines 88-96    Link Here 
88
  return m_help;
89
  return m_help;
89
}
90
}
90
void
91
void
92
GlobalValue::ResetValue (void)
93
{
94
  InitializeFromEnv ();
95
}
96
void
97
GlobalValue::ResetAll (void)
98
{
99
  for (Iterator i = Begin (); i != End (); i++)
100
    {
101
      (*i)->ResetValue ();
102
    }
103
}
104
void
91
GlobalValue::GetValue (AttributeValue &value) const
105
GlobalValue::GetValue (AttributeValue &value) const
92
{
106
{
93
  bool ok = m_checker->Copy (*m_initialValue, value);
107
  bool ok = m_checker->Copy (*m_value, value);
94
  if (ok)
108
  if (ok)
95
    {
109
    {
96
      return;
110
      return;
 Lines 100-106    Link Here 
100
    {
114
    {
101
      NS_FATAL_ERROR ("GlobalValue name="<<m_name<<": input value is not a string");
115
      NS_FATAL_ERROR ("GlobalValue name="<<m_name<<": input value is not a string");
102
    }
116
    }
103
  str->Set (m_initialValue->SerializeToString (m_checker));
117
  str->Set (m_value->SerializeToString (m_checker));
104
}
118
}
105
Ptr<const AttributeChecker> 
119
Ptr<const AttributeChecker> 
106
GlobalValue::GetChecker (void) const
120
GlobalValue::GetChecker (void) const
 Lines 113-119    Link Here 
113
{
127
{
114
  if (m_checker->Check (value))
128
  if (m_checker->Check (value))
115
    {
129
    {
116
      m_initialValue = value.Copy ();
130
      m_value = value.Copy ();
117
      return true;
131
      return true;
118
    }
132
    }
119
  // attempt to convert to string.
133
  // attempt to convert to string.
 Lines 134-140    Link Here 
134
    {
148
    {
135
      return false;
149
      return false;
136
    }
150
    }
137
  m_checker->Copy (*v, *PeekPointer (m_initialValue));
151
  m_checker->Copy (*v, *PeekPointer (m_value));
138
  return true;
152
  return true;
139
}
153
}
140
154
(-)a/src/core/model/global-value.h (+10 lines)
 Lines 84-89    Link Here 
84
   * \param value the new value to set in this GlobalValue.
84
   * \param value the new value to set in this GlobalValue.
85
   */
85
   */
86
  bool SetValue (const AttributeValue &value);
86
  bool SetValue (const AttributeValue &value);
87
  /**
88
   * Reset the global value to its default/initial value.
89
   */
90
  void ResetValue ();
87
91
88
  /**
92
  /**
89
   * \param name the name of the global value
93
   * \param name the name of the global value
 Lines 136-141    Link Here 
136
   * 
140
   * 
137
   */
141
   */
138
  static void GetValueByName (std::string name, AttributeValue &value);
142
  static void GetValueByName (std::string name, AttributeValue &value);
143
  
144
  /**
145
   * Resets all GlobalValue s to their defaults.
146
   */
147
  static void ResetAll ();
139
148
140
149
141
private:
150
private:
 Lines 145-150    Link Here 
145
  void InitializeFromEnv (void);
154
  void InitializeFromEnv (void);
146
  std::string m_name;
155
  std::string m_name;
147
  std::string m_help;
156
  std::string m_help;
157
  Ptr<AttributeValue> m_value;
148
  Ptr<AttributeValue> m_initialValue;
158
  Ptr<AttributeValue> m_initialValue;
149
  Ptr<const AttributeChecker> m_checker;
159
  Ptr<const AttributeChecker> m_checker;
150
};
160
};
(-)a/src/core/model/random-variable.cc (+5 lines)
 Lines 64-69    Link Here 
64
void SeedManager::SetSeed (uint32_t seed)
64
void SeedManager::SetSeed (uint32_t seed)
65
{
65
{
66
  Config::SetGlobal ("RngSeed", IntegerValue (seed));
66
  Config::SetGlobal ("RngSeed", IntegerValue (seed));
67
  
68
  // A call to SeedManager::SetSeed is an explicit request for a reproducible
69
  // state. RngStream does not re-initialize itself after setting the global
70
  // value above, unless we explicitly call SetPackageSeed.
71
  RngStream::SetPackageSeed(seed);
67
}
72
}
68
73
69
void SeedManager::SetRun (uint32_t run)
74
void SeedManager::SetRun (uint32_t run)
(-)a/src/core/model/rng-stream.cc (-3 / +7 lines)
 Lines 305-311    Link Here 
305
RngStream::EnsureGlobalInitialized (void)
305
RngStream::EnsureGlobalInitialized (void)
306
{
306
{
307
  static bool initialized = false;
307
  static bool initialized = false;
308
  static uint32_t run = 0;
308
  uint32_t run = 0;
309
  
310
  IntegerValue value;
311
  g_rngRun.GetValue (value);
312
  run = value.Get ();
313
  
309
  if (!initialized)
314
  if (!initialized)
310
    {
315
    {
311
      initialized = true;
316
      initialized = true;
 Lines 313-322    Link Here 
313
      IntegerValue value;
318
      IntegerValue value;
314
      g_rngSeed.GetValue (value);
319
      g_rngSeed.GetValue (value);
315
      seed = value.Get ();
320
      seed = value.Get ();
316
      g_rngRun.GetValue (value);
317
      run = value.Get ();
318
      SetPackageSeed (seed);
321
      SetPackageSeed (seed);
319
    }
322
    }
323
    
320
  return run;
324
  return run;
321
}
325
}
322
326
(-)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 (-1 / +11 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 753-759    Link Here 
753
          actualStream << actual;                                                                          \
754
          actualStream << actual;                                                                          \
754
          std::ostringstream limitStream;                                                                  \
755
          std::ostringstream limitStream;                                                                  \
755
          limitStream << limit;                                                                            \
756
          limitStream << limit;                                                                            \
756
          ReporTesttFailure (std::string (# actual) + " (actual) > " + std::string (# limit) + " (limit)",   \
757
          ReportTestFailure (std::string (# actual) + " (actual) > " + std::string (# limit) + " (limit)",   \
757
                             actualStream.str (), limitStream.str (), msgStream.str (), file, line);           \
758
                             actualStream.str (), limitStream.str (), msgStream.str (), file, line);           \
758
        }                                                                                                  \
759
        }                                                                                                  \
759
    } while (false)
760
    } while (false)
 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/model/packet-metadata.cc (+20 lines)
 Lines 67-72    Link Here 
67
  m_enableChecking = true;
67
  m_enableChecking = true;
68
}
68
}
69
69
70
void 
71
PacketMetadata::Disable (void)
72
{
73
  NS_ASSERT_MSG (!m_metadataSkipped,
74
                 "Error: attempting to enable the packet metadata "
75
                 "subsystem too late in the simulation, which is not allowed.\n"
76
                 "A common cause for this problem is to enable ASCII tracing "
77
                 "after sending any packets.  One way to fix this problem is "
78
                 "to call ns3::PacketMetadata::Enable () near the beginning of"
79
                 " the program, before any packets are sent.");
80
  m_enable = false;
81
}
82
83
void 
84
PacketMetadata::DisableChecking (void)
85
{
86
  Disable ();
87
  m_enableChecking = false;
88
}
89
70
void
90
void
71
PacketMetadata::ReserveCopy (uint32_t size)
91
PacketMetadata::ReserveCopy (uint32_t size)
72
{
92
{
(-)a/src/network/model/packet-metadata.h (+3 lines)
 Lines 127-132    Link Here 
127
  static void Enable (void);
127
  static void Enable (void);
128
  static void EnableChecking (void);
128
  static void EnableChecking (void);
129
129
130
  static void Disable (void);
131
  static void DisableChecking (void);
132
130
  inline PacketMetadata (uint64_t uid, uint32_t size);
133
  inline PacketMetadata (uint64_t uid, uint32_t size);
131
  inline PacketMetadata (PacketMetadata const &o);
134
  inline PacketMetadata (PacketMetadata const &o);
132
  inline PacketMetadata &operator = (PacketMetadata const& o);
135
  inline PacketMetadata &operator = (PacketMetadata const& o);
(-)a/src/network/model/packet.cc (+14 lines)
 Lines 560-565    Link Here 
560
  PacketMetadata::EnableChecking ();
560
  PacketMetadata::EnableChecking ();
561
}
561
}
562
562
563
void
564
Packet::DisablePrinting (void)
565
{
566
  NS_LOG_FUNCTION_NOARGS ();
567
  PacketMetadata::Disable ();
568
}
569
570
void
571
Packet::DisableChecking (void)
572
{
573
  NS_LOG_FUNCTION_NOARGS ();
574
  PacketMetadata::DisableChecking ();
575
}
576
563
uint32_t Packet::GetSerializedSize (void) const
577
uint32_t Packet::GetSerializedSize (void) const
564
{
578
{
565
  uint32_t size = 0;
579
  uint32_t size = 0;
(-)a/src/network/model/packet.h (+8 lines)
 Lines 429-434    Link Here 
429
   * errors will be detected and will abort the program.
429
   * errors will be detected and will abort the program.
430
   */
430
   */
431
  static void EnableChecking (void);
431
  static void EnableChecking (void);
432
  /**
433
   * \sa EnablePrinting
434
   */
435
  static void DisablePrinting (void);
436
  /**
437
   * \sa EnableChecking
438
   */
439
  static void DisableChecking (void);
432
440
433
  /**
441
  /**
434
   * For packet serializtion, the total size is checked 
442
   * For packet serializtion, the total size is checked 
(-)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/network/utils/mac48-address.cc (-1 / +15 lines)
 Lines 20-29    Link Here 
20
#include "mac48-address.h"
20
#include "mac48-address.h"
21
#include "ns3/address.h"
21
#include "ns3/address.h"
22
#include "ns3/assert.h"
22
#include "ns3/assert.h"
23
#include "ns3/uinteger.h"
24
#include "ns3/global-value.h"
23
#include <iomanip>
25
#include <iomanip>
24
#include <iostream>
26
#include <iostream>
25
#include <string.h>
27
#include <string.h>
26
28
29
static ns3::GlobalValue g_Mac48Origin ("Mac48Origin", 
30
                                   "The initial value the Mac48Address::Allocate helper will use.",
31
                                   ns3::UintegerValue (0),
32
                                   ns3::MakeUintegerChecker<uint64_t> ());
33
27
namespace ns3 {
34
namespace ns3 {
28
35
29
ATTRIBUTE_HELPER_CPP (Mac48Address);
36
ATTRIBUTE_HELPER_CPP (Mac48Address);
 Lines 118-124    Link Here 
118
Mac48Address 
125
Mac48Address 
119
Mac48Address::Allocate (void)
126
Mac48Address::Allocate (void)
120
{
127
{
121
  static uint64_t id = 0;
128
  UintegerValue value;
129
  g_Mac48Origin.GetValue (value);
130
  uint64_t id = value.Get();
131
  
122
  id++;
132
  id++;
123
  Mac48Address address;
133
  Mac48Address address;
124
  address.m_address[0] = (id >> 40) & 0xff;
134
  address.m_address[0] = (id >> 40) & 0xff;
 Lines 127-132    Link Here 
127
  address.m_address[3] = (id >> 16) & 0xff;
137
  address.m_address[3] = (id >> 16) & 0xff;
128
  address.m_address[4] = (id >> 8) & 0xff;
138
  address.m_address[4] = (id >> 8) & 0xff;
129
  address.m_address[5] = (id >> 0) & 0xff;
139
  address.m_address[5] = (id >> 0) & 0xff;
140
  
141
  value.Set(id);
142
  g_Mac48Origin.SetValue (value);
143
  
130
  return address;
144
  return address;
131
}
145
}
132
uint8_t 
146
uint8_t 
(-)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

Return to bug 1192