Bugzilla – Bug 888
Writing ascii trace to addtional tests fails
Last modified: 2010-04-28 10:19:45 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.
(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)
(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.
(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?
(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); }
changeset 006a660a021a