doc/tutorial/tracing.texi
changeset 5392 80b9ae7b5e26
parent 5391 569b7b51f650
child 5394 cb9619dd492e
equal deleted inserted replaced
5391:569b7b51f650 5392:80b9ae7b5e26
   681 You should recognize this as the trace source we used in the @code{third.cc}
   681 You should recognize this as the trace source we used in the @code{third.cc}
   682 example.  Perusing this list will be helpful.
   682 example.  Perusing this list will be helpful.
   683 
   683 
   684 @subsection What String do I use to Connect?
   684 @subsection What String do I use to Connect?
   685 
   685 
   686 The key to this question is found in the @code{ns-3} Doxygen as well.  It will
   686 The easiest way to do this is to grep around in the @ns-3 codebase for someone
   687 be simplest just to walk through the ``CourseChanged'' example.
   687 who has already figured it out,  You should always try to copy someone else's
       
   688 working code before you start to write your own.  Try something like:
       
   689 
       
   690 @verbatim
       
   691   find . -name '*.cc' | xargs grep CourseChange | grep Connect
       
   692 @end verbatim
       
   693 
       
   694 and you may find your answer along with working code.  For example, in this
       
   695 case, @code{./ns-3-dev/examples/wireless/mixed-wireless.cc} has something
       
   696 just waiting for you to use:
       
   697 
       
   698 @verbatim
       
   699   Config::Connect (``/NodeList/*/$ns3::MobilityModel/CourseChange'', 
       
   700     MakeCallback (&CourseChangeCallback));
       
   701 @end verbatim
       
   702 
       
   703 If you cannot find any examples in the distribution, you can find this out
       
   704 from the @code{ns-3} Doxygen.  It will probably be simplest just to walk 
       
   705 through the ``CourseChanged'' example.
   688 
   706 
   689 Let's assume that you have just found the ``CourseChanged'' trace source in 
   707 Let's assume that you have just found the ``CourseChanged'' trace source in 
   690 ``The list of all trace sources'' and you want to figure out how to connect to
   708 ``The list of all trace sources'' and you want to figure out how to connect to
   691 it.  You know that you are using (again, from the @code{third.cc} example) an
   709 it.  You know that you are using (again, from the @code{third.cc} example) an
   692 @code{ns3::RandomWalk2dMobilityModel}.  So open the ``Class List'' book in
   710 @code{ns3::RandomWalk2dMobilityModel}.  So open the ``Class List'' book in
   771   /NodeList/7/$ns3::MobilityModel
   789   /NodeList/7/$ns3::MobilityModel
   772 @end verbatim
   790 @end verbatim
   773 
   791 
   774 @subsection What Return Value and Formal Arguments?
   792 @subsection What Return Value and Formal Arguments?
   775 
   793 
   776 This is a bit more involved.  There are two ways you can figure this out.
   794 The easiest way to do this is to grep around in the @ns-3 codebase for someone
   777 
   795 who has already figured it out,  You should always try to copy someone else's
   778 
   796 working code.  Try something like:
   779 
   797 
   780 
   798 @verbatim
   781 
   799   find . -name '*.cc' | xargs grep CourseChange | grep Connect
   782 
   800 @end verbatim
       
   801 
       
   802 and you may find your answer along with working code.  For example, in this
       
   803 case, @code{./ns-3-dev/examples/wireless/mixed-wireless.cc} has something
       
   804 just waiting for you to use.  You will find
       
   805 
       
   806 @verbatim
       
   807   Config::Connect (``/NodeList/*/$ns3::MobilityModel/CourseChange'', 
       
   808     MakeCallback (&CourseChangeCallback));
       
   809 @end verbatim
       
   810 
       
   811 as a result of your grep.  The @code{MakeCallback} should indicate to you that
       
   812 there is a callback function there which you can use.  Sure enough, there is:
       
   813 
       
   814 @verbatim
       
   815   static void
       
   816   CourseChangeCallback (std::string path, Ptr<const MobilityModel> model)
       
   817   {
       
   818     ...
       
   819   }
       
   820 @end verbatim
       
   821 
       
   822 If there are no examples to work from, this can be a bit more challenging.
       
   823 
       
   824 
       
   825 
       
   826 
       
   827 
       
   828 
       
   829