branch merge
authorCraig Dowell <craigdo@ee.washington.edu>
Wed Mar 26 21:28:27 2008 -0700 (22 months ago)
changeset 285230000484443d
parent 2851 3d683ff1543a
parent 2760 d745bd7a18e8
child 2853 1cff5dd98f63
branch merge
     1.1 --- a/examples/csma-broadcast.cc	Wed Mar 26 21:28:13 2008 -0700
     1.2 +++ b/examples/csma-broadcast.cc	Wed Mar 26 21:28:27 2008 -0700
     1.3 @@ -35,6 +35,7 @@
     1.4  #include "ns3/core-module.h"
     1.5  #include "ns3/helper-module.h"
     1.6  #include "ns3/internet-node-module.h"
     1.7 +#include "ns3/simulator-module.h"
     1.8  
     1.9  using namespace ns3;
    1.10  
     2.1 --- a/examples/mixed-global-routing.cc	Wed Mar 26 21:28:13 2008 -0700
     2.2 +++ b/examples/mixed-global-routing.cc	Wed Mar 26 21:28:27 2008 -0700
     2.3 @@ -36,36 +36,12 @@
     2.4  #include <string>
     2.5  #include <cassert>
     2.6  
     2.7 -#include "ns3/log.h"
     2.8 -
     2.9 -#include "ns3/command-line.h"
    2.10 -#include "ns3/ptr.h"
    2.11 -#include "ns3/random-variable.h"
    2.12 -#include "ns3/config.h"
    2.13 -
    2.14 -#include "ns3/simulator.h"
    2.15 -#include "ns3/nstime.h"
    2.16 -#include "ns3/data-rate.h"
    2.17 -
    2.18 +#include "ns3/core-module.h"
    2.19 +#include "ns3/helper-module.h"
    2.20 +#include "ns3/simulator-module.h"
    2.21  #include "ns3/ascii-trace.h"
    2.22  #include "ns3/pcap-trace.h"
    2.23 -#include "ns3/internet-node.h"
    2.24 -#include "ns3/point-to-point-channel.h"
    2.25 -#include "ns3/point-to-point-net-device.h"
    2.26 -#include "ns3/csma-channel.h"
    2.27 -#include "ns3/csma-net-device.h"
    2.28 -#include "ns3/csma-topology.h"
    2.29 -#include "ns3/csma-ipv4-topology.h"
    2.30 -#include "ns3/mac48-address.h"
    2.31 -#include "ns3/ipv4-address.h"
    2.32 -#include "ns3/ipv4.h"
    2.33 -#include "ns3/socket.h"
    2.34 -#include "ns3/inet-socket-address.h"
    2.35 -#include "ns3/ipv4-route.h"
    2.36 -#include "ns3/point-to-point-topology.h"
    2.37 -#include "ns3/onoff-application.h"
    2.38  #include "ns3/global-route-manager.h"
    2.39 -#include "ns3/uinteger.h"
    2.40  
    2.41  using namespace ns3;
    2.42  
    2.43 @@ -114,68 +90,49 @@
    2.44    cmd.Parse (argc, argv);
    2.45  
    2.46    NS_LOG_INFO ("Create nodes.");
    2.47 -  Ptr<Node> n0 = CreateObject<InternetNode> ();
    2.48 -  Ptr<Node> n1 = CreateObject<InternetNode> (); 
    2.49 -  Ptr<Node> n2 = CreateObject<InternetNode> (); 
    2.50 -  Ptr<Node> n3 = CreateObject<InternetNode> ();
    2.51 -  Ptr<Node> n4 = CreateObject<InternetNode> (); 
    2.52 -  Ptr<Node> n5 = CreateObject<InternetNode> (); 
    2.53 -  Ptr<Node> n6 = CreateObject<InternetNode> ();
    2.54 +  NodeContainer c;
    2.55 +  c.Create (7);
    2.56 +  NodeContainer n0n2 = NodeContainer (c.Get (0), c.Get (2));
    2.57 +  NodeContainer n1n2 = NodeContainer (c.Get (1), c.Get (2));
    2.58 +  NodeContainer n5n6 = NodeContainer (c.Get (5), c.Get (6));
    2.59 +  NodeContainer n2345 = NodeContainer (c.Get (2), c.Get (3), c.Get (4), c.Get (5));
    2.60 +
    2.61 +  InternetStackHelper internet;
    2.62 +  internet.Build (c);
    2.63  
    2.64    // We create the channels first without any IP addressing information
    2.65    NS_LOG_INFO ("Create channels.");
    2.66 -  Ptr<PointToPointChannel> channel0 = 
    2.67 -    PointToPointTopology::AddPointToPointLink (
    2.68 -      n0, n2, DataRate (5000000), MilliSeconds (2));
    2.69 +  PointToPointHelper p2p;
    2.70 +  p2p.SetChannelParameter ("BitRate", DataRate (5000000));
    2.71 +  p2p.SetChannelParameter ("Delay", MilliSeconds (2));
    2.72 +  NetDeviceContainer d0d2 = p2p.Build (n0n2);
    2.73  
    2.74 -  Ptr<PointToPointChannel> channel1 = 
    2.75 -    PointToPointTopology::AddPointToPointLink (
    2.76 -      n1, n2, DataRate (5000000), MilliSeconds (2));
    2.77 -  
    2.78 -  Ptr<PointToPointChannel> channel2 = 
    2.79 -    PointToPointTopology::AddPointToPointLink (
    2.80 -      n5, n6, DataRate (1500000), MilliSeconds (10));
    2.81 +  NetDeviceContainer d1d2 = p2p.Build (n1n2);
    2.82 +
    2.83 +  p2p.SetChannelParameter ("BitRate", DataRate (1500000));
    2.84 +  p2p.SetChannelParameter ("Delay", MilliSeconds (10));
    2.85 +  NetDeviceContainer d5d6 = p2p.Build (n5n6);
    2.86  
    2.87    // We create the channels first without any IP addressing information
    2.88 -  Ptr<CsmaChannel> channelc0 = 
    2.89 -    CsmaTopology::CreateCsmaChannel(
    2.90 -      DataRate(5000000), MilliSeconds(2));
    2.91 -
    2.92 -  NS_LOG_INFO ("Build Topology.");
    2.93 -  uint32_t n2ifIndex = CsmaIpv4Topology::AddIpv4CsmaNetDevice (n2, channelc0,
    2.94 -                                         Mac48Address("10:54:23:54:23:50"));
    2.95 -  uint32_t n3ifIndex = CsmaIpv4Topology::AddIpv4CsmaNetDevice (n3, channelc0,
    2.96 -                                         Mac48Address("10:54:23:54:23:51"));
    2.97 -  uint32_t n4ifIndex = CsmaIpv4Topology::AddIpv4CsmaNetDevice (n4, channelc0,
    2.98 -                                         Mac48Address("10:54:23:54:23:52"));
    2.99 -  uint32_t n5ifIndex = CsmaIpv4Topology::AddIpv4CsmaNetDevice (n5, channelc0,
   2.100 -                                         Mac48Address("10:54:23:54:23:53"));
   2.101 -
   2.102 +  CsmaHelper csma;
   2.103 +  csma.SetChannelParameter ("BitRate", DataRate (5000000));
   2.104 +  csma.SetChannelParameter ("Delay", MilliSeconds (2));
   2.105 +  NetDeviceContainer d2345 = csma.Build (n2345);
   2.106 +  
   2.107    // Later, we add IP addresses.  
   2.108    NS_LOG_INFO ("Assign IP Addresses.");
   2.109 -  PointToPointTopology::AddIpv4Addresses (
   2.110 -      channel0, n0, Ipv4Address ("10.1.1.1"),
   2.111 -      n2, Ipv4Address ("10.1.1.2"));
   2.112 -  
   2.113 -  PointToPointTopology::AddIpv4Addresses (
   2.114 -      channel1, n1, Ipv4Address ("10.1.2.1"),
   2.115 -      n2, Ipv4Address ("10.1.2.2"));
   2.116 -  
   2.117 -  PointToPointTopology::AddIpv4Addresses (
   2.118 -      channel2, n5, Ipv4Address ("10.1.3.1"),
   2.119 -      n6, Ipv4Address ("10.1.3.2"));
   2.120 +  Ipv4AddressHelper ipv4;
   2.121 +  ipv4.SetBase ("10.1.1.0", "255.255.255.0");
   2.122 +  ipv4.Allocate (d0d2);
   2.123  
   2.124 -  CsmaIpv4Topology::AddIpv4Address (
   2.125 -      n2, n2ifIndex, Ipv4Address("10.250.1.1"), Ipv4Mask("255.255.255.0"));
   2.126 +  ipv4.SetBase ("10.1.2.0", "255.255.255.0");
   2.127 +  ipv4.Allocate (d1d2);
   2.128  
   2.129 -  CsmaIpv4Topology::AddIpv4Address (
   2.130 -      n3, n3ifIndex, Ipv4Address("10.250.1.2"), Ipv4Mask("255.255.255.0"));
   2.131 -  
   2.132 -  CsmaIpv4Topology::AddIpv4Address (
   2.133 -      n4, n4ifIndex, Ipv4Address("10.250.1.3"), Ipv4Mask("255.255.255.0"));
   2.134 -  
   2.135 -  CsmaIpv4Topology::AddIpv4Address (
   2.136 -      n5, n5ifIndex, Ipv4Address("10.250.1.4"), Ipv4Mask("255.255.255.0"));
   2.137 +  ipv4.SetBase ("10.1.3.0", "255.255.255.0");
   2.138 +  Ipv4InterfaceContainer i5i6 = ipv4.Allocate (d5d6);
   2.139 +
   2.140 +  ipv4.SetBase ("10.250.1.0", "255.255.255.0");
   2.141 +  ipv4.Allocate (d2345);
   2.142  
   2.143    // Create router nodes, initialize routing database and set up the routing
   2.144    // tables in the nodes.
   2.145 @@ -185,17 +142,15 @@
   2.146    // 210 bytes at a rate of 448 Kb/s
   2.147    NS_LOG_INFO ("Create Applications.");
   2.148    uint16_t port = 9;   // Discard port (RFC 863)
   2.149 -  Ptr<OnOffApplication> ooff = 
   2.150 -    CreateObject<OnOffApplication> ("Remote", Address (InetSocketAddress ("10.1.3.2", port)), 
   2.151 -                                    "Protocol", TypeId::LookupByName ("ns3::Udp"),
   2.152 -                                    "OnTime", ConstantVariable (1), 
   2.153 -                                    "OffTime", ConstantVariable (0),
   2.154 -                                    "DataRate", DataRate("300bps"),
   2.155 -                                    "PacketSize", Uinteger (50));
   2.156 -  n0->AddApplication (ooff);
   2.157 -  // Start the application
   2.158 -  ooff->Start (Seconds (1.0));
   2.159 -  ooff->Stop (Seconds (10.0));
   2.160 +  OnOffHelper onoff;
   2.161 +  onoff.SetAppAttribute ("OnTime", ConstantVariable (1));
   2.162 +  onoff.SetAppAttribute ("OffTime", ConstantVariable (0));
   2.163 +  onoff.SetAppAttribute ("DataRate", DataRate("300bps"));
   2.164 +  onoff.SetAppAttribute ("PacketSize", Uinteger (50));
   2.165 +  onoff.SetUdpRemote (i5i6.GetAddress (1), port);
   2.166 +  ApplicationContainer apps = onoff.Build (c.Get (0));
   2.167 +  apps.Start (Seconds (1.0));
   2.168 +  apps.Stop (Seconds (10.0));
   2.169  
   2.170    // Configure tracing of all enqueue, dequeue, and NetDevice receive events
   2.171    // Trace output will be sent to the simple-global-routing.tr file
     3.1 --- a/examples/simple-alternate-routing.cc	Wed Mar 26 21:28:13 2008 -0700
     3.2 +++ b/examples/simple-alternate-routing.cc	Wed Mar 26 21:28:27 2008 -0700
     3.3 @@ -37,32 +37,12 @@
     3.4  #include <string>
     3.5  #include <cassert>
     3.6  
     3.7 -#include "ns3/log.h"
     3.8 -
     3.9 -#include "ns3/command-line.h"
    3.10 -#include "ns3/ptr.h"
    3.11 -#include "ns3/random-variable.h"
    3.12 -#include "ns3/config.h"
    3.13 -#include "ns3/uinteger.h"
    3.14 -
    3.15 -#include "ns3/simulator.h"
    3.16 -#include "ns3/nstime.h"
    3.17 -#include "ns3/data-rate.h"
    3.18 -
    3.19 +#include "ns3/core-module.h"
    3.20 +#include "ns3/simulator-module.h"
    3.21 +#include "ns3/helper-module.h"
    3.22 +#include "ns3/global-route-manager.h"
    3.23  #include "ns3/ascii-trace.h"
    3.24  #include "ns3/pcap-trace.h"
    3.25 -#include "ns3/internet-node.h"
    3.26 -#include "ns3/point-to-point-channel.h"
    3.27 -#include "ns3/point-to-point-net-device.h"
    3.28 -#include "ns3/ipv4-address.h"
    3.29 -#include "ns3/ipv4.h"
    3.30 -#include "ns3/socket.h"
    3.31 -#include "ns3/inet-socket-address.h"
    3.32 -#include "ns3/ipv4-route.h"
    3.33 -#include "ns3/point-to-point-topology.h"
    3.34 -#include "ns3/onoff-application.h"
    3.35 -#include "ns3/packet-sink.h"
    3.36 -#include "ns3/global-route-manager.h"
    3.37  
    3.38  using namespace ns3;
    3.39  
    3.40 @@ -128,50 +108,50 @@
    3.41    // Here, we will explicitly create four nodes.  In more sophisticated
    3.42    // topologies, we could configure a node factory.
    3.43    NS_LOG_INFO ("Create nodes.");
    3.44 -  Ptr<Node> n0 = CreateObject<InternetNode> ();
    3.45 -  Ptr<Node> n1 = CreateObject<InternetNode> (); 
    3.46 -  Ptr<Node> n2 = CreateObject<InternetNode> (); 
    3.47 -  Ptr<Node> n3 = CreateObject<InternetNode> ();
    3.48 +  NodeContainer c;
    3.49 +  c.Create (4);
    3.50 +  NodeContainer n0n2 = NodeContainer (c.Get (0), c.Get (2));
    3.51 +  NodeContainer n1n2 = NodeContainer (c.Get (1), c.Get (2));
    3.52 +  NodeContainer n3n2 = NodeContainer (c.Get (3), c.Get (2));
    3.53 +  NodeContainer n1n3 = NodeContainer (c.Get (1), c.Get (3));
    3.54  
    3.55    // We create the channels first without any IP addressing information
    3.56    NS_LOG_INFO ("Create channels.");
    3.57 -  Ptr<PointToPointChannel> channel0 = 
    3.58 -    PointToPointTopology::AddPointToPointLink (
    3.59 -      n0, n2, DataRate (5000000), MilliSeconds (2));
    3.60 +  PointToPointHelper p2p;
    3.61 +  p2p.SetChannelParameter ("BitRate", DataRate (5000000));
    3.62 +  p2p.SetChannelParameter ("Delay", MilliSeconds (2));
    3.63 +  NetDeviceContainer d0d2 = p2p.Build (n0n2);
    3.64  
    3.65 -  Ptr<PointToPointChannel> channel1 = 
    3.66 -    PointToPointTopology::AddPointToPointLink (
    3.67 -      n1, n2, DataRate (5000000), MilliSeconds (2));
    3.68 -  
    3.69 -  Ptr<PointToPointChannel> channel2 = 
    3.70 -    PointToPointTopology::AddPointToPointLink (
    3.71 -      n2, n3, DataRate (1500000), MilliSeconds (10));
    3.72 -  
    3.73 -  Ptr<PointToPointChannel> channel3 = 
    3.74 -    PointToPointTopology::AddPointToPointLink (
    3.75 -      n1, n3, DataRate (1500000), MilliSeconds (100));
    3.76 +  NetDeviceContainer d1d2 = p2p.Build (n1n2);
    3.77 +
    3.78 +  p2p.SetChannelParameter ("BitRate", DataRate(1500000));
    3.79 +  p2p.SetChannelParameter ("Delay", MilliSeconds (10));
    3.80 +  NetDeviceContainer d3d2 = p2p.Build (n3n2);
    3.81 +
    3.82 +  p2p.SetChannelParameter ("Delay", MilliSeconds (100));
    3.83 +  NetDeviceContainer d1d3 = p2p.Build (n1n3);
    3.84 +
    3.85 +  InternetStackHelper internet;
    3.86 +  internet.Build (c);
    3.87    
    3.88    // Later, we add IP addresses.  The middle two octets correspond to 
    3.89   // the channel number.  
    3.90    NS_LOG_INFO ("Assign IP Addresses.");
    3.91 -  PointToPointTopology::AddIpv4Addresses (
    3.92 -      channel0, n0, Ipv4Address ("10.0.0.1"),
    3.93 -      n2, Ipv4Address ("10.0.0.2"));
    3.94 +  Ipv4AddressHelper ipv4;
    3.95 +  ipv4.SetBase ("10.0.0.0", "255.255.255.0");
    3.96 +  ipv4.Allocate (d0d2);
    3.97    
    3.98 -  PointToPointTopology::AddIpv4Addresses (
    3.99 -      channel1, n1, Ipv4Address ("10.1.1.1"),
   3.100 -      n2, Ipv4Address ("10.1.1.2"));
   3.101 +  ipv4.SetBase ("10.1.1.0", "255.255.255.0");
   3.102 +  Ipv4InterfaceContainer i1i2 = ipv4.Allocate (d1d2);
   3.103    
   3.104 -  PointToPointTopology::AddIpv4Addresses (
   3.105 -      channel2, n2, Ipv4Address ("10.2.2.1"),
   3.106 -      n3, Ipv4Address ("10.2.2.2"));
   3.107 +  ipv4.SetBase ("10.2.2.0", "255.255.255.0");
   3.108 +  ipv4.Allocate (d3d2);
   3.109  
   3.110 -  PointToPointTopology::AddIpv4Addresses (
   3.111 -      channel3, n1, Ipv4Address ("10.3.3.1"),
   3.112 -      n3, Ipv4Address ("10.3.3.2"));
   3.113 +  ipv4.SetBase ("10.3.3.0", "255.255.255.0");
   3.114 +  Ipv4InterfaceContainer i1i3 = ipv4.Allocate (d1d3);
   3.115  
   3.116 -  PointToPointTopology::SetIpv4Metric (
   3.117 -      channel3, n1, n3, sampleMetric);
   3.118 +  i1i3.SetMetric (0, sampleMetric);
   3.119 +  i1i3.SetMetric (1, sampleMetric);
   3.120  
   3.121    // Create router nodes, initialize routing database and set up the routing
   3.122    // tables in the nodes.
   3.123 @@ -182,24 +162,20 @@
   3.124    uint16_t port = 9;   // Discard port (RFC 863)
   3.125  
   3.126    // Create a flow from n3 to n1, starting at time 1.1 seconds
   3.127 -  Ptr<OnOffApplication> ooff = 
   3.128 -    CreateObject<OnOffApplication> ("Remote", Address (InetSocketAddress ("10.1.1.1", port)),
   3.129 -                                    "Protocol", TypeId::LookupByName ("ns3::Udp"),
   3.130 -                                    "OnTime", ConstantVariable (1), 
   3.131 -                                    "OffTime", ConstantVariable (0));
   3.132 -  n3->AddApplication (ooff);
   3.133 -  // Start the application
   3.134 -  ooff->Start (Seconds (1.1));
   3.135 -  ooff->Stop (Seconds (10.0));
   3.136 +  OnOffHelper onoff;
   3.137 +  onoff.SetAppAttribute ("OnTime", ConstantVariable (1));
   3.138 +  onoff.SetAppAttribute ("OffTime", ConstantVariable (0));
   3.139 +  onoff.SetUdpRemote (i1i2.GetAddress (0), port);
   3.140 +  ApplicationContainer apps = onoff.Build (c.Get (3));
   3.141 +  apps.Start (Seconds (1.1));
   3.142 +  apps.Start (Seconds (10.0));
   3.143  
   3.144    // Create a packet sink to receive these packets
   3.145 -  Ptr<PacketSink> sink = 
   3.146 -    CreateObject<PacketSink> ("Remote", Address (InetSocketAddress (Ipv4Address::GetAny (), port)), 
   3.147 -                              "Protocol", TypeId::LookupByName ("ns3::Udp"));
   3.148 -  n1->AddApplication (sink);
   3.149 -  // Start the sink
   3.150 -  sink->Start (Seconds (1.1));
   3.151 -  sink->Stop (Seconds (10.0));
   3.152 +  PacketSinkHelper sink;
   3.153 +  sink.SetupUdp (Ipv4Address::GetAny (), port);
   3.154 +  apps = sink.Build (c.Get (1));
   3.155 +  apps.Start (Seconds (1.1));
   3.156 +  apps.Stop (Seconds (10.0));
   3.157  
   3.158    // Configure tracing of all enqueue, dequeue, and NetDevice receive events
   3.159    // Trace output will be sent to the simple-alternate-routing.tr file
     4.1 --- a/examples/simple-error-model.cc	Wed Mar 26 21:28:13 2008 -0700
     4.2 +++ b/examples/simple-error-model.cc	Wed Mar 26 21:28:27 2008 -0700
     4.3 @@ -38,34 +38,13 @@
     4.4  // - Tracing of queues and packet receptions to file 
     4.5  //   "simple-error-model.tr"
     4.6  
     4.7 -#include "ns3/log.h"
     4.8 -#include "ns3/assert.h"
     4.9 -#include "ns3/command-line.h"
    4.10 -#include "ns3/ptr.h"
    4.11 -#include "ns3/config.h"
    4.12 -#include "ns3/uinteger.h"
    4.13 -#include "ns3/string.h"
    4.14 -
    4.15 -#include "ns3/simulator.h"
    4.16 -#include "ns3/nstime.h"
    4.17 -#include "ns3/data-rate.h"
    4.18 -
    4.19 +#include "ns3/core-module.h"
    4.20 +#include "ns3/common-module.h"
    4.21 +#include "ns3/simulator-module.h"
    4.22 +#include "ns3/helper-module.h"
    4.23  #include "ns3/ascii-trace.h"
    4.24  #include "ns3/pcap-trace.h"
    4.25 -#include "ns3/internet-node.h"
    4.26 -#include "ns3/random-variable.h"
    4.27 -#include "ns3/point-to-point-channel.h"
    4.28 -#include "ns3/point-to-point-net-device.h"
    4.29 -#include "ns3/ipv4-address.h"
    4.30 -#include "ns3/inet-socket-address.h"
    4.31 -#include "ns3/ipv4.h"
    4.32 -#include "ns3/socket.h"
    4.33 -#include "ns3/ipv4-route.h"
    4.34 -#include "ns3/point-to-point-topology.h"
    4.35 -#include "ns3/onoff-application.h"
    4.36 -#include "ns3/packet-sink.h"
    4.37 -#include "ns3/error-model.h"
    4.38 -#include "ns3/double.h"
    4.39 +#include "ns3/global-route-manager.h"
    4.40  
    4.41  using namespace ns3;
    4.42  
    4.43 @@ -96,122 +75,92 @@
    4.44    // Here, we will explicitly create four nodes.  In more sophisticated
    4.45    // topologies, we could configure a node factory.
    4.46    NS_LOG_INFO ("Create nodes.");
    4.47 -  Ptr<Node> n0 = CreateObject<InternetNode> ();
    4.48 -  Ptr<Node> n1 = CreateObject<InternetNode> (); 
    4.49 -  Ptr<Node> n2 = CreateObject<InternetNode> (); 
    4.50 -  Ptr<Node> n3 = CreateObject<InternetNode> ();
    4.51 +  NodeContainer c;
    4.52 +  c.Create (4);
    4.53 +  NodeContainer n0n2 = NodeContainer (c.Get (0), c.Get (2));
    4.54 +  NodeContainer n1n2 = NodeContainer (c.Get (1), c.Get (2));
    4.55 +  NodeContainer n3n2 = NodeContainer (c.Get (3), c.Get (2));
    4.56 +
    4.57 +  InternetStackHelper internet;
    4.58 +  internet.Build (c);
    4.59  
    4.60    // We create the channels first without any IP addressing information
    4.61    NS_LOG_INFO ("Create channels.");
    4.62 -  Ptr<PointToPointChannel> channel0 = 
    4.63 -    PointToPointTopology::AddPointToPointLink (
    4.64 -      n0, n2, DataRate(5000000), MilliSeconds(2));
    4.65 +  PointToPointHelper p2p;
    4.66 +  p2p.SetChannelParameter ("BitRate", DataRate (5000000));
    4.67 +  p2p.SetChannelParameter ("Delay", MilliSeconds (2));
    4.68 +  NetDeviceContainer d0d2 = p2p.Build (n0n2);
    4.69  
    4.70 -  Ptr<PointToPointChannel> channel1 = 
    4.71 -    PointToPointTopology::AddPointToPointLink (
    4.72 -      n1, n2, DataRate(5000000), MilliSeconds(2));
    4.73 -  
    4.74 -  Ptr<PointToPointChannel> channel2 = 
    4.75 -    PointToPointTopology::AddPointToPointLink (
    4.76 -      n2, n3, DataRate(1500000), MilliSeconds(10));
    4.77 +  NetDeviceContainer d1d2 = p2p.Build (n1n2);
    4.78 +
    4.79 +  p2p.SetChannelParameter ("BitRate", DataRate (1500000));
    4.80 +  p2p.SetChannelParameter ("Delay", MilliSeconds (10));
    4.81 +  NetDeviceContainer d3d2 = p2p.Build (n3n2);
    4.82    
    4.83    // Later, we add IP addresses.  
    4.84    NS_LOG_INFO ("Assign IP Addresses.");
    4.85 -  PointToPointTopology::AddIpv4Addresses (
    4.86 -      channel0, n0, Ipv4Address("10.1.1.1"),
    4.87 -      n2, Ipv4Address("10.1.1.2"));
    4.88 +  Ipv4AddressHelper ipv4;
    4.89 +  ipv4.SetBase ("10.1.1.0", "255.255.255.0");
    4.90 +  ipv4.Allocate (d0d2);
    4.91    
    4.92 -  PointToPointTopology::AddIpv4Addresses (
    4.93 -      channel1, n1, Ipv4Address("10.1.2.1"),
    4.94 -      n2, Ipv4Address("10.1.2.2"));
    4.95 -  
    4.96 -  PointToPointTopology::AddIpv4Addresses (
    4.97 -      channel2, n2, Ipv4Address("10.1.3.1"),
    4.98 -      n3, Ipv4Address("10.1.3.2"));
    4.99 +  ipv4.SetBase ("10.1.2.0", "255.255.255.0");
   4.100 +  Ipv4InterfaceContainer i1i2 = ipv4.Allocate (d1d2);
   4.101  
   4.102 -  // Finally, we add static routes.  These three steps (Channel and
   4.103 -  // NetDevice creation, IP Address assignment, and routing) are 
   4.104 -  // separated because there may be a need to postpone IP Address
   4.105 -  // assignment (emulation) or modify to use dynamic routing
   4.106 -  NS_LOG_INFO ("Add Static Routes.");
   4.107 -  PointToPointTopology::AddIpv4Routes(n0, n2, channel0);
   4.108 -  PointToPointTopology::AddIpv4Routes(n1, n2, channel1);
   4.109 -  PointToPointTopology::AddIpv4Routes(n2, n3, channel2);
   4.110 +  ipv4.SetBase ("10.1.3.0", "255.255.255.0");
   4.111 +  Ipv4InterfaceContainer i3i2 = ipv4.Allocate (d3d2);
   4.112 +
   4.113 +  NS_LOG_INFO ("Use global routing.");
   4.114 +  GlobalRouteManager::PopulateRoutingTables ();
   4.115  
   4.116    // Create the OnOff application to send UDP datagrams of size
   4.117    // 210 bytes at a rate of 448 Kb/s
   4.118    NS_LOG_INFO ("Create Applications.");
   4.119    uint16_t port = 9;   // Discard port (RFC 863)
   4.120 -  Ptr<OnOffApplication> ooff = 
   4.121 -    CreateObject<OnOffApplication> ("Remote", Address (InetSocketAddress ("10.1.3.2", port)), 
   4.122 -                                    "Protocol", TypeId::LookupByName ("ns3::Udp"),
   4.123 -                                    "OnTime", ConstantVariable(1), 
   4.124 -                                    "OffTime", ConstantVariable(0));
   4.125 -  n0->AddApplication (ooff);
   4.126 -  // Start the application
   4.127 -  ooff->Start(Seconds(1.0));
   4.128 -  ooff->Stop (Seconds(10.0));
   4.129 +  OnOffHelper onoff;
   4.130 +  onoff.SetUdpRemote (i3i2.GetAddress (1), port);
   4.131 +  onoff.SetAppAttribute ("OnTime", ConstantVariable(1));
   4.132 +  onoff.SetAppAttribute ("OffTime", ConstantVariable(0));
   4.133 +  ApplicationContainer apps = onoff.Build (c.Get (0));
   4.134 +  apps.Start(Seconds(1.0));
   4.135 +  apps.Stop (Seconds(10.0));
   4.136  
   4.137    // Create an optional packet sink to receive these packets
   4.138 -  Ptr<PacketSink> sink = CreateObject<PacketSink> ("Local", Address (InetSocketAddress (Ipv4Address::GetAny (), port)),
   4.139 -                                                   "Protocol", TypeId::LookupByName ("ns3::Udp"));
   4.140 -  n3->AddApplication (sink);
   4.141 -  // Start the sink
   4.142 -  sink->Start (Seconds (1.0));
   4.143 -  sink->Stop (Seconds (10.0));
   4.144 +  PacketSinkHelper sink;
   4.145 +  sink.SetupUdp (Ipv4Address::GetAny (), port);
   4.146 +  apps = sink.Build (c.Get (3));
   4.147 +  apps.Start (Seconds (1.0));
   4.148 +  apps.Stop (Seconds (10.0));
   4.149  
   4.150    // Create a similar flow from n3 to n1, starting at time 1.1 seconds
   4.151 -  ooff = CreateObject<OnOffApplication> ("Remote", Address (InetSocketAddress ("10.1.2.1", port)), 
   4.152 -                                         "Protocol", TypeId::LookupByName ("ns3::Udp"),
   4.153 -                                         "OnTime", ConstantVariable(1), 
   4.154 -                                         "OffTime", ConstantVariable(0));
   4.155 -  n3->AddApplication (ooff);
   4.156 -  // Start the application
   4.157 -  ooff->Start(Seconds(1.1));
   4.158 -  ooff->Stop (Seconds(10.0));
   4.159 +  onoff.SetUdpRemote (i1i2.GetAddress (0), port);
   4.160 +  apps = onoff.Build (c.Get (3));
   4.161 +  apps.Start(Seconds(1.1));
   4.162 +  apps.Stop (Seconds(10.0));
   4.163  
   4.164    // Create a packet sink to receive these packets
   4.165 -  sink = CreateObject<PacketSink> ("Local", Address (InetSocketAddress (Ipv4Address::GetAny (), port)),
   4.166 -                                   "Protocol", TypeId::LookupByName ("ns3::Udp"));
   4.167 -  n1->AddApplication (sink);
   4.168 -  // Start the sink
   4.169 -  sink->Start (Seconds (1.1));
   4.170 -  sink->Stop (Seconds (10.0));
   4.171 -
   4.172 -  // Here, finish off packet routing configuration
   4.173 -  // This will likely set by some global StaticRouting object in the future
   4.174 -  NS_LOG_INFO ("Set Default Routes.");
   4.175 -  Ptr<Ipv4> ipv4;
   4.176 -  ipv4 = n0->GetObject<Ipv4> ();
   4.177 -  ipv4->SetDefaultRoute (Ipv4Address ("10.1.1.2"), 1);
   4.178 -  ipv4 = n3->GetObject<Ipv4> ();
   4.179 -  ipv4->SetDefaultRoute (Ipv4Address ("10.1.3.1"), 1);
   4.180 +  sink.SetupUdp (Ipv4Address::GetAny (), port);
   4.181 +  apps = sink.Build (c.Get (1));
   4.182 +  apps.Start (Seconds (1.1));
   4.183 +  apps.Stop (Seconds (10.0));
   4.184  
   4.185    //
   4.186    // Error model
   4.187    //
   4.188 -  // We want to add an error model to node 3's NetDevice
   4.189 -  // We can obtain a handle to the NetDevice via the channel and node 
   4.190 -  // pointers
   4.191 -  Ptr<PointToPointNetDevice> nd3 = PointToPointTopology::GetNetDevice
   4.192 -    (n3, channel2);
   4.193    // Create an ErrorModel based on the implementation (constructor)
   4.194    // specified by the default classId
   4.195    Ptr<RateErrorModel> em = CreateObject<RateErrorModel> ("RanVar", UniformVariable (0.0, 1.0),
   4.196 -                                                             "Rate", Double (0.001));
   4.197 -  nd3->AddReceiveErrorModel (em);
   4.198 +                                                         "ErrorRate", Double (0.001));
   4.199 +  d3d2.Get (0)->SetAttribute ("ReceiveErrorModel", em);
   4.200  
   4.201    // Now, let's use the ListErrorModel and explicitly force a loss
   4.202    // of the packets with pkt-uids = 11 and 17 on node 2, device 0
   4.203 -  Ptr<PointToPointNetDevice> nd2 = PointToPointTopology::GetNetDevice
   4.204 -    (n2, channel0);
   4.205    std::list<uint32_t> sampleList;
   4.206    sampleList.push_back (11);
   4.207    sampleList.push_back (17);
   4.208    // This time, we'll explicitly create the error model we want
   4.209    Ptr<ListErrorModel> pem = CreateObject<ListErrorModel> ();
   4.210    pem->SetList (sampleList);
   4.211 -  nd2->AddReceiveErrorModel (pem);
   4.212 +  d0d2.Get (1)->SetAttribute ("ReceiveErrorModel", pem);
   4.213  
   4.214    // Configure tracing of all enqueue, dequeue, and NetDevice receive events
   4.215    // Trace output will be sent to the simple-error-model.tr file
     5.1 --- a/examples/tcp-large-transfer.cc	Wed Mar 26 21:28:13 2008 -0700
     5.2 +++ b/examples/tcp-large-transfer.cc	Wed Mar 26 21:28:27 2008 -0700
     5.3 @@ -36,12 +36,13 @@
     5.4  
     5.5  #include "ns3/core-module.h"
     5.6  #include "ns3/helper-module.h"
     5.7 +#include "ns3/node-module.h"
     5.8 +#include "ns3/global-route-manager.h"
     5.9 +#include "ns3/simulator-module.h"
    5.10  
    5.11  #include "ns3/ascii-trace.h"
    5.12  #include "ns3/pcap-trace.h"
    5.13  
    5.14 -#include "ns3/internet-node-module.h"
    5.15 -
    5.16  using namespace ns3;
    5.17  
    5.18  NS_LOG_COMPONENT_DEFINE ("TcpLargeTransfer");
    5.19 @@ -149,7 +150,7 @@
    5.20    ipv4.SetBase ("10.1.3.0", "255.255.255.0");
    5.21    ipv4.Allocate (dev0);
    5.22    ipv4.SetBase ("10.1.2.0", "255.255.255.0");
    5.23 -  ipv4.Allocate (dev1);
    5.24 +  Ipv4InterfaceContainer ipInterfs = ipv4.Allocate (dev1);
    5.25  
    5.26    // and setup ip routing tables to get total ip-level connectivity.
    5.27    GlobalRouteManager::PopulateRoutingTables ();
    5.28 @@ -177,7 +178,7 @@
    5.29    Ptr<Socket> localSocket = socketFactory->CreateSocket ();
    5.30    localSocket->Bind ();
    5.31    Simulator::ScheduleNow (&StartFlow, localSocket, nBytes,
    5.32 -                          Ipv4Address ("10.1.2.2"), servPort);
    5.33 +                          ipInterfs.GetAddress (1), servPort);
    5.34  
    5.35    // Configure tracing of all enqueue, dequeue, and NetDevice receive events
    5.36    // Trace output will be sent to the simple-examples.tr file
     6.1 --- a/samples/main-random-topology.cc	Wed Mar 26 21:28:13 2008 -0700
     6.2 +++ b/samples/main-random-topology.cc	Wed Mar 26 21:28:27 2008 -0700
     6.3 @@ -3,6 +3,7 @@
     6.4  #include "ns3/core-module.h"
     6.5  #include "ns3/mobility-module.h"
     6.6  #include "ns3/helper-module.h"
     6.7 +#include "ns3/simulator-module.h"
     6.8  
     6.9  using namespace ns3;
    6.10  
     7.1 --- a/samples/main-random-walk.cc	Wed Mar 26 21:28:13 2008 -0700
     7.2 +++ b/samples/main-random-walk.cc	Wed Mar 26 21:28:27 2008 -0700
     7.3 @@ -3,6 +3,7 @@
     7.4  #include "ns3/core-module.h"
     7.5  #include "ns3/helper-module.h"
     7.6  #include "ns3/mobility-module.h"
     7.7 +#include "ns3/simulator-module.h"
     7.8  
     7.9  using namespace ns3;
    7.10  
     8.1 --- a/src/devices/point-to-point/point-to-point-net-device.cc	Wed Mar 26 21:28:13 2008 -0700
     8.2 +++ b/src/devices/point-to-point/point-to-point-net-device.cc	Wed Mar 26 21:28:27 2008 -0700
     8.3 @@ -50,7 +50,7 @@
     8.4                     DataRate ("10Mb/s"),
     8.5                     MakeDataRateAccessor (&PointToPointNetDevice::m_bps),
     8.6                     MakeDataRateChecker ())
     8.7 -    .AddAttribute ("RxErrorModel", "XXX",
     8.8 +    .AddAttribute ("ReceiveErrorModel", "XXX",
     8.9                     Ptr<ErrorModel> (0),
    8.10                     MakePtrAccessor (&PointToPointNetDevice::m_receiveErrorModel),
    8.11                     MakePtrChecker<ErrorModel> ())
    8.12 @@ -224,7 +224,6 @@
    8.13    NS_LOG_PARAMS ("(" << em << ")");
    8.14  
    8.15    m_receiveErrorModel = em;
    8.16 -  AggregateObject (em);
    8.17  }
    8.18  
    8.19  void PointToPointNetDevice::Receive (Ptr<Packet> packet)
     9.1 --- a/src/helper/ipv4-address-helper.cc	Wed Mar 26 21:28:13 2008 -0700
     9.2 +++ b/src/helper/ipv4-address-helper.cc	Wed Mar 26 21:28:27 2008 -0700
     9.3 @@ -120,10 +120,11 @@
     9.4    return Ipv4Address (m_network << m_shift);
     9.5  }
     9.6  
     9.7 -  void
     9.8 +Ipv4InterfaceContainer
     9.9  Ipv4AddressHelper::Allocate (const NetDeviceContainer &c)
    9.10  {
    9.11    NS_LOG_FUNCTION;
    9.12 +  Ipv4InterfaceContainer retval;
    9.13    for (uint32_t i = 0; i < c.GetN (); ++i) {
    9.14      Ptr<NetDevice> device = c.Get (i);
    9.15  
    9.16 @@ -145,7 +146,9 @@
    9.17      ipv4->SetNetworkMask (ifIndex, m_mask);
    9.18      ipv4->SetMetric (ifIndex, 1);
    9.19      ipv4->SetUp (ifIndex);
    9.20 +    retval.Add (ipv4, ifIndex);
    9.21    }
    9.22 +  return retval;
    9.23  }
    9.24  
    9.25  const uint32_t N_BITS = 32;
    10.1 --- a/src/helper/ipv4-address-helper.h	Wed Mar 26 21:28:13 2008 -0700
    10.2 +++ b/src/helper/ipv4-address-helper.h	Wed Mar 26 21:28:27 2008 -0700
    10.3 @@ -20,7 +20,8 @@
    10.4  #define IPV4_ADDRESS_HELPER_H
    10.5  
    10.6  #include "ns3/ipv4-address.h"
    10.7 -#include "ns3/net-device-container.h"
    10.8 +#include "net-device-container.h"
    10.9 +#include "ipv4-interface-container.h"
   10.10  
   10.11  namespace ns3 {
   10.12  
   10.13 @@ -164,7 +165,7 @@
   10.14   * @see SetBase
   10.15   * @see NewNetwork
   10.16   */
   10.17 -  void Allocate (const NetDeviceContainer &c);
   10.18 +  Ipv4InterfaceContainer Allocate (const NetDeviceContainer &c);
   10.19  
   10.20  private:
   10.21    uint32_t NumAddressBits (uint32_t maskbits) const;
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/src/helper/ipv4-interface-container.cc	Wed Mar 26 21:28:27 2008 -0700
    11.3 @@ -0,0 +1,34 @@
    11.4 +#include "ipv4-interface-container.h"
    11.5 +#include "ns3/node-list.h"
    11.6 +
    11.7 +namespace ns3 {
    11.8 +
    11.9 +Ipv4InterfaceContainer::Ipv4InterfaceContainer ()
   11.10 +{}
   11.11 +
   11.12 +uint32_t 
   11.13 +Ipv4InterfaceContainer::GetN (void) const
   11.14 +{
   11.15 +  return m_interfaces.size ();
   11.16 +}
   11.17 +Ipv4Address 
   11.18 +Ipv4InterfaceContainer::GetAddress (uint32_t i) const
   11.19 +{
   11.20 +  Ptr<Ipv4> ipv4 = m_interfaces[i].first;
   11.21 +  uint32_t interface = m_interfaces[i].second;
   11.22 +  return ipv4->GetAddress (interface);
   11.23 +}
   11.24 +void 
   11.25 +Ipv4InterfaceContainer::SetMetric (uint32_t i, uint16_t metric)
   11.26 +{
   11.27 +  Ptr<Ipv4> ipv4 = m_interfaces[i].first;
   11.28 +  uint32_t interface = m_interfaces[i].second;
   11.29 +  ipv4->SetMetric (interface, metric);
   11.30 +}
   11.31 +void 
   11.32 +Ipv4InterfaceContainer::Add (Ptr<Ipv4> ipv4, uint32_t interface)
   11.33 +{
   11.34 +  m_interfaces.push_back (std::make_pair (ipv4, interface));
   11.35 +}
   11.36 +
   11.37 +} // namespace ns3
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/src/helper/ipv4-interface-container.h	Wed Mar 26 21:28:27 2008 -0700
    12.3 @@ -0,0 +1,39 @@
    12.4 +#ifndef IPV4_INTERFACE_CONTAINER_H
    12.5 +#define IPV4_INTERFACE_CONTAINER_H
    12.6 +
    12.7 +#include <stdint.h>
    12.8 +#include <vector>
    12.9 +#include "ns3/ipv4.h"
   12.10 +#include "ns3/ipv4-address.h"
   12.11 +
   12.12 +namespace ns3 {
   12.13 +
   12.14 +/**
   12.15 + * \brief keep track of a set of ipv4 interfaces.
   12.16 + *
   12.17 + */
   12.18 +class Ipv4InterfaceContainer
   12.19 +{
   12.20 +public:
   12.21 +  /**
   12.22 +   * Create an empty Ipv4InterfaceContainer.
   12.23 +   */
   12.24 +  Ipv4InterfaceContainer ();
   12.25 +
   12.26 +  /**
   12.27 +   * \returns the number of interfaces stored in this Ipv4InterfaceContainer.
   12.28 +   */
   12.29 +  uint32_t GetN (void) const;
   12.30 +
   12.31 +  Ipv4Address GetAddress (uint32_t i) const;
   12.32 +  void SetMetric (uint32_t i, uint16_t metric);
   12.33 +
   12.34 +  void Add (Ptr<Ipv4> ipv4, uint32_t interface);
   12.35 +
   12.36 + private:
   12.37 +  std::vector<std::pair<Ptr<Ipv4>,uint32_t> > m_interfaces;
   12.38 +};
   12.39 +
   12.40 +} // namespace ns3
   12.41 +
   12.42 +#endif /* IPV4_INTERFACE_CONTAINER_H */
    13.1 --- a/src/helper/node-container.cc	Wed Mar 26 21:28:13 2008 -0700
    13.2 +++ b/src/helper/node-container.cc	Wed Mar 26 21:28:27 2008 -0700
    13.3 @@ -15,6 +15,21 @@
    13.4    Add (a);
    13.5    Add (b);
    13.6  }
    13.7 +NodeContainer::NodeContainer (const NodeContainer &a, const NodeContainer &b, 
    13.8 +			      const NodeContainer &c)
    13.9 +{
   13.10 +  Add (a);
   13.11 +  Add (b);
   13.12 +  Add (c);
   13.13 +}
   13.14 +NodeContainer::NodeContainer (const NodeContainer &a, const NodeContainer &b, 
   13.15 +			      const NodeContainer &c, const NodeContainer &d)
   13.16 +{
   13.17 +  Add (a);
   13.18 +  Add (b);
   13.19 +  Add (c);
   13.20 +  Add (d);
   13.21 +}
   13.22  
   13.23  NodeContainer::Iterator 
   13.24  NodeContainer::Begin (void) const
    14.1 --- a/src/helper/node-container.h	Wed Mar 26 21:28:13 2008 -0700
    14.2 +++ b/src/helper/node-container.h	Wed Mar 26 21:28:27 2008 -0700
    14.3 @@ -35,6 +35,9 @@
    14.4     */
    14.5    NodeContainer (const NodeContainer &a, const NodeContainer &b);
    14.6  
    14.7 +  NodeContainer (const NodeContainer &a, const NodeContainer &b, const NodeContainer &c);
    14.8 +  NodeContainer (const NodeContainer &a, const NodeContainer &b, const NodeContainer &c, const NodeContainer &d);
    14.9 +
   14.10    /**
   14.11     * \returns an iterator to the start of the vector of node pointers.
   14.12     */
    15.1 --- a/src/helper/wscript	Wed Mar 26 21:28:13 2008 -0700
    15.2 +++ b/src/helper/wscript	Wed Mar 26 21:28:27 2008 -0700
    15.3 @@ -17,6 +17,7 @@
    15.4          'on-off-helper.cc',
    15.5          'packet-sink-helper.cc',
    15.6          'packet-socket-helper.cc',
    15.7 +        'ipv4-interface-container.cc',
    15.8          ]
    15.9  
   15.10      headers = bld.create_obj('ns3header')
   15.11 @@ -36,4 +37,5 @@
   15.12          'on-off-helper.h',
   15.13          'packet-sink-helper.h',
   15.14          'packet-socket-helper.h',
   15.15 +        'ipv4-interface-container.h',
   15.16          ]