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/core/model/test.h (-1 / +1 lines)
 Lines 753-759    Link Here 
753
          actualStream << actual;                                                                          \
753
          actualStream << actual;                                                                          \
754
          std::ostringstream limitStream;                                                                  \
754
          std::ostringstream limitStream;                                                                  \
755
          limitStream << limit;                                                                            \
755
          limitStream << limit;                                                                            \
756
          ReporTesttFailure (std::string (# actual) + " (actual) > " + std::string (# limit) + " (limit)",   \
756
          ReportTestFailure (std::string (# actual) + " (actual) > " + std::string (# limit) + " (limit)",   \
757
                             actualStream.str (), limitStream.str (), msgStream.str (), file, line);           \
757
                             actualStream.str (), limitStream.str (), msgStream.str (), file, line);           \
758
        }                                                                                                  \
758
        }                                                                                                  \
759
    } while (false)
759
    } while (false)
(-)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 (-34 / +52 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-112    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;
109
  m_beta = 0.637;
119
  m_beta = 0.637;
120
  
121
  // create load profiles for variable load test
122
  CreateLoadProfiles ();
110
}
123
}
111
124
112
BatteryLifetimeTest::~BatteryLifetimeTest ()
125
BatteryLifetimeTest::~BatteryLifetimeTest ()
 Lines 638-647    Link Here 
638
}
651
}
639
652
640
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
641
BatteryLifetimeTest::DoRun (void)
682
BatteryLifetimeTest::DoRun (void)
642
{
683
{
643
  NS_LOG_DEBUG ("Constant load run.");
684
  NS_LOG_DEBUG ("Constant load run.");
644
685
686
  // set constant load test parameters
687
  m_alpha = 35220;
688
  m_beta = 0.637;
689
645
  // 640mA
690
  // 640mA
646
  NS_TEST_ASSERT_MSG_EQ (ConstantLoadTest (0.640, Seconds (2844.0)), false,  "Problems with constant load test (640mA).");
691
  NS_TEST_ASSERT_MSG_EQ (ConstantLoadTest (0.640, Seconds (2844.0)), false,  "Problems with constant load test (640mA).");
647
  // 320mA
692
  // 320mA
 Lines 653-661    Link Here 
653
  // 32mA
698
  // 32mA
654
  NS_TEST_ASSERT_MSG_EQ (ConstantLoadTest (0.032, Seconds (65580.0)), false,  "Problems with constant load test (32).");
699
  NS_TEST_ASSERT_MSG_EQ (ConstantLoadTest (0.032, Seconds (65580.0)), false,  "Problems with constant load test (32).");
655
700
656
  // create load profiles for variable load test
657
  CreateLoadProfiles ();
658
659
  // variable load with Itsy battery
701
  // variable load with Itsy battery
660
  NS_LOG_DEBUG ("\n\nItsy");
702
  NS_LOG_DEBUG ("\n\nItsy");
661
  m_alpha = 35220;
703
  m_alpha = 35220;
 Lines 696-713    Link Here 
696
  NodeContainer c;
738
  NodeContainer c;
697
  c.Create (1);
739
  c.Create (1);
698
740
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
741
  // install YansWifiPhy
712
  WifiHelper wifi;
742
  WifiHelper wifi;
713
  wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
743
  wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
 Lines 728-735    Link Here 
728
  // Add a non-QoS upper MAC, and disable rate control
758
  // Add a non-QoS upper MAC, and disable rate control
729
  NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
759
  NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
730
  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
760
  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
731
                                "DataMode", StringValue (phyMode),
761
                                "DataMode", StringValue (m_phyMode),
732
                                "ControlMode", StringValue (phyMode));
762
                                "ControlMode", StringValue (m_phyMode));
733
  // Set it to ad-hoc mode
763
  // Set it to ad-hoc mode
734
  wifiMac.SetType ("ns3::AdhocWifiMac");
764
  wifiMac.SetType ("ns3::AdhocWifiMac");
735
  NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, c);
765
  NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, c);
 Lines 759-765    Link Here 
759
789
760
  NS_LOG_DEBUG ("Expected lifetime = " << expLifetime.GetSeconds () << "s");
790
  NS_LOG_DEBUG ("Expected lifetime = " << expLifetime.GetSeconds () << "s");
761
  NS_LOG_DEBUG ("Actual lifetime = " << actualLifetime.GetSeconds () << "s");
791
  NS_LOG_DEBUG ("Actual lifetime = " << actualLifetime.GetSeconds () << "s");
762
792
  
763
  NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL (actualLifetime, expLifetime, "Incorrect lifetime!");
793
  NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL (actualLifetime, expLifetime, "Incorrect lifetime!");
764
  /*
794
  /*
765
  NS_TEST_ASSERT_MSG_EQ_TOL_RETURNS_BOOL (actualLifetime.GetSeconds () / 60,
795
  NS_TEST_ASSERT_MSG_EQ_TOL_RETURNS_BOOL (actualLifetime.GetSeconds () / 60,
 Lines 783-800    Link Here 
783
  NodeContainer c;
813
  NodeContainer c;
784
  c.Create (1);
814
  c.Create (1);
785
815
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
816
  // install YansWifiPhy
799
  WifiHelper wifi;
817
  WifiHelper wifi;
800
  wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
818
  wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
 Lines 815-822    Link Here 
815
  // Add a non-QoS upper MAC, and disable rate control
833
  // Add a non-QoS upper MAC, and disable rate control
816
  NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
834
  NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
817
  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
835
  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
818
                                "DataMode", StringValue (phyMode),
836
                                "DataMode", StringValue (m_phyMode),
819
                                "ControlMode", StringValue (phyMode));
837
                                "ControlMode", StringValue (m_phyMode));
820
  // Set it to ad-hoc mode
838
  // Set it to ad-hoc mode
821
  wifiMac.SetType ("ns3::AdhocWifiMac");
839
  wifiMac.SetType ("ns3::AdhocWifiMac");
822
  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/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/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

Return to bug 1192