doc/tutorial/tracing.texi
changeset 6189 450a3f4d9906
parent 6105 aa0d0770a4b2
child 6225 ada86e5d646c
equal deleted inserted replaced
6188:e1728a633e69 6189:450a3f4d9906
    32 strategies to work with in @code{ns-3}: using generic pre-defined bulk output 
    32 strategies to work with in @code{ns-3}: using generic pre-defined bulk output 
    33 mechanisms and parsing their content to extract interesting information; or 
    33 mechanisms and parsing their content to extract interesting information; or 
    34 somehow developing an output mechanism that conveys exactly (and perhaps only) 
    34 somehow developing an output mechanism that conveys exactly (and perhaps only) 
    35 the information wanted.
    35 the information wanted.
    36 
    36 
    37 Using pre-defined bulk output mechansims has the advantage of not requiring any
    37 Using pre-defined bulk output mechanisms has the advantage of not requiring any
    38 changes to @code{ns-3}, but it does require programming.  Often, pcap or NS_LOG
    38 changes to @code{ns-3}, but it does require programming.  Often, pcap or NS_LOG
    39 output messages are gathered during simulation runs and separately run through 
    39 output messages are gathered during simulation runs and separately run through 
    40 scripts that use grep, sed or awk to parse the messages and reduce and transform
    40 scripts that use grep, sed or awk to parse the messages and reduce and transform
    41 the data to a manageable form.  Programs must be written to do the 
    41 the data to a manageable form.  Programs must be written to do the 
    42 transformation, so this does not come for free.  Of course, if the information
    42 transformation, so this does not come for free.  Of course, if the information
   759 
   759 
   760 The difference is due to the fact that two @code{GetObject} calls are implied 
   760 The difference is due to the fact that two @code{GetObject} calls are implied 
   761 in the string found in the documentation.  The first, for @code{$ns3::MobilityModel}
   761 in the string found in the documentation.  The first, for @code{$ns3::MobilityModel}
   762 will query the aggregation for the base class.  The second implied 
   762 will query the aggregation for the base class.  The second implied 
   763 @code{GetObject} call, for @code{$ns3::RandomWalk2dMobilityModel}, is used to ``cast''
   763 @code{GetObject} call, for @code{$ns3::RandomWalk2dMobilityModel}, is used to ``cast''
   764 the base class to the concrete imlementation class.  The documentation shows 
   764 the base class to the concrete implementation class.  The documentation shows 
   765 both of these operations for you.  It turns out that the actual Attribute you are
   765 both of these operations for you.  It turns out that the actual Attribute you are
   766 going to be looking for is found in the base class as we have seen.
   766 going to be looking for is found in the base class as we have seen.
   767 
   767 
   768 Look further down in the @code{GetTypeId} doxygen.  You will find,
   768 Look further down in the @code{GetTypeId} doxygen.  You will find,
   769 
   769 
  1474   app->SetStopTime (stopTime);
  1474   app->SetStopTime (stopTime);
  1475 @end verbatim
  1475 @end verbatim
  1476 
  1476 
  1477 as a result of the @code{apps.Stop} call.
  1477 as a result of the @code{apps.Stop} call.
  1478 
  1478 
  1479 The ulitmate result of these calls is that we want to have the simulator 
  1479 The ultimate result of these calls is that we want to have the simulator 
  1480 automatically make calls into our @code{Applications} to tell them when to
  1480 automatically make calls into our @code{Applications} to tell them when to
  1481 start and stop.  In the case of @code{MyApp}, it inherits from class
  1481 start and stop.  In the case of @code{MyApp}, it inherits from class
  1482 @code{Application} and overrides @code{StartApplication}, and 
  1482 @code{Application} and overrides @code{StartApplication}, and 
  1483 @code{StopApplication}.  These are the functions that will be called by
  1483 @code{StopApplication}.  These are the functions that will be called by
  1484 the simulator at the appropriate time.  In the case of @code{MyApp} you
  1484 the simulator at the appropriate time.  In the case of @code{MyApp} you
  1530 
  1530 
  1531 Take a look at @code{src/core/object.cc} next and search for @code{Object::Start}.
  1531 Take a look at @code{src/core/object.cc} next and search for @code{Object::Start}.
  1532 This code is not as straightforward as you might have expected since 
  1532 This code is not as straightforward as you might have expected since 
  1533 @command{ns-3} @code{Objects} support aggregation.  The code in 
  1533 @command{ns-3} @code{Objects} support aggregation.  The code in 
  1534 @code{Object::Start} then loops through all of the objects that have been
  1534 @code{Object::Start} then loops through all of the objects that have been
  1535 aggretated together and calls their @code{DoStart} method.  This is another
  1535 aggregated together and calls their @code{DoStart} method.  This is another
  1536 idiom that is very common in @command{ns-3}.  There is a public API method,
  1536 idiom that is very common in @command{ns-3}.  There is a public API method,
  1537 that stays constant across implementations, that calls a private implementation
  1537 that stays constant across implementations, that calls a private implementation
  1538 method that is inherited and implemented by subclasses.  The names are typically
  1538 method that is inherited and implemented by subclasses.  The names are typically
  1539 something like @code{MethodName} for the public API and @code{DoMethodName} for
  1539 something like @code{MethodName} for the public API and @code{DoMethodName} for
  1540 the private API.
  1540 the private API.
  1728         m_sendEvent = Simulator::Schedule (tNext, &MyApp::SendPacket, this);
  1728         m_sendEvent = Simulator::Schedule (tNext, &MyApp::SendPacket, this);
  1729       }
  1729       }
  1730   }
  1730   }
  1731 @end verbatim
  1731 @end verbatim
  1732 
  1732 
  1733 Here, you see that @code{ScheduleTx} does exactly that.  If the @code{Applciation}
  1733 Here, you see that @code{ScheduleTx} does exactly that.  If the @code{Application}
  1734 is running (if @code{StopApplication} has not been called) it will schedule a 
  1734 is running (if @code{StopApplication} has not been called) it will schedule a 
  1735 new event, which calls @code{SendPacket} again.  The alert reader will spot
  1735 new event, which calls @code{SendPacket} again.  The alert reader will spot
  1736 something that also trips up new users.  The data rate of an @code{Application} is
  1736 something that also trips up new users.  The data rate of an @code{Application} is
  1737 just that.  It has nothing to do with the data rate of an underlying @code{Channel}.
  1737 just that.  It has nothing to do with the data rate of an underlying @code{Channel}.
  1738 This is the rate at which the @code{Application} produces bits.  It does not take
  1738 This is the rate at which the @code{Application} produces bits.  It does not take
  2295 Device helpers and protocol helpers.  Device helpers look at the problem
  2295 Device helpers and protocol helpers.  Device helpers look at the problem
  2296 of specifying which traces should be enabled through a node, device pair.  For 
  2296 of specifying which traces should be enabled through a node, device pair.  For 
  2297 example, you may want to specify that pcap tracing should be enabled on a 
  2297 example, you may want to specify that pcap tracing should be enabled on a 
  2298 particular device on a specific node.  This follows from the @code{ns-3} device
  2298 particular device on a specific node.  This follows from the @code{ns-3} device
  2299 conceptual model, and also the conceptual models of the various device helpers.
  2299 conceptual model, and also the conceptual models of the various device helpers.
  2300 Following naturallyu from this, the files created follow a 
  2300 Following naturally from this, the files created follow a 
  2301 <prefix>-<node>-<device> naming convention.  
  2301 <prefix>-<node>-<device> naming convention.  
  2302 
  2302 
  2303 Protocol helpers look at the problem of specifying which traces should be
  2303 Protocol helpers look at the problem of specifying which traces should be
  2304 enabled through a protocol and interface pair.  This follows from the @code{ns-3}
  2304 enabled through a protocol and interface pair.  This follows from the @code{ns-3}
  2305 protocol stack conceptual model, and also the conceptual models of internet
  2305 protocol stack conceptual model, and also the conceptual models of internet
  2478 
  2478 
  2479 Finally, two of the methods shown above,
  2479 Finally, two of the methods shown above,
  2480 
  2480 
  2481 @verbatim
  2481 @verbatim
  2482   void EnablePcap (std::string prefix, Ptr<NetDevice> nd, bool promiscuous = false, bool explicitFilename = false);
  2482   void EnablePcap (std::string prefix, Ptr<NetDevice> nd, bool promiscuous = false, bool explicitFilename = false);
  2483   void EnablePcap (std::string prefix, std::string ndName, bool promiscuous = false, bool explicitFilenaqme = false);
  2483   void EnablePcap (std::string prefix, std::string ndName, bool promiscuous = false, bool explicitFilename = false);
  2484 @end verbatim
  2484 @end verbatim
  2485 
  2485 
  2486 have a default parameter called @code{explicitFilename}.  When set to true,
  2486 have a default parameter called @code{explicitFilename}.  When set to true,
  2487 this parameter disables the automatic filename completion mechanism and allows
  2487 this parameter disables the automatic filename completion mechanism and allows
  2488 you to create an explicit filename.  This option is only available in the 
  2488 you to create an explicit filename.  This option is only available in the 
  2874 taken for devices in the @code{ns-3} system are of the form 
  2874 taken for devices in the @code{ns-3} system are of the form 
  2875 ``<prefix>-<node id>-<device id>.pcap''.  In the case of protocol traces,
  2875 ``<prefix>-<node id>-<device id>.pcap''.  In the case of protocol traces,
  2876 there is a one-to-one correspondence between protocols and @code{Nodes}.
  2876 there is a one-to-one correspondence between protocols and @code{Nodes}.
  2877 This is because protocol @code{Objects} are aggregated to @code{Node Objects}.
  2877 This is because protocol @code{Objects} are aggregated to @code{Node Objects}.
  2878 Since there is no global protocol id in the system, we use the corresponding
  2878 Since there is no global protocol id in the system, we use the corresponding
  2879 node id in file naming.  Threfore there is a possibility for file name 
  2879 node id in file naming.  Therefore there is a possibility for file name 
  2880 collisions in automatically chosen trace file names.  For this reason, the
  2880 collisions in automatically chosen trace file names.  For this reason, the
  2881 file name convention is changed for protocol traces.
  2881 file name convention is changed for protocol traces.
  2882 
  2882 
  2883 As previously mentioned, every node in the system will have a system-assigned
  2883 As previously mentioned, every node in the system will have a system-assigned
  2884 node id.  Since there is a one-to-one correspondence between protocol instances
  2884 node id.  Since there is a one-to-one correspondence between protocol instances
  3131 in the @code{ns-3} system are of the form ``<prefix>-<node id>-<device id>.tr''
  3131 in the @code{ns-3} system are of the form ``<prefix>-<node id>-<device id>.tr''
  3132 
  3132 
  3133 As previously mentioned, every node in the system will have a system-assigned
  3133 As previously mentioned, every node in the system will have a system-assigned
  3134 node id.  Since there is a one-to-one correspondence between protocols and nodes
  3134 node id.  Since there is a one-to-one correspondence between protocols and nodes
  3135 we use to node-id to identify the protocol identity.  Every interface on a 
  3135 we use to node-id to identify the protocol identity.  Every interface on a 
  3136 given rotocol will have an interface index (also called simply an interface) 
  3136 given protocol will have an interface index (also called simply an interface) 
  3137 relative to its protocol.  By default, then, an ascii trace file created as a result
  3137 relative to its protocol.  By default, then, an ascii trace file created as a result
  3138 of enabling tracing on the first device of node 21, using the prefix ``prefix'',
  3138 of enabling tracing on the first device of node 21, using the prefix ``prefix'',
  3139 would be ``prefix-n21-i1.tr''.  Use the prefix to disambiguate multiple protocols
  3139 would be ``prefix-n21-i1.tr''.  Use the prefix to disambiguate multiple protocols
  3140 per node.
  3140 per node.
  3141 
  3141 
  3162 There are high-level helper functions that allow users to simply control the 
  3162 There are high-level helper functions that allow users to simply control the 
  3163 collection of pre-defined outputs to a fine granularity.  There are mid-level
  3163 collection of pre-defined outputs to a fine granularity.  There are mid-level
  3164 helper functions to allow more sophisticated users to customize how information
  3164 helper functions to allow more sophisticated users to customize how information
  3165 is extracted and saved; and there are low-level core functions to allow expert
  3165 is extracted and saved; and there are low-level core functions to allow expert
  3166 users to alter the system to present new and previously unexported information
  3166 users to alter the system to present new and previously unexported information
  3167 in a way that will be immediatly accessible to users at higher levels.
  3167 in a way that will be immediately accessible to users at higher levels.
  3168 
  3168 
  3169 This is a very comprehensive system, and we realize that it is a lot to 
  3169 This is a very comprehensive system, and we realize that it is a lot to 
  3170 digest, especially for new users or those not intimately familiar with C++
  3170 digest, especially for new users or those not intimately familiar with C++
  3171 and its idioms.  We do consider the tracing system a very important part of
  3171 and its idioms.  We do consider the tracing system a very important part of
  3172 @code{ns-3} and so recommend becoming as familiar as possible with it.  It is
  3172 @code{ns-3} and so recommend becoming as familiar as possible with it.  It is