doc: remove space before paren in code samples
This commit is contained in:
committed by
Peter Barnes
parent
820c029e8b
commit
700543b01a
@@ -76,7 +76,7 @@ This is all just as it was in ``first.cc``, so there is nothing new yet.
|
||||
|
||||
using namespace ns3;
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("SecondScriptExample");
|
||||
NS_LOG_COMPONENT_DEFINE("SecondScriptExample");
|
||||
|
||||
The main program begins with a slightly different twist. We use a verbose
|
||||
flag to determine whether or not the ``UdpEchoClientApplication`` and
|
||||
@@ -99,10 +99,10 @@ entirely comfortable with the following code at this point in the tutorial.
|
||||
uint32_t nCsma = 3;
|
||||
|
||||
CommandLine cmd;
|
||||
cmd.AddValue ("nCsma", "Number of \"extra\" CSMA nodes/devices", nCsma);
|
||||
cmd.AddValue ("verbose", "Tell echo applications to log if true", verbose);
|
||||
cmd.AddValue("nCsma", "Number of \"extra\" CSMA nodes/devices", nCsma);
|
||||
cmd.AddValue("verbose", "Tell echo applications to log if true", verbose);
|
||||
|
||||
cmd.Parse (argc, argv);
|
||||
cmd.Parse(argc, argv);
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
@@ -119,7 +119,7 @@ done in ``first.cc``.
|
||||
::
|
||||
|
||||
NodeContainer p2pNodes;
|
||||
p2pNodes.Create (2);
|
||||
p2pNodes.Create(2);
|
||||
|
||||
Next, we declare another ``NodeContainer`` to hold the nodes that will be
|
||||
part of the bus (CSMA) network. First, we just instantiate the container
|
||||
@@ -128,8 +128,8 @@ object itself.
|
||||
::
|
||||
|
||||
NodeContainer csmaNodes;
|
||||
csmaNodes.Add (p2pNodes.Get (1));
|
||||
csmaNodes.Create (nCsma);
|
||||
csmaNodes.Add(p2pNodes.Get(1));
|
||||
csmaNodes.Create(nCsma);
|
||||
|
||||
The next line of code ``Gets`` the first node (as in having an index of one)
|
||||
from the point-to-point node container and adds it to the container of nodes
|
||||
@@ -148,11 +148,11 @@ the helper and a two millisecond delay on channels created by the helper.
|
||||
::
|
||||
|
||||
PointToPointHelper pointToPoint;
|
||||
pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
|
||||
pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));
|
||||
pointToPoint.SetDeviceAttribute("DataRate", StringValue("5Mbps"));
|
||||
pointToPoint.SetChannelAttribute("Delay", StringValue("2ms"));
|
||||
|
||||
NetDeviceContainer p2pDevices;
|
||||
p2pDevices = pointToPoint.Install (p2pNodes);
|
||||
p2pDevices = pointToPoint.Install(p2pNodes);
|
||||
|
||||
We then instantiate a ``NetDeviceContainer`` to keep track of the
|
||||
point-to-point net devices and we ``Install`` devices on the
|
||||
@@ -173,11 +173,11 @@ its native data type.
|
||||
::
|
||||
|
||||
CsmaHelper csma;
|
||||
csma.SetChannelAttribute ("DataRate", StringValue ("100Mbps"));
|
||||
csma.SetChannelAttribute ("Delay", TimeValue (NanoSeconds (6560)));
|
||||
csma.SetChannelAttribute("DataRate", StringValue("100Mbps"));
|
||||
csma.SetChannelAttribute("Delay", TimeValue(NanoSeconds(6560)));
|
||||
|
||||
NetDeviceContainer csmaDevices;
|
||||
csmaDevices = csma.Install (csmaNodes);
|
||||
csmaDevices = csma.Install(csmaNodes);
|
||||
|
||||
Just as we created a ``NetDeviceContainer`` to hold the devices created by
|
||||
the ``PointToPointHelper`` we create a ``NetDeviceContainer`` to hold
|
||||
@@ -192,8 +192,8 @@ stacks present. Just as in the ``first.cc`` script, we will use the
|
||||
::
|
||||
|
||||
InternetStackHelper stack;
|
||||
stack.Install (p2pNodes.Get (0));
|
||||
stack.Install (csmaNodes);
|
||||
stack.Install(p2pNodes.Get(0));
|
||||
stack.Install(csmaNodes);
|
||||
|
||||
Recall that we took one of the nodes from the ``p2pNodes`` container and
|
||||
added it to the ``csmaNodes`` container. Thus we only need to install
|
||||
@@ -208,9 +208,9 @@ two point-to-point devices.
|
||||
::
|
||||
|
||||
Ipv4AddressHelper address;
|
||||
address.SetBase ("10.1.1.0", "255.255.255.0");
|
||||
address.SetBase("10.1.1.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer p2pInterfaces;
|
||||
p2pInterfaces = address.Assign (p2pDevices);
|
||||
p2pInterfaces = address.Assign(p2pDevices);
|
||||
|
||||
Recall that we save the created interfaces in a container to make it easy to
|
||||
pull out addressing information later for use in setting up the applications.
|
||||
@@ -224,9 +224,9 @@ from network number 10.1.2.0 in this case, as seen below.
|
||||
|
||||
::
|
||||
|
||||
address.SetBase ("10.1.2.0", "255.255.255.0");
|
||||
address.SetBase("10.1.2.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer csmaInterfaces;
|
||||
csmaInterfaces = address.Assign (csmaDevices);
|
||||
csmaInterfaces = address.Assign(csmaDevices);
|
||||
|
||||
Now we have a topology built, but we need applications. This section is
|
||||
going to be fundamentally similar to the applications section of
|
||||
@@ -242,11 +242,11 @@ the constructor.
|
||||
|
||||
::
|
||||
|
||||
UdpEchoServerHelper echoServer (9);
|
||||
UdpEchoServerHelper echoServer(9);
|
||||
|
||||
ApplicationContainer serverApps = echoServer.Install (csmaNodes.Get (nCsma));
|
||||
serverApps.Start (Seconds (1.0));
|
||||
serverApps.Stop (Seconds (10.0));
|
||||
ApplicationContainer serverApps = echoServer.Install(csmaNodes.Get(nCsma));
|
||||
serverApps.Start(Seconds(1.0));
|
||||
serverApps.Stop(Seconds(10.0));
|
||||
|
||||
Recall that the ``csmaNodes NodeContainer`` contains one of the
|
||||
nodes created for the point-to-point network and ``nCsma`` "extra" nodes.
|
||||
@@ -267,14 +267,14 @@ leftmost point-to-point node seen in the topology illustration.
|
||||
|
||||
::
|
||||
|
||||
UdpEchoClientHelper echoClient (csmaInterfaces.GetAddress (nCsma), 9);
|
||||
echoClient.SetAttribute ("MaxPackets", UintegerValue (1));
|
||||
echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.0)));
|
||||
echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
|
||||
UdpEchoClientHelper echoClient(csmaInterfaces.GetAddress(nCsma), 9);
|
||||
echoClient.SetAttribute("MaxPackets", UintegerValue(1));
|
||||
echoClient.SetAttribute("Interval", TimeValue(Seconds(1.0)));
|
||||
echoClient.SetAttribute("PacketSize", UintegerValue(1024));
|
||||
|
||||
ApplicationContainer clientApps = echoClient.Install (p2pNodes.Get (0));
|
||||
clientApps.Start (Seconds (2.0));
|
||||
clientApps.Stop (Seconds (10.0));
|
||||
ApplicationContainer clientApps = echoClient.Install(p2pNodes.Get(0));
|
||||
clientApps.Start(Seconds(2.0));
|
||||
clientApps.Stop(Seconds(10.0));
|
||||
|
||||
Since we have actually built an internetwork here, we need some form of
|
||||
internetwork routing. |ns3| provides what we call global routing to
|
||||
@@ -292,7 +292,7 @@ is a one-liner:
|
||||
|
||||
::
|
||||
|
||||
Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
|
||||
Ipv4GlobalRoutingHelper::PopulateRoutingTables();
|
||||
|
||||
Next we enable pcap tracing. The first line of code to enable pcap tracing
|
||||
in the point-to-point helper should be familiar to you by now. The second
|
||||
@@ -301,8 +301,8 @@ you haven't encountered yet.
|
||||
|
||||
::
|
||||
|
||||
pointToPoint.EnablePcapAll ("second");
|
||||
csma.EnablePcap ("second", csmaDevices.Get (1), true);
|
||||
pointToPoint.EnablePcapAll("second");
|
||||
csma.EnablePcap("second", csmaDevices.Get(1), true);
|
||||
|
||||
The CSMA network is a multi-point-to-point network. This means that there
|
||||
can (and are in this case) multiple endpoints on a shared medium. Each of
|
||||
@@ -329,8 +329,8 @@ the ``first.cc`` example.
|
||||
|
||||
::
|
||||
|
||||
Simulator::Run ();
|
||||
Simulator::Destroy ();
|
||||
Simulator::Run();
|
||||
Simulator::Destroy();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -564,9 +564,9 @@ number and device number as parameters. Go ahead and replace the
|
||||
|
||||
::
|
||||
|
||||
pointToPoint.EnablePcap ("second", p2pNodes.Get (0)->GetId (), 0);
|
||||
csma.EnablePcap ("second", csmaNodes.Get (nCsma)->GetId (), 0, false);
|
||||
csma.EnablePcap ("second", csmaNodes.Get (nCsma-1)->GetId (), 0, false);
|
||||
pointToPoint.EnablePcap("second", p2pNodes.Get(0)->GetId(), 0);
|
||||
csma.EnablePcap("second", csmaNodes.Get(nCsma)->GetId(), 0, false);
|
||||
csma.EnablePcap("second", csmaNodes.Get(nCsma-1)->GetId(), 0, false);
|
||||
|
||||
We know that we want to create a pcap file with the base name "second" and
|
||||
we also know that the device of interest in both cases is going to be zero,
|
||||
@@ -610,14 +610,14 @@ On line 110, notice the following command to enable tracing on one node
|
||||
|
||||
.. sourcecode:: bash
|
||||
|
||||
csma.EnablePcap ("second", csmaDevices.Get (1), true);
|
||||
csma.EnablePcap("second", csmaDevices.Get(1), true);
|
||||
|
||||
Change the index to the quantity ``nCsma``, corresponding to the last
|
||||
node in the topology-- the node that contains the echo server:
|
||||
|
||||
.. sourcecode:: bash
|
||||
|
||||
csma.EnablePcap ("second", csmaDevices.Get (nCsma), true);
|
||||
csma.EnablePcap("second", csmaDevices.Get(nCsma), true);
|
||||
|
||||
If you build the new script and run the simulation setting ``nCsma`` to 100,
|
||||
|
||||
@@ -657,7 +657,7 @@ argument of ``false`` indicates that you would like a non-promiscuous trace:
|
||||
|
||||
.. sourcecode:: bash
|
||||
|
||||
csma.EnablePcap ("second", csmaDevices.Get (nCsma - 1), false);
|
||||
csma.EnablePcap("second", csmaDevices.Get(nCsma - 1), false);
|
||||
|
||||
Now build and run as before:
|
||||
|
||||
@@ -872,7 +872,7 @@ component is defined. This should all be quite familiar by now.
|
||||
|
||||
using namespace ns3;
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("ThirdScriptExample");
|
||||
NS_LOG_COMPONENT_DEFINE("ThirdScriptExample");
|
||||
|
||||
The main program begins just like ``second.cc`` by adding some command line
|
||||
parameters for enabling or disabling logging components and for changing the
|
||||
@@ -885,11 +885,11 @@ number of devices created.
|
||||
uint32_t nWifi = 3;
|
||||
|
||||
CommandLine cmd;
|
||||
cmd.AddValue ("nCsma", "Number of \"extra\" CSMA nodes/devices", nCsma);
|
||||
cmd.AddValue ("nWifi", "Number of wifi STA devices", nWifi);
|
||||
cmd.AddValue ("verbose", "Tell echo applications to log if true", verbose);
|
||||
cmd.AddValue("nCsma", "Number of \"extra\" CSMA nodes/devices", nCsma);
|
||||
cmd.AddValue("nWifi", "Number of wifi STA devices", nWifi);
|
||||
cmd.AddValue("verbose", "Tell echo applications to log if true", verbose);
|
||||
|
||||
cmd.Parse (argc,argv);
|
||||
cmd.Parse(argc,argv);
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
@@ -903,7 +903,7 @@ that we will connect via the point-to-point link.
|
||||
::
|
||||
|
||||
NodeContainer p2pNodes;
|
||||
p2pNodes.Create (2);
|
||||
p2pNodes.Create(2);
|
||||
|
||||
Next, we see an old friend. We instantiate a ``PointToPointHelper`` and
|
||||
set the associated default ``Attributes`` so that we create a five megabit
|
||||
@@ -914,11 +914,11 @@ on the nodes and the channel between them.
|
||||
::
|
||||
|
||||
PointToPointHelper pointToPoint;
|
||||
pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
|
||||
pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));
|
||||
pointToPoint.SetDeviceAttribute("DataRate", StringValue("5Mbps"));
|
||||
pointToPoint.SetChannelAttribute("Delay", StringValue("2ms"));
|
||||
|
||||
NetDeviceContainer p2pDevices;
|
||||
p2pDevices = pointToPoint.Install (p2pNodes);
|
||||
p2pDevices = pointToPoint.Install(p2pNodes);
|
||||
|
||||
Next, we declare another ``NodeContainer`` to hold the nodes that will be
|
||||
part of the bus (CSMA) network.
|
||||
@@ -926,8 +926,8 @@ part of the bus (CSMA) network.
|
||||
::
|
||||
|
||||
NodeContainer csmaNodes;
|
||||
csmaNodes.Add (p2pNodes.Get (1));
|
||||
csmaNodes.Create (nCsma);
|
||||
csmaNodes.Add(p2pNodes.Get(1));
|
||||
csmaNodes.Create(nCsma);
|
||||
|
||||
The next line of code ``Gets`` the first node (as in having an index of one)
|
||||
from the point-to-point node container and adds it to the container of nodes
|
||||
@@ -943,11 +943,11 @@ selected nodes.
|
||||
::
|
||||
|
||||
CsmaHelper csma;
|
||||
csma.SetChannelAttribute ("DataRate", StringValue ("100Mbps"));
|
||||
csma.SetChannelAttribute ("Delay", TimeValue (NanoSeconds (6560)));
|
||||
csma.SetChannelAttribute("DataRate", StringValue("100Mbps"));
|
||||
csma.SetChannelAttribute("Delay", TimeValue(NanoSeconds(6560)));
|
||||
|
||||
NetDeviceContainer csmaDevices;
|
||||
csmaDevices = csma.Install (csmaNodes);
|
||||
csmaDevices = csma.Install(csmaNodes);
|
||||
|
||||
Next, we are going to create the nodes that will be part of the Wi-Fi network.
|
||||
We are going to create a number of "station" nodes as specified by the
|
||||
@@ -957,8 +957,8 @@ point-to-point link as the node for the access point.
|
||||
::
|
||||
|
||||
NodeContainer wifiStaNodes;
|
||||
wifiStaNodes.Create (nWifi);
|
||||
NodeContainer wifiApNode = p2pNodes.Get (0);
|
||||
wifiStaNodes.Create(nWifi);
|
||||
NodeContainer wifiApNode = p2pNodes.Get(0);
|
||||
|
||||
The next bit of code constructs the wifi devices and the interconnection
|
||||
channel between these wifi nodes. First, we configure the PHY and channel
|
||||
@@ -966,8 +966,8 @@ helpers:
|
||||
|
||||
::
|
||||
|
||||
YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
|
||||
YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
|
||||
YansWifiChannelHelper channel = YansWifiChannelHelper::Default();
|
||||
YansWifiPhyHelper phy = YansWifiPhyHelper::Default();
|
||||
|
||||
For simplicity, this code uses the default PHY layer configuration and
|
||||
channel models which are documented in the API doxygen documentation for
|
||||
@@ -980,7 +980,7 @@ wireless medium and can communicate and interfere:
|
||||
|
||||
::
|
||||
|
||||
phy.SetChannel (channel.Create ());
|
||||
phy.SetChannel(channel.Create());
|
||||
|
||||
Once the PHY helper is configured, we can focus on the MAC layer. The
|
||||
WifiMacHelper object is used to set MAC parameters.
|
||||
@@ -992,7 +992,7 @@ the MAC layer implementation.
|
||||
::
|
||||
|
||||
WifiMacHelper mac;
|
||||
Ssid ssid = Ssid ("ns-3-ssid");
|
||||
Ssid ssid = Ssid("ns-3-ssid");
|
||||
|
||||
WifiHelper will, by default, configure
|
||||
the standard in use to be 802.11ax (known commercially as Wi-Fi 6) and configure
|
||||
@@ -1013,9 +1013,9 @@ the WifiNetDevice objects that the helper create.
|
||||
::
|
||||
|
||||
NetDeviceContainer staDevices
|
||||
mac.SetType ("ns3::StaWifiMac",
|
||||
"Ssid", SsidValue (ssid),
|
||||
"ActiveProbing", BooleanValue (false));
|
||||
mac.SetType("ns3::StaWifiMac",
|
||||
"Ssid", SsidValue(ssid),
|
||||
"ActiveProbing", BooleanValue(false));
|
||||
|
||||
In the above code, the specific kind of MAC layer that
|
||||
will be created by the helper is specified by the TypeId value
|
||||
@@ -1035,7 +1035,7 @@ create the Wi-Fi devices of these stations:
|
||||
::
|
||||
|
||||
NetDeviceContainer staDevices;
|
||||
staDevices = wifi.Install (phy, mac, wifiStaNodes);
|
||||
staDevices = wifi.Install(phy, mac, wifiStaNodes);
|
||||
|
||||
We have configured Wi-Fi for all of our STA nodes, and now we need to
|
||||
configure the AP (access point) node. We begin this process by changing
|
||||
@@ -1044,8 +1044,8 @@ requirements of the AP.
|
||||
|
||||
::
|
||||
|
||||
mac.SetType ("ns3::ApWifiMac",
|
||||
"Ssid", SsidValue (ssid));
|
||||
mac.SetType("ns3::ApWifiMac",
|
||||
"Ssid", SsidValue(ssid));
|
||||
|
||||
In this case, the ``WifiMacHelper`` is going to create MAC
|
||||
layers of the "ns3::ApWifiMac", the latter specifying that a MAC
|
||||
@@ -1057,7 +1057,7 @@ The next lines create the single AP which shares the same set of PHY-level
|
||||
::
|
||||
|
||||
NetDeviceContainer apDevices;
|
||||
apDevices = wifi.Install (phy, mac, wifiApNode);
|
||||
apDevices = wifi.Install(phy, mac, wifiApNode);
|
||||
|
||||
Now, we are going to add mobility models. We want the STA nodes to be mobile,
|
||||
wandering around inside a bounding box, and we want to make the AP node
|
||||
@@ -1069,13 +1069,13 @@ First, we instantiate a ``MobilityHelper`` object and set some
|
||||
|
||||
MobilityHelper mobility;
|
||||
|
||||
mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
|
||||
"MinX", DoubleValue (0.0),
|
||||
"MinY", DoubleValue (0.0),
|
||||
"DeltaX", DoubleValue (5.0),
|
||||
"DeltaY", DoubleValue (10.0),
|
||||
"GridWidth", UintegerValue (3),
|
||||
"LayoutType", StringValue ("RowFirst"));
|
||||
mobility.SetPositionAllocator("ns3::GridPositionAllocator",
|
||||
"MinX", DoubleValue(0.0),
|
||||
"MinY", DoubleValue(0.0),
|
||||
"DeltaX", DoubleValue(5.0),
|
||||
"DeltaY", DoubleValue(10.0),
|
||||
"GridWidth", UintegerValue(3),
|
||||
"LayoutType", StringValue("RowFirst"));
|
||||
|
||||
This code tells the mobility helper to use a two-dimensional grid to initially
|
||||
place the STA nodes. Feel free to explore the Doxygen for class
|
||||
@@ -1088,15 +1088,15 @@ box.
|
||||
|
||||
::
|
||||
|
||||
mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel",
|
||||
"Bounds", RectangleValue (Rectangle (-50, 50, -50, 50)));
|
||||
mobility.SetMobilityModel("ns3::RandomWalk2dMobilityModel",
|
||||
"Bounds", RectangleValue(Rectangle(-50, 50, -50, 50)));
|
||||
|
||||
We now tell the ``MobilityHelper`` to install the mobility models on the
|
||||
STA nodes.
|
||||
|
||||
::
|
||||
|
||||
mobility.Install (wifiStaNodes);
|
||||
mobility.Install(wifiStaNodes);
|
||||
|
||||
We want the access point to remain in a fixed position during the simulation.
|
||||
We accomplish this by setting the mobility model for this node to be the
|
||||
@@ -1104,8 +1104,8 @@ We accomplish this by setting the mobility model for this node to be the
|
||||
|
||||
::
|
||||
|
||||
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
|
||||
mobility.Install (wifiApNode);
|
||||
mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
|
||||
mobility.Install(wifiApNode);
|
||||
|
||||
We now have our nodes, devices and channels created, and mobility models
|
||||
chosen for the Wi-Fi nodes, but we have no protocol stacks present. Just as
|
||||
@@ -1115,9 +1115,9 @@ to install these stacks.
|
||||
::
|
||||
|
||||
InternetStackHelper stack;
|
||||
stack.Install (csmaNodes);
|
||||
stack.Install (wifiApNode);
|
||||
stack.Install (wifiStaNodes);
|
||||
stack.Install(csmaNodes);
|
||||
stack.Install(wifiApNode);
|
||||
stack.Install(wifiStaNodes);
|
||||
|
||||
Just as in the ``second.cc`` example script, we are going to use the
|
||||
``Ipv4AddressHelper`` to assign IP addresses to our device interfaces.
|
||||
@@ -1130,50 +1130,50 @@ both the STA devices and the AP on the wireless network.
|
||||
|
||||
Ipv4AddressHelper address;
|
||||
|
||||
address.SetBase ("10.1.1.0", "255.255.255.0");
|
||||
address.SetBase("10.1.1.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer p2pInterfaces;
|
||||
p2pInterfaces = address.Assign (p2pDevices);
|
||||
p2pInterfaces = address.Assign(p2pDevices);
|
||||
|
||||
address.SetBase ("10.1.2.0", "255.255.255.0");
|
||||
address.SetBase("10.1.2.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer csmaInterfaces;
|
||||
csmaInterfaces = address.Assign (csmaDevices);
|
||||
csmaInterfaces = address.Assign(csmaDevices);
|
||||
|
||||
address.SetBase ("10.1.3.0", "255.255.255.0");
|
||||
address.Assign (staDevices);
|
||||
address.Assign (apDevices);
|
||||
address.SetBase("10.1.3.0", "255.255.255.0");
|
||||
address.Assign(staDevices);
|
||||
address.Assign(apDevices);
|
||||
|
||||
We put the echo server on the "rightmost" node in the illustration at the
|
||||
start of the file. We have done this before.
|
||||
|
||||
::
|
||||
|
||||
UdpEchoServerHelper echoServer (9);
|
||||
UdpEchoServerHelper echoServer(9);
|
||||
|
||||
ApplicationContainer serverApps = echoServer.Install (csmaNodes.Get (nCsma));
|
||||
serverApps.Start (Seconds (1.0));
|
||||
serverApps.Stop (Seconds (10.0));
|
||||
ApplicationContainer serverApps = echoServer.Install(csmaNodes.Get(nCsma));
|
||||
serverApps.Start(Seconds(1.0));
|
||||
serverApps.Stop(Seconds(10.0));
|
||||
|
||||
And we put the echo client on the last STA node we created, pointing it to
|
||||
the server on the CSMA network. We have also seen similar operations before.
|
||||
|
||||
::
|
||||
|
||||
UdpEchoClientHelper echoClient (csmaInterfaces.GetAddress (nCsma), 9);
|
||||
echoClient.SetAttribute ("MaxPackets", UintegerValue (1));
|
||||
echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.0)));
|
||||
echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
|
||||
UdpEchoClientHelper echoClient(csmaInterfaces.GetAddress(nCsma), 9);
|
||||
echoClient.SetAttribute("MaxPackets", UintegerValue(1));
|
||||
echoClient.SetAttribute("Interval", TimeValue(Seconds(1.0)));
|
||||
echoClient.SetAttribute("PacketSize", UintegerValue(1024));
|
||||
|
||||
ApplicationContainer clientApps =
|
||||
echoClient.Install (wifiStaNodes.Get (nWifi - 1));
|
||||
clientApps.Start (Seconds (2.0));
|
||||
clientApps.Stop (Seconds (10.0));
|
||||
echoClient.Install(wifiStaNodes.Get(nWifi - 1));
|
||||
clientApps.Start(Seconds(2.0));
|
||||
clientApps.Stop(Seconds(10.0));
|
||||
|
||||
Since we have built an internetwork here, we need to enable internetwork routing
|
||||
just as we did in the ``second.cc`` example script.
|
||||
|
||||
::
|
||||
|
||||
Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
|
||||
Ipv4GlobalRoutingHelper::PopulateRoutingTables();
|
||||
|
||||
One thing that can surprise some users is the fact that the simulation we just
|
||||
created will never "naturally" stop. This is because we asked the wireless
|
||||
@@ -1186,15 +1186,15 @@ loop.
|
||||
|
||||
::
|
||||
|
||||
Simulator::Stop (Seconds (10.0));
|
||||
Simulator::Stop(Seconds(10.0));
|
||||
|
||||
We create just enough tracing to cover all three networks:
|
||||
|
||||
::
|
||||
|
||||
pointToPoint.EnablePcapAll ("third");
|
||||
phy.EnablePcap ("third", apDevices.Get (0));
|
||||
csma.EnablePcap ("third", csmaDevices.Get (0), true);
|
||||
pointToPoint.EnablePcapAll("third");
|
||||
phy.EnablePcap("third", apDevices.Get(0));
|
||||
csma.EnablePcap("third", csmaDevices.Get(0), true);
|
||||
|
||||
These three lines of code will start pcap tracing on both of the point-to-point
|
||||
nodes that serves as our backbone, will start a promiscuous (monitor) mode
|
||||
@@ -1206,8 +1206,8 @@ Finally, we actually run the simulation, clean up and then exit the program.
|
||||
|
||||
::
|
||||
|
||||
Simulator::Run ();
|
||||
Simulator::Destroy ();
|
||||
Simulator::Run();
|
||||
Simulator::Destroy();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1357,11 +1357,11 @@ following function:
|
||||
::
|
||||
|
||||
void
|
||||
CourseChange (std::string context, Ptr<const MobilityModel> model)
|
||||
CourseChange(std::string context, Ptr<const MobilityModel> model)
|
||||
{
|
||||
Vector position = model->GetPosition ();
|
||||
NS_LOG_UNCOND (context <<
|
||||
" x = " << position.x << ", y = " << position.y);
|
||||
Vector position = model->GetPosition();
|
||||
NS_LOG_UNCOND(context <<
|
||||
" x = " << position.x << ", y = " << position.y);
|
||||
}
|
||||
|
||||
This code just pulls the position information from the mobility model and
|
||||
@@ -1374,11 +1374,10 @@ script just before the ``Simulator::Run`` call.
|
||||
::
|
||||
|
||||
std::ostringstream oss;
|
||||
oss <<
|
||||
"/NodeList/" << wifiStaNodes.Get (nWifi - 1)->GetId () <<
|
||||
"/$ns3::MobilityModel/CourseChange";
|
||||
oss << "/NodeList/" << wifiStaNodes.Get(nWifi - 1)->GetId()
|
||||
<< "/$ns3::MobilityModel/CourseChange";
|
||||
|
||||
Config::Connect (oss.str (), MakeCallback (&CourseChange));
|
||||
Config::Connect(oss.str(), MakeCallback(&CourseChange));
|
||||
|
||||
What we do here is to create a string containing the tracing namespace path
|
||||
of the event to which we want to connect. First, we have to figure out which
|
||||
@@ -1535,29 +1534,29 @@ Changing from the defaults
|
||||
* The type of queue used by a NetDevice can be usually modified through the device helper::
|
||||
|
||||
NodeContainer nodes;
|
||||
nodes.Create (2);
|
||||
nodes.Create(2);
|
||||
|
||||
PointToPointHelper p2p;
|
||||
p2p.SetQueue ("ns3::DropTailQueue", "MaxSize", StringValue ("50p"));
|
||||
p2p.SetQueue("ns3::DropTailQueue", "MaxSize", StringValue("50p"));
|
||||
|
||||
NetDeviceContainer devices = p2p.Install (nodes);
|
||||
NetDeviceContainer devices = p2p.Install(nodes);
|
||||
|
||||
* The type of queue disc installed on a NetDevice can be modified through the
|
||||
traffic control helper::
|
||||
|
||||
InternetStackHelper stack;
|
||||
stack.Install (nodes);
|
||||
stack.Install(nodes);
|
||||
|
||||
TrafficControlHelper tch;
|
||||
tch.SetRootQueueDisc ("ns3::CoDelQueueDisc", "MaxSize", StringValue ("1000p"));
|
||||
tch.Install (devices);
|
||||
tch.SetRootQueueDisc("ns3::CoDelQueueDisc", "MaxSize", StringValue("1000p"));
|
||||
tch.Install(devices);
|
||||
|
||||
* BQL can be enabled on a device that supports it through the traffic control helper::
|
||||
|
||||
InternetStackHelper stack;
|
||||
stack.Install (nodes);
|
||||
stack.Install(nodes);
|
||||
|
||||
TrafficControlHelper tch;
|
||||
tch.SetRootQueueDisc ("ns3::CoDelQueueDisc", "MaxSize", StringValue ("1000p"));
|
||||
tch.SetQueueLimits ("ns3::DynamicQueueLimits", "HoldTime", StringValue ("4ms"));
|
||||
tch.Install (devices);
|
||||
tch.SetRootQueueDisc("ns3::CoDelQueueDisc", "MaxSize", StringValue("1000p"));
|
||||
tch.SetQueueLimits("ns3::DynamicQueueLimits", "HoldTime", StringValue("4ms"));
|
||||
tch.Install(devices);
|
||||
|
||||
@@ -292,7 +292,7 @@ The next line of the script is the following,
|
||||
|
||||
::
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("FirstScriptExample");
|
||||
NS_LOG_COMPONENT_DEFINE("FirstScriptExample");
|
||||
|
||||
We will use this statement as a convenient place to talk about our Doxygen
|
||||
documentation system. If you look at the project web site,
|
||||
@@ -334,7 +334,7 @@ The next lines of the script you will find are,
|
||||
::
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
This is just the declaration of the main function of your program (script).
|
||||
@@ -347,7 +347,7 @@ to be the default value:
|
||||
|
||||
::
|
||||
|
||||
Time::SetResolution (Time::NS);
|
||||
Time::SetResolution(Time::NS);
|
||||
|
||||
The resolution is the smallest time value that can be represented (as well as
|
||||
the smallest representable difference between two time values).
|
||||
@@ -386,7 +386,7 @@ simulation.
|
||||
::
|
||||
|
||||
NodeContainer nodes;
|
||||
nodes.Create (2);
|
||||
nodes.Create(2);
|
||||
|
||||
Let's find the documentation for the ``NodeContainer`` class before we
|
||||
continue. Another way to get into the documentation for a given class is via
|
||||
@@ -433,8 +433,8 @@ The next three lines in the script are,
|
||||
::
|
||||
|
||||
PointToPointHelper pointToPoint;
|
||||
pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
|
||||
pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));
|
||||
pointToPoint.SetDeviceAttribute("DataRate", StringValue("5Mbps"));
|
||||
pointToPoint.SetChannelAttribute("Delay", StringValue("2ms"));
|
||||
|
||||
The first line,
|
||||
|
||||
@@ -447,7 +447,7 @@ high-level perspective the next line,
|
||||
|
||||
::
|
||||
|
||||
pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
|
||||
pointToPoint.SetDeviceAttribute("DataRate", StringValue("5Mbps"));
|
||||
|
||||
tells the ``PointToPointHelper`` object to use the value "5Mbps"
|
||||
(five megabits per second) as the "DataRate" when it creates a
|
||||
@@ -468,7 +468,7 @@ final line,
|
||||
|
||||
::
|
||||
|
||||
pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));
|
||||
pointToPoint.SetChannelAttribute("Delay", StringValue("2ms"));
|
||||
|
||||
tells the ``PointToPointHelper`` to use the value "2ms" (two milliseconds)
|
||||
as the value of the propagation delay of every point to point channel it
|
||||
@@ -490,7 +490,7 @@ following two lines of code,
|
||||
::
|
||||
|
||||
NetDeviceContainer devices;
|
||||
devices = pointToPoint.Install (nodes);
|
||||
devices = pointToPoint.Install(nodes);
|
||||
|
||||
will finish configuring the devices and channel. The first line declares the
|
||||
device container mentioned above and the second does the heavy lifting. The
|
||||
@@ -504,7 +504,7 @@ by the ``PointToPointHelper``, the ``Attributes`` previously set in the
|
||||
helper are used to initialize the corresponding ``Attributes`` in the
|
||||
created objects.
|
||||
|
||||
After executing the ``pointToPoint.Install (nodes)`` call we will have
|
||||
After executing the ``pointToPoint.Install(nodes)`` call we will have
|
||||
two nodes, each with an installed point-to-point net device and a single
|
||||
point-to-point channel between them. Both devices will be configured to
|
||||
transmit data at five megabits per second over the channel which has a two
|
||||
@@ -518,7 +518,7 @@ installed on our nodes. The next two lines of code will take care of that.
|
||||
::
|
||||
|
||||
InternetStackHelper stack;
|
||||
stack.Install (nodes);
|
||||
stack.Install(nodes);
|
||||
|
||||
The ``InternetStackHelper`` is a topology helper that is to internet stacks
|
||||
what the ``PointToPointHelper`` is to point-to-point net devices. The
|
||||
@@ -539,7 +539,7 @@ The next two lines of code in our example script, ``first.cc``,
|
||||
::
|
||||
|
||||
Ipv4AddressHelper address;
|
||||
address.SetBase ("10.1.1.0", "255.255.255.0");
|
||||
address.SetBase("10.1.1.0", "255.255.255.0");
|
||||
|
||||
declare an address helper object and tell it that it should begin allocating IP
|
||||
addresses from the network 10.1.1.0 using the mask 255.255.255.0 to define
|
||||
@@ -554,7 +554,7 @@ The next line of code,
|
||||
|
||||
::
|
||||
|
||||
Ipv4InterfaceContainer interfaces = address.Assign (devices);
|
||||
Ipv4InterfaceContainer interfaces = address.Assign(devices);
|
||||
|
||||
performs the actual address assignment. In |ns3| we make the
|
||||
association between an IP address and a device using an ``Ipv4Interface``
|
||||
@@ -584,11 +584,11 @@ created.
|
||||
|
||||
::
|
||||
|
||||
UdpEchoServerHelper echoServer (9);
|
||||
UdpEchoServerHelper echoServer(9);
|
||||
|
||||
ApplicationContainer serverApps = echoServer.Install (nodes.Get (1));
|
||||
serverApps.Start (Seconds (1.0));
|
||||
serverApps.Stop (Seconds (10.0));
|
||||
ApplicationContainer serverApps = echoServer.Install(nodes.Get(1));
|
||||
serverApps.Start(Seconds(1.0));
|
||||
serverApps.Stop(Seconds(10.0));
|
||||
|
||||
The first line of code in the above snippet declares the
|
||||
``UdpEchoServerHelper``. As usual, this isn't the application itself, it
|
||||
@@ -608,7 +608,7 @@ to a node. Interestingly, the ``Install`` method takes a
|
||||
``NodeContainter`` as a parameter just as the other ``Install`` methods
|
||||
we have seen. This is actually what is passed to the method even though it
|
||||
doesn't look so in this case. There is a C++ *implicit conversion* at
|
||||
work here that takes the result of ``nodes.Get (1)`` (which returns a smart
|
||||
work here that takes the result of ``nodes.Get(1)`` (which returns a smart
|
||||
pointer to a node object --- ``Ptr<Node>``) and uses that in a constructor
|
||||
for an unnamed ``NodeContainer`` that is then passed to ``Install``.
|
||||
If you are ever at a loss to find a particular method signature in C++ code
|
||||
@@ -633,8 +633,8 @@ converted for you. The two lines,
|
||||
|
||||
::
|
||||
|
||||
serverApps.Start (Seconds (1.0));
|
||||
serverApps.Stop (Seconds (10.0));
|
||||
serverApps.Start(Seconds(1.0));
|
||||
serverApps.Stop(Seconds(10.0));
|
||||
|
||||
will cause the echo server application to ``Start`` (enable itself) at one
|
||||
second into the simulation and to ``Stop`` (disable itself) at ten seconds
|
||||
@@ -651,14 +651,14 @@ that is managed by an ``UdpEchoClientHelper``.
|
||||
|
||||
::
|
||||
|
||||
UdpEchoClientHelper echoClient (interfaces.GetAddress (1), 9);
|
||||
echoClient.SetAttribute ("MaxPackets", UintegerValue (1));
|
||||
echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.0)));
|
||||
echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
|
||||
UdpEchoClientHelper echoClient(interfaces.GetAddress(1), 9);
|
||||
echoClient.SetAttribute("MaxPackets", UintegerValue(1));
|
||||
echoClient.SetAttribute("Interval", TimeValue(Seconds(1.0)));
|
||||
echoClient.SetAttribute("PacketSize", UintegerValue(1024));
|
||||
|
||||
ApplicationContainer clientApps = echoClient.Install (nodes.Get (0));
|
||||
clientApps.Start (Seconds (2.0));
|
||||
clientApps.Stop (Seconds (10.0));
|
||||
ApplicationContainer clientApps = echoClient.Install(nodes.Get(0));
|
||||
clientApps.Start(Seconds(2.0));
|
||||
clientApps.Stop(Seconds(10.0));
|
||||
|
||||
For the echo client, however, we need to set five different ``Attributes``.
|
||||
The first two ``Attributes`` are set during construction of the
|
||||
@@ -695,17 +695,17 @@ done using the global function ``Simulator::Run``.
|
||||
|
||||
::
|
||||
|
||||
Simulator::Run ();
|
||||
Simulator::Run();
|
||||
|
||||
When we previously called the methods,
|
||||
|
||||
::
|
||||
|
||||
serverApps.Start (Seconds (1.0));
|
||||
serverApps.Stop (Seconds (10.0));
|
||||
serverApps.Start(Seconds(1.0));
|
||||
serverApps.Stop(Seconds(10.0));
|
||||
...
|
||||
clientApps.Start (Seconds (2.0));
|
||||
clientApps.Stop (Seconds (10.0));
|
||||
clientApps.Start(Seconds(2.0));
|
||||
clientApps.Stop(Seconds(10.0));
|
||||
|
||||
we actually scheduled events in the simulator at 1.0 seconds, 2.0 seconds and
|
||||
two events at 10.0 seconds. When ``Simulator::Run`` is called, the system
|
||||
@@ -741,7 +741,7 @@ took care of the hard part for you. The remaining lines of our first
|
||||
|
||||
::
|
||||
|
||||
Simulator::Destroy ();
|
||||
Simulator::Destroy();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -764,7 +764,7 @@ not) be generated.
|
||||
The simulation will stop automatically when no further events are in the
|
||||
event queue, or when a special Stop event is found. The Stop event is
|
||||
created through the
|
||||
``Simulator::Stop (stopTime);`` function.
|
||||
``Simulator::Stop(stopTime);`` function.
|
||||
|
||||
There is a typical case where ``Simulator::Stop`` is absolutely necessary
|
||||
to stop the simulation: when there is a self-sustaining event.
|
||||
@@ -791,9 +791,9 @@ in the first example program will schedule an explicit stop at 11 seconds:
|
||||
|
||||
::
|
||||
|
||||
+ Simulator::Stop (Seconds (11.0));
|
||||
Simulator::Run ();
|
||||
Simulator::Destroy ();
|
||||
+ Simulator::Stop(Seconds(11.0));
|
||||
Simulator::Run();
|
||||
Simulator::Destroy();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -50,8 +50,8 @@ First, it has been enabled for IPv6 support with a command-line option:
|
||||
::
|
||||
|
||||
CommandLine cmd;
|
||||
cmd.AddValue ("useIpv6", "Use Ipv6", useV6);
|
||||
cmd.Parse (argc, argv);
|
||||
cmd.AddValue("useIpv6", "Use Ipv6", useV6);
|
||||
cmd.Parse(argc, argv);
|
||||
|
||||
If the user specifies ``useIpv6``, option, the program will be run
|
||||
using IPv6 instead of IPv4. The ``help`` option, available on all |ns3|
|
||||
@@ -124,40 +124,40 @@ some of the new lines of this diff:
|
||||
+ // Configure the plot. The first argument is the file name prefix
|
||||
+ // for the output files generated. The second, third, and fourth
|
||||
+ // arguments are, respectively, the plot title, x-axis, and y-axis labels
|
||||
+ plotHelper.ConfigurePlot ("seventh-packet-byte-count",
|
||||
+ "Packet Byte Count vs. Time",
|
||||
+ "Time (Seconds)",
|
||||
+ "Packet Byte Count");
|
||||
+ plotHelper.ConfigurePlot("seventh-packet-byte-count",
|
||||
+ "Packet Byte Count vs. Time",
|
||||
+ "Time(Seconds)",
|
||||
+ "Packet Byte Count");
|
||||
+
|
||||
+ // Specify the probe type, trace source path (in configuration namespace), and
|
||||
+ // probe output trace source ("OutputBytes") to plot. The fourth argument
|
||||
+ // specifies the name of the data series label on the plot. The last
|
||||
+ // argument formats the plot by specifying where the key should be placed.
|
||||
+ plotHelper.PlotProbe (probeType,
|
||||
+ tracePath,
|
||||
+ "OutputBytes",
|
||||
+ "Packet Byte Count",
|
||||
+ GnuplotAggregator::KEY_BELOW);
|
||||
+ plotHelper.PlotProbe(probeType,
|
||||
+ tracePath,
|
||||
+ "OutputBytes",
|
||||
+ "Packet Byte Count",
|
||||
+ GnuplotAggregator::KEY_BELOW);
|
||||
+
|
||||
+ // Use FileHelper to write out the packet byte count over time
|
||||
+ FileHelper fileHelper;
|
||||
+
|
||||
+ // Configure the file to be written, and the formatting of output data.
|
||||
+ fileHelper.ConfigureFile ("seventh-packet-byte-count",
|
||||
+ FileAggregator::FORMATTED);
|
||||
+ fileHelper.ConfigureFile("seventh-packet-byte-count",
|
||||
+ FileAggregator::FORMATTED);
|
||||
+
|
||||
+ // Set the labels for this formatted output file.
|
||||
+ fileHelper.Set2dFormat ("Time (Seconds) = %.3e\tPacket Byte Count = %.0f");
|
||||
+ fileHelper.Set2dFormat("Time (Seconds) = %.3e\tPacket Byte Count = %.0f");
|
||||
+
|
||||
+ // Specify the probe type, probe path (in configuration namespace), and
|
||||
+ // probe output trace source ("OutputBytes") to write.
|
||||
+ fileHelper.WriteProbe (probeType,
|
||||
+ tracePath,
|
||||
+ "OutputBytes");
|
||||
+ fileHelper.WriteProbe(probeType,
|
||||
+ tracePath,
|
||||
+ "OutputBytes");
|
||||
+
|
||||
Simulator::Stop (Seconds (20));
|
||||
Simulator::Run ();
|
||||
Simulator::Destroy ();
|
||||
Simulator::Stop(Seconds(20));
|
||||
Simulator::Run();
|
||||
Simulator::Destroy();
|
||||
|
||||
|
||||
The careful reader will have noticed, when testing the IPv6 command
|
||||
@@ -243,10 +243,10 @@ the GnuplotHelper object must be declared and configured:
|
||||
+ // Configure the plot. The first argument is the file name prefix
|
||||
+ // for the output files generated. The second, third, and fourth
|
||||
+ // arguments are, respectively, the plot title, x-axis, and y-axis labels
|
||||
+ plotHelper.ConfigurePlot ("seventh-packet-byte-count",
|
||||
+ "Packet Byte Count vs. Time",
|
||||
+ "Time (Seconds)",
|
||||
+ "Packet Byte Count");
|
||||
+ plotHelper.ConfigurePlot("seventh-packet-byte-count",
|
||||
+ "Packet Byte Count vs. Time",
|
||||
+ "Time (Seconds)",
|
||||
+ "Packet Byte Count");
|
||||
|
||||
|
||||
To this point, an empty plot has been configured. The filename prefix
|
||||
@@ -272,11 +272,11 @@ We use them here:
|
||||
+ // probe output trace source ("OutputBytes") to plot. The fourth argument
|
||||
+ // specifies the name of the data series label on the plot. The last
|
||||
+ // argument formats the plot by specifying where the key should be placed.
|
||||
+ plotHelper.PlotProbe (probeType,
|
||||
+ tracePath,
|
||||
+ "OutputBytes",
|
||||
+ "Packet Byte Count",
|
||||
+ GnuplotAggregator::KEY_BELOW);
|
||||
+ plotHelper.PlotProbe(probeType,
|
||||
+ tracePath,
|
||||
+ "OutputBytes",
|
||||
+ "Packet Byte Count",
|
||||
+ GnuplotAggregator::KEY_BELOW);
|
||||
|
||||
The first two arguments are the name of the probe type and the trace source path.
|
||||
These two are probably the hardest to determine when you try to use
|
||||
@@ -287,8 +287,8 @@ observe:
|
||||
|
||||
::
|
||||
|
||||
.AddTraceSource ("Tx", "Send IPv6 packet to outgoing interface.",
|
||||
MakeTraceSourceAccessor (&Ipv6L3Protocol::m_txTrace))
|
||||
.AddTraceSource("Tx", "Send IPv6 packet to outgoing interface.",
|
||||
MakeTraceSourceAccessor(&Ipv6L3Protocol::m_txTrace))
|
||||
|
||||
This says that ``Tx`` is a name for variable ``m_txTrace``, which has
|
||||
a declaration of:
|
||||
@@ -317,18 +317,18 @@ the data out of the probed Packet object:
|
||||
::
|
||||
|
||||
TypeId
|
||||
Ipv6PacketProbe::GetTypeId ()
|
||||
Ipv6PacketProbe::GetTypeId()
|
||||
{
|
||||
static TypeId tid = TypeId ("ns3::Ipv6PacketProbe")
|
||||
.SetParent<Probe> ()
|
||||
.SetGroupName ("Stats")
|
||||
.AddConstructor<Ipv6PacketProbe> ()
|
||||
.AddTraceSource ( "Output",
|
||||
"The packet plus its IPv6 object and interface that serve as the output for this probe",
|
||||
MakeTraceSourceAccessor (&Ipv6PacketProbe::m_output))
|
||||
.AddTraceSource ( "OutputBytes",
|
||||
"The number of bytes in the packet",
|
||||
MakeTraceSourceAccessor (&Ipv6PacketProbe::m_outputBytes))
|
||||
static TypeId tid = TypeId("ns3::Ipv6PacketProbe")
|
||||
.SetParent<Probe>()
|
||||
.SetGroupName("Stats")
|
||||
.AddConstructor<Ipv6PacketProbe>()
|
||||
.AddTraceSource("Output",
|
||||
"The packet plus its IPv6 object and interface that serve as the output for this probe",
|
||||
MakeTraceSourceAccessor(&Ipv6PacketProbe::m_output))
|
||||
.AddTraceSource("OutputBytes",
|
||||
"The number of bytes in the packet",
|
||||
MakeTraceSourceAccessor(&Ipv6PacketProbe::m_outputBytes))
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
@@ -407,8 +407,8 @@ be seen in the filenames. Let's look at the code piece-by-piece:
|
||||
+ FileHelper fileHelper;
|
||||
+
|
||||
+ // Configure the file to be written, and the formatting of output data.
|
||||
+ fileHelper.ConfigureFile ("seventh-packet-byte-count",
|
||||
+ FileAggregator::FORMATTED);
|
||||
+ fileHelper.ConfigureFile("seventh-packet-byte-count",
|
||||
+ FileAggregator::FORMATTED);
|
||||
|
||||
The file helper file prefix is the first argument, and a format specifier
|
||||
is next.
|
||||
@@ -420,7 +420,7 @@ FORMATTED is specified) with a format string such as follows:
|
||||
|
||||
+
|
||||
+ // Set the labels for this formatted output file.
|
||||
+ fileHelper.Set2dFormat ("Time (Seconds) = %.3e\tPacket Byte Count = %.0f");
|
||||
+ fileHelper.Set2dFormat("Time (Seconds) = %.3e\tPacket Byte Count = %.0f");
|
||||
|
||||
Finally, the trace source of interest must be hooked. Again, the probeType and
|
||||
tracePath variables in this example are used, and the probe's output
|
||||
@@ -431,9 +431,9 @@ trace source "OutputBytes" is hooked:
|
||||
+
|
||||
+ // Specify the probe type, trace source path (in configuration namespace), and
|
||||
+ // probe output trace source ("OutputBytes") to write.
|
||||
+ fileHelper.WriteProbe (probeType,
|
||||
+ tracePath,
|
||||
+ "OutputBytes");
|
||||
+ fileHelper.WriteProbe(probeType,
|
||||
+ tracePath,
|
||||
+ "OutputBytes");
|
||||
+
|
||||
|
||||
The wildcard fields in this trace source specifier match two trace sources.
|
||||
@@ -448,4 +448,3 @@ providing time series output has been added. The basic pattern described
|
||||
above may be replicated within the scope of support of the existing
|
||||
probes and trace sources. More capabilities including statistics
|
||||
processing will be added in future releases.
|
||||
|
||||
|
||||
@@ -822,9 +822,9 @@ use the indicated Code Wrapper macro:
|
||||
|
||||
.. sourcecode:: cpp
|
||||
|
||||
NS_BUILD_DEBUG (std::cout << "Part of an output line..." << std::flush; timer.Start ());
|
||||
DoLongInvolvedComputation ();
|
||||
NS_BUILD_DEBUG (timer.Stop (); std::cout << "Done: " << timer << std::endl;)
|
||||
NS_BUILD_DEBUG(std::cout << "Part of an output line..." << std::flush; timer.Start());
|
||||
DoLongInvolvedComputation();
|
||||
NS_BUILD_DEBUG(timer.Stop(); std::cout << "Done: " << timer << std::endl;)
|
||||
|
||||
By default ns3 puts the build artifacts in the ``build`` directory.
|
||||
You can specify a different output directory with the ``--out``
|
||||
@@ -1626,4 +1626,3 @@ The resulting text file can then be saved with any corresponding
|
||||
then
|
||||
echo "$gitDiff" >> version.txt
|
||||
fi
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -350,7 +350,7 @@ Recall that we have defined a logging component in that script:
|
||||
|
||||
::
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("FirstScriptExample");
|
||||
NS_LOG_COMPONENT_DEFINE("FirstScriptExample");
|
||||
|
||||
You now know that you can enable all of the logging for this component by
|
||||
setting the ``NS_LOG`` environment variable to the various levels. Let's
|
||||
@@ -363,14 +363,14 @@ Open ``scratch/myfirst.cc`` in your favorite editor and add the line,
|
||||
|
||||
::
|
||||
|
||||
NS_LOG_INFO ("Creating Topology");
|
||||
NS_LOG_INFO("Creating Topology");
|
||||
|
||||
right before the lines,
|
||||
|
||||
::
|
||||
|
||||
NodeContainer nodes;
|
||||
nodes.Create (2);
|
||||
nodes.Create(2);
|
||||
|
||||
Now build the script using ns3 and clear the ``NS_LOG`` variable to turn
|
||||
off the torrent of logging we previously enabled:
|
||||
@@ -426,12 +426,12 @@ in the following code,
|
||||
::
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
...
|
||||
|
||||
CommandLine cmd;
|
||||
cmd.Parse (argc, argv);
|
||||
cmd.Parse(argc, argv);
|
||||
|
||||
...
|
||||
}
|
||||
@@ -470,8 +470,8 @@ at the |ns3| ``Attribute`` system while walking through the
|
||||
::
|
||||
|
||||
PointToPointHelper pointToPoint;
|
||||
pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
|
||||
pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));
|
||||
pointToPoint.SetDeviceAttribute("DataRate", StringValue("5Mbps"));
|
||||
pointToPoint.SetChannelAttribute("Delay", StringValue("2ms"));
|
||||
|
||||
and mentioned that ``DataRate`` was actually an ``Attribute`` of the
|
||||
``PointToPointNetDevice``. Let's use the command line argument parser
|
||||
@@ -507,12 +507,12 @@ any ``set`` operations as in the following example,
|
||||
...
|
||||
|
||||
NodeContainer nodes;
|
||||
nodes.Create (2);
|
||||
nodes.Create(2);
|
||||
|
||||
PointToPointHelper pointToPoint;
|
||||
|
||||
NetDeviceContainer devices;
|
||||
devices = pointToPoint.Install (nodes);
|
||||
devices = pointToPoint.Install(nodes);
|
||||
|
||||
...
|
||||
|
||||
@@ -680,13 +680,13 @@ start with the following code,
|
||||
::
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
uint32_t nPackets = 1;
|
||||
|
||||
CommandLine cmd;
|
||||
cmd.AddValue("nPackets", "Number of packets to echo", nPackets);
|
||||
cmd.Parse (argc, argv);
|
||||
cmd.Parse(argc, argv);
|
||||
|
||||
...
|
||||
|
||||
@@ -696,7 +696,7 @@ instead of the constant ``1`` as is shown below.
|
||||
|
||||
::
|
||||
|
||||
echoClient.SetAttribute ("MaxPackets", UintegerValue (nPackets));
|
||||
echoClient.SetAttribute("MaxPackets", UintegerValue(nPackets));
|
||||
|
||||
Now if you run the script and provide the ``--PrintHelp`` argument, you
|
||||
should see your new ``User Argument`` listed in the help display.
|
||||
@@ -778,7 +778,7 @@ from C++ programs could be used:
|
||||
|
||||
#include <iostream>
|
||||
...
|
||||
int main ()
|
||||
int main()
|
||||
{
|
||||
...
|
||||
std::cout << "The value of x is " << x << std::endl;
|
||||
@@ -838,12 +838,12 @@ generated by many scripts.
|
||||
|
||||
Let's just jump right in and add some ASCII tracing output to our
|
||||
``scratch/myfirst.cc`` script. Right before the call to
|
||||
``Simulator::Run ()``, add the following lines of code:
|
||||
``Simulator::Run()``, add the following lines of code:
|
||||
|
||||
::
|
||||
|
||||
AsciiTraceHelper ascii;
|
||||
pointToPoint.EnableAsciiAll (ascii.CreateFileStream ("myfirst.tr"));
|
||||
pointToPoint.EnableAsciiAll(ascii.CreateFileStream("myfirst.tr"));
|
||||
|
||||
Like in many other |ns3| idioms, this code uses a helper object to
|
||||
help create ASCII traces. The second line contains two nested method calls.
|
||||
@@ -998,7 +998,7 @@ The code used to enable pcap tracing is a one-liner.
|
||||
|
||||
::
|
||||
|
||||
pointToPoint.EnablePcapAll ("myfirst");
|
||||
pointToPoint.EnablePcapAll("myfirst");
|
||||
|
||||
Go ahead and insert this line of code after the ASCII tracing code we just
|
||||
added to ``scratch/myfirst.cc``. Notice that we only passed the string
|
||||
|
||||
Reference in New Issue
Block a user