1.1 --- a/examples/csma-broadcast.cc Wed Mar 26 01:33:41 2008 -0700
1.2 +++ b/examples/csma-broadcast.cc Wed Mar 26 11:42:12 2008 -0700
1.3 @@ -33,26 +33,8 @@
1.4 #include <cassert>
1.5
1.6 #include "ns3/core-module.h"
1.7 -#include "ns3/common-module.h"
1.8 -#include "ns3/simulator-module.h"
1.9 #include "ns3/helper-module.h"
1.10 -
1.11 -#include "ns3/ascii-trace.h"
1.12 -#include "ns3/pcap-trace.h"
1.13 -
1.14 -#include "ns3/internet-node.h"
1.15 -#include "ns3/csma-channel.h"
1.16 -#include "ns3/csma-net-device.h"
1.17 -#include "ns3/csma-topology.h"
1.18 -#include "ns3/csma-ipv4-topology.h"
1.19 -#include "ns3/mac48-address.h"
1.20 -#include "ns3/ipv4-address.h"
1.21 -#include "ns3/inet-socket-address.h"
1.22 -#include "ns3/ipv4.h"
1.23 -#include "ns3/socket.h"
1.24 -#include "ns3/ipv4-route.h"
1.25 -#include "ns3/onoff-application.h"
1.26 -#include "ns3/packet-sink.h"
1.27 +#include "ns3/internet-node-module.h"
1.28
1.29 using namespace ns3;
1.30
2.1 --- a/examples/tcp-large-transfer.cc Wed Mar 26 01:33:41 2008 -0700
2.2 +++ b/examples/tcp-large-transfer.cc Wed Mar 26 11:42:12 2008 -0700
2.3 @@ -34,33 +34,13 @@
2.4 #include <string>
2.5 #include <cassert>
2.6
2.7 -#include "ns3/command-line.h"
2.8 -#include "ns3/ptr.h"
2.9 -#include "ns3/random-variable.h"
2.10 -#include "ns3/log.h"
2.11 -
2.12 -#include "ns3/simulator.h"
2.13 -#include "ns3/nstime.h"
2.14 -#include "ns3/data-rate.h"
2.15 +#include "ns3/core-module.h"
2.16 +#include "ns3/helper-module.h"
2.17
2.18 #include "ns3/ascii-trace.h"
2.19 #include "ns3/pcap-trace.h"
2.20 -#include "ns3/internet-node.h"
2.21 -#include "ns3/point-to-point-channel.h"
2.22 -#include "ns3/point-to-point-net-device.h"
2.23 -#include "ns3/ipv4-address.h"
2.24 -#include "ns3/inet-socket-address.h"
2.25 -#include "ns3/ipv4.h"
2.26 -#include "ns3/socket.h"
2.27 -#include "ns3/ipv4-route.h"
2.28 -#include "ns3/point-to-point-topology.h"
2.29 -#include "ns3/onoff-application.h"
2.30 -#include "ns3/packet-sink.h"
2.31 -#include "ns3/error-model.h"
2.32 -#include "ns3/node-list.h"
2.33 -#include "ns3/config.h"
2.34
2.35 -#include "ns3/tcp.h"
2.36 +#include "ns3/internet-node-module.h"
2.37
2.38 using namespace ns3;
2.39
2.40 @@ -101,10 +81,11 @@
2.41 }
2.42
2.43 void StartFlow(Ptr<Socket> localSocket, uint32_t nBytes,
2.44 - uint16_t servPort)
2.45 + Ipv4Address servAddress,
2.46 + uint16_t servPort)
2.47 {
2.48 // NS_LOG_LOGIC("Starting flow at time " << Simulator::Now ().GetSeconds ());
2.49 - localSocket->Connect (InetSocketAddress ("10.1.2.2", servPort));//connect
2.50 + localSocket->Connect (InetSocketAddress (servAddress, servPort));//connect
2.51 localSocket->SetConnectCallback (MakeCallback (&CloseConnection),
2.52 Callback<void, Ptr<Socket> > (),
2.53 Callback<void, Ptr<Socket> > ());
2.54 @@ -133,52 +114,45 @@
2.55
2.56 // Users may find it convenient to turn on explicit debugging
2.57 // for selected modules; the below lines suggest how to do this
2.58 -// LogComponentEnable("TcpL4Protocol", LOG_LEVEL_ALL);
2.59 -// LogComponentEnable("TcpSocket", LOG_LEVEL_ALL);
2.60 -// LogComponentEnable("PacketSink", LOG_LEVEL_ALL);
2.61 - //LogComponentEnable("TcpLargeTransfer", LOG_LEVEL_ALL);
2.62 + // LogComponentEnable("TcpL4Protocol", LOG_LEVEL_ALL);
2.63 + // LogComponentEnable("TcpSocket", LOG_LEVEL_ALL);
2.64 + // LogComponentEnable("PacketSink", LOG_LEVEL_ALL);
2.65 + // LogComponentEnable("TcpLargeTransfer", LOG_LEVEL_ALL);
2.66
2.67 // Allow the user to override any of the defaults and the above
2.68 // Bind()s at run-time, via command-line arguments
2.69 CommandLine cmd;
2.70 cmd.Parse (argc, argv);
2.71
2.72 - // Here, we will explicitly create three nodes. In more sophisticated
2.73 - // topologies, we could configure a node factory.
2.74 - Ptr<Node> n0 = Create<InternetNode> ();
2.75 - Ptr<Node> n1 = Create<InternetNode> ();
2.76 - Ptr<Node> n2 = Create<InternetNode> ();
2.77 + // Here, we will explicitly create three nodes.
2.78 + NodeContainer c0;
2.79 + c0.Create (2);
2.80 +
2.81 + NodeContainer c1;
2.82 + c1.Add (c0.Get (1));
2.83 + c1.Create (1);
2.84
2.85 // We create the channels first without any IP addressing information
2.86 - Ptr<PointToPointChannel> channel0 =
2.87 - PointToPointTopology::AddPointToPointLink (
2.88 - n0, n1, DataRate(10000000), MilliSeconds(10));
2.89 -
2.90 + PointToPointHelper p2p;
2.91 + p2p.SetChannelParameter ("BitRate", DataRate(10000000));
2.92 + p2p.SetChannelParameter ("Delay", MilliSeconds(10));
2.93 + NetDeviceContainer dev0 = p2p.Build (c0);
2.94 + NetDeviceContainer dev1 = p2p.Build (c1);
2.95 +
2.96 + // add ip/tcp stack to nodes.
2.97 + NodeContainer c = NodeContainer (c0, c1.Get (1));
2.98 + InternetStackHelper internet;
2.99 + internet.Build (c);
2.100 +
2.101 // Later, we add IP addresses.
2.102 - PointToPointTopology::AddIpv4Addresses (
2.103 - channel0, n0, Ipv4Address("10.1.3.1"),
2.104 - n1, Ipv4Address("10.1.3.2"));
2.105 + Ipv4AddressHelper ipv4;
2.106 + ipv4.SetBase ("10.1.3.0", "255.255.255.0");
2.107 + ipv4.Allocate (dev0);
2.108 + ipv4.SetBase ("10.1.2.0", "255.255.255.0");
2.109 + ipv4.Allocate (dev1);
2.110
2.111 - Ptr<PointToPointChannel> channel1 =
2.112 - PointToPointTopology::AddPointToPointLink (
2.113 - n1, n2, DataRate(10000000), MilliSeconds(10));
2.114 -
2.115 - PointToPointTopology::AddIpv4Addresses (
2.116 - channel1, n1, Ipv4Address("10.1.2.1"),
2.117 - n2, Ipv4Address("10.1.2.2"));
2.118 -
2.119 - // Finally, we add static routes. These three steps (Channel and
2.120 - // NetDevice creation, IP Address assignment, and routing) are
2.121 - // separated because there may be a need to postpone IP Address
2.122 - // assignment (emulation) or modify to use dynamic routing
2.123 - PointToPointTopology::AddIpv4Routes(n0, n1, channel0);
2.124 - PointToPointTopology::AddIpv4Routes(n1, n2, channel1);
2.125 - Ptr<Ipv4> ipv4;
2.126 - ipv4 = n0->GetObject<Ipv4> ();
2.127 - ipv4->SetDefaultRoute (Ipv4Address ("10.1.3.2"), 1);
2.128 - ipv4 = n2->GetObject<Ipv4> ();
2.129 - ipv4->SetDefaultRoute (Ipv4Address ("10.1.2.1"), 1);
2.130 -
2.131 + // and setup ip routing tables to get total ip-level connectivity.
2.132 + GlobalRouteManager::PopulateRoutingTables ();
2.133
2.134 ///////////////////////////////////////////////////////////////////////////
2.135 // Simulation 1
2.136 @@ -191,21 +165,19 @@
2.137 int nBytes = 2000000;
2.138 uint16_t servPort = 50000;
2.139
2.140 + // Create a packet sink to receive these packets
2.141 + PacketSinkHelper sink;
2.142 + sink.SetupTcp (Ipv4Address::GetAny (), servPort);
2.143 + ApplicationContainer apps = sink.Build (c1.Get (1));
2.144 + apps.Start (Seconds (0.0));
2.145 +
2.146 + // and generate traffic to remote sink.
2.147 Ptr<SocketFactory> socketFactory =
2.148 - n0->GetObject<SocketFactory> ();
2.149 + c0.Get (0)->GetObject<Tcp> ();
2.150 Ptr<Socket> localSocket = socketFactory->CreateSocket ();
2.151 localSocket->Bind ();
2.152 -
2.153 - // Create a packet sink to receive these packets
2.154 - Ptr<PacketSink> sink =
2.155 - CreateObject<PacketSink> ("Local", Address (InetSocketAddress (Ipv4Address::GetAny (), servPort)),
2.156 - "Protocol", TypeId::LookupByName ("ns3::Tcp"));
2.157 - n2->AddApplication (sink);
2.158 - sink->Start (Seconds (0.0));
2.159 - sink->Stop (Seconds (100.0));
2.160 -
2.161 - Simulator::Schedule(Seconds(0), &StartFlow, localSocket, nBytes,
2.162 - servPort);
2.163 + Simulator::ScheduleNow (&StartFlow, localSocket, nBytes,
2.164 + Ipv4Address ("10.1.2.2"), servPort);
2.165
2.166 // Configure tracing of all enqueue, dequeue, and NetDevice receive events
2.167 // Trace output will be sent to the simple-examples.tr file
3.1 --- a/src/applications/onoff/onoff-application.cc Wed Mar 26 01:33:41 2008 -0700
3.2 +++ b/src/applications/onoff/onoff-application.cc Wed Mar 26 11:42:12 2008 -0700
3.3 @@ -71,6 +71,13 @@
3.4 ConstantVariable (1.0),
3.5 MakeRandomVariableAccessor (&OnOffApplication::m_offTime),
3.6 MakeRandomVariableChecker ())
3.7 + .AddAttribute ("MaxBytes",
3.8 + "The total number of bytes to send. Once these bytes are sent, "
3.9 + "no packet is sent again, even in on state. The value zero means "
3.10 + "that there is no limit.",
3.11 + Uinteger (0),
3.12 + MakeUintegerAccessor (&OnOffApplication::m_maxBytes),
3.13 + MakeUintegerChecker<uint32_t> ())
3.14 .AddAttribute ("Protocol", "The type of protocol to use.",
3.15 Udp::GetTypeId (),
3.16 MakeTypeIdAccessor (&OnOffApplication::m_tid),
3.17 @@ -89,7 +96,6 @@
3.18 m_connected = false;
3.19 m_residualBits = 0;
3.20 m_lastStartTime = Seconds (0);
3.21 - m_maxBytes = 0;
3.22 m_totBytes = 0;
3.23 }
3.24
4.1 --- a/src/devices/csma/csma-channel.cc Wed Mar 26 01:33:41 2008 -0700
4.2 +++ b/src/devices/csma/csma-channel.cc Wed Mar 26 11:42:12 2008 -0700
4.3 @@ -358,7 +358,7 @@
4.4 Ptr<NetDevice>
4.5 CsmaChannel::GetDevice (uint32_t i) const
4.6 {
4.7 - return GetDevice (i);
4.8 + return GetCsmaDevice (i);
4.9 }
4.10
4.11 } // namespace ns3
5.1 --- a/src/devices/point-to-point/point-to-point-channel.cc Wed Mar 26 01:33:41 2008 -0700
5.2 +++ b/src/devices/point-to-point/point-to-point-channel.cc Wed Mar 26 11:42:12 2008 -0700
5.3 @@ -29,6 +29,8 @@
5.4
5.5 namespace ns3 {
5.6
5.7 +NS_OBJECT_ENSURE_REGISTERED (PointToPointChannel);
5.8 +
5.9 TypeId
5.10 PointToPointChannel::GetTypeId (void)
5.11 {
6.1 --- a/src/helper/point-to-point-helper.cc Wed Mar 26 01:33:41 2008 -0700
6.2 +++ b/src/helper/point-to-point-helper.cc Wed Mar 26 11:42:12 2008 -0700
6.3 @@ -7,7 +7,11 @@
6.4
6.5
6.6 PointToPointHelper::PointToPointHelper ()
6.7 -{}
6.8 +{
6.9 + m_queueFactory.SetTypeId ("ns3::DropTailQueue");
6.10 + m_deviceFactory.SetTypeId ("ns3::PointToPointNetDevice");
6.11 + m_channelFactory.SetTypeId ("ns3::PointToPointChannel");
6.12 +}
6.13
6.14 void
6.15 PointToPointHelper::SetQueue (std::string type,
6.16 @@ -47,17 +51,17 @@
6.17 {
6.18 NetDeviceContainer container;
6.19
6.20 - Ptr<PointToPointNetDevice> devA = CreateObject<PointToPointNetDevice> ();
6.21 + Ptr<PointToPointNetDevice> devA = m_deviceFactory.Create<PointToPointNetDevice> ();
6.22 devA->SetAddress (Mac48Address::Allocate ());
6.23 a->AddDevice (devA);
6.24 Ptr<Queue> queueA = m_queueFactory.Create<Queue> ();
6.25 devA->AddQueue (queueA);
6.26 - Ptr<PointToPointNetDevice> devB = CreateObject<PointToPointNetDevice> ();
6.27 + Ptr<PointToPointNetDevice> devB = m_deviceFactory.Create<PointToPointNetDevice> ();
6.28 devB->SetAddress (Mac48Address::Allocate ());
6.29 b->AddDevice (devB);
6.30 Ptr<Queue> queueB = m_queueFactory.Create<Queue> ();
6.31 devB->AddQueue (queueB);
6.32 - Ptr<PointToPointChannel> channel = CreateObject<PointToPointChannel> ();
6.33 + Ptr<PointToPointChannel> channel = m_channelFactory.Create<PointToPointChannel> ();
6.34 devA->Attach (channel);
6.35 devB->Attach (channel);
6.36 container.Add (devA);
7.1 --- a/src/wscript Wed Mar 26 01:33:41 2008 -0700
7.2 +++ b/src/wscript Wed Mar 26 11:42:12 2008 -0700
7.3 @@ -153,10 +153,10 @@
7.4 #ifndef NS3_MODULE_%s
7.5 """ % (task.module.upper().replace('-', '_'),)
7.6
7.7 - if task.module_deps:
7.8 - print >> outfile, "// Module dependencies:"
7.9 - for dep in task.module_deps:
7.10 - print >> outfile, "#include \"%s-module.h\"" % dep
7.11 +# if task.module_deps:
7.12 +# print >> outfile, "// Module dependencies:"
7.13 +# for dep in task.module_deps:
7.14 +# print >> outfile, "#include \"%s-module.h\"" % dep
7.15
7.16 print >> outfile
7.17 print >> outfile, "// Module headers:"