Ipv4L3Protocol Trace not working

70 views
Skip to first unread message

Jack Higgins

unread,
Dec 30, 2015, 8:44:38 AM12/30/15
to ns-3-users


Dear all

I implemented a protocol in which the header  gets changed in RouteOuput, increasing the overHead  and therefore the packet size. For this reason I can not use FlowMonitor to check my packet  Rx/Tx count, throughput,etc (I tried it...)
According to some messages in the mailing list I found out that I can use  the Rx/Tx tracing source from Ipv4L3Protocol to check this.

(https://groups.google.com/forum/#!searchin/ns-3-users/Ipv4L3Protocol$20trace/ns-3-users/1aijcX51pOk/9xM_1mOjpxcJ)


I set the connection to the trace source in my simulation file  like this :


  Config::Connect ("/NodeList/*/$ns3::Ipv4L3Protocol/Rx",MakeCallback (&RxTrace));


and my function called like this:

void RxTrace (Ptr<const Packet> p, Ptr<Ipv4> ipv4 , uint32_t interface)
{

   
RxCount = RxCount+1;
    std
::cout<<"Inside RxTrace \n";


}

At the end of the simulation printing the RxCount. Although everything compiles and  packets are sent and received the results are still 0 , like something is wrong with my trace setting....

Any ideas... perhaps the Config::Connect is not placed in the correct place.... or something missing in my protocol ... (my protocol is a Ipv4L3Protocol)  as a reference I attached the simulation file.


Its my first time doing this kind of tracing.... (its my first time in everything in ns-3 lately....) , any ideas would be much appreciated.



maspExample.cc

Tommaso Pecorella

unread,
Dec 30, 2015, 1:38:37 PM12/30/15
to ns-3-users
Works for me.

Two things tho.
1) the function signature is wrong, it should be:
void RxTrace (std::string context, Ptr<const Packet> p, Ptr<Ipv4> ipv4 , uint32_t interface)
{
  std
::cout<< " Inside RxTrace in " << context << std::endl;
}
because it's a TracedCalback.

2) Mare sure to call the Connect AFTER the Internet stack initialization, ideally just before the Simulation::Run().

Cheers,

T.

Jack Higgins

unread,
Dec 30, 2015, 11:45:47 PM12/30/15
to ns-3-users

Thank you Tommaso , that function signature was breaking my head. Now it works!

Thanks for the help, and Happy new year 2016


Reply all
Reply to author
Forward
0 new messages