Adding trace sources

336 views
Skip to first unread message

C Facchini

unread,
Sep 28, 2009, 8:40:12 AM9/28/09
to ns-3-users
Dear list,

I've defined two new trace sources, belonging to the DcaTxop Object,
to trace contention window and datarate.
I've defined the two variables in the dca-txop.h file:
private:
TracedValue<uint32_t> m_cw;
TracedValue<uint32_t> m_dataRate;

Next step, I've modified dca-txop.cc the following way:
TypeId
DcaTxop::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::DcaTxop")
.SetParent<Object> ()
.AddConstructor<DcaTxop> ()
.AddTraceSource ("Cw",
"Contention window.",
MakeTraceSourceAccessor (&DcaTxop::m_cw))
.AddTraceSource ("Datarate",
"Transmission data rate.",
MakeTraceSourceAccessor (&DcaTxop::m_dataRate))
;
return tid;
}

Then, down the file, when there is a transmission (for instance in the
DcaTxop::NotifyAccessGranted function) I updated the variables:
m_cw = m_dcf->GetCw (); // this should trigger the callback...
NS_LOG_INFO(m_low->GetAddress () << " Cw updated (NoNeedFrag) " <<
m_cw);
Low ()->StartTransmission (m_currentPacket, &m_currentHdr,
params, m_transmissionListener);
if (m_currentHdr.IsData ())
{
WifiMacTrailer fcs;
uint32_t size = m_currentPacket->GetSize () + m_currentHdr.GetSize
() + fcs.GetSerializedSize ();
WifiRemoteStation *station = GetStation (m_currentHdr.GetAddr1
());
m_dataRate = station->GetDataMode (m_currentPacket,
size).GetDataRate (); // this should trigger the callback...
NS_LOG_INFO(m_low->GetAddress () << " DataRate updated
(NoNeedFrag) " << m_dataRate);
}

Finally I wrote a couple of simple callbacks, which however, never get
triggered.
I have to say that logging, by means of NS_LOG_INFO, works.
Did I go wrong in defining the trace sources?

Regards,
Christian

Mathieu Lacage

unread,
Sep 28, 2009, 9:01:53 AM9/28/09
to ns-3-...@googlegroups.com
On Mon, Sep 28, 2009 at 2:40 PM, C Facchini <c.fac...@gmail.com> wrote:
> Finally I wrote a couple of simple callbacks, which however, never get
> triggered.
> I have to say that logging, by means of NS_LOG_INFO, works.
> Did I go wrong in defining the trace sources?

How do you connect ?

Mathieu
--
Mathieu Lacage <mathieu...@gmail.com>

C Facchini

unread,
Sep 28, 2009, 9:04:58 AM9/28/09
to ns-3-users
On Sep 28, 10:01 am, Mathieu Lacage wrote:
>
> How do you connect ?
This way:
Config::ConnectWithoutContext ("/NodeList/0/DeviceList/0/DcaTxop/Cw",
MakeCallback (&CwTrace));

Christian

Mathieu Lacage

unread,
Sep 28, 2009, 9:42:07 AM9/28/09
to ns-3-...@googlegroups.com
On Mon, Sep 28, 2009 at 3:04 PM, C Facchini <c.fac...@gmail.com> wrote:
>> How do you connect ?
> This way:
> Config::ConnectWithoutContext ("/NodeList/0/DeviceList/0/DcaTxop/Cw",

Try this:
/NodeList/0/DeviceList/0/Mac/DcaTxop/Cw

(the above is for a Adhoc, Nqap or Nqsta mac)

C Facchini

unread,
Sep 28, 2009, 9:49:22 AM9/28/09
to ns-3-users
On Sep 28, 10:42 am, Mathieu Lacage wrote:
> Try this:
> /NodeList/0/DeviceList/0/Mac/DcaTxop/Cw
>
> (the above is for a Adhoc, Nqap or Nqsta mac)
The mac type is AdhocWifiMac, still the code doesn't produce any
output.

The callback is this one:
static void
CwTrace (uint32_t oldval, uint32_t newval)
{
std::cout << Simulator::Now ().GetSeconds () << ": old " << oldval
<< " new: " << newval << std::endl;
}

Christian

Mathieu Lacage

unread,
Sep 28, 2009, 10:23:52 AM9/28/09
to ns-3-...@googlegroups.com
On Mon, Sep 28, 2009 at 3:49 PM, C Facchini <c.fac...@gmail.com> wrote:

>> Try this:
>> /NodeList/0/DeviceList/0/Mac/DcaTxop/Cw
>>
>> (the above is for a Adhoc, Nqap or Nqsta mac)
> The mac type is AdhocWifiMac, still the code doesn't produce any
> output.

As far as I can tell, it should work, but It's hard to tell what's
wrong without the code.

C Facchini

unread,
Sep 28, 2009, 10:50:28 AM9/28/09
to ns-3-users
On Sep 28, 11:23 am, Mathieu Lacage wrote:
> >> /NodeList/0/DeviceList/0/Mac/DcaTxop/Cw
>
> As far as I can tell, it should work, but It's hard to tell what's
> wrong without the code.
Right, sorry for not posting it before.

The main file is here:
http://pastebin.com/m1adbd022

The modified dca-txop.[cc,h] are here:
http://pastebin.com/m20eeaa6d
http://pastebin.com/m7c9831ab

Christian

C Facchini

unread,
Sep 28, 2009, 11:33:19 AM9/28/09
to ns-3-users
> On Sep 28, 11:23 am, Mathieu Lacage wrote:
> >> /NodeList/0/DeviceList/0/Mac/DcaTxop/Cw
> > As far as I can tell, it should work, but It's hard to tell what's
> > wrong without the code.

Turns out I messed up with the simulation files.
The above path is definitely correct.

Sorry for the mess and thank you for helping me out.
Christian
Reply all
Reply to author
Forward
0 new messages