Bug 305

Summary: Tracing asserts too easily now
Product: ns-3 Reporter: Gustavo J. A. M. Carneiro <gjcarneiro>
Component: coreAssignee: ns-bugs <ns-bugs>
Status: RESOLVED INVALID    
Severity: normal    
Priority: P3    
Version: pre-release   
Hardware: All   
OS: All   

Description Gustavo J. A. M. Carneiro 2008-09-03 10:22:50 UTC
With this simple tracing code: http://code.nsnam.org/gjc/ns-3-pyviz/rev/6eccb090137c

This happens:

Incompatible types. (feed to "c++filt -t") got=N3ns318MemPtrCallbackImplIPNS_5PyVizEMS1_FvSsNS_3PtrIKNS_6PacketEEENS_12Mac48AddressEEvSsS6_S7_NS_5emptyESA_SA_EE, expected=PN3ns312CallbackImplIvSsNS_3PtrIKNS_6PacketEEENS_5emptyES5_S5_S5_EE
Command ['/usr/bin/python', 'examples/mixed-wireless.py'] exited with code -11 

It turns out that CsmaNetDevice and WifiNetDevice have different Tx/Rx trace event signatures:

wifi:   TracedCallback<Ptr<const Packet>, Mac48Address> m_rxLogger;
csma:   TracedCallback<Ptr<const Packet> > m_rxTrace;

The code asserted when connecting on a csma netdevice, which has a different signature.

Why they have different signatures is another problem.  Right now I am concerned about why TraceConnect asserts.  Why does this common use case of catching every transmission have to be so damn hard in NS-3? :-(

Thoughts?
Comment 1 Mathieu Lacage 2008-09-03 11:18:28 UTC
There is no such thing as "connect to all tx events" and I said so many times. You have to be specific to request to which events you want to connect. I would suggest using the $ns3::CsmaNetDevice notation:

"/NodeList/*/DeviceList/*/$ns3::CsmaNetDevice/Tx"
"/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Tx"

If you want an API which hides this, you need to use the Helper API.
Comment 2 Gustavo J. A. M. Carneiro 2008-09-03 12:51:52 UTC
OK, cool trick, but not easy to come up with the idea :P
Maybe we need a FAQ, or code snippets repository :)
Comment 3 Mathieu Lacage 2008-09-03 12:57:02 UTC
(In reply to comment #2)
> OK, cool trick, but not easy to come up with the idea :P
> Maybe we need a FAQ, or code snippets repository :)

I am all for a FAQ and I will fill answers for questions added there.
Comment 4 Tom Henderson 2008-09-05 00:05:48 UTC
(In reply to comment #3)
> (In reply to comment #2)
> > OK, cool trick, but not easy to come up with the idea :P
> > Maybe we need a FAQ, or code snippets repository :)
> 
> I am all for a FAQ and I will fill answers for questions added there.
> 

There are several places for this type of information.

Joe started this page:
http://www.nsnam.org/wiki/index.php/Category:Samples

We also have a user FAQ:
http://www.nsnam.org/wiki/index.php/User_FAQ

Or the manual.