examples/tutorial/seventh.cc
changeset 11027 e943837b17ad
parent 10125 49db55240008
child 11432 d2656819dd54
equal deleted inserted replaced
11026:19b4146b1d39 11027:e943837b17ad
   208   stack.Install (nodes);
   208   stack.Install (nodes);
   209 
   209 
   210   uint16_t sinkPort = 8080;
   210   uint16_t sinkPort = 8080;
   211   Address sinkAddress;
   211   Address sinkAddress;
   212   Address anyAddress;
   212   Address anyAddress;
   213   std::string probeName;
   213   std::string probeType;
   214   std::string probeTrace;
   214   std::string tracePath;
   215   if (useV6 == false)
   215   if (useV6 == false)
   216     {
   216     {
   217       Ipv4AddressHelper address;
   217       Ipv4AddressHelper address;
   218       address.SetBase ("10.1.1.0", "255.255.255.0");
   218       address.SetBase ("10.1.1.0", "255.255.255.0");
   219       Ipv4InterfaceContainer interfaces = address.Assign (devices);
   219       Ipv4InterfaceContainer interfaces = address.Assign (devices);
   220       sinkAddress = InetSocketAddress (interfaces.GetAddress (1), sinkPort);
   220       sinkAddress = InetSocketAddress (interfaces.GetAddress (1), sinkPort);
   221       anyAddress = InetSocketAddress (Ipv4Address::GetAny (), sinkPort);
   221       anyAddress = InetSocketAddress (Ipv4Address::GetAny (), sinkPort);
   222       probeName = "ns3::Ipv4PacketProbe";
   222       probeType = "ns3::Ipv4PacketProbe";
   223       probeTrace = "/NodeList/*/$ns3::Ipv4L3Protocol/Tx";
   223       tracePath = "/NodeList/*/$ns3::Ipv4L3Protocol/Tx";
   224     }
   224     }
   225   else
   225   else
   226     {
   226     {
   227       Ipv6AddressHelper address;
   227       Ipv6AddressHelper address;
   228       address.SetBase ("2001:0000:f00d:cafe::", Ipv6Prefix (64));
   228       address.SetBase ("2001:0000:f00d:cafe::", Ipv6Prefix (64));
   229       Ipv6InterfaceContainer interfaces = address.Assign (devices);
   229       Ipv6InterfaceContainer interfaces = address.Assign (devices);
   230       sinkAddress = Inet6SocketAddress (interfaces.GetAddress (1,1), sinkPort);
   230       sinkAddress = Inet6SocketAddress (interfaces.GetAddress (1,1), sinkPort);
   231       anyAddress = Inet6SocketAddress (Ipv6Address::GetAny (), sinkPort);
   231       anyAddress = Inet6SocketAddress (Ipv6Address::GetAny (), sinkPort);
   232       probeName = "ns3::Ipv6PacketProbe";
   232       probeType = "ns3::Ipv6PacketProbe";
   233       probeTrace = "/NodeList/*/$ns3::Ipv6L3Protocol/Tx";
   233       tracePath = "/NodeList/*/$ns3::Ipv6L3Protocol/Tx";
   234     }
   234     }
   235 
   235 
   236   PacketSinkHelper packetSinkHelper ("ns3::TcpSocketFactory", anyAddress);
   236   PacketSinkHelper packetSinkHelper ("ns3::TcpSocketFactory", anyAddress);
   237   ApplicationContainer sinkApps = packetSinkHelper.Install (nodes.Get (1));
   237   ApplicationContainer sinkApps = packetSinkHelper.Install (nodes.Get (1));
   238   sinkApps.Start (Seconds (0.));
   238   sinkApps.Start (Seconds (0.));
   263   plotHelper.ConfigurePlot ("seventh-packet-byte-count",
   263   plotHelper.ConfigurePlot ("seventh-packet-byte-count",
   264                             "Packet Byte Count vs. Time",
   264                             "Packet Byte Count vs. Time",
   265                             "Time (Seconds)",
   265                             "Time (Seconds)",
   266                             "Packet Byte Count");
   266                             "Packet Byte Count");
   267 
   267 
   268   // Specify the probe type, probe path (in configuration namespace), and
   268   // Specify the probe type, trace source path (in configuration namespace), and
   269   // probe output trace source ("OutputBytes") to plot.  The fourth argument
   269   // probe output trace source ("OutputBytes") to plot.  The fourth argument
   270   // specifies the name of the data series label on the plot.  The last
   270   // specifies the name of the data series label on the plot.  The last
   271   // argument formats the plot by specifying where the key should be placed.
   271   // argument formats the plot by specifying where the key should be placed.
   272   plotHelper.PlotProbe (probeName,
   272   plotHelper.PlotProbe (probeType,
   273                         probeTrace,
   273                         tracePath,
   274                         "OutputBytes",
   274                         "OutputBytes",
   275                         "Packet Byte Count",
   275                         "Packet Byte Count",
   276                         GnuplotAggregator::KEY_BELOW);
   276                         GnuplotAggregator::KEY_BELOW);
   277 
   277 
   278   // Use FileHelper to write out the packet byte count over time
   278   // Use FileHelper to write out the packet byte count over time
   283                             FileAggregator::FORMATTED);
   283                             FileAggregator::FORMATTED);
   284 
   284 
   285   // Set the labels for this formatted output file.
   285   // Set the labels for this formatted output file.
   286   fileHelper.Set2dFormat ("Time (Seconds) = %.3e\tPacket Byte Count = %.0f");
   286   fileHelper.Set2dFormat ("Time (Seconds) = %.3e\tPacket Byte Count = %.0f");
   287 
   287 
   288   // Specify the probe type, probe path (in configuration namespace), and
   288   // Specify the probe type, trace source path (in configuration namespace), and
   289   // probe output trace source ("OutputBytes") to write.
   289   // probe output trace source ("OutputBytes") to write.
   290   fileHelper.WriteProbe (probeName,
   290   fileHelper.WriteProbe (probeType,
   291                          probeTrace,
   291                          tracePath,
   292                          "OutputBytes");
   292                          "OutputBytes");
   293 
   293 
   294   Simulator::Stop (Seconds (20));
   294   Simulator::Stop (Seconds (20));
   295   Simulator::Run ();
   295   Simulator::Run ();
   296   Simulator::Destroy ();
   296   Simulator::Destroy ();