How to connect to a trace source of extended model

75 views
Skip to first unread message

Ubaid ur Rahman

unread,
Jan 25, 2017, 3:38:59 AM1/25/17
to ns-3-users
Hello,

I have extended the Node class added a trace source, if I want to connect my sink to the source via path how would I do that, from my understanding NodeList has pointers to Node class.

Konstantinos

unread,
Jan 25, 2017, 4:44:07 AM1/25/17
to ns-3-users
Hi Ubaid,

Please refer to the documentation on how to access a trace source, either directly from the object or using Config::Connect

I would like to comment though on the desing and the introduction of a trace source on the Node class. I believe that this is a wrong choice (given the limited information you provided). 
The Node class serves only as a 'box' that you add components (NetDevices) and protocols. There isn't much you could trace. 

Regards,
K

Ubaid ur Rahman

unread,
Jan 25, 2017, 4:50:51 AM1/25/17
to ns-3-users
Hello,

I have extended the Node model, so I can make it a computational Node. Now I have traces to indicate their utilization. For that I need to connect to those traces, Now I can connect to them via object but those objects are in an extremely complex architecture, and I want to access my data collector classes outside that.

Konstantinos

unread,
Jan 25, 2017, 4:57:48 AM1/25/17
to ns-3-users
As I said, the Node class is more like a black-box that you add functionality.
One of that functionality could be some class to do computations. Therefore, I would suggest to add the trace source in that class, not the Node.

If you still keep the trace source in the Node class, the trace path that can be used in Config or data collector, should be "NodeList/*/<trace_source>".

Regards
K

Ubaid ur Rahman

unread,
Jan 25, 2017, 5:08:56 AM1/25/17
to ns-3-...@googlegroups.com
By extending i mean I have created a child class, inheritance, I want to access that child class <trace_source> will the above work?

--
Posting to this group should follow these guidelines https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
---
You received this message because you are subscribed to a topic in the Google Groups "ns-3-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ns-3-users/X5jhye1jEYE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ns-3-users+unsubscribe@googlegroups.com.
To post to this group, send email to ns-3-...@googlegroups.com.
Visit this group at https://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/d/optout.



--
Regards,

Ubaid ur Rahman
Untitled Diagram.png

Ubaid ur Rahman

unread,
Jan 25, 2017, 6:32:38 AM1/25/17
to ns-3-users
Nope! Not working... please consider my earlier response, I have extending it through inheritance. now want to connect to child Node which is ComputationalNode

Konstantinos

unread,
Jan 25, 2017, 6:34:51 AM1/25/17
to ns-3-users

Ubaid ur Rahman

unread,
Jan 25, 2017, 12:17:55 PM1/25/17
to ns-3-...@googlegroups.com
No luck :(

--
Posting to this group should follow these guidelines https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
---
You received this message because you are subscribed to a topic in the Google Groups "ns-3-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ns-3-users/X5jhye1jEYE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ns-3-users+unsubscribe@googlegroups.com.
To post to this group, send email to ns-3-...@googlegroups.com.
Visit this group at https://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/d/optout.

Ubaid ur Rahman

unread,
Jan 25, 2017, 2:08:08 PM1/25/17
to ns-3-users
Solved with the separate "class" approach. Thanks :)

Ubaid ur Rahman

unread,
Jan 26, 2017, 12:05:29 PM1/26/17
to ns-3-...@googlegroups.com
Hello,

Can you please tell me what am I doing wrong, files are attached? I am struggling with tracing, is there a documentation which shows how we can specify the type of callback required like ns3::Packet::TracedCallback

--
Posting to this group should follow these guidelines https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
---
You received this message because you are subscribed to a topic in the Google Groups "ns-3-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ns-3-users/X5jhye1jEYE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ns-3-users+unsubscribe@googlegroups.com.
To post to this group, send email to ns-3-...@googlegroups.com.
Visit this group at https://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/d/optout.
tracingTest.zip

Konstantinos

unread,
Jan 26, 2017, 12:16:34 PM1/26/17
to ns-3-users
Hi,

You have defined your trace source as a TracedValue<uint64_t>.
There are numerous instances throughout ns-3 of definition of a TracedValue. 
Simply 'grep' for TracedValue in src folder an you can find them.

This should be the required type for your case
 "ns3::TracedValueCallback::Uint64"

Regards,
K

Ubaid ur Rahman

unread,
Jan 26, 2017, 12:19:58 PM1/26/17
to ns-3-...@googlegroups.com
Hello,

I tired this earlier, but the call back function does not execute.

Konstantinos

unread,
Jan 26, 2017, 1:19:55 PM1/26/17
to ns-3-users
Hi,

Solved this issue. 

Two major problems with your code:
1) The tracing has to be placed AFTER the node is created and it will trace after the simulation starts. Hence, your change of the value at t=[-0] will not be traced. Simply schedule the change in the future, after the simulation starts.

2) To be able to use the path (which is correct the way you wrote it), the object (NodeUtilization) has to be created and aggregated to the node. So in your Compute-Node constructor add something like this:
m_utilization = CreateObject<NodeUtilization>();
this->AggregateObject(m_utilization);

You will also need to modify the m_utilization from NodeUtilization to Ptr<NodeUtilization> (in the header file) and modify how you call the methods on the m_utilization (from . to -> )

Ubaid ur Rahman

unread,
Jan 26, 2017, 1:30:36 PM1/26/17
to ns-3-...@googlegroups.com
Hello,

Thank you for your time, worked :)
Reply all
Reply to author
Forward
0 new messages