Bug 888 - Writing ascii trace to addtional tests fails
Writing ascii trace to addtional tests fails
Status: RESOLVED FIXED
Product: ns-3
Classification: Unclassified
Component: test framework
ns-3-dev
All All
: P5 normal
Assigned To: ns-bugs
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-04-20 15:14 UTC by Josh Pelkey
Modified: 2010-04-28 10:19 UTC (History)
2 users (show)

See Also:


Attachments
possible fix (6.45 KB, patch)
2010-04-20 15:14 UTC, Josh Pelkey
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Josh Pelkey 2010-04-20 15:14:10 UTC
Created attachment 839 [details]
possible fix

For example, in src/test/ns3tcp/ns3tcp-loss-test-suite.cc, setting m_writeResults to true for the second test case (and leaving the first test case's m_writeResults false) I get this error:

Error: attempting to enable the packet metadata subsystem too late in the simulation, which is not allowed.
A common cause for this problem is to enable ASCII tracing after sending any packets.  One way to fix this problem is to call ns3::PacketMetadata::Enable () near the beginning of the program, before any packets are sent.
Segmentation fault

I have resolved this by simply moving up the call to enable ascii to immediately after the point-to-point helper is created and used.  Patch attached.  Note: only the change in src/test/ns3tcp/ns3tcp-loss-test-suite.cc regarding the second test case is needed to fix the bug.  The others are done for consistency.
Comment 1 Tom Henderson 2010-04-21 00:32:55 UTC
(In reply to comment #0)
> Created an attachment (id=839) [details]
> possible fix
> 
> For example, in src/test/ns3tcp/ns3tcp-loss-test-suite.cc, setting
> m_writeResults to true for the second test case (and leaving the first test
> case's m_writeResults false) I get this error:
> 
> Error: attempting to enable the packet metadata subsystem too late in the
> simulation, which is not allowed.
> A common cause for this problem is to enable ASCII tracing after sending any
> packets.  One way to fix this problem is to call ns3::PacketMetadata::Enable ()
> near the beginning of the program, before any packets are sent.
> Segmentation fault
> 
> I have resolved this by simply moving up the call to enable ascii to
> immediately after the point-to-point helper is created and used.  Patch
> attached.  Note: only the change in src/test/ns3tcp/ns3tcp-loss-test-suite.cc
> regarding the second test case is needed to fix the bug.  The others are done
> for consistency.

Are there packets getting created before Simulator::Run () is called?  (I would like to know why your patch works)
Comment 2 Josh Pelkey 2010-04-23 13:50:53 UTC
(In reply to comment #1)
> Are there packets getting created before Simulator::Run () is called?  (I would
> like to know why your patch works)

It doesn't work :)  After looking at this more, simply moving the call EnableAsciiAll up stops the crash, but it doesn't actually write the file anymore.  I will have to look some more.
Comment 3 Josh Pelkey 2010-04-23 13:58:29 UTC
(In reply to comment #2)
> (In reply to comment #1)
> > Are there packets getting created before Simulator::Run () is called?  (I would
> > like to know why your patch works)
> 
> It doesn't work :)  After looking at this more, simply moving the call
> EnableAsciiAll up stops the crash, but it doesn't actually write the file
> anymore.  I will have to look some more.

Ok, I should have moved it to just after the p2p link was installed.  However, it still crashes.  I'm guessing it doesn't like the packets that are sent from the first test case?
Comment 4 Tom Henderson 2010-04-28 01:10:27 UTC
(In reply to comment #3)
> (In reply to comment #2)
> > (In reply to comment #1)
> > > Are there packets getting created before Simulator::Run () is called?  (I would
> > > like to know why your patch works)
> > 
> > It doesn't work :)  After looking at this more, simply moving the call
> > EnableAsciiAll up stops the crash, but it doesn't actually write the file
> > anymore.  I will have to look some more.
> 
> Ok, I should have moved it to just after the p2p link was installed.  However,
> it still crashes.  I'm guessing it doesn't like the packets that are sent from
> the first test case?

The problem is that test cases do not fully reset the simulator (no re-initialization of statics), and if test case 1 runs without metadata enabled, it is too late to enable it in later test cases.

The below (tested) patch should be safe to apply now, and close out this bug.

diff -r e2fe1c30eb3a src/test/ns3tcp/ns3tcp-loss-test-suite.cc
--- a/src/test/ns3tcp/ns3tcp-loss-test-suite.cc Sun Apr 25 11:37:50 2010 -0400
+++ b/src/test/ns3tcp/ns3tcp-loss-test-suite.cc Tue Apr 27 22:07:49 2010 -0700
@@ -274,6 +274,7 @@
 Ns3TcpLossTestSuite::Ns3TcpLossTestSuite ()
   : TestSuite ("ns3-tcp-loss", SYSTEM)
 {
+  Packet::EnablePrinting ();  // Enable packet metadata for all test cases
   AddTestCase (new Ns3TcpLossTestCase1);
   AddTestCase (new Ns3TcpLossTestCase2);
 }
Comment 5 Josh Pelkey 2010-04-28 10:19:45 UTC
changeset 006a660a021a