--- a/doc/tutorial/building-topologies.texi Mon Jul 07 12:52:48 2008 +0100
+++ b/doc/tutorial/building-topologies.texi Tue Jul 08 14:18:50 2008 +0100
@@ -149,8 +149,8 @@
@verbatim
PointToPointHelper pointToPoint;
- pointToPoint.SetDeviceParameter ("DataRate", StringValue ("5Mbps"));
- pointToPoint.SetChannelParameter ("Delay", StringValue ("2ms"));
+ pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
+ pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));
NetDeviceContainer p2pDevices;
p2pDevices = pointToPoint.Install (p2pNodes);
@@ -227,9 +227,15 @@
nodes that has a CSMA node and the client on the node having only a
point-to-point device.
-First, we set up the echo server.
+First, we set up the echo server. We create a @code{UdpEchoServerHelper} and
+provide a required attribute value to the constructor which is the server port
+number. Recall that this port can be changed later using the
+@code{SetAttribute} method if desired, but we require it to be provided to
+the constructor.
@verbatim
+ UdpEchoServerHelper echoServer (9);
+
ApplicationContainer serverApps = echoServer.Install (csmaNodes.Get (nCsma));
serverApps.Start (Seconds (1.0));
serverApps.Stop (Seconds (10.0));
@@ -246,16 +252,17 @@
code.
The client application is set up exactly as we did in the @code{first.cc}
-example script. We tell the client to send packets to the server we just
-installed on the last of the ``extra'' CSMA nodes. We install the client on
-the leftmost point-to-point node seen in the topology illustration.
+example script. Again, we provide required attributes to the
+@code{UdpEchoClientHelper} in the constructor (in this case the remote address
+and port). We tell the client to send packets to the server we just installed
+on the last of the ``extra'' CSMA nodes. We install the client on the
+leftmost point-to-point node seen in the topology illustration.
@verbatim
- UdpEchoClientHelper echoClient;
- echoClient.SetRemote (csmaInterfaces.GetAddress (nCsma), 9);
- echoClient.SetAppAttribute ("MaxPackets", UintegerValue (1));
- echoClient.SetAppAttribute ("Interval", TimeValue (Seconds (1.)));
- echoClient.SetAppAttribute ("PacketSize", UintegerValue (1024));
+ UdpEchoClientHelper echoClient (csmaInterfaces.GetAddress (nCsma), 9);
+ echoClient.SetAttribute ("MaxPackets", UintegerValue (1));
+ echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.)));
+ echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
ApplicationContainer clientApps = echoClient.Install (p2pNodes.Get (0));
clientApps.Start (Seconds (2.0));
@@ -669,8 +676,8 @@
@verbatim
PointToPointHelper pointToPoint;
- pointToPoint.SetDeviceParameter ("DataRate", StringValue ("5Mbps"));
- pointToPoint.SetChannelParameter ("Delay", StringValue ("2ms"));
+ pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
+ pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));
NetDeviceContainer p2pDevices;
p2pDevices = pointToPoint.Install (p2pNodes);
@@ -964,8 +971,7 @@
start of the file. We have done this before.
@verbatim
- UdpEchoServerHelper echoServer;
- echoServer.SetPort (9);
+ UdpEchoServerHelper echoServer (9);
ApplicationContainer serverApps = echoServer.Install (csmaNodes.Get (nCsma));
serverApps.Start (Seconds (1.0));
@@ -976,11 +982,10 @@
the server on the CSMA network. We have also seen similar operations before.
@verbatim
- UdpEchoClientHelper echoClient;
- echoClient.SetRemote (csmaInterfaces.GetAddress (nCsma), 9);
- echoClient.SetAppAttribute ("MaxPackets", UintegerValue (1));
- echoClient.SetAppAttribute ("Interval", TimeValue (Seconds (1.)));
- echoClient.SetAppAttribute ("PacketSize", UintegerValue (1024));
+ UdpEchoClientHelper echoClient (csmaInterfaces.GetAddress (nCsma), 9);
+ echoClient.SetAttribute ("MaxPackets", UintegerValue (1));
+ echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.)));
+ echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
ApplicationContainer clientApps =
echoClient.Install (wifiStaNodes.Get (nWifi - 1));
--- a/doc/tutorial/conceptual-overview.texi Mon Jul 07 12:52:48 2008 +0100
+++ b/doc/tutorial/conceptual-overview.texi Tue Jul 08 14:18:50 2008 +0100
@@ -420,8 +420,8 @@
@verbatim
PointToPointHelper pointToPoint;
- pointToPoint.SetDeviceParameter ("DataRate", StringValue ("5Mbps"));
- pointToPoint.SetChannelParameter ("Delay", StringValue ("2ms"));
+ pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
+ pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));
@end verbatim
The first line
@@ -434,7 +434,7 @@
high-level perspective the next line,
@verbatim
- pointToPoint.SetDeviceParameter ("DataRate", StringValue ("5Mbps"));
+ pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
@end verbatim
tells the @code{PointToPointHelper} object to use the value ``5mbps''
@@ -455,7 +455,7 @@
final line,
@verbatim
- pointToPoint.SetChannelParameter ("Delay", StringValue ("2ms"));
+ pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));
@end verbatim
tells the @code{PointToPointHelper} to use the value ``2ms'' (two milliseconds)
@@ -565,8 +565,7 @@
created.
@verbatim
- UdpEchoServerHelper echoServer;
- echoServer.SetPort (9);
+ UdpEchoServerHelper echoServer (9);
ApplicationContainer serverApps = echoServer.Install (nodes.Get (1));
serverApps.Start (Seconds (1.0));
@@ -575,10 +574,14 @@
The first line of code in the above snippet declares the
@code{UdpEchoServerHelper}. As usual, this isn't the application itself, it
-is an object used to help us create the actual applications. The second line
-that has the @code{SetPort} call, is used to tell the helper to assign the
-value nine to the ``Port'' attribute when creating
-@code{UdpEchoServerApplication} objects.
+is an object used to help us create the actual applications. One of our
+conventions is to place required attributes in the helper constructor. In this
+case, the helper can't do anything useful unless it is provided with a port
+number that the client also knows about. Rather than just picking one and
+hoping it all works out, we require the port number as a parameter to the
+constructor. The constructor, in turn, simply does a @code{SetAttribute}
+with the passed value. You can, if desired, set the ``Port'' attribute to
+another value later.
Similar to many other helper objects, the @code{UdpEchoServerHelper} object
has an @code{Install} method. It is the execution of this method that actually
@@ -621,32 +624,32 @@
that is managed by an @code{UdpEchoClientHelper}.
@verbatim
- UdpEchoClientHelper echoClient;
- echoClient.SetRemote (interfaces.GetAddress (1), 9);
- echoClient.SetAppAttribute ("MaxPackets", UintegerValue (1));
- echoClient.SetAppAttribute ("Interval", TimeValue (Seconds (1.)));
- echoClient.SetAppAttribute ("PacketSize", UintegerValue (1024));
+ UdpEchoClientHelper echoClient (interfaces.GetAddress (1), 9);
+ echoClient.SetAttribute ("MaxPackets", UintegerValue (1));
+ 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));
@end verbatim
-For the echo client, however, we need to set four different attributes. The
-first attribute is set using the @code{SetRemote} method. Recall that
-we used an @code{Ipv4InterfaceContainer} to keep track of the IP addresses we
-assigned to our devices. The zeroth interface in the @code{interfaces}
-container is going to coorespond to the IP address of the zeroth node in the
-@code{nodes} container. The first interface in the @code{interfaces}
-container cooresponds to the IP address of the first node in the @code{nodes}
-container. So, in the following line of code (reproduced from above), we are
-setting the remote address of the client to be the IP address assigned to the
-node on which the server resides. We also tell it to send packets to port
-nine while we are at ti.
+For the echo client, however, we need to set five different attributes. The
+first two attributes are set during construction of the
+@code{UdpEchoClientHelper}. We pass parameters that are used (internally to
+the helper) to set the ``RemoteAddress'' and ``RemotePort'' attributes in
+accordance with our convention to make required attributes parameters in the
+helper constructors.
-@verbatim
- echoClient.SetRemote (interfaces.GetAddress (1), 9);
-@end verbatim
+Recall that we used an @code{Ipv4InterfaceContainer} to keep track of the IP
+addresses we assigned to our devices. The zeroth interface in the
+@code{interfaces} container is going to coorespond to the IP address of the
+zeroth node in the @code{nodes} container. The first interface in the
+@code{interfaces} container cooresponds to the IP address of the first node
+in the @code{nodes} container. So, in the first line of code (from above), we
+are creating the helper and telling it so set the remote address of the client
+to be the IP address assigned to the node on which the server resides. We
+also tell it to arrange to send packets to port nine.
The ``MaxPackets'' attribute tells the client the maximum number of packets
we allow it to send during the simulation. The ``Interval'' attribute tells
--- a/doc/tutorial/tweaking.texi Mon Jul 07 12:52:48 2008 +0100
+++ b/doc/tutorial/tweaking.texi Tue Jul 08 14:18:50 2008 +0100
@@ -462,8 +462,8 @@
@verbatim
PointToPointHelper pointToPoint;
- pointToPoint.SetDeviceParameter ("DataRate", StringValue ("5Mbps"));
- pointToPoint.SetChannelParameter ("Delay", StringValue ("2ms"));
+ pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
+ pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));
@end verbatim
and mentioned that @code{DataRate} was actually an @code{Attribute} of the
@@ -486,10 +486,10 @@
@end verbatim
This is the default value that will be used when a @code{PointToPointNetDevice}
-is created in the system. We overrode this default with the ``parameter''
+is created in the system. We overrode this default with the attribute
setting in the @code{PointToPointHelper} above. Let's use the default values
for the point-to-point devices and channels by deleting the
-@code{SetDeviceParameter} call and the @code{SetChannelParameter} call from
+@code{SetDeviceAttribute} call and the @code{SetChannelAttribute} call from
the @code{first.cc} we have in the scratch directory.
Your script should now just declare the @code{PointToPointHelper} and not do
--- a/examples/csma-broadcast.cc Mon Jul 07 12:52:48 2008 +0100
+++ b/examples/csma-broadcast.cc Tue Jul 08 14:18:50 2008 +0100
@@ -69,8 +69,8 @@
NS_LOG_INFO ("Build Topology.");
CsmaHelper csma;
- csma.SetChannelParameter ("DataRate", DataRateValue (DataRate(5000000)));
- csma.SetChannelParameter ("Delay", TimeValue (MilliSeconds(2)));
+ csma.SetChannelAttribute ("DataRate", DataRateValue (DataRate(5000000)));
+ csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds(2)));
NetDeviceContainer n0 = csma.Install (c0);
NetDeviceContainer n1 = csma.Install (c1);
--- a/examples/csma-multicast.cc Mon Jul 07 12:52:48 2008 +0100
+++ b/examples/csma-multicast.cc Tue Jul 08 14:18:50 2008 +0100
@@ -75,8 +75,8 @@
NS_LOG_INFO ("Build Topology.");
CsmaHelper csma;
- csma.SetChannelParameter ("DataRate", DataRateValue (DataRate (5000000)));
- csma.SetChannelParameter ("Delay", TimeValue (MilliSeconds (2)));
+ csma.SetChannelAttribute ("DataRate", DataRateValue (DataRate (5000000)));
+ csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2)));
// We will use these NetDevice containers later, for IP addressing
NetDeviceContainer nd0 = csma.Install (c0); // First LAN
--- a/examples/csma-one-subnet.cc Mon Jul 07 12:52:48 2008 +0100
+++ b/examples/csma-one-subnet.cc Tue Jul 08 14:18:50 2008 +0100
@@ -66,8 +66,8 @@
NS_LOG_INFO ("Build Topology");
CsmaHelper csma;
- csma.SetChannelParameter ("DataRate", DataRateValue (5000000));
- csma.SetChannelParameter ("Delay", TimeValue (MilliSeconds (2)));
+ csma.SetChannelAttribute ("DataRate", DataRateValue (5000000));
+ csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2)));
//
// Now fill out the topology by creating the net devices required to connect
// the nodes to the channels and hooking them up. AddIpv4CsmaNetDevice will
--- a/examples/csma-packet-socket.cc Mon Jul 07 12:52:48 2008 +0100
+++ b/examples/csma-packet-socket.cc Tue Jul 08 14:18:50 2008 +0100
@@ -74,7 +74,7 @@
// use a helper function to connect our nodes to the shared channel.
NS_LOG_INFO ("Build Topology.");
CsmaHelper csma;
- csma.SetDeviceParameter ("EncapsulationMode", StringValue ("Llc"));
+ csma.SetDeviceAttribute ("EncapsulationMode", StringValue ("Llc"));
NetDeviceContainer devs = csma.Install (c, channel);
NS_LOG_INFO ("Create Applications.");
--- a/examples/first.cc Mon Jul 07 12:52:48 2008 +0100
+++ b/examples/first.cc Tue Jul 08 14:18:50 2008 +0100
@@ -33,8 +33,8 @@
nodes.Create (2);
PointToPointHelper pointToPoint;
- pointToPoint.SetDeviceParameter ("DataRate", StringValue ("5Mbps"));
- pointToPoint.SetChannelParameter ("Delay", StringValue ("2ms"));
+ pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
+ pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));
NetDeviceContainer devices;
devices = pointToPoint.Install (nodes);
@@ -47,18 +47,16 @@
Ipv4InterfaceContainer interfaces = address.Assign (devices);
- UdpEchoServerHelper echoServer;
- echoServer.SetPort (9);
+ UdpEchoServerHelper echoServer (9);
ApplicationContainer serverApps = echoServer.Install (nodes.Get (1));
serverApps.Start (Seconds (1.0));
serverApps.Stop (Seconds (10.0));
- UdpEchoClientHelper echoClient;
- echoClient.SetRemote (interfaces.GetAddress (1), 9);
- echoClient.SetAppAttribute ("MaxPackets", UintegerValue (1));
- echoClient.SetAppAttribute ("Interval", TimeValue (Seconds (1.)));
- echoClient.SetAppAttribute ("PacketSize", UintegerValue (1024));
+ UdpEchoClientHelper echoClient (interfaces.GetAddress (1), 9);
+ echoClient.SetAttribute ("MaxPackets", UintegerValue (1));
+ echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.)));
+ echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
ApplicationContainer clientApps = echoClient.Install (nodes.Get (0));
clientApps.Start (Seconds (2.0));
--- a/examples/mixed-global-routing.cc Mon Jul 07 12:52:48 2008 +0100
+++ b/examples/mixed-global-routing.cc Tue Jul 08 14:18:50 2008 +0100
@@ -71,20 +71,20 @@
// We create the channels first without any IP addressing information
NS_LOG_INFO ("Create channels.");
PointToPointHelper p2p;
- p2p.SetDeviceParameter ("DataRate", StringValue ("5Mbps"));
- p2p.SetChannelParameter ("Delay", StringValue ("2ms"));
+ p2p.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
+ p2p.SetChannelAttribute ("Delay", StringValue ("2ms"));
NetDeviceContainer d0d2 = p2p.Install (n0n2);
NetDeviceContainer d1d2 = p2p.Install (n1n2);
- p2p.SetDeviceParameter ("DataRate", StringValue ("1500kbps"));
- p2p.SetChannelParameter ("Delay", StringValue ("10ms"));
+ p2p.SetDeviceAttribute ("DataRate", StringValue ("1500kbps"));
+ p2p.SetChannelAttribute ("Delay", StringValue ("10ms"));
NetDeviceContainer d5d6 = p2p.Install (n5n6);
// We create the channels first without any IP addressing information
CsmaHelper csma;
- csma.SetChannelParameter ("DataRate", StringValue ("5Mbps"));
- csma.SetChannelParameter ("Delay", StringValue ("2ms"));
+ csma.SetChannelAttribute ("DataRate", StringValue ("5Mbps"));
+ csma.SetChannelAttribute ("Delay", StringValue ("2ms"));
NetDeviceContainer d2345 = csma.Install (n2345);
// Later, we add IP addresses.
--- a/examples/mixed-wireless.cc Mon Jul 07 12:52:48 2008 +0100
+++ b/examples/mixed-wireless.cc Tue Jul 08 14:18:50 2008 +0100
@@ -200,9 +200,9 @@
// collection.
//
CsmaHelper csma;
- csma.SetChannelParameter ("DataRate",
+ csma.SetChannelAttribute ("DataRate",
DataRateValue (DataRate (5000000)));
- csma.SetChannelParameter ("Delay", TimeValue (MilliSeconds (2)));
+ csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2)));
NetDeviceContainer lanDevices = csma.Install (lan);
//
// Add the IPv4 protocol stack to the new LAN nodes
--- a/examples/second.cc Mon Jul 07 12:52:48 2008 +0100
+++ b/examples/second.cc Tue Jul 08 14:18:50 2008 +0100
@@ -52,8 +52,8 @@
csmaNodes.Create (nCsma);
PointToPointHelper pointToPoint;
- pointToPoint.SetDeviceParameter ("DataRate", StringValue ("5Mbps"));
- pointToPoint.SetChannelParameter ("Delay", StringValue ("2ms"));
+ pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
+ pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));
NetDeviceContainer p2pDevices;
p2pDevices = pointToPoint.Install (p2pNodes);
@@ -76,18 +76,16 @@
Ipv4InterfaceContainer csmaInterfaces;
csmaInterfaces = address.Assign (csmaDevices);
- UdpEchoServerHelper echoServer;
- echoServer.SetPort (9);
+ UdpEchoServerHelper echoServer (9);
ApplicationContainer serverApps = echoServer.Install (csmaNodes.Get (nCsma));
serverApps.Start (Seconds (1.0));
serverApps.Stop (Seconds (10.0));
- UdpEchoClientHelper echoClient;
- echoClient.SetRemote (csmaInterfaces.GetAddress (nCsma), 9);
- echoClient.SetAppAttribute ("MaxPackets", UintegerValue (1));
- echoClient.SetAppAttribute ("Interval", TimeValue (Seconds (1.)));
- echoClient.SetAppAttribute ("PacketSize", UintegerValue (1024));
+ UdpEchoClientHelper echoClient (csmaInterfaces.GetAddress (nCsma), 9);
+ echoClient.SetAttribute ("MaxPackets", UintegerValue (1));
+ echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.)));
+ echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
ApplicationContainer clientApps = echoClient.Install (p2pNodes.Get (0));
clientApps.Start (Seconds (2.0));
--- a/examples/simple-alternate-routing.cc Mon Jul 07 12:52:48 2008 +0100
+++ b/examples/simple-alternate-routing.cc Tue Jul 08 14:18:50 2008 +0100
@@ -97,17 +97,17 @@
// We create the channels first without any IP addressing information
NS_LOG_INFO ("Create channels.");
PointToPointHelper p2p;
- p2p.SetDeviceParameter ("DataRate", StringValue ("5Mbps"));
- p2p.SetChannelParameter ("Delay", StringValue ("2ms"));
+ p2p.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
+ p2p.SetChannelAttribute ("Delay", StringValue ("2ms"));
NetDeviceContainer d0d2 = p2p.Install (n0n2);
NetDeviceContainer d1d2 = p2p.Install (n1n2);
- p2p.SetDeviceParameter ("DataRate", StringValue ("1500kbps"));
- p2p.SetChannelParameter ("Delay", StringValue ("10ms"));
+ p2p.SetDeviceAttribute ("DataRate", StringValue ("1500kbps"));
+ p2p.SetChannelAttribute ("Delay", StringValue ("10ms"));
NetDeviceContainer d3d2 = p2p.Install (n3n2);
- p2p.SetChannelParameter ("Delay", StringValue ("100ms"));
+ p2p.SetChannelAttribute ("Delay", StringValue ("100ms"));
NetDeviceContainer d1d3 = p2p.Install (n1n3);
InternetStackHelper internet;
--- a/examples/simple-error-model.cc Mon Jul 07 12:52:48 2008 +0100
+++ b/examples/simple-error-model.cc Tue Jul 08 14:18:50 2008 +0100
@@ -64,7 +64,7 @@
//
RandomVariable::UseGlobalSeed (1, 1, 2, 3, 5, 8);
- // Set a few parameters
+ // Set a few attributes
Config::SetDefault ("ns3::RateErrorModel::ErrorRate", DoubleValue (0.01));
Config::SetDefault ("ns3::RateErrorModel::ErrorUnit", StringValue ("EU_PKT"));
@@ -92,14 +92,14 @@
// We create the channels first without any IP addressing information
NS_LOG_INFO ("Create channels.");
PointToPointHelper p2p;
- p2p.SetDeviceParameter ("DataRate", DataRateValue (DataRate (5000000)));
- p2p.SetChannelParameter ("Delay", TimeValue (MilliSeconds (2)));
+ p2p.SetDeviceAttribute ("DataRate", DataRateValue (DataRate (5000000)));
+ p2p.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2)));
NetDeviceContainer d0d2 = p2p.Install (n0n2);
NetDeviceContainer d1d2 = p2p.Install (n1n2);
- p2p.SetDeviceParameter ("DataRate", DataRateValue (DataRate (1500000)));
- p2p.SetChannelParameter ("Delay", TimeValue (MilliSeconds (10)));
+ p2p.SetDeviceAttribute ("DataRate", DataRateValue (DataRate (1500000)));
+ p2p.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (10)));
NetDeviceContainer d3d2 = p2p.Install (n3n2);
// Later, we add IP addresses.
--- a/examples/simple-global-routing.cc Mon Jul 07 12:52:48 2008 +0100
+++ b/examples/simple-global-routing.cc Tue Jul 08 14:18:50 2008 +0100
@@ -92,14 +92,14 @@
// We create the channels first without any IP addressing information
NS_LOG_INFO ("Create channels.");
PointToPointHelper p2p;
- p2p.SetDeviceParameter ("DataRate", StringValue ("5Mbps"));
- p2p.SetChannelParameter ("Delay", StringValue ("2ms"));
+ p2p.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
+ p2p.SetChannelAttribute ("Delay", StringValue ("2ms"));
NetDeviceContainer d0d2 = p2p.Install (n0n2);
NetDeviceContainer d1d2 = p2p.Install (n1n2);
- p2p.SetDeviceParameter ("DataRate", StringValue ("1500kbps"));
- p2p.SetChannelParameter ("Delay", StringValue ("10ms"));
+ p2p.SetDeviceAttribute ("DataRate", StringValue ("1500kbps"));
+ p2p.SetChannelAttribute ("Delay", StringValue ("10ms"));
NetDeviceContainer d3d2 = p2p.Install (n3n2);
// Later, we add IP addresses.
--- a/examples/simple-point-to-point-olsr.cc Mon Jul 07 12:52:48 2008 +0100
+++ b/examples/simple-point-to-point-olsr.cc Tue Jul 08 14:18:50 2008 +0100
@@ -93,12 +93,12 @@
// We create the channels first without any IP addressing information
NS_LOG_INFO ("Create channels.");
PointToPointHelper p2p;
- p2p.SetDeviceParameter ("DataRate", StringValue ("5Mbps"));
- p2p.SetChannelParameter ("Delay", StringValue ("2ms"));
+ p2p.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
+ p2p.SetChannelAttribute ("Delay", StringValue ("2ms"));
NetDeviceContainer nd02 = p2p.Install (n02);
NetDeviceContainer nd12 = p2p.Install (n12);
- p2p.SetDeviceParameter ("DataRate", StringValue ("1500kbps"));
- p2p.SetChannelParameter ("Delay", StringValue ("10ms"));
+ p2p.SetDeviceAttribute ("DataRate", StringValue ("1500kbps"));
+ p2p.SetChannelAttribute ("Delay", StringValue ("10ms"));
NetDeviceContainer nd32 = p2p.Install (n32);
NetDeviceContainer nd34 = p2p.Install (n34);
--- a/examples/tcp-large-transfer.cc Mon Jul 07 12:52:48 2008 +0100
+++ b/examples/tcp-large-transfer.cc Tue Jul 08 14:18:50 2008 +0100
@@ -90,10 +90,10 @@
// We create the channels first without any IP addressing information
// First make and configure the helper, so that it will put the appropriate
- // parameters on the network interfaces and channels we are about to install.
+ // attributes on the network interfaces and channels we are about to install.
PointToPointHelper p2p;
- p2p.SetDeviceParameter ("DataRate", DataRateValue (DataRate(10000000)));
- p2p.SetChannelParameter ("Delay", TimeValue (MilliSeconds(10)));
+ p2p.SetDeviceAttribute ("DataRate", DataRateValue (DataRate(10000000)));
+ p2p.SetChannelAttribute ("Delay", TimeValue (MilliSeconds(10)));
// And then install devices and channels connecting our topology.
NetDeviceContainer dev0 = p2p.Install (n0n1);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/tcp-star-server.cc Tue Jul 08 14:18:50 2008 +0100
@@ -0,0 +1,172 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+
+// Default Network topology, 9 nodes in a star
+/*
+ n2 n3 n4
+ \ | /
+ \|/
+ n1---n0---n5
+ /|\
+ / | \
+ n8 n7 n6
+*/
+// - CBR Traffic goes from the star "arms" to the "hub"
+// - Tracing of queues and packet receptions to file
+// "tcp-star-server.tr"
+// - pcap traces also generated in the following files
+// "tcp-star-server-$n-$i.pcap" where n and i represent node and interface
+// numbers respectively
+// Usage examples for things you might want to tweak:
+// ./waf --run="tcp-star-server"
+// ./waf --run="tcp-star-server --nNodes=25"
+// ./waf --run="tcp-star-server --ns3::OnOffApplication::DataRate=10000"
+// ./waf --run="tcp-star-server --ns3::OnOffApplication::PacketSize=500"
+// See the ns-3 tutorial for more info on the command line:
+// http://www.nsnam.org/tutorials.html
+
+
+
+
+#include <iostream>
+#include <fstream>
+#include <string>
+#include <cassert>
+
+#include "ns3/core-module.h"
+#include "ns3/simulator-module.h"
+#include "ns3/node-module.h"
+#include "ns3/helper-module.h"
+#include "ns3/global-route-manager.h"
+
+using namespace ns3;
+
+NS_LOG_COMPONENT_DEFINE ("TcpServer");
+
+int
+main (int argc, char *argv[])
+{
+ // Users may find it convenient to turn on explicit debugging
+ // for selected modules; the below lines suggest how to do this
+
+ //LogComponentEnable ("TcpServer", LOG_LEVEL_INFO);
+ //LogComponentEnable ("TcpL4Protocol", LOG_LEVEL_ALL);
+ //LogComponentEnable ("TcpSocketImpl", LOG_LEVEL_ALL);
+ //LogComponentEnable ("PacketSink", LOG_LEVEL_ALL);
+ //
+ // Make the random number generators generate reproducible results.
+ //
+ RandomVariable::UseGlobalSeed (1, 1, 2, 3, 5, 8);
+
+ // Set up some default values for the simulation.
+ Config::SetDefault ("ns3::OnOffApplication::PacketSize", UintegerValue (250));
+ Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue ("5kb/s"));
+ uint32_t N = 9; //number of nodes in the star
+
+ // Allow the user to override any of the defaults and the above
+ // Config::SetDefault()s at run-time, via command-line arguments
+ CommandLine cmd;
+ cmd.AddValue("nNodes", "Number of nodes to place in the star", N);
+ cmd.Parse (argc, argv);
+
+ // Here, we will create N nodes in a star.
+ NS_LOG_INFO ("Create nodes.");
+ NodeContainer serverNode;
+ NodeContainer clientNodes;
+ serverNode.Create(1);
+ clientNodes.Create(N-1);
+ NodeContainer allNodes = NodeContainer(serverNode, clientNodes);
+
+ // Install network stacks on the nodes
+ InternetStackHelper internet;
+ internet.Install (allNodes);
+
+ //Collect an adjacency list of nodes for the p2p topology
+ std::vector<NodeContainer> nodeAdjacencyList(N-1);
+ for(uint32_t i=0; i<nodeAdjacencyList.size(); ++i)
+ {
+ nodeAdjacencyList[i] = NodeContainer (serverNode, clientNodes.Get (i));
+ }
+
+ // We create the channels first without any IP addressing information
+ NS_LOG_INFO ("Create channels.");
+ PointToPointHelper p2p;
+ p2p.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
+ p2p.SetChannelAttribute ("Delay", StringValue ("2ms"));
+ std::vector<NetDeviceContainer> deviceAdjacencyList(N-1);
+ for(uint32_t i=0; i<deviceAdjacencyList.size(); ++i)
+ {
+ deviceAdjacencyList[i] = p2p.Install (nodeAdjacencyList[i]);
+ }
+
+ // Later, we add IP addresses.
+ NS_LOG_INFO ("Assign IP Addresses.");
+ Ipv4AddressHelper ipv4;
+ std::vector<Ipv4InterfaceContainer> interfaceAdjacencyList(N-1);
+ for(uint32_t i=0; i<interfaceAdjacencyList.size(); ++i)
+ {
+ std::ostringstream subnet;
+ subnet<<"10.1."<<i+1<<".0";
+ ipv4.SetBase (subnet.str().c_str(), "255.255.255.0");
+ interfaceAdjacencyList[i] = ipv4.Assign (deviceAdjacencyList[i]);
+ }
+
+ //Turn on global static routing
+ GlobalRouteManager::PopulateRoutingTables ();
+
+ // Create a packet sink on the star "hub" to receive these packets
+ uint16_t port = 50000;
+ Address sinkLocalAddress(InetSocketAddress (Ipv4Address::GetAny (), port));
+ PacketSinkHelper sinkHelper ("ns3::TcpSocketFactory", sinkLocalAddress);
+ ApplicationContainer sinkApp = sinkHelper.Install (serverNode);
+ sinkApp.Start (Seconds (1.0));
+ sinkApp.Stop (Seconds (10.0));
+
+ // Create the OnOff applications to send TCP to the server
+ OnOffHelper clientHelper ("ns3::TcpSocketFactory", Address ());
+ clientHelper.SetAttribute
+ ("OnTime", RandomVariableValue (ConstantVariable (1)));
+ clientHelper.SetAttribute
+ ("OffTime", RandomVariableValue (ConstantVariable (0)));
+ //normally wouldn't need a loop here but the server IP address is different
+ //on each p2p subnet
+ ApplicationContainer clientApps;
+ for(uint32_t i=0; i<clientNodes.GetN(); ++i)
+ {
+ AddressValue remoteAddress
+ (InetSocketAddress (interfaceAdjacencyList[i].GetAddress (0), port));
+ clientHelper.SetAttribute ("Remote", remoteAddress);
+ clientApps.Add(clientHelper.Install (clientNodes.Get(i)));
+ }
+ clientApps.Start (Seconds (1.0));
+ clientApps.Stop (Seconds (10.0));
+
+
+ //configure tracing
+ std::ofstream ascii;
+ ascii.open ("tcp-star-server.tr");
+ PointToPointHelper::EnablePcapAll ("tcp-star-server");
+ PointToPointHelper::EnableAsciiAll (ascii);
+
+ NS_LOG_INFO ("Run Simulation.");
+ Simulator::Run ();
+ Simulator::Destroy ();
+ NS_LOG_INFO ("Done.");
+
+ return 0;
+}
--- a/examples/third.cc Mon Jul 07 12:52:48 2008 +0100
+++ b/examples/third.cc Tue Jul 08 14:18:50 2008 +0100
@@ -54,8 +54,8 @@
p2pNodes.Create (2);
PointToPointHelper pointToPoint;
- pointToPoint.SetDeviceParameter ("DataRate", StringValue ("5Mbps"));
- pointToPoint.SetChannelParameter ("Delay", StringValue ("2ms"));
+ pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
+ pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));
NetDeviceContainer p2pDevices;
p2pDevices = pointToPoint.Install (p2pNodes);
@@ -141,18 +141,16 @@
address.Assign (staDevices);
address.Assign (apDevices);
- UdpEchoServerHelper echoServer;
- echoServer.SetPort (9);
+ UdpEchoServerHelper echoServer (9);
ApplicationContainer serverApps = echoServer.Install (csmaNodes.Get (nCsma));
serverApps.Start (Seconds (1.0));
serverApps.Stop (Seconds (10.0));
- UdpEchoClientHelper echoClient;
- echoClient.SetRemote (csmaInterfaces.GetAddress (nCsma), 9);
- echoClient.SetAppAttribute ("MaxPackets", UintegerValue (1));
- echoClient.SetAppAttribute ("Interval", TimeValue (Seconds (1.)));
- echoClient.SetAppAttribute ("PacketSize", UintegerValue (1024));
+ UdpEchoClientHelper echoClient (csmaInterfaces.GetAddress (nCsma), 9);
+ echoClient.SetAttribute ("MaxPackets", UintegerValue (1));
+ echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.)));
+ echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
ApplicationContainer clientApps =
echoClient.Install (wifiStaNodes.Get (nWifi - 1));
--- a/examples/udp-echo.cc Mon Jul 07 12:52:48 2008 +0100
+++ b/examples/udp-echo.cc Tue Jul 08 14:18:50 2008 +0100
@@ -87,8 +87,8 @@
// Explicitly create the channels required by the topology (shown above).
//
CsmaHelper csma;
- csma.SetChannelParameter ("DataRate", DataRateValue (DataRate(5000000)));
- csma.SetChannelParameter ("Delay", TimeValue (MilliSeconds (2)));
+ csma.SetChannelAttribute ("DataRate", DataRateValue (DataRate(5000000)));
+ csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2)));
NetDeviceContainer d = csma.Install (n);
Ipv4AddressHelper ipv4;
@@ -104,8 +104,7 @@
// Create a UdpEchoServer application on node one.
//
uint16_t port = 9; // well-known echo port number
- UdpEchoServerHelper server;
- server.SetPort (port);
+ UdpEchoServerHelper server (port);
ApplicationContainer apps = server.Install (n.Get(1));
apps.Start (Seconds (1.0));
apps.Stop (Seconds (10.0));
@@ -117,11 +116,10 @@
uint32_t packetSize = 1024;
uint32_t maxPacketCount = 1;
Time interPacketInterval = Seconds (1.);
- UdpEchoClientHelper client;
- client.SetRemote (i.GetAddress (1), port);
- client.SetAppAttribute ("MaxPackets", UintegerValue (maxPacketCount));
- client.SetAppAttribute ("Interval", TimeValue (interPacketInterval));
- client.SetAppAttribute ("PacketSize", UintegerValue (packetSize));
+ UdpEchoClientHelper client (i.GetAddress (1), port);
+ client.SetAttribute ("MaxPackets", UintegerValue (maxPacketCount));
+ client.SetAttribute ("Interval", TimeValue (interPacketInterval));
+ client.SetAttribute ("PacketSize", UintegerValue (packetSize));
apps = client.Install (n.Get (0));
apps.Start (Seconds (2.0));
apps.Stop (Seconds (10.0));
--- a/examples/wscript Mon Jul 07 12:52:48 2008 +0100
+++ b/examples/wscript Tue Jul 08 14:18:50 2008 +0100
@@ -56,6 +56,10 @@
['point-to-point', 'internet-stack'])
obj.source = 'tcp-large-transfer.cc'
+ obj = bld.create_ns3_program('tcp-star-server',
+ ['point-to-point', 'internet-stack'])
+ obj.source = 'tcp-star-server.cc'
+
obj = bld.create_ns3_program('wifi-adhoc',
['core', 'simulator', 'mobility', 'wifi'])
obj.source = 'wifi-adhoc.cc'
--- a/src/applications/packet-sink/packet-sink.cc Mon Jul 07 12:52:48 2008 +0100
+++ b/src/applications/packet-sink/packet-sink.cc Tue Jul 08 14:18:50 2008 +0100
@@ -95,6 +95,7 @@
{
if (m_socket)
{
+ m_socket->Close ();
m_socket->SetRecvCallback (MakeNullCallback<void, Ptr<Socket> > ());
}
}
--- a/src/applications/udp-echo/udp-echo-client.cc Mon Jul 07 12:52:48 2008 +0100
+++ b/src/applications/udp-echo/udp-echo-client.cc Tue Jul 08 14:18:50 2008 +0100
@@ -47,8 +47,8 @@
TimeValue (Seconds (1.0)),
MakeTimeAccessor (&UdpEchoClient::m_interval),
MakeTimeChecker ())
- .AddAttribute ("RemoteIpv4",
- "The Ipv4Address of the outbound packets",
+ .AddAttribute ("RemoteAddress",
+ "The destination Ipv4Address of the outbound packets",
Ipv4AddressValue (),
MakeIpv4AddressAccessor (&UdpEchoClient::m_peerAddress),
MakeIpv4AddressChecker ())
--- a/src/common/buffer.h Mon Jul 07 12:52:48 2008 +0100
+++ b/src/common/buffer.h Tue Jul 08 14:18:50 2008 +0100
@@ -536,6 +536,7 @@
#ifdef BUFFER_USE_INLINE
#include "ns3/assert.h"
+#include <string.h>
namespace ns3 {
--- a/src/common/data-rate.cc Mon Jul 07 12:52:48 2008 +0100
+++ b/src/common/data-rate.cc Tue Jul 08 14:18:50 2008 +0100
@@ -29,7 +29,10 @@
std::string::size_type n = s.find_first_not_of("0123456789.");
if (n != std::string::npos)
{ // Found non-numeric
- double r = ::atof(s.substr(0, n).c_str());
+ std::istringstream iss;
+ iss.str (s.substr(0, n));
+ double r;
+ iss >> r;
std::string trailer = s.substr(n, std::string::npos);
if (trailer == "bps")
{
@@ -117,7 +120,9 @@
}
return true;
}
- *v = ::atoll(s.c_str());
+ std::istringstream iss;
+ iss.str (s);
+ iss >> *v;
return true;
}
--- a/src/common/error-model.cc Mon Jul 07 12:52:48 2008 +0100
+++ b/src/common/error-model.cc Tue Jul 08 14:18:50 2008 +0100
@@ -178,7 +178,7 @@
RateErrorModel::DoCorrupt (Ptr<Packet> p)
{
NS_LOG_FUNCTION_NOARGS ();
- if (!m_enable)
+ if (!IsEnabled ())
{
return false;
}
@@ -275,7 +275,7 @@
ListErrorModel::DoCorrupt (Ptr<Packet> p)
{
NS_LOG_FUNCTION_NOARGS ();
- if (!m_enable)
+ if (!IsEnabled ())
{
return false;
}
--- a/src/common/error-model.h Mon Jul 07 12:52:48 2008 +0100
+++ b/src/common/error-model.h Tue Jul 08 14:18:50 2008 +0100
@@ -104,9 +104,6 @@
*/
bool IsEnabled (void) const;
-protected:
- bool m_enable;
-
private:
/*
* These methods must be implemented by subclasses
@@ -114,6 +111,7 @@
virtual bool DoCorrupt (Ptr<Packet>) = 0;
virtual void DoReset (void) = 0;
+ bool m_enable;
};
enum ErrorUnit
--- a/src/common/tag-list.cc Mon Jul 07 12:52:48 2008 +0100
+++ b/src/common/tag-list.cc Tue Jul 08 14:18:50 2008 +0100
@@ -20,6 +20,7 @@
#include "tag-list.h"
#include "ns3/log.h"
#include <vector>
+#include <string.h>
NS_LOG_COMPONENT_DEFINE ("TagList");
--- a/src/contrib/config-store.cc Mon Jul 07 12:52:48 2008 +0100
+++ b/src/contrib/config-store.cc Tue Jul 08 14:18:50 2008 +0100
@@ -8,6 +8,7 @@
#include <fstream>
#include <iostream>
#include <unistd.h>
+#include <stdlib.h>
NS_LOG_COMPONENT_DEFINE ("ConfigStore");
--- a/src/core/callback.h Mon Jul 07 12:52:48 2008 +0100
+++ b/src/core/callback.h Tue Jul 08 14:18:50 2008 +0100
@@ -25,6 +25,7 @@
#include "fatal-error.h"
#include "empty.h"
#include "type-traits.h"
+#include <typeinfo>
namespace ns3 {
--- a/src/core/double.h Mon Jul 07 12:52:48 2008 +0100
+++ b/src/core/double.h Tue Jul 08 14:18:50 2008 +0100
@@ -23,6 +23,7 @@
#include "attribute.h"
#include "attribute-helper.h"
#include <stdint.h>
+#include <limits>
namespace ns3 {
--- a/src/core/int-to-type.h Mon Jul 07 12:52:48 2008 +0100
+++ b/src/core/int-to-type.h Tue Jul 08 14:18:50 2008 +0100
@@ -11,7 +11,7 @@
template <int v>
struct IntToType
{
- enum {value = v};
+ enum v_e {value = v};
};
} // namespace ns3
--- a/src/core/integer.h Mon Jul 07 12:52:48 2008 +0100
+++ b/src/core/integer.h Tue Jul 08 14:18:50 2008 +0100
@@ -23,6 +23,7 @@
#include "attribute.h"
#include "attribute-helper.h"
#include <stdint.h>
+#include <limits>
namespace ns3 {
--- a/src/core/type-id.h Mon Jul 07 12:52:48 2008 +0100
+++ b/src/core/type-id.h Tue Jul 08 14:18:50 2008 +0100
@@ -44,7 +44,7 @@
class TypeId
{
public:
- enum {
+ enum AttributeFlag {
/**
* The attribute can be read
*/
--- a/src/core/uinteger.h Mon Jul 07 12:52:48 2008 +0100
+++ b/src/core/uinteger.h Tue Jul 08 14:18:50 2008 +0100
@@ -23,6 +23,7 @@
#include "attribute.h"
#include "attribute-helper.h"
#include <stdint.h>
+#include <limits>
namespace ns3 {
--- a/src/devices/wifi/jakes-propagation-loss-model.h Mon Jul 07 12:52:48 2008 +0100
+++ b/src/devices/wifi/jakes-propagation-loss-model.h Tue Jul 08 14:18:50 2008 +0100
@@ -97,7 +97,8 @@
* Set the number of oscillators to use to compute the ray coefficient
*/
void SetNOscillators (uint8_t nOscillators);
-protected:
+
+private:
class PathCoefficients;
struct ComplexNumber {
double real;
@@ -109,7 +110,7 @@
ComplexNumber* m_amp;
RandomVariable m_variable;
double m_fd;
-private:
+
typedef std::vector<PathCoefficients *> DestinationList;
struct PathsSet {
Ptr<MobilityModel> sender;
--- a/src/devices/wifi/status-code.h Mon Jul 07 12:52:48 2008 +0100
+++ b/src/devices/wifi/status-code.h Tue Jul 08 14:18:50 2008 +0100
@@ -21,6 +21,7 @@
#define STATUS_CODE_H
#include <stdint.h>
+#include <ostream>
#include "ns3/buffer.h"
namespace ns3 {
--- a/src/devices/wifi/supported-rates.h Mon Jul 07 12:52:48 2008 +0100
+++ b/src/devices/wifi/supported-rates.h Tue Jul 08 14:18:50 2008 +0100
@@ -21,6 +21,7 @@
#define SUPPORTED_RATES_H
#include <stdint.h>
+#include <ostream>
#include "ns3/buffer.h"
namespace ns3 {
--- a/src/helper/csma-helper.cc Mon Jul 07 12:52:48 2008 +0100
+++ b/src/helper/csma-helper.cc Tue Jul 08 14:18:50 2008 +0100
@@ -52,13 +52,13 @@
}
void
-CsmaHelper::SetDeviceParameter (std::string n1, const AttributeValue &v1)
+CsmaHelper::SetDeviceAttribute (std::string n1, const AttributeValue &v1)
{
m_deviceFactory.Set (n1, v1);
}
void
-CsmaHelper::SetChannelParameter (std::string n1, const AttributeValue &v1)
+CsmaHelper::SetChannelAttribute (std::string n1, const AttributeValue &v1)
{
m_channelFactory.Set (n1, v1);
}
--- a/src/helper/csma-helper.h Mon Jul 07 12:52:48 2008 +0100
+++ b/src/helper/csma-helper.h Tue Jul 08 14:18:50 2008 +0100
@@ -65,19 +65,19 @@
* \param n1 the name of the attribute to set
* \param v1 the value of the attribute to set
*
- * Set these parameters on each ns3::CsmaNetDevice created
+ * Set these attributes on each ns3::CsmaNetDevice created
* by CsmaHelper::Install
*/
- void SetDeviceParameter (std::string n1, const AttributeValue &v1);
+ void SetDeviceAttribute (std::string n1, const AttributeValue &v1);
/**
* \param n1 the name of the attribute to set
* \param v1 the value of the attribute to set
*
- * Set these parameters on each ns3::CsmaChannel created
+ * Set these attributes on each ns3::CsmaChannel created
* by CsmaHelper::Install
*/
- void SetChannelParameter (std::string n1, const AttributeValue &v1);
+ void SetChannelAttribute (std::string n1, const AttributeValue &v1);
/**
* \param filename filename prefix to use for pcap files.
@@ -160,7 +160,7 @@
* \param c a set of nodes
*
* This method creates a simple ns3::CsmaChannel with the
- * attributes configured by CsmaHelper::SetChannelParameter and
+ * attributes configured by CsmaHelper::SetChannelAttribute and
* then calls CsmaHelper::Install.
*/
NetDeviceContainer Install (const NodeContainer &c);
@@ -170,7 +170,7 @@
* \param channel the channel to use as a backbone.
*
* For each node in the input container, we create a ns3::CsmaNetDevice with
- * the requested parameters, a queue for this NetDevice, and associate
+ * the requested attributes, a queue for this NetDevice, and associate
* the resulting ns3::NetDevice with the ns3::Node and ns3::CsmaChannel.
*/
NetDeviceContainer Install (const NodeContainer &c, Ptr<CsmaChannel> channel);
--- a/src/helper/internet-stack-helper.cc Mon Jul 07 12:52:48 2008 +0100
+++ b/src/helper/internet-stack-helper.cc Tue Jul 08 14:18:50 2008 +0100
@@ -26,6 +26,7 @@
#include "ns3/packet-socket-factory.h"
#include "ns3/config.h"
#include "ns3/simulator.h"
+#include <limits>
namespace ns3 {
--- a/src/helper/olsr-helper.h Mon Jul 07 12:52:48 2008 +0100
+++ b/src/helper/olsr-helper.h Tue Jul 08 14:18:50 2008 +0100
@@ -35,11 +35,11 @@
OlsrHelper ();
/**
- * \brief Set default OLSR routing agent parameters
+ * \brief Set default OLSR routing agent attributes
*/
void SetAgent (std::string tid,
std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (),
- std::string n1 = "", const AttributeValue &v2 = EmptyAttributeValue (),
+ std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (),
std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (),
std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (),
std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (),
--- a/src/helper/point-to-point-helper.cc Mon Jul 07 12:52:48 2008 +0100
+++ b/src/helper/point-to-point-helper.cc Tue Jul 08 14:18:50 2008 +0100
@@ -52,13 +52,13 @@
}
void
-PointToPointHelper::SetDeviceParameter (std::string n1, const AttributeValue &v1)
+PointToPointHelper::SetDeviceAttribute (std::string n1, const AttributeValue &v1)
{
m_deviceFactory.Set (n1, v1);
}
void
-PointToPointHelper::SetChannelParameter (std::string n1, const AttributeValue &v1)
+PointToPointHelper::SetChannelAttribute (std::string n1, const AttributeValue &v1)
{
m_channelFactory.Set (n1, v1);
}
--- a/src/helper/point-to-point-helper.h Mon Jul 07 12:52:48 2008 +0100
+++ b/src/helper/point-to-point-helper.h Tue Jul 08 14:18:50 2008 +0100
@@ -65,18 +65,18 @@
* \param name the name of the attribute to set
* \param value the value of the attribute to set
*
- * Set these parameters on each ns3::PointToPointNetDevice created
+ * Set these attributes on each ns3::PointToPointNetDevice created
* by PointToPointHelper::Install
*/
- void SetDeviceParameter (std::string name, const AttributeValue &value);
+ void SetDeviceAttribute (std::string name, const AttributeValue &value);
/**
* \param name the name of the attribute to set
* \param value the value of the attribute to set
*
- * Set these parameters on each ns3::PointToPointChannel created
+ * Set these attribute on each ns3::PointToPointChannel created
* by PointToPointHelper::Install
*/
- void SetChannelParameter (std::string name, const AttributeValue &value);
+ void SetChannelAttribute (std::string name, const AttributeValue &value);
/**
* \param filename filename prefix to use for pcap files.
@@ -159,9 +159,9 @@
* \param c a set of nodes
*
* This method creates a ns3::PointToPointChannel with the
- * attributes configured by PointToPointHelper::SetChannelParameter,
+ * attributes configured by PointToPointHelper::SetChannelAttribute,
* then, for each node in the input container, we create a
- * ns3::PointToPointNetDevice with the requested parameters,
+ * ns3::PointToPointNetDevice with the requested attributes,
* a queue for this ns3::NetDevice, and associate the resulting
* ns3::NetDevice with the ns3::Node and ns3::PointToPointChannel.
*/
--- a/src/helper/udp-echo-helper.cc Mon Jul 07 12:52:48 2008 +0100
+++ b/src/helper/udp-echo-helper.cc Tue Jul 08 14:18:50 2008 +0100
@@ -24,15 +24,21 @@
namespace ns3 {
-UdpEchoServerHelper::UdpEchoServerHelper ()
- : m_port (9)
-{}
+UdpEchoServerHelper::UdpEchoServerHelper (uint16_t port)
+{
+ m_factory.SetTypeId (UdpEchoServer::GetTypeId ());
+ SetAttribute ("Port", UintegerValue(port));
+}
void
-UdpEchoServerHelper::SetPort (uint16_t port)
+UdpEchoServerHelper::SetAttribute (
+ std::string name,
+ const AttributeValue &value)
{
- m_port = port;
+ m_factory.Set (name, value);
}
+
+
ApplicationContainer
UdpEchoServerHelper::Install (NodeContainer c)
{
@@ -40,25 +46,24 @@
for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
{
Ptr<Node> node = *i;
- Ptr<UdpEchoServer> server = CreateObject<UdpEchoServer> ("Port", UintegerValue (m_port));
+ Ptr<UdpEchoServer> server = m_factory.Create<UdpEchoServer> ();
node->AddApplication (server);
apps.Add (server);
}
return apps;
}
-UdpEchoClientHelper::UdpEchoClientHelper ()
+UdpEchoClientHelper::UdpEchoClientHelper (Ipv4Address address, uint16_t port)
{
m_factory.SetTypeId (UdpEchoClient::GetTypeId ());
+ SetAttribute ("RemoteAddress", Ipv4AddressValue (address));
+ SetAttribute ("RemotePort", UintegerValue (port));
}
+
void
-UdpEchoClientHelper::SetRemote (Ipv4Address ip, uint16_t port)
-{
- m_remoteIp = ip;
- m_remotePort = port;
-}
-void
-UdpEchoClientHelper::SetAppAttribute (std::string name, const AttributeValue &value)
+UdpEchoClientHelper::SetAttribute (
+ std::string name,
+ const AttributeValue &value)
{
m_factory.Set (name, value);
}
@@ -71,13 +76,10 @@
{
Ptr<Node> node = *i;
Ptr<UdpEchoClient> client = m_factory.Create<UdpEchoClient> ();
- client->SetRemote (m_remoteIp, m_remotePort);
node->AddApplication (client);
apps.Add (client);
}
return apps;
}
-
-
} // namespace ns3
--- a/src/helper/udp-echo-helper.h Mon Jul 07 12:52:48 2008 +0100
+++ b/src/helper/udp-echo-helper.h Tue Jul 08 14:18:50 2008 +0100
@@ -31,25 +31,25 @@
class UdpEchoServerHelper
{
public:
- UdpEchoServerHelper ();
- void SetPort (uint16_t port);
+ UdpEchoServerHelper (uint16_t port);
+
+ void SetAttribute (std::string name, const AttributeValue &value);
ApplicationContainer Install (NodeContainer c);
-private:
- uint16_t m_port;
+
+ private:
+ ObjectFactory m_factory;
};
class UdpEchoClientHelper
{
public:
- UdpEchoClientHelper ();
+ UdpEchoClientHelper (Ipv4Address ip, uint16_t port);
- void SetRemote (Ipv4Address ip, uint16_t port);
- void SetAppAttribute (std::string name, const AttributeValue &value);
+ void SetAttribute (std::string name, const AttributeValue &value);
ApplicationContainer Install (NodeContainer c);
+
private:
ObjectFactory m_factory;
- Ipv4Address m_remoteIp;
- uint16_t m_remotePort;
};
--- a/src/helper/wifi-helper.h Mon Jul 07 12:52:48 2008 +0100
+++ b/src/helper/wifi-helper.h Tue Jul 08 14:18:50 2008 +0100
@@ -35,7 +35,7 @@
*
* This class can help to create a large set of similar
* WifiNetDevice objects and to configure a large set of
- * their parameters during creation.
+ * their attributes during creation.
*/
class WifiHelper
{
--- a/src/internet-stack/sgi-hashmap.h Mon Jul 07 12:52:48 2008 +0100
+++ b/src/internet-stack/sgi-hashmap.h Tue Jul 08 14:18:50 2008 +0100
@@ -20,8 +20,14 @@
namespace sgi = ::__gnu_cxx; // GCC 3.1 and later
#endif
#else // gcc 4.x and later
+ #if __GNUC_MINOR__ < 3
#include <ext/hash_map>
- namespace sgi = ::__gnu_cxx;
+namespace sgi = ::__gnu_cxx;
+ #else
+#undef __DEPRECATED
+ #include <backward/hash_map>
+namespace sgi = ::__gnu_cxx;
+ #endif
#endif
#endif
#else // ... there are other compilers, right?
--- a/src/internet-stack/wscript Mon Jul 07 12:52:48 2008 +0100
+++ b/src/internet-stack/wscript Tue Jul 08 14:18:50 2008 +0100
@@ -39,4 +39,7 @@
'udp-header.h',
'tcp-header.h',
'sequence-number.h',
+ 'ipv4-interface.h',
+ 'ipv4-l3-protocol.h',
+ 'ipv4-static-routing.h',
]
--- a/src/node/address.cc Mon Jul 07 12:52:48 2008 +0100
+++ b/src/node/address.cc Tue Jul 08 14:18:50 2008 +0100
@@ -1,5 +1,6 @@
#include "ns3/assert.h"
#include "address.h"
+#include <string.h>
#include <iostream>
#include <iomanip>
--- a/src/node/address.h Mon Jul 07 12:52:48 2008 +0100
+++ b/src/node/address.h Tue Jul 08 14:18:50 2008 +0100
@@ -66,7 +66,7 @@
class Address
{
public:
- enum {
+ enum MaxSize_e {
/**
* The maximum size of a byte buffer which
* can be stored in an Address instance.
--- a/src/node/channel.h Mon Jul 07 12:52:48 2008 +0100
+++ b/src/node/channel.h Tue Jul 08 14:18:50 2008 +0100
@@ -44,6 +44,7 @@
Channel ();
Channel (std::string name);
+ virtual ~Channel ();
void SetName(std::string);
std::string GetName(void);
@@ -62,8 +63,7 @@
*/
virtual Ptr<NetDevice> GetDevice (uint32_t i) const = 0;
-protected:
- virtual ~Channel ();
+private:
std::string m_name;
};
--- a/src/node/ipv4.h Mon Jul 07 12:52:48 2008 +0100
+++ b/src/node/ipv4.h Tue Jul 08 14:18:50 2008 +0100
@@ -425,6 +425,11 @@
/**
* \param i index of ipv4 interface
* \returns the address associated to the underlying ipv4 interface
+ *
+ * Note that the broadcast address for this interface may be fetched
+ * from the Ipv4Address object returned here using
+ * Ipv4Address::GetSubnetDirectedBroadcast(mask), where the mask for
+ * the interface may be retrived using Ipv4::GetNetworkMask(i).
*/
virtual Ipv4Address GetAddress (uint32_t i) const = 0;
@@ -432,6 +437,11 @@
* \param destination The IP address of a hypothetical destination.
* \returns The IP address assigned to the interface that will be used
* if we were to send a packet to destination.
+ *
+ * Note that the broadcast address for this interface may be fetched
+ * from the Ipv4Address object returned here using
+ * Ipv4Address::GetSubnetDirectedBroadcast(mask), where the mask for
+ * the interface may be retrived using Ipv4::GetNetworkMask(i).
*/
virtual Ipv4Address GetSourceAddress (Ipv4Address destination) const = 0;
--- a/src/node/mac48-address.cc Mon Jul 07 12:52:48 2008 +0100
+++ b/src/node/mac48-address.cc Tue Jul 08 14:18:50 2008 +0100
@@ -22,6 +22,7 @@
#include "ns3/assert.h"
#include <iomanip>
#include <iostream>
+#include <string.h>
namespace ns3 {
--- a/src/node/mac64-address.cc Mon Jul 07 12:52:48 2008 +0100
+++ b/src/node/mac64-address.cc Tue Jul 08 14:18:50 2008 +0100
@@ -22,6 +22,7 @@
#include "ns3/assert.h"
#include <iomanip>
#include <iostream>
+#include <string.h>
namespace ns3 {
--- a/src/node/node.cc Mon Jul 07 12:52:48 2008 +0100
+++ b/src/node/node.cc Tue Jul 08 14:18:50 2008 +0100
@@ -128,6 +128,18 @@
{
return m_applications.size ();
}
+Ptr<Application>
+Node::GetFirstApplication(TypeId tid)
+{
+ for (std::vector<Ptr<Application> >::iterator i = m_applications.begin ();
+ i != m_applications.end (); i++) {
+ Ptr<Application> app = *i;
+ if (app->GetInstanceTypeId() == tid)
+ return app;
+ }
+
+ return 0;
+}
void
Node::DoDispose()
--- a/src/node/node.h Mon Jul 07 12:52:48 2008 +0100
+++ b/src/node/node.h Tue Jul 08 14:18:50 2008 +0100
@@ -123,6 +123,13 @@
*/
Ptr<Application> GetApplication (uint32_t index) const;
/**
+ * \param index
+ * \returns the application associated to this requested index
+ * within this Node.
+ */
+ Ptr<Application> GetFirstApplication (TypeId tid);
+
+ /**
* \returns the number of applications associated to this Node.
*/
uint32_t GetNApplications (void) const;
--- a/src/node/socket.cc Mon Jul 07 12:52:48 2008 +0100
+++ b/src/node/socket.cc Tue Jul 08 14:18:50 2008 +0100
@@ -25,6 +25,7 @@
#include "node.h"
#include "socket.h"
#include "socket-factory.h"
+#include <limits>
NS_LOG_COMPONENT_DEFINE ("Socket");
--- a/src/node/socket.h Mon Jul 07 12:52:48 2008 +0100
+++ b/src/node/socket.h Tue Jul 08 14:18:50 2008 +0100
@@ -501,7 +501,7 @@
void NotifyDataSent (uint32_t size);
void NotifySend (uint32_t spaceAvailable);
void NotifyDataRecv (void);
-
+private:
Callback<void, Ptr<Socket> > m_connectionSucceeded;
Callback<void, Ptr<Socket> > m_connectionFailed;
Callback<bool, Ptr<Socket>, const Address &> m_connectionRequest;
--- a/src/routing/global-routing/candidate-queue.h Mon Jul 07 12:52:48 2008 +0100
+++ b/src/routing/global-routing/candidate-queue.h Tue Jul 08 14:18:50 2008 +0100
@@ -162,10 +162,6 @@
*/
void Reorder (void);
-protected:
- typedef std::list<SPFVertex*> CandidateList_t;
- CandidateList_t m_candidates;
-
private:
/**
* Candidate Queue copy construction is disallowed (not implemented) to
@@ -180,6 +176,9 @@
* properly deal with deep copies.
*/
CandidateQueue& operator= (CandidateQueue& sr);
+
+ typedef std::list<SPFVertex*> CandidateList_t;
+ CandidateList_t m_candidates;
};
} // namespace ns3
--- a/src/routing/global-routing/global-route-manager-impl.cc Mon Jul 07 12:52:48 2008 +0100
+++ b/src/routing/global-routing/global-route-manager-impl.cc Tue Jul 08 14:18:50 2008 +0100
@@ -1425,6 +1425,7 @@
#include "ns3/test.h"
#include "ns3/simulator.h"
+#include <stdlib.h> // for rand ()
namespace ns3 {
--- a/src/routing/global-routing/wscript Mon Jul 07 12:52:48 2008 +0100
+++ b/src/routing/global-routing/wscript Tue Jul 08 14:18:50 2008 +0100
@@ -13,6 +13,5 @@
headers.source = [
'global-router-interface.h',
'global-route-manager.h',
- 'candidate-queue.h',
]
--- a/src/simulator/simulator.h Mon Jul 07 12:52:48 2008 +0100
+++ b/src/simulator/simulator.h Tue Jul 08 14:18:50 2008 +0100
@@ -554,6 +554,31 @@
* The returned value will always be bigger than or equal to Simulator::Now.
*/
static Time GetMaximumSimulationTime (void);
+ /**
+ * \param time delay until the event expires
+ * \param event the event to schedule
+ * \returns a unique identifier for the newly-scheduled event.
+ *
+ * This method will be typically used by language bindings
+ * to delegate events to their own subclass of the EventImpl base class.
+ */
+ static EventId Schedule (Time const &time, const Ptr<EventImpl> &event);
+ /**
+ * \param event the event to schedule
+ * \returns a unique identifier for the newly-scheduled event.
+ *
+ * This method will be typically used by language bindings
+ * to delegate events to their own subclass of the EventImpl base class.
+ */
+ static EventId ScheduleDestroy (const Ptr<EventImpl> &event);
+ /**
+ * \param event the event to schedule
+ * \returns a unique identifier for the newly-scheduled event.
+ *
+ * This method will be typically used by language bindings
+ * to delegate events to their own subclass of the EventImpl base class.
+ */
+ static EventId ScheduleNow (const Ptr<EventImpl> &event);
private:
Simulator ();
~Simulator ();
@@ -594,9 +619,6 @@
static Ptr<EventImpl> MakeEvent (void (*f) (U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5);
static Ptr<SimulatorPrivate> GetPriv (void);
- static EventId Schedule (Time const &time, const Ptr<EventImpl> &event);
- static EventId ScheduleDestroy (const Ptr<EventImpl> &event);
- static EventId ScheduleNow (const Ptr<EventImpl> &event);
static Ptr<SimulatorPrivate> m_priv;
};
--- a/src/simulator/time.cc Mon Jul 07 12:52:48 2008 +0100
+++ b/src/simulator/time.cc Tue Jul 08 14:18:50 2008 +0100
@@ -72,7 +72,10 @@
std::string::size_type n = s.find_first_not_of("0123456789.");
if (n != std::string::npos)
{ // Found non-numeric
- double r = atof(s.substr(0, n).c_str());
+ std::istringstream iss;
+ iss.str (s.substr(0, n));
+ double r;
+ iss >> r;
std::string trailer = s.substr(n, std::string::npos);
if (trailer == std::string("s"))
{
@@ -113,7 +116,11 @@
}
//else
//they didn't provide units, assume seconds
- m_data = HighPrecision (atof(s.c_str()) * TimeStepPrecision::g_tsPrecFactor);
+ std::istringstream iss;
+ iss. str (s);
+ double v;
+ iss >> v;
+ m_data = HighPrecision (v * TimeStepPrecision::g_tsPrecFactor);
}
double
--- a/utils/bench-packets.cc Mon Jul 07 12:52:48 2008 +0100
+++ b/utils/bench-packets.cc Tue Jul 08 14:18:50 2008 +0100
@@ -23,6 +23,7 @@
#include <iostream>
#include <sstream>
#include <string>
+#include <stdlib.h> // for exit ()
using namespace ns3;
@@ -261,7 +262,9 @@
if (strncmp ("--n=", argv[0],strlen ("--n=")) == 0)
{
char const *nAscii = argv[0] + strlen ("--n=");
- n = atoi (nAscii);
+ std::istringstream iss;
+ iss.str (nAscii);
+ iss >> n;
}
argc--;
argv++;
--- a/utils/bench-simulator.cc Mon Jul 07 12:52:48 2008 +0100
+++ b/utils/bench-simulator.cc Tue Jul 08 14:18:50 2008 +0100
@@ -23,6 +23,7 @@
#include <iostream>
#include <fstream>
#include <vector>
+#include <string.h>
using namespace ns3;
--- a/utils/replay-simulation.cc Mon Jul 07 12:52:48 2008 +0100
+++ b/utils/replay-simulation.cc Tue Jul 08 14:18:50 2008 +0100
@@ -24,6 +24,7 @@
#include <deque>
#include <fstream>
#include <iostream>
+#include <string.h>
using namespace ns3;