diff --git a/doc/tutorial/building-topologies.texi b/doc/tutorial/building-topologies.texi index 04b737df3..5ee28dde8 100644 --- a/doc/tutorial/building-topologies.texi +++ b/doc/tutorial/building-topologies.texi @@ -149,8 +149,8 @@ helper and a two millisecond delay on channels created by the helper. @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 @@ going to be fundamentally similar to the applications section of 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 @@ if we create @code{nCsma} ``extra'' nodes the last one will be at index 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 @@ on the nodes and the channel between them. @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 @@ We put the echo server on the ``rightmost'' node in the illustration at the 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 @@ 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. @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)); diff --git a/doc/tutorial/conceptual-overview.texi b/doc/tutorial/conceptual-overview.texi index 232df70f3..50656b937 100644 --- a/doc/tutorial/conceptual-overview.texi +++ b/doc/tutorial/conceptual-overview.texi @@ -420,8 +420,8 @@ The next three lines in the script are, @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 @@ instantiates a @code{PointToPointHelper} object on the stack. From a 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 @@ Similar to the ``DataRate'' on the @code{PointToPointNetDevice} you will find a 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 @@ to set up a UDP echo server application on one of the nodes we have previously 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 @@ created. 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 for the server. There is an underlying @code{UdpEchoClientApplication} 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 diff --git a/doc/tutorial/tweaking.texi b/doc/tutorial/tweaking.texi index 1a8623392..9b01449fe 100644 --- a/doc/tutorial/tweaking.texi +++ b/doc/tutorial/tweaking.texi @@ -462,8 +462,8 @@ at the @command{ns-3} attribute system while walking through the @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 @@ Among the attributes you will see listed is, @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 diff --git a/examples/csma-broadcast.cc b/examples/csma-broadcast.cc index 963be3ff5..64c20645d 100644 --- a/examples/csma-broadcast.cc +++ b/examples/csma-broadcast.cc @@ -69,8 +69,8 @@ main (int argc, char *argv[]) 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); diff --git a/examples/csma-multicast.cc b/examples/csma-multicast.cc index a7775c7b8..6b92958b8 100644 --- a/examples/csma-multicast.cc +++ b/examples/csma-multicast.cc @@ -75,8 +75,8 @@ main (int argc, char *argv[]) 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 diff --git a/examples/csma-one-subnet.cc b/examples/csma-one-subnet.cc index bd827b904..23514b117 100644 --- a/examples/csma-one-subnet.cc +++ b/examples/csma-one-subnet.cc @@ -66,8 +66,8 @@ main (int argc, char *argv[]) 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 diff --git a/examples/csma-packet-socket.cc b/examples/csma-packet-socket.cc index f35fc77c5..a2798e216 100644 --- a/examples/csma-packet-socket.cc +++ b/examples/csma-packet-socket.cc @@ -74,7 +74,7 @@ main (int argc, char *argv[]) // 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."); diff --git a/examples/first.cc b/examples/first.cc index 74d7f54f3..0461d4cc9 100644 --- a/examples/first.cc +++ b/examples/first.cc @@ -33,8 +33,8 @@ main (int argc, char *argv[]) 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 @@ main (int argc, char *argv[]) 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)); diff --git a/examples/mixed-global-routing.cc b/examples/mixed-global-routing.cc index dfa262414..18141a7d1 100644 --- a/examples/mixed-global-routing.cc +++ b/examples/mixed-global-routing.cc @@ -71,20 +71,20 @@ main (int argc, char *argv[]) // 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. diff --git a/examples/mixed-wireless.cc b/examples/mixed-wireless.cc index 6b062b4d4..21ec3f850 100644 --- a/examples/mixed-wireless.cc +++ b/examples/mixed-wireless.cc @@ -200,9 +200,9 @@ main (int argc, char *argv[]) // 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 diff --git a/examples/second.cc b/examples/second.cc index 817a5e0b9..a54205f58 100644 --- a/examples/second.cc +++ b/examples/second.cc @@ -52,8 +52,8 @@ main (int argc, char *argv[]) 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 @@ main (int argc, char *argv[]) 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)); diff --git a/examples/simple-alternate-routing.cc b/examples/simple-alternate-routing.cc index 2d130e7f0..ad5446a1a 100644 --- a/examples/simple-alternate-routing.cc +++ b/examples/simple-alternate-routing.cc @@ -97,17 +97,17 @@ main (int argc, char *argv[]) // 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; diff --git a/examples/simple-error-model.cc b/examples/simple-error-model.cc index 71d022200..3fbc8c355 100644 --- a/examples/simple-error-model.cc +++ b/examples/simple-error-model.cc @@ -64,7 +64,7 @@ main (int argc, char *argv[]) // 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 @@ main (int argc, char *argv[]) // 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. diff --git a/examples/simple-global-routing.cc b/examples/simple-global-routing.cc index 35fb96d94..a0ddb0d7a 100644 --- a/examples/simple-global-routing.cc +++ b/examples/simple-global-routing.cc @@ -92,14 +92,14 @@ main (int argc, char *argv[]) // 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. diff --git a/examples/simple-point-to-point-olsr.cc b/examples/simple-point-to-point-olsr.cc index e11816bff..5079706ed 100644 --- a/examples/simple-point-to-point-olsr.cc +++ b/examples/simple-point-to-point-olsr.cc @@ -93,12 +93,12 @@ main (int argc, char *argv[]) // 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); diff --git a/examples/tcp-large-transfer.cc b/examples/tcp-large-transfer.cc index f052b478c..d4afeab08 100644 --- a/examples/tcp-large-transfer.cc +++ b/examples/tcp-large-transfer.cc @@ -90,10 +90,10 @@ int main (int argc, char *argv[]) // 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); diff --git a/examples/tcp-star-server.cc b/examples/tcp-star-server.cc new file mode 100644 index 000000000..ca79d681e --- /dev/null +++ b/examples/tcp-star-server.cc @@ -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 +#include +#include +#include + +#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 nodeAdjacencyList(N-1); + for(uint32_t i=0; i deviceAdjacencyList(N-1); + for(uint32_t i=0; i interfaceAdjacencyList(N-1); + for(uint32_t i=0; iClose (); m_socket->SetRecvCallback (MakeNullCallback > ()); } } diff --git a/src/applications/udp-echo/udp-echo-client.cc b/src/applications/udp-echo/udp-echo-client.cc index 9580b7dbe..d92779aa3 100644 --- a/src/applications/udp-echo/udp-echo-client.cc +++ b/src/applications/udp-echo/udp-echo-client.cc @@ -47,8 +47,8 @@ UdpEchoClient::GetTypeId (void) 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 ()) diff --git a/src/common/buffer.h b/src/common/buffer.h index b86d0a49c..245f31ea8 100644 --- a/src/common/buffer.h +++ b/src/common/buffer.h @@ -536,6 +536,7 @@ private: #ifdef BUFFER_USE_INLINE #include "ns3/assert.h" +#include namespace ns3 { diff --git a/src/common/data-rate.cc b/src/common/data-rate.cc index e7727dda0..61d6f6550 100644 --- a/src/common/data-rate.cc +++ b/src/common/data-rate.cc @@ -29,7 +29,10 @@ DoParse (const std::string s, uint64_t *v) 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 @@ DoParse (const std::string s, uint64_t *v) } return true; } - *v = ::atoll(s.c_str()); + std::istringstream iss; + iss.str (s); + iss >> *v; return true; } diff --git a/src/common/error-model.cc b/src/common/error-model.cc index 77b5854ef..02bfac62d 100644 --- a/src/common/error-model.cc +++ b/src/common/error-model.cc @@ -178,7 +178,7 @@ bool RateErrorModel::DoCorrupt (Ptr p) { NS_LOG_FUNCTION_NOARGS (); - if (!m_enable) + if (!IsEnabled ()) { return false; } @@ -275,7 +275,7 @@ bool ListErrorModel::DoCorrupt (Ptr p) { NS_LOG_FUNCTION_NOARGS (); - if (!m_enable) + if (!IsEnabled ()) { return false; } diff --git a/src/common/error-model.h b/src/common/error-model.h index 825487750..bf3767637 100644 --- a/src/common/error-model.h +++ b/src/common/error-model.h @@ -104,9 +104,6 @@ public: */ bool IsEnabled (void) const; -protected: - bool m_enable; - private: /* * These methods must be implemented by subclasses @@ -114,6 +111,7 @@ private: virtual bool DoCorrupt (Ptr) = 0; virtual void DoReset (void) = 0; + bool m_enable; }; enum ErrorUnit diff --git a/src/common/tag-list.cc b/src/common/tag-list.cc index 6af8ec7a9..4f8fdaf92 100644 --- a/src/common/tag-list.cc +++ b/src/common/tag-list.cc @@ -20,6 +20,7 @@ #include "tag-list.h" #include "ns3/log.h" #include +#include NS_LOG_COMPONENT_DEFINE ("TagList"); diff --git a/src/contrib/config-store.cc b/src/contrib/config-store.cc index 55f9d7070..d4250bb50 100644 --- a/src/contrib/config-store.cc +++ b/src/contrib/config-store.cc @@ -8,6 +8,7 @@ #include #include #include +#include NS_LOG_COMPONENT_DEFINE ("ConfigStore"); diff --git a/src/core/callback.h b/src/core/callback.h index 40afbd1a6..9d72aeb84 100644 --- a/src/core/callback.h +++ b/src/core/callback.h @@ -25,6 +25,7 @@ #include "fatal-error.h" #include "empty.h" #include "type-traits.h" +#include namespace ns3 { diff --git a/src/core/double.h b/src/core/double.h index 1ed54ecdd..d21b97847 100644 --- a/src/core/double.h +++ b/src/core/double.h @@ -23,6 +23,7 @@ #include "attribute.h" #include "attribute-helper.h" #include +#include namespace ns3 { diff --git a/src/core/int-to-type.h b/src/core/int-to-type.h index 240fe8a71..612820cf9 100644 --- a/src/core/int-to-type.h +++ b/src/core/int-to-type.h @@ -11,7 +11,7 @@ namespace ns3 { template struct IntToType { - enum {value = v}; + enum v_e {value = v}; }; } // namespace ns3 diff --git a/src/core/integer.h b/src/core/integer.h index 8ac78e47d..2bb8125a9 100644 --- a/src/core/integer.h +++ b/src/core/integer.h @@ -23,6 +23,7 @@ #include "attribute.h" #include "attribute-helper.h" #include +#include namespace ns3 { diff --git a/src/core/type-id.h b/src/core/type-id.h index 48455f06f..c75f71490 100644 --- a/src/core/type-id.h +++ b/src/core/type-id.h @@ -44,7 +44,7 @@ class TraceSourceAccessor; class TypeId { public: - enum { + enum AttributeFlag { /** * The attribute can be read */ diff --git a/src/core/uinteger.h b/src/core/uinteger.h index c67709272..881f103bf 100644 --- a/src/core/uinteger.h +++ b/src/core/uinteger.h @@ -23,6 +23,7 @@ #include "attribute.h" #include "attribute-helper.h" #include +#include namespace ns3 { diff --git a/src/devices/wifi/jakes-propagation-loss-model.h b/src/devices/wifi/jakes-propagation-loss-model.h index 17ae36e63..bf7c76b50 100644 --- a/src/devices/wifi/jakes-propagation-loss-model.h +++ b/src/devices/wifi/jakes-propagation-loss-model.h @@ -97,7 +97,8 @@ public: * 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 @@ protected: ComplexNumber* m_amp; RandomVariable m_variable; double m_fd; -private: + typedef std::vector DestinationList; struct PathsSet { Ptr sender; diff --git a/src/devices/wifi/status-code.h b/src/devices/wifi/status-code.h index e7daf9e26..cbeffc570 100644 --- a/src/devices/wifi/status-code.h +++ b/src/devices/wifi/status-code.h @@ -21,6 +21,7 @@ #define STATUS_CODE_H #include +#include #include "ns3/buffer.h" namespace ns3 { diff --git a/src/devices/wifi/supported-rates.h b/src/devices/wifi/supported-rates.h index 417390f1a..0e52cbe50 100644 --- a/src/devices/wifi/supported-rates.h +++ b/src/devices/wifi/supported-rates.h @@ -21,6 +21,7 @@ #define SUPPORTED_RATES_H #include +#include #include "ns3/buffer.h" namespace ns3 { diff --git a/src/helper/csma-helper.cc b/src/helper/csma-helper.cc index 391e529c7..8524a7122 100644 --- a/src/helper/csma-helper.cc +++ b/src/helper/csma-helper.cc @@ -52,13 +52,13 @@ CsmaHelper::SetQueue (std::string type, } 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); } diff --git a/src/helper/csma-helper.h b/src/helper/csma-helper.h index 2a2822f3b..595c525ea 100644 --- a/src/helper/csma-helper.h +++ b/src/helper/csma-helper.h @@ -65,19 +65,19 @@ public: * \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 @@ public: * \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 @@ public: * \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 channel); diff --git a/src/helper/internet-stack-helper.cc b/src/helper/internet-stack-helper.cc index 8b6661bfb..792f6e528 100644 --- a/src/helper/internet-stack-helper.cc +++ b/src/helper/internet-stack-helper.cc @@ -26,6 +26,7 @@ #include "ns3/packet-socket-factory.h" #include "ns3/config.h" #include "ns3/simulator.h" +#include namespace ns3 { diff --git a/src/helper/olsr-helper.h b/src/helper/olsr-helper.h index f481fe110..d2eaea80d 100644 --- a/src/helper/olsr-helper.h +++ b/src/helper/olsr-helper.h @@ -35,11 +35,11 @@ public: 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 (), diff --git a/src/helper/point-to-point-helper.cc b/src/helper/point-to-point-helper.cc index 7f1fbcd03..eba654a17 100644 --- a/src/helper/point-to-point-helper.cc +++ b/src/helper/point-to-point-helper.cc @@ -52,13 +52,13 @@ PointToPointHelper::SetQueue (std::string type, } 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); } diff --git a/src/helper/point-to-point-helper.h b/src/helper/point-to-point-helper.h index f945a144f..7603a50d0 100644 --- a/src/helper/point-to-point-helper.h +++ b/src/helper/point-to-point-helper.h @@ -65,18 +65,18 @@ public: * \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 @@ public: * \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. */ diff --git a/src/helper/udp-echo-helper.cc b/src/helper/udp-echo-helper.cc index ef5f59777..c346cb6b2 100644 --- a/src/helper/udp-echo-helper.cc +++ b/src/helper/udp-echo-helper.cc @@ -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 @@ UdpEchoServerHelper::Install (NodeContainer c) for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i) { Ptr node = *i; - Ptr server = CreateObject ("Port", UintegerValue (m_port)); + Ptr server = m_factory.Create (); 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 @@ UdpEchoClientHelper::Install (NodeContainer c) { Ptr node = *i; Ptr client = m_factory.Create (); - client->SetRemote (m_remoteIp, m_remotePort); node->AddApplication (client); apps.Add (client); } return apps; } - - } // namespace ns3 diff --git a/src/helper/udp-echo-helper.h b/src/helper/udp-echo-helper.h index ef13c959a..4e06519a1 100644 --- a/src/helper/udp-echo-helper.h +++ b/src/helper/udp-echo-helper.h @@ -31,25 +31,25 @@ namespace ns3 { 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; }; diff --git a/src/helper/wifi-helper.h b/src/helper/wifi-helper.h index 35ec3141b..72cc4a198 100644 --- a/src/helper/wifi-helper.h +++ b/src/helper/wifi-helper.h @@ -35,7 +35,7 @@ class WifiChannel; * * 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 { diff --git a/src/internet-stack/sgi-hashmap.h b/src/internet-stack/sgi-hashmap.h index 375d25fee..642fb5f5b 100644 --- a/src/internet-stack/sgi-hashmap.h +++ b/src/internet-stack/sgi-hashmap.h @@ -20,8 +20,14 @@ namespace sgi = std; // GCC 3.0 namespace sgi = ::__gnu_cxx; // GCC 3.1 and later #endif #else // gcc 4.x and later + #if __GNUC_MINOR__ < 3 #include - namespace sgi = ::__gnu_cxx; +namespace sgi = ::__gnu_cxx; + #else +#undef __DEPRECATED + #include +namespace sgi = ::__gnu_cxx; + #endif #endif #endif #else // ... there are other compilers, right? diff --git a/src/internet-stack/wscript b/src/internet-stack/wscript index 780a84a98..6f1b7bbd7 100644 --- a/src/internet-stack/wscript +++ b/src/internet-stack/wscript @@ -39,4 +39,7 @@ def build(bld): 'udp-header.h', 'tcp-header.h', 'sequence-number.h', + 'ipv4-interface.h', + 'ipv4-l3-protocol.h', + 'ipv4-static-routing.h', ] diff --git a/src/node/address.cc b/src/node/address.cc index 365161e63..a9f679c63 100644 --- a/src/node/address.cc +++ b/src/node/address.cc @@ -1,5 +1,6 @@ #include "ns3/assert.h" #include "address.h" +#include #include #include diff --git a/src/node/address.h b/src/node/address.h index 7e1b5c3ef..b53c6bb6f 100644 --- a/src/node/address.h +++ b/src/node/address.h @@ -66,7 +66,7 @@ namespace ns3 { class Address { public: - enum { + enum MaxSize_e { /** * The maximum size of a byte buffer which * can be stored in an Address instance. diff --git a/src/node/channel.h b/src/node/channel.h index 78c3fc5f0..750a8ef20 100644 --- a/src/node/channel.h +++ b/src/node/channel.h @@ -44,6 +44,7 @@ public: Channel (); Channel (std::string name); + virtual ~Channel (); void SetName(std::string); std::string GetName(void); @@ -62,8 +63,7 @@ public: */ virtual Ptr GetDevice (uint32_t i) const = 0; -protected: - virtual ~Channel (); +private: std::string m_name; }; diff --git a/src/node/ipv4.h b/src/node/ipv4.h index d2157c959..f6ccec45e 100644 --- a/src/node/ipv4.h +++ b/src/node/ipv4.h @@ -425,6 +425,11 @@ public: /** * \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 @@ public: * \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; diff --git a/src/node/mac48-address.cc b/src/node/mac48-address.cc index 9683f80d1..6dbb8d312 100644 --- a/src/node/mac48-address.cc +++ b/src/node/mac48-address.cc @@ -22,6 +22,7 @@ #include "ns3/assert.h" #include #include +#include namespace ns3 { diff --git a/src/node/mac64-address.cc b/src/node/mac64-address.cc index 13c4913eb..666397624 100644 --- a/src/node/mac64-address.cc +++ b/src/node/mac64-address.cc @@ -22,6 +22,7 @@ #include "ns3/assert.h" #include #include +#include namespace ns3 { diff --git a/src/node/node.cc b/src/node/node.cc index 91a996a74..e1c650e00 100644 --- a/src/node/node.cc +++ b/src/node/node.cc @@ -128,6 +128,18 @@ Node::GetNApplications (void) const { return m_applications.size (); } +Ptr +Node::GetFirstApplication(TypeId tid) +{ + for (std::vector >::iterator i = m_applications.begin (); + i != m_applications.end (); i++) { + Ptr app = *i; + if (app->GetInstanceTypeId() == tid) + return app; + } + + return 0; +} void Node::DoDispose() diff --git a/src/node/node.h b/src/node/node.h index 84f4c31f9..1608fd314 100644 --- a/src/node/node.h +++ b/src/node/node.h @@ -122,6 +122,13 @@ public: * within this Node. */ Ptr GetApplication (uint32_t index) const; + /** + * \param index + * \returns the application associated to this requested index + * within this Node. + */ + Ptr GetFirstApplication (TypeId tid); + /** * \returns the number of applications associated to this Node. */ diff --git a/src/node/socket.cc b/src/node/socket.cc index 52f691c57..d133e936f 100644 --- a/src/node/socket.cc +++ b/src/node/socket.cc @@ -25,6 +25,7 @@ #include "node.h" #include "socket.h" #include "socket-factory.h" +#include NS_LOG_COMPONENT_DEFINE ("Socket"); diff --git a/src/node/socket.h b/src/node/socket.h index 21f060ca0..1c4e650e0 100644 --- a/src/node/socket.h +++ b/src/node/socket.h @@ -501,7 +501,7 @@ protected: void NotifyDataSent (uint32_t size); void NotifySend (uint32_t spaceAvailable); void NotifyDataRecv (void); - +private: Callback > m_connectionSucceeded; Callback > m_connectionFailed; Callback, const Address &> m_connectionRequest; diff --git a/src/routing/global-routing/candidate-queue.h b/src/routing/global-routing/candidate-queue.h index 35747ec9f..c8b900e44 100644 --- a/src/routing/global-routing/candidate-queue.h +++ b/src/routing/global-routing/candidate-queue.h @@ -162,10 +162,6 @@ public: */ void Reorder (void); -protected: - typedef std::list CandidateList_t; - CandidateList_t m_candidates; - private: /** * Candidate Queue copy construction is disallowed (not implemented) to @@ -180,6 +176,9 @@ private: * properly deal with deep copies. */ CandidateQueue& operator= (CandidateQueue& sr); + + typedef std::list CandidateList_t; + CandidateList_t m_candidates; }; } // namespace ns3 diff --git a/src/routing/global-routing/global-route-manager-impl.cc b/src/routing/global-routing/global-route-manager-impl.cc index bf40994b0..8230c2a7f 100644 --- a/src/routing/global-routing/global-route-manager-impl.cc +++ b/src/routing/global-routing/global-route-manager-impl.cc @@ -1425,6 +1425,7 @@ GlobalRouteManagerImpl::SPFVertexAddParent (SPFVertex* v) #include "ns3/test.h" #include "ns3/simulator.h" +#include // for rand () namespace ns3 { diff --git a/src/routing/global-routing/wscript b/src/routing/global-routing/wscript index b2758cc54..17816ade1 100644 --- a/src/routing/global-routing/wscript +++ b/src/routing/global-routing/wscript @@ -13,6 +13,5 @@ def build(bld): headers.source = [ 'global-router-interface.h', 'global-route-manager.h', - 'candidate-queue.h', ] diff --git a/src/simulator/simulator.h b/src/simulator/simulator.h index 892f9eb2f..b2eed6685 100644 --- a/src/simulator/simulator.h +++ b/src/simulator/simulator.h @@ -554,6 +554,31 @@ public: * 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 &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 &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 &event); private: Simulator (); ~Simulator (); @@ -594,9 +619,6 @@ private: static Ptr MakeEvent (void (*f) (U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); static Ptr GetPriv (void); - static EventId Schedule (Time const &time, const Ptr &event); - static EventId ScheduleDestroy (const Ptr &event); - static EventId ScheduleNow (const Ptr &event); static Ptr m_priv; }; diff --git a/src/simulator/time.cc b/src/simulator/time.cc index a25770277..ba36543e6 100644 --- a/src/simulator/time.cc +++ b/src/simulator/time.cc @@ -72,7 +72,10 @@ TimeUnit<1>::TimeUnit(const std::string& s) 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 @@ TimeUnit<1>::TimeUnit(const std::string& s) } //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 diff --git a/utils/bench-packets.cc b/utils/bench-packets.cc index 22643a52c..5ea80088e 100644 --- a/utils/bench-packets.cc +++ b/utils/bench-packets.cc @@ -23,6 +23,7 @@ #include #include #include +#include // for exit () using namespace ns3; @@ -261,7 +262,9 @@ int main (int argc, char *argv[]) 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++; diff --git a/utils/bench-simulator.cc b/utils/bench-simulator.cc index 6b9eb2c2b..6480ab5f5 100644 --- a/utils/bench-simulator.cc +++ b/utils/bench-simulator.cc @@ -23,6 +23,7 @@ #include #include #include +#include using namespace ns3; diff --git a/utils/replay-simulation.cc b/utils/replay-simulation.cc index 1ce94dab9..33a81a398 100644 --- a/utils/replay-simulation.cc +++ b/utils/replay-simulation.cc @@ -24,6 +24,7 @@ #include #include #include +#include using namespace ns3;