merge with HEAD
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Wed Jul 02 13:21:01 2008 -0700 (19 months ago)
changeset 33702f8c7ecfe3ba
parent 3369 30750f23d51a
parent 3367 8587b5520e63
child 3371 e472358ea634
merge with HEAD
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/examples/tcp-star-server.cc	Wed Jul 02 13:21:01 2008 -0700
     1.3 @@ -0,0 +1,172 @@
     1.4 +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
     1.5 +/*
     1.6 + * This program is free software; you can redistribute it and/or modify
     1.7 + * it under the terms of the GNU General Public License version 2 as
     1.8 + * published by the Free Software Foundation;
     1.9 + *
    1.10 + * This program is distributed in the hope that it will be useful,
    1.11 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.12 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.13 + * GNU General Public License for more details.
    1.14 + *
    1.15 + * You should have received a copy of the GNU General Public License
    1.16 + * along with this program; if not, write to the Free Software
    1.17 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    1.18 + *
    1.19 + */
    1.20 +
    1.21 +
    1.22 +// Default Network topology, 9 nodes in a star
    1.23 +/*
    1.24 +          n2 n3 n4
    1.25 +           \ | /
    1.26 +            \|/
    1.27 +       n1---n0---n5
    1.28 +            /|\
    1.29 +           / | \
    1.30 +          n8 n7 n6
    1.31 +*/
    1.32 +// - CBR Traffic goes from the star "arms" to the "hub"
    1.33 +// - Tracing of queues and packet receptions to file
    1.34 +//   "tcp-star-server.tr"
    1.35 +// - pcap traces also generated in the following files
    1.36 +//   "tcp-star-server-$n-$i.pcap" where n and i represent node and interface
    1.37 +//   numbers respectively
    1.38 +// Usage examples for things you might want to tweak:
    1.39 +//       ./waf --run="tcp-star-server"
    1.40 +//       ./waf --run="tcp-star-server --nNodes=25"
    1.41 +//       ./waf --run="tcp-star-server --ns3::OnOffApplication::DataRate=10000"
    1.42 +//       ./waf --run="tcp-star-server --ns3::OnOffApplication::PacketSize=500"
    1.43 +// See the ns-3 tutorial for more info on the command line: 
    1.44 +// http://www.nsnam.org/tutorials.html
    1.45 +
    1.46 +
    1.47 +
    1.48 +
    1.49 +#include <iostream>
    1.50 +#include <fstream>
    1.51 +#include <string>
    1.52 +#include <cassert>
    1.53 +
    1.54 +#include "ns3/core-module.h"
    1.55 +#include "ns3/simulator-module.h"
    1.56 +#include "ns3/node-module.h"
    1.57 +#include "ns3/helper-module.h"
    1.58 +#include "ns3/global-route-manager.h"
    1.59 +
    1.60 +using namespace ns3;
    1.61 +
    1.62 +NS_LOG_COMPONENT_DEFINE ("TcpServer");
    1.63 +
    1.64 +int 
    1.65 +main (int argc, char *argv[])
    1.66 +{
    1.67 +  // Users may find it convenient to turn on explicit debugging
    1.68 +  // for selected modules; the below lines suggest how to do this
    1.69 +
    1.70 +  //LogComponentEnable ("TcpServer", LOG_LEVEL_INFO);
    1.71 +  //LogComponentEnable ("TcpL4Protocol", LOG_LEVEL_ALL);
    1.72 +  //LogComponentEnable ("TcpSocketImpl", LOG_LEVEL_ALL);
    1.73 +  //LogComponentEnable ("PacketSink", LOG_LEVEL_ALL);
    1.74 +  //
    1.75 +  // Make the random number generators generate reproducible results.
    1.76 +  //
    1.77 +  RandomVariable::UseGlobalSeed (1, 1, 2, 3, 5, 8);
    1.78 +
    1.79 +  // Set up some default values for the simulation.
    1.80 +  Config::SetDefault ("ns3::OnOffApplication::PacketSize", UintegerValue (250));
    1.81 +  Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue ("5kb/s"));
    1.82 +  uint32_t N = 9; //number of nodes in the star
    1.83 +
    1.84 +  // Allow the user to override any of the defaults and the above
    1.85 +  // Config::SetDefault()s at run-time, via command-line arguments
    1.86 +  CommandLine cmd;
    1.87 +  cmd.AddValue("nNodes", "Number of nodes to place in the star", N);
    1.88 +  cmd.Parse (argc, argv);
    1.89 +
    1.90 +  // Here, we will create N nodes in a star.
    1.91 +  NS_LOG_INFO ("Create nodes.");
    1.92 +  NodeContainer serverNode;
    1.93 +  NodeContainer clientNodes;
    1.94 +  serverNode.Create(1);
    1.95 +  clientNodes.Create(N-1);
    1.96 +  NodeContainer allNodes = NodeContainer(serverNode, clientNodes);
    1.97 +
    1.98 +  // Install network stacks on the nodes
    1.99 +  InternetStackHelper internet;
   1.100 +  internet.Install (allNodes);
   1.101 +
   1.102 +  //Collect an adjacency list of nodes for the p2p topology
   1.103 +  std::vector<NodeContainer> nodeAdjacencyList(N-1);
   1.104 +  for(uint32_t i=0; i<nodeAdjacencyList.size(); ++i)
   1.105 +  {
   1.106 +    nodeAdjacencyList[i] = NodeContainer (serverNode, clientNodes.Get (i));
   1.107 +  }
   1.108 +
   1.109 +  // We create the channels first without any IP addressing information
   1.110 +  NS_LOG_INFO ("Create channels.");
   1.111 +  PointToPointHelper p2p;
   1.112 +  p2p.SetDeviceParameter ("DataRate", StringValue ("5Mbps"));
   1.113 +  p2p.SetChannelParameter ("Delay", StringValue ("2ms"));
   1.114 +  std::vector<NetDeviceContainer> deviceAdjacencyList(N-1);
   1.115 +  for(uint32_t i=0; i<deviceAdjacencyList.size(); ++i)
   1.116 +  {
   1.117 +    deviceAdjacencyList[i] = p2p.Install (nodeAdjacencyList[i]);
   1.118 +  }
   1.119 +
   1.120 +  // Later, we add IP addresses.  
   1.121 +  NS_LOG_INFO ("Assign IP Addresses.");
   1.122 +  Ipv4AddressHelper ipv4;
   1.123 +  std::vector<Ipv4InterfaceContainer> interfaceAdjacencyList(N-1);
   1.124 +  for(uint32_t i=0; i<interfaceAdjacencyList.size(); ++i)
   1.125 +  {
   1.126 +    std::ostringstream subnet;
   1.127 +    subnet<<"10.1."<<i+1<<".0";
   1.128 +    ipv4.SetBase (subnet.str().c_str(), "255.255.255.0");
   1.129 +    interfaceAdjacencyList[i] = ipv4.Assign (deviceAdjacencyList[i]);
   1.130 +  }
   1.131 +
   1.132 +  //Turn on global static routing
   1.133 +  GlobalRouteManager::PopulateRoutingTables ();
   1.134 +
   1.135 +  // Create a packet sink on the star "hub" to receive these packets
   1.136 +  uint16_t port = 50000;
   1.137 +  Address sinkLocalAddress(InetSocketAddress (Ipv4Address::GetAny (), port));
   1.138 +  PacketSinkHelper sinkHelper ("ns3::TcpSocketFactory", sinkLocalAddress);
   1.139 +  ApplicationContainer sinkApp = sinkHelper.Install (serverNode);
   1.140 +  sinkApp.Start (Seconds (1.0));
   1.141 +  sinkApp.Stop (Seconds (10.0));
   1.142 +
   1.143 +  // Create the OnOff applications to send TCP to the server
   1.144 +  OnOffHelper clientHelper ("ns3::TcpSocketFactory", Address ());
   1.145 +  clientHelper.SetAttribute 
   1.146 +      ("OnTime", RandomVariableValue (ConstantVariable (1)));
   1.147 +  clientHelper.SetAttribute 
   1.148 +      ("OffTime", RandomVariableValue (ConstantVariable (0)));
   1.149 +  //normally wouldn't need a loop here but the server IP address is different
   1.150 +  //on each p2p subnet
   1.151 +  ApplicationContainer clientApps;
   1.152 +  for(uint32_t i=0; i<clientNodes.GetN(); ++i)
   1.153 +  {
   1.154 +    AddressValue remoteAddress
   1.155 +        (InetSocketAddress (interfaceAdjacencyList[i].GetAddress (0), port));
   1.156 +    clientHelper.SetAttribute ("Remote", remoteAddress);
   1.157 +    clientApps.Add(clientHelper.Install (clientNodes.Get(i)));
   1.158 +  }
   1.159 +  clientApps.Start (Seconds (1.0));
   1.160 +  clientApps.Stop (Seconds (10.0));
   1.161 +
   1.162 +
   1.163 +  //configure tracing
   1.164 +  std::ofstream ascii;
   1.165 +  ascii.open ("tcp-star-server.tr");
   1.166 +  PointToPointHelper::EnablePcapAll ("tcp-star-server");
   1.167 +  PointToPointHelper::EnableAsciiAll (ascii);
   1.168 +
   1.169 +  NS_LOG_INFO ("Run Simulation.");
   1.170 +  Simulator::Run ();
   1.171 +  Simulator::Destroy ();
   1.172 +  NS_LOG_INFO ("Done.");
   1.173 +
   1.174 +  return 0;
   1.175 +}
     2.1 --- a/examples/wscript	Wed Jul 02 08:37:57 2008 -0700
     2.2 +++ b/examples/wscript	Wed Jul 02 13:21:01 2008 -0700
     2.3 @@ -52,6 +52,10 @@
     2.4          ['point-to-point', 'internet-stack'])
     2.5      obj.source = 'tcp-large-transfer.cc'
     2.6  
     2.7 +    obj = bld.create_ns3_program('tcp-star-server',
     2.8 +        ['point-to-point', 'internet-stack'])
     2.9 +    obj.source = 'tcp-star-server.cc'
    2.10 +
    2.11      obj = bld.create_ns3_program('wifi-adhoc',
    2.12                                   ['core', 'simulator', 'mobility', 'wifi'])
    2.13      obj.source = 'wifi-adhoc.cc'
     3.1 --- a/src/common/buffer.h	Wed Jul 02 08:37:57 2008 -0700
     3.2 +++ b/src/common/buffer.h	Wed Jul 02 13:21:01 2008 -0700
     3.3 @@ -536,6 +536,7 @@
     3.4  #ifdef BUFFER_USE_INLINE
     3.5  
     3.6  #include "ns3/assert.h"
     3.7 +#include <string.h>
     3.8  
     3.9  namespace ns3 {
    3.10  
     4.1 --- a/src/common/data-rate.cc	Wed Jul 02 08:37:57 2008 -0700
     4.2 +++ b/src/common/data-rate.cc	Wed Jul 02 13:21:01 2008 -0700
     4.3 @@ -29,7 +29,10 @@
     4.4    std::string::size_type n = s.find_first_not_of("0123456789.");
     4.5    if (n != std::string::npos)
     4.6    { // Found non-numeric
     4.7 -    double r = ::atof(s.substr(0, n).c_str());
     4.8 +    std::istringstream iss;
     4.9 +    iss.str (s.substr(0, n));
    4.10 +    double r;
    4.11 +    iss >> r;
    4.12      std::string trailer = s.substr(n, std::string::npos);
    4.13      if (trailer == "bps")
    4.14        {
    4.15 @@ -117,7 +120,9 @@
    4.16        }
    4.17      return true;
    4.18    }
    4.19 -  *v = ::atoll(s.c_str());
    4.20 +  std::istringstream iss;
    4.21 +  iss.str (s);
    4.22 +  iss >> *v;
    4.23    return true;
    4.24  }
    4.25  
     5.1 --- a/src/common/tag-list.cc	Wed Jul 02 08:37:57 2008 -0700
     5.2 +++ b/src/common/tag-list.cc	Wed Jul 02 13:21:01 2008 -0700
     5.3 @@ -20,6 +20,7 @@
     5.4  #include "tag-list.h"
     5.5  #include "ns3/log.h"
     5.6  #include <vector>
     5.7 +#include <string.h>
     5.8  
     5.9  NS_LOG_COMPONENT_DEFINE ("TagList");
    5.10  
     6.1 --- a/src/contrib/config-store.cc	Wed Jul 02 08:37:57 2008 -0700
     6.2 +++ b/src/contrib/config-store.cc	Wed Jul 02 13:21:01 2008 -0700
     6.3 @@ -8,6 +8,7 @@
     6.4  #include <fstream>
     6.5  #include <iostream>
     6.6  #include <unistd.h>
     6.7 +#include <stdlib.h>
     6.8  
     6.9  NS_LOG_COMPONENT_DEFINE ("ConfigStore");
    6.10  
     7.1 --- a/src/core/callback.h	Wed Jul 02 08:37:57 2008 -0700
     7.2 +++ b/src/core/callback.h	Wed Jul 02 13:21:01 2008 -0700
     7.3 @@ -25,6 +25,7 @@
     7.4  #include "fatal-error.h"
     7.5  #include "empty.h"
     7.6  #include "type-traits.h"
     7.7 +#include <typeinfo>
     7.8  
     7.9  namespace ns3 {
    7.10  
     8.1 --- a/src/core/double.h	Wed Jul 02 08:37:57 2008 -0700
     8.2 +++ b/src/core/double.h	Wed Jul 02 13:21:01 2008 -0700
     8.3 @@ -23,6 +23,7 @@
     8.4  #include "attribute.h"
     8.5  #include "attribute-helper.h"
     8.6  #include <stdint.h>
     8.7 +#include <limits>
     8.8  
     8.9  namespace ns3 {
    8.10  
     9.1 --- a/src/core/integer.h	Wed Jul 02 08:37:57 2008 -0700
     9.2 +++ b/src/core/integer.h	Wed Jul 02 13:21:01 2008 -0700
     9.3 @@ -23,6 +23,7 @@
     9.4  #include "attribute.h"
     9.5  #include "attribute-helper.h"
     9.6  #include <stdint.h>
     9.7 +#include <limits>
     9.8  
     9.9  namespace ns3 {
    9.10  
    10.1 --- a/src/core/uinteger.h	Wed Jul 02 08:37:57 2008 -0700
    10.2 +++ b/src/core/uinteger.h	Wed Jul 02 13:21:01 2008 -0700
    10.3 @@ -23,6 +23,7 @@
    10.4  #include "attribute.h"
    10.5  #include "attribute-helper.h"
    10.6  #include <stdint.h>
    10.7 +#include <limits>
    10.8  
    10.9  namespace ns3 {
   10.10  
    11.1 --- a/src/devices/wifi/status-code.h	Wed Jul 02 08:37:57 2008 -0700
    11.2 +++ b/src/devices/wifi/status-code.h	Wed Jul 02 13:21:01 2008 -0700
    11.3 @@ -21,6 +21,7 @@
    11.4  #define STATUS_CODE_H
    11.5  
    11.6  #include <stdint.h>
    11.7 +#include <ostream>
    11.8  #include "ns3/buffer.h"
    11.9  
   11.10  namespace ns3 {
    12.1 --- a/src/devices/wifi/supported-rates.h	Wed Jul 02 08:37:57 2008 -0700
    12.2 +++ b/src/devices/wifi/supported-rates.h	Wed Jul 02 13:21:01 2008 -0700
    12.3 @@ -21,6 +21,7 @@
    12.4  #define SUPPORTED_RATES_H
    12.5  
    12.6  #include <stdint.h>
    12.7 +#include <ostream>
    12.8  #include "ns3/buffer.h"
    12.9  
   12.10  namespace ns3 {
    13.1 --- a/src/helper/internet-stack-helper.cc	Wed Jul 02 08:37:57 2008 -0700
    13.2 +++ b/src/helper/internet-stack-helper.cc	Wed Jul 02 13:21:01 2008 -0700
    13.3 @@ -26,6 +26,7 @@
    13.4  #include "ns3/packet-socket-factory.h"
    13.5  #include "ns3/config.h"
    13.6  #include "ns3/simulator.h"
    13.7 +#include <limits>
    13.8  
    13.9  namespace ns3 {
   13.10  
    14.1 --- a/src/helper/olsr-helper.h	Wed Jul 02 08:37:57 2008 -0700
    14.2 +++ b/src/helper/olsr-helper.h	Wed Jul 02 13:21:01 2008 -0700
    14.3 @@ -39,7 +39,7 @@
    14.4     */
    14.5    void SetAgent (std::string tid,
    14.6  		 std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (),
    14.7 -		 std::string n1 = "", const AttributeValue &v2 = EmptyAttributeValue (),
    14.8 +		 std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (),
    14.9  		 std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (),
   14.10  		 std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (),
   14.11  		 std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (),
    15.1 --- a/src/internet-stack/sgi-hashmap.h	Wed Jul 02 08:37:57 2008 -0700
    15.2 +++ b/src/internet-stack/sgi-hashmap.h	Wed Jul 02 13:21:01 2008 -0700
    15.3 @@ -20,8 +20,14 @@
    15.4  namespace sgi = ::__gnu_cxx;       // GCC 3.1 and later
    15.5         #endif
    15.6       #else  // gcc 4.x and later
    15.7 +       #if __GNUC_MINOR__ < 3
    15.8         #include <ext/hash_map>
    15.9 -       namespace sgi = ::__gnu_cxx;
   15.10 +namespace sgi = ::__gnu_cxx;
   15.11 +       #else
   15.12 +#undef __DEPRECATED
   15.13 +       #include <backward/hash_map>
   15.14 +namespace sgi = ::__gnu_cxx;
   15.15 +       #endif
   15.16       #endif
   15.17    #endif
   15.18  #else      // ...  there are other compilers, right?
    16.1 --- a/src/node/address.cc	Wed Jul 02 08:37:57 2008 -0700
    16.2 +++ b/src/node/address.cc	Wed Jul 02 13:21:01 2008 -0700
    16.3 @@ -1,5 +1,6 @@
    16.4  #include "ns3/assert.h"
    16.5  #include "address.h"
    16.6 +#include <string.h>
    16.7  #include <iostream>
    16.8  #include <iomanip>
    16.9  
    17.1 --- a/src/node/mac48-address.cc	Wed Jul 02 08:37:57 2008 -0700
    17.2 +++ b/src/node/mac48-address.cc	Wed Jul 02 13:21:01 2008 -0700
    17.3 @@ -22,6 +22,7 @@
    17.4  #include "ns3/assert.h"
    17.5  #include <iomanip>
    17.6  #include <iostream>
    17.7 +#include <string.h>
    17.8  
    17.9  namespace ns3 {
   17.10  
    18.1 --- a/src/node/mac64-address.cc	Wed Jul 02 08:37:57 2008 -0700
    18.2 +++ b/src/node/mac64-address.cc	Wed Jul 02 13:21:01 2008 -0700
    18.3 @@ -22,6 +22,7 @@
    18.4  #include "ns3/assert.h"
    18.5  #include <iomanip>
    18.6  #include <iostream>
    18.7 +#include <string.h>
    18.8  
    18.9  namespace ns3 {
   18.10  
    19.1 --- a/src/node/socket.cc	Wed Jul 02 08:37:57 2008 -0700
    19.2 +++ b/src/node/socket.cc	Wed Jul 02 13:21:01 2008 -0700
    19.3 @@ -25,6 +25,7 @@
    19.4  #include "node.h"
    19.5  #include "socket.h"
    19.6  #include "socket-factory.h"
    19.7 +#include <limits>
    19.8  
    19.9  NS_LOG_COMPONENT_DEFINE ("Socket");
   19.10  
    20.1 --- a/src/routing/global-routing/global-route-manager-impl.cc	Wed Jul 02 08:37:57 2008 -0700
    20.2 +++ b/src/routing/global-routing/global-route-manager-impl.cc	Wed Jul 02 13:21:01 2008 -0700
    20.3 @@ -1425,6 +1425,7 @@
    20.4  
    20.5  #include "ns3/test.h"
    20.6  #include "ns3/simulator.h"
    20.7 +#include <stdlib.h> // for rand ()
    20.8  
    20.9  namespace ns3 {
   20.10  
    21.1 --- a/src/simulator/time.cc	Wed Jul 02 08:37:57 2008 -0700
    21.2 +++ b/src/simulator/time.cc	Wed Jul 02 13:21:01 2008 -0700
    21.3 @@ -72,7 +72,10 @@
    21.4    std::string::size_type n = s.find_first_not_of("0123456789.");
    21.5    if (n != std::string::npos)
    21.6    { // Found non-numeric
    21.7 -    double r = atof(s.substr(0, n).c_str());
    21.8 +    std::istringstream iss;
    21.9 +    iss.str (s.substr(0, n));
   21.10 +    double r;
   21.11 +    iss >> r;
   21.12      std::string trailer = s.substr(n, std::string::npos);
   21.13      if (trailer == std::string("s"))
   21.14      {
   21.15 @@ -113,7 +116,11 @@
   21.16    }
   21.17    //else
   21.18    //they didn't provide units, assume seconds
   21.19 -  m_data = HighPrecision (atof(s.c_str()) * TimeStepPrecision::g_tsPrecFactor);
   21.20 +  std::istringstream iss;
   21.21 +  iss. str (s);
   21.22 +  double v;
   21.23 +  iss >> v;
   21.24 +  m_data = HighPrecision (v * TimeStepPrecision::g_tsPrecFactor);
   21.25  }
   21.26  
   21.27  double 
    22.1 --- a/utils/bench-packets.cc	Wed Jul 02 08:37:57 2008 -0700
    22.2 +++ b/utils/bench-packets.cc	Wed Jul 02 13:21:01 2008 -0700
    22.3 @@ -23,6 +23,7 @@
    22.4  #include <iostream>
    22.5  #include <sstream>
    22.6  #include <string>
    22.7 +#include <stdlib.h> // for exit ()
    22.8  
    22.9  using namespace ns3;
   22.10  
   22.11 @@ -261,7 +262,9 @@
   22.12        if (strncmp ("--n=", argv[0],strlen ("--n=")) == 0) 
   22.13          {
   22.14            char const *nAscii = argv[0] + strlen ("--n=");
   22.15 -          n = atoi (nAscii);
   22.16 +          std::istringstream iss;
   22.17 +          iss.str (nAscii);
   22.18 +          iss >> n;
   22.19          }
   22.20        argc--;
   22.21        argv++;
    23.1 --- a/utils/bench-simulator.cc	Wed Jul 02 08:37:57 2008 -0700
    23.2 +++ b/utils/bench-simulator.cc	Wed Jul 02 13:21:01 2008 -0700
    23.3 @@ -23,6 +23,7 @@
    23.4  #include <iostream>
    23.5  #include <fstream>
    23.6  #include <vector>
    23.7 +#include <string.h>
    23.8  
    23.9  using namespace ns3;
   23.10  
    24.1 --- a/utils/replay-simulation.cc	Wed Jul 02 08:37:57 2008 -0700
    24.2 +++ b/utils/replay-simulation.cc	Wed Jul 02 13:21:01 2008 -0700
    24.3 @@ -24,6 +24,7 @@
    24.4  #include <deque>
    24.5  #include <fstream>
    24.6  #include <iostream>
    24.7 +#include <string.h>
    24.8  
    24.9  using namespace ns3;
   24.10