diff --git a/examples/tcp-star-server.cc b/examples/tcp-star-server.cc new file mode 100644 index 000000000..81c7f58f3 --- /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; i 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/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/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/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/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/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..cce8e4aea 100644 --- a/src/helper/olsr-helper.h +++ b/src/helper/olsr-helper.h @@ -39,7 +39,7 @@ public: */ 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/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/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/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/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/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/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;