Use Time() constructor with integer values

This commit is contained in:
Eduardo Almeida
2024-11-08 18:01:13 +00:00
parent 5d104f6f90
commit 5afa1fd7ef
314 changed files with 1771 additions and 1775 deletions

View File

@@ -245,8 +245,8 @@ the constructor.
UdpEchoServerHelper echoServer(9);
ApplicationContainer serverApps = echoServer.Install(csmaNodes.Get(nCsma));
serverApps.Start(Seconds(1.0));
serverApps.Stop(Seconds(10.0));
serverApps.Start(Seconds(1));
serverApps.Stop(Seconds(10));
Recall that the ``csmaNodes NodeContainer`` contains one of the
nodes created for the point-to-point network and ``nCsma`` "extra" nodes.
@@ -269,12 +269,12 @@ 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("Interval", TimeValue(Seconds(1)));
echoClient.SetAttribute("PacketSize", UintegerValue(1024));
ApplicationContainer clientApps = echoClient.Install(p2pNodes.Get(0));
clientApps.Start(Seconds(2.0));
clientApps.Stop(Seconds(10.0));
clientApps.Start(Seconds(2));
clientApps.Stop(Seconds(10));
Since we have actually built an internetwork here, we need some form of
internetwork routing. |ns3| provides what we call global routing to
@@ -1150,8 +1150,8 @@ start of the file. We have done this before.
UdpEchoServerHelper echoServer(9);
ApplicationContainer serverApps = echoServer.Install(csmaNodes.Get(nCsma));
serverApps.Start(Seconds(1.0));
serverApps.Stop(Seconds(10.0));
serverApps.Start(Seconds(1));
serverApps.Stop(Seconds(10));
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.
@@ -1160,13 +1160,13 @@ 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("Interval", TimeValue(Seconds(1)));
echoClient.SetAttribute("PacketSize", UintegerValue(1024));
ApplicationContainer clientApps =
echoClient.Install(wifiStaNodes.Get(nWifi - 1));
clientApps.Start(Seconds(2.0));
clientApps.Stop(Seconds(10.0));
clientApps.Start(Seconds(2));
clientApps.Stop(Seconds(10));
Since we have built an internetwork here, we need to enable internetwork routing
just as we did in the ``second.cc`` example script.
@@ -1186,7 +1186,7 @@ loop.
::
Simulator::Stop(Seconds(10.0));
Simulator::Stop(Seconds(10));
We create just enough tracing to cover all three networks:

View File

@@ -554,8 +554,8 @@ created.
UdpEchoServerHelper echoServer(9);
ApplicationContainer serverApps = echoServer.Install(nodes.Get(1));
serverApps.Start(Seconds(1.0));
serverApps.Stop(Seconds(10.0));
serverApps.Start(Seconds(1));
serverApps.Stop(Seconds(10));
The first line of code in the above snippet declares the
``UdpEchoServerHelper``. As usual, this isn't the application itself, it
@@ -600,8 +600,8 @@ converted for you. The two lines,
::
serverApps.Start(Seconds(1.0));
serverApps.Stop(Seconds(10.0));
serverApps.Start(Seconds(1));
serverApps.Stop(Seconds(10));
will cause the echo server application to ``Start`` (enable itself) at one
second into the simulation and to ``Stop`` (disable itself) at ten seconds
@@ -620,12 +620,12 @@ 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("Interval", TimeValue(Seconds(1)));
echoClient.SetAttribute("PacketSize", UintegerValue(1024));
ApplicationContainer clientApps = echoClient.Install(nodes.Get(0));
clientApps.Start(Seconds(2.0));
clientApps.Stop(Seconds(10.0));
clientApps.Start(Seconds(2));
clientApps.Stop(Seconds(10));
For the echo client, however, we need to set five different ``Attributes``.
The first two ``Attributes`` are set during construction of the
@@ -668,11 +668,11 @@ When we previously called the methods,
::
serverApps.Start(Seconds(1.0));
serverApps.Stop(Seconds(10.0));
serverApps.Start(Seconds(1));
serverApps.Stop(Seconds(10));
...
clientApps.Start(Seconds(2.0));
clientApps.Stop(Seconds(10.0));
clientApps.Start(Seconds(2));
clientApps.Stop(Seconds(10));
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
@@ -758,7 +758,7 @@ in the first example program will schedule an explicit stop at 11 seconds:
::
+ Simulator::Stop(Seconds(11.0));
+ Simulator::Stop(Seconds(11));
Simulator::Run();
Simulator::Destroy();
return 0;

View File

@@ -1518,8 +1518,8 @@ The most common way to start pumping events is to start an
(hopefully) familiar lines of an |ns3| script::
ApplicationContainer apps = ...
apps.Start(Seconds(1.0));
apps.Stop(Seconds(10.0));
apps.Start(Seconds(1));
apps.Stop(Seconds(10));
The application container code (see
``src/network/helper/application-container.h`` if you are interested)