NS-3 Trace Files Creation

225 views
Skip to first unread message

mshuk...@gmail.com

unread,
Aug 11, 2018, 12:47:27 PM8/11/18
to ns-3-users
Dear all

I have gone through the NS-3 tutorial. I am new to this nightmare software.

I have a question. I want to generate the default trace files in simulations. Like ns-2 by default generates .tr file, I have found that ns-3 does not generate .tr files.
Ns-3 tutorial does talk about tracing and logging but I am not able to get anything from it. It says there are two methods to generate tracing in ns-3 - one by default everything and the other selection what parameters are to be collected in tracing. I want to generate all the parameters in tracefile and will use python to extract whatever is required (easier method).

How can one generate by default all the tracefile?

Thanks.

Erdem Tuna

unread,
Aug 21, 2018, 11:39:30 AM8/21/18
to ns-3-users
Hello,

Could you please give an example of a specific trace file you want to generate?



11 Ağustos 2018 Cumartesi 19:47:27 UTC+3 tarihinde mshuk...@gmail.com yazdı:

Mukul Shukla

unread,
Aug 24, 2018, 4:18:55 PM8/24/18
to ns-3-...@googlegroups.com
Thanks for the reply Erden. I can understand, its a too trivial question for others to answer me.

I am learning to simulate the Mobile AdHoc Network Routing Protocols (eg. AODV). I have some background of ns-2 in doing so. When I use to simulate the protocol it use to generate the .tr file which I then use to parse it to extract meaningful information. I want to do the same now using ns3. There is a mention of generating the trace file in the tutorial but hard for me to understand.
I want to generated the file with all the possible information (as was in ns2) and I will then parse it for extracting meaningful information (like Packet Delivery Ratio). The tutorial mentions that there is a better way of doing so which means I can extract the only information which I require. But I am OK with getting all the information and will slowly use this feature later.
The question is how can I generate all the information to a trace file? Is there an explanation of the trace file format of ns-3 (NS-2 is having wonderful explanation on the wireless trace files)?.

I hope am clear now.




--
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 the Google Groups "ns-3-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-users+...@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.

Erdem Tuna

unread,
Aug 25, 2018, 3:24:05 PM8/25/18
to ns-3-users
Hello Mukul,

I see your point, generally, I follow the following procedure ( I hope it will be correct to generate a trace of a custom variable):
  • To  print the custom traces, first the related variable must be found in respective “.cc” class file.

  • Once the variable is found, find the method that the variable is in.

  • Go to the “.h” file of the same class.

  • If the method is private and constant, declare the following variables in the private section of the header file.

    • mutable std::ofstream m_mmWaveOutFile;

    • mutable std::string m_mmWaveOutputFilename;

  • Then in the “.cc” file find the ClassName::ClassName() method. Enter the following line inside the method.

    • m_mmWaveOutputFilename = "example.txt";

  • Find the ClassName::~ClassName() method and enter the folowing lines inside the method.

    • if(m_mmWaveOutFile.is_open())

  {

        m_mmWaveOutFile.close();

     }

  • Then find again the related method in “.cc” file and type

    • if (!m_mmWaveOutFile.is_open ())

          {

                      m_mmWaveOutFile.open(m_mmWaveOutputFilename.c_str());

          }

  • Lastly,  below the above codes type,

m_mmWaveOutFile << respectiveVariable << std::endl;



24 Ağustos 2018 Cuma 23:18:55 UTC+3 tarihinde Mukul Shukla yazdı:
Reply all
Reply to author
Forward
0 new messages