doc/tutorial/source/data-collection.rst
changeset 11027 e943837b17ad
parent 10186 cfbc9491d7e7
child 11028 abeb2185bce5
equal deleted inserted replaced
11026:19b4146b1d39 11027:e943837b17ad
   101 type the following command: ``diff -u sixth.cc seventh.cc``, and examine
   101 type the following command: ``diff -u sixth.cc seventh.cc``, and examine
   102 some of the new lines of this diff:
   102 some of the new lines of this diff:
   103 
   103 
   104 ::
   104 ::
   105 
   105 
   106   +  std::string probeName;
   106   +  std::string probeType;
   107   +  std::string probeTrace;
   107   +  std::string tracePath;
   108   +  if (useV6 == false)
   108   +  if (useV6 == false)
   109   +    {
   109   +    {
   110      ...
   110      ...
   111   +      probeName = "ns3::Ipv4PacketProbe";
   111   +      probeType = "ns3::Ipv4PacketProbe";
   112   +      probeTrace = "/NodeList/*/$ns3::Ipv4L3Protocol/Tx";
   112   +      tracePath = "/NodeList/*/$ns3::Ipv4L3Protocol/Tx";
   113   +    }
   113   +    }
   114   +  else
   114   +  else
   115   +    {
   115   +    {
   116      ...
   116      ...
   117   +      probeName = "ns3::Ipv6PacketProbe";
   117   +      probeType = "ns3::Ipv6PacketProbe";
   118   +      probeTrace = "/NodeList/*/$ns3::Ipv6L3Protocol/Tx";
   118   +      tracePath = "/NodeList/*/$ns3::Ipv6L3Protocol/Tx";
   119   +    }
   119   +    }
   120    ...
   120    ...
   121   +   // Use GnuplotHelper to plot the packet byte count over time
   121   +   // Use GnuplotHelper to plot the packet byte count over time
   122   +   GnuplotHelper plotHelper;
   122   +   GnuplotHelper plotHelper;
   123   + 
   123   + 
   127   +   plotHelper.ConfigurePlot ("seventh-packet-byte-count",
   127   +   plotHelper.ConfigurePlot ("seventh-packet-byte-count",
   128   +                             "Packet Byte Count vs. Time",
   128   +                             "Packet Byte Count vs. Time",
   129   +                             "Time (Seconds)",
   129   +                             "Time (Seconds)",
   130   +                             "Packet Byte Count");
   130   +                             "Packet Byte Count");
   131   + 
   131   + 
   132   +   // Specify the probe type, probe path (in configuration namespace), and
   132   +   // Specify the probe type, trace source path (in configuration namespace), and
   133   +   // probe output trace source ("OutputBytes") to plot.  The fourth argument
   133   +   // probe output trace source ("OutputBytes") to plot.  The fourth argument
   134   +   // specifies the name of the data series label on the plot.  The last
   134   +   // specifies the name of the data series label on the plot.  The last
   135   +   // argument formats the plot by specifying where the key should be placed.
   135   +   // argument formats the plot by specifying where the key should be placed.
   136   +   plotHelper.PlotProbe (probeName,
   136   +   plotHelper.PlotProbe (probeType,
   137   +                         probeTrace,
   137   +                         tracePath,
   138   +                         "OutputBytes",
   138   +                         "OutputBytes",
   139   +                         "Packet Byte Count",
   139   +                         "Packet Byte Count",
   140   +                         GnuplotAggregator::KEY_BELOW);
   140   +                         GnuplotAggregator::KEY_BELOW);
   141   + 
   141   + 
   142   +   // Use FileHelper to write out the packet byte count over time
   142   +   // Use FileHelper to write out the packet byte count over time
   149   +   // Set the labels for this formatted output file.
   149   +   // Set the labels for this formatted output file.
   150   +   fileHelper.Set2dFormat ("Time (Seconds) = %.3e\tPacket Byte Count = %.0f");
   150   +   fileHelper.Set2dFormat ("Time (Seconds) = %.3e\tPacket Byte Count = %.0f");
   151   + 
   151   + 
   152   +   // Specify the probe type, probe path (in configuration namespace), and
   152   +   // Specify the probe type, probe path (in configuration namespace), and
   153   +   // probe output trace source ("OutputBytes") to write.
   153   +   // probe output trace source ("OutputBytes") to write.
   154   +   fileHelper.WriteProbe (probeName,
   154   +   fileHelper.WriteProbe (probeType,
   155   +                          probeTrace,
   155   +                          tracePath,
   156   +                          "OutputBytes");
   156   +                          "OutputBytes");
   157   + 
   157   + 
   158       Simulator::Stop (Seconds (20));
   158       Simulator::Stop (Seconds (20));
   159       Simulator::Run ();
   159       Simulator::Run ();
   160       Simulator::Destroy ();
   160       Simulator::Destroy ();
   161   
   161   
   162 
   162 
   163 The careful reader will have noticed, when testing the IPv6 command
   163 The careful reader will have noticed, when testing the IPv6 command
   164 line attribute, that ``seventh.cc`` had created a number of new output files:
   164 line attribute above, that ``seventh.cc`` had created a number of new output files:
   165 
   165 
   166 ::
   166 ::
   167 
   167 
   168   seventh-packet-byte-count-0.txt
   168   seventh-packet-byte-count-0.txt
   169   seventh-packet-byte-count-1.txt
   169   seventh-packet-byte-count-1.txt
   255 source is hooked.  First, note above in the program we declared a few 
   255 source is hooked.  First, note above in the program we declared a few 
   256 variables for later use:
   256 variables for later use:
   257 
   257 
   258 ::
   258 ::
   259 
   259 
   260   +  std::string probeName;
   260   +  std::string probeType;
   261   +  std::string probeTrace;
   261   +  std::string tracePath;
   262   +  probeName = "ns3::Ipv6PacketProbe";
   262   +  probeType = "ns3::Ipv6PacketProbe";
   263   +  probeTrace = "/NodeList/*/$ns3::Ipv6L3Protocol/Tx";
   263   +  tracePath = "/NodeList/*/$ns3::Ipv6L3Protocol/Tx";
   264 
   264 
   265 We use them here:
   265 We use them here:
   266 
   266 
   267 ::
   267 ::
   268    
   268    
   269   +  // Specify the probe type, probe path (in configuration namespace), and
   269   +  // Specify the probe type, trace source path (in configuration namespace), and
   270   +  // probe output trace source ("OutputBytes") to plot.  The fourth argument
   270   +  // probe output trace source ("OutputBytes") to plot.  The fourth argument
   271   +  // specifies the name of the data series label on the plot.  The last
   271   +  // specifies the name of the data series label on the plot.  The last
   272   +  // argument formats the plot by specifying where the key should be placed.
   272   +  // argument formats the plot by specifying where the key should be placed.
   273   +  plotHelper.PlotProbe (probeName,
   273   +  plotHelper.PlotProbe (probeType,
   274   +                        probeTrace,
   274   +                        tracePath,
   275   +                        "OutputBytes",
   275   +                        "OutputBytes",
   276   +                        "Packet Byte Count",
   276   +                        "Packet Byte Count",
   277   +                        GnuplotAggregator::KEY_BELOW);
   277   +                        GnuplotAggregator::KEY_BELOW);
   278 
   278 
   279 The first two arguments are the name of the probe type and the probe trace.
   279 The first two arguments are the name of the probe type and the trace source path.
   280 These two are probably the hardest to determine when you try to use
   280 These two are probably the hardest to determine when you try to use
   281 this framework to plot other traces.  The probe trace here is the ``Tx``
   281 this framework to plot other traces.  The probe trace here is the ``Tx``
   282 trace source of class ``Ipv6L3Protocol``.  When we examine this class
   282 trace source of class ``Ipv6L3Protocol``.  When we examine this class
   283 implementation (``src/internet/model/ipv6-l3-protocol.cc``) we can
   283 implementation (``src/internet/model/ipv6-l3-protocol.cc``) we can
   284 observe:
   284 observe:
   415 
   415 
   416   + 
   416   + 
   417   +   // Set the labels for this formatted output file.
   417   +   // Set the labels for this formatted output file.
   418   +   fileHelper.Set2dFormat ("Time (Seconds) = %.3e\tPacket Byte Count = %.0f");
   418   +   fileHelper.Set2dFormat ("Time (Seconds) = %.3e\tPacket Byte Count = %.0f");
   419 
   419 
   420 Finally, the probe of interest must be hooked.  Again, the probeName and
   420 Finally, the trace source of interest must be hooked.  Again, the probeType and
   421 probeTrace variables in this example are used, and the probe's output
   421 tracePath variables in this example are used, and the probe's output
   422 trace source "OutputBytes" is hooked:
   422 trace source "OutputBytes" is hooked:
   423 
   423 
   424 ::
   424 ::
   425 
   425 
   426   + 
   426   + 
   427   +   // Specify the probe type, probe path (in configuration namespace), and
   427   +   // Specify the probe type, trace source path (in configuration namespace), and
   428   +   // probe output trace source ("OutputBytes") to write.
   428   +   // probe output trace source ("OutputBytes") to write.
   429   +   fileHelper.WriteProbe (probeName,
   429   +   fileHelper.WriteProbe (probeType,
   430   +                          probeTrace,
   430   +                          tracePath,
   431   +                          "OutputBytes");
   431   +                          "OutputBytes");
   432   + 
   432   + 
   433 
   433 
   434 The wildcard fields in this trace source specifier match two trace sources.
   434 The wildcard fields in this trace source specifier match two trace sources.
   435 Unlike the GnuplotHelper example, in which two data series were overlaid
   435 Unlike the GnuplotHelper example, in which two data series were overlaid