merge with HEAD
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Wed, 02 Jul 2008 13:21:01 -0700
changeset 3370 2f8c7ecfe3ba
parent 3369 30750f23d51a (current diff)
parent 3367 8587b5520e63 (diff)
child 3371 e472358ea634
merge with HEAD
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/tcp-star-server.cc	Wed Jul 02 13:21:01 2008 -0700
@@ -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.SetDeviceParameter ("DataRate", StringValue ("5Mbps"));
+  p2p.SetChannelParameter ("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/wscript	Wed Jul 02 08:37:57 2008 -0700
+++ b/examples/wscript	Wed Jul 02 13:21:01 2008 -0700
@@ -52,6 +52,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/common/buffer.h	Wed Jul 02 08:37:57 2008 -0700
+++ b/src/common/buffer.h	Wed Jul 02 13:21:01 2008 -0700
@@ -536,6 +536,7 @@
 #ifdef BUFFER_USE_INLINE
 
 #include "ns3/assert.h"
+#include <string.h>
 
 namespace ns3 {
 
--- a/src/common/data-rate.cc	Wed Jul 02 08:37:57 2008 -0700
+++ b/src/common/data-rate.cc	Wed Jul 02 13:21:01 2008 -0700
@@ -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/tag-list.cc	Wed Jul 02 08:37:57 2008 -0700
+++ b/src/common/tag-list.cc	Wed Jul 02 13:21:01 2008 -0700
@@ -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	Wed Jul 02 08:37:57 2008 -0700
+++ b/src/contrib/config-store.cc	Wed Jul 02 13:21:01 2008 -0700
@@ -8,6 +8,7 @@
 #include <fstream>
 #include <iostream>
 #include <unistd.h>
+#include <stdlib.h>
 
 NS_LOG_COMPONENT_DEFINE ("ConfigStore");
 
--- a/src/core/callback.h	Wed Jul 02 08:37:57 2008 -0700
+++ b/src/core/callback.h	Wed Jul 02 13:21:01 2008 -0700
@@ -25,6 +25,7 @@
 #include "fatal-error.h"
 #include "empty.h"
 #include "type-traits.h"
+#include <typeinfo>
 
 namespace ns3 {
 
--- a/src/core/double.h	Wed Jul 02 08:37:57 2008 -0700
+++ b/src/core/double.h	Wed Jul 02 13:21:01 2008 -0700
@@ -23,6 +23,7 @@
 #include "attribute.h"
 #include "attribute-helper.h"
 #include <stdint.h>
+#include <limits>
 
 namespace ns3 {
 
--- a/src/core/integer.h	Wed Jul 02 08:37:57 2008 -0700
+++ b/src/core/integer.h	Wed Jul 02 13:21:01 2008 -0700
@@ -23,6 +23,7 @@
 #include "attribute.h"
 #include "attribute-helper.h"
 #include <stdint.h>
+#include <limits>
 
 namespace ns3 {
 
--- a/src/core/uinteger.h	Wed Jul 02 08:37:57 2008 -0700
+++ b/src/core/uinteger.h	Wed Jul 02 13:21:01 2008 -0700
@@ -23,6 +23,7 @@
 #include "attribute.h"
 #include "attribute-helper.h"
 #include <stdint.h>
+#include <limits>
 
 namespace ns3 {
 
--- a/src/devices/wifi/status-code.h	Wed Jul 02 08:37:57 2008 -0700
+++ b/src/devices/wifi/status-code.h	Wed Jul 02 13:21:01 2008 -0700
@@ -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	Wed Jul 02 08:37:57 2008 -0700
+++ b/src/devices/wifi/supported-rates.h	Wed Jul 02 13:21:01 2008 -0700
@@ -21,6 +21,7 @@
 #define SUPPORTED_RATES_H
 
 #include <stdint.h>
+#include <ostream>
 #include "ns3/buffer.h"
 
 namespace ns3 {
--- a/src/helper/internet-stack-helper.cc	Wed Jul 02 08:37:57 2008 -0700
+++ b/src/helper/internet-stack-helper.cc	Wed Jul 02 13:21:01 2008 -0700
@@ -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	Wed Jul 02 08:37:57 2008 -0700
+++ b/src/helper/olsr-helper.h	Wed Jul 02 13:21:01 2008 -0700
@@ -39,7 +39,7 @@
    */
   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/internet-stack/sgi-hashmap.h	Wed Jul 02 08:37:57 2008 -0700
+++ b/src/internet-stack/sgi-hashmap.h	Wed Jul 02 13:21:01 2008 -0700
@@ -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/node/address.cc	Wed Jul 02 08:37:57 2008 -0700
+++ b/src/node/address.cc	Wed Jul 02 13:21:01 2008 -0700
@@ -1,5 +1,6 @@
 #include "ns3/assert.h"
 #include "address.h"
+#include <string.h>
 #include <iostream>
 #include <iomanip>
 
--- a/src/node/mac48-address.cc	Wed Jul 02 08:37:57 2008 -0700
+++ b/src/node/mac48-address.cc	Wed Jul 02 13:21:01 2008 -0700
@@ -22,6 +22,7 @@
 #include "ns3/assert.h"
 #include <iomanip>
 #include <iostream>
+#include <string.h>
 
 namespace ns3 {
 
--- a/src/node/mac64-address.cc	Wed Jul 02 08:37:57 2008 -0700
+++ b/src/node/mac64-address.cc	Wed Jul 02 13:21:01 2008 -0700
@@ -22,6 +22,7 @@
 #include "ns3/assert.h"
 #include <iomanip>
 #include <iostream>
+#include <string.h>
 
 namespace ns3 {
 
--- a/src/node/socket.cc	Wed Jul 02 08:37:57 2008 -0700
+++ b/src/node/socket.cc	Wed Jul 02 13:21:01 2008 -0700
@@ -25,6 +25,7 @@
 #include "node.h"
 #include "socket.h"
 #include "socket-factory.h"
+#include <limits>
 
 NS_LOG_COMPONENT_DEFINE ("Socket");
 
--- a/src/routing/global-routing/global-route-manager-impl.cc	Wed Jul 02 08:37:57 2008 -0700
+++ b/src/routing/global-routing/global-route-manager-impl.cc	Wed Jul 02 13:21:01 2008 -0700
@@ -1425,6 +1425,7 @@
 
 #include "ns3/test.h"
 #include "ns3/simulator.h"
+#include <stdlib.h> // for rand ()
 
 namespace ns3 {
 
--- a/src/simulator/time.cc	Wed Jul 02 08:37:57 2008 -0700
+++ b/src/simulator/time.cc	Wed Jul 02 13:21:01 2008 -0700
@@ -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	Wed Jul 02 08:37:57 2008 -0700
+++ b/utils/bench-packets.cc	Wed Jul 02 13:21:01 2008 -0700
@@ -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	Wed Jul 02 08:37:57 2008 -0700
+++ b/utils/bench-simulator.cc	Wed Jul 02 13:21:01 2008 -0700
@@ -23,6 +23,7 @@
 #include <iostream>
 #include <fstream>
 #include <vector>
+#include <string.h>
 
 using namespace ns3;
 
--- a/utils/replay-simulation.cc	Wed Jul 02 08:37:57 2008 -0700
+++ b/utils/replay-simulation.cc	Wed Jul 02 13:21:01 2008 -0700
@@ -24,6 +24,7 @@
 #include <deque>
 #include <fstream>
 #include <iostream>
+#include <string.h>
 
 using namespace ns3;