use better variable names.
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Tue Sep 23 16:14:00 2008 -0700 (16 months ago)
changeset 3714249ec8d21b24
parent 3713 9f5d59e52e38
child 3715 594e2052e5b2
use better variable names.
examples/csma-one-subnet.cc
     1.1 --- a/examples/csma-one-subnet.cc	Tue Sep 23 16:02:30 2008 -0700
     1.2 +++ b/examples/csma-one-subnet.cc	Tue Sep 23 16:14:00 2008 -0700
     1.3 @@ -61,8 +61,8 @@
     1.4  // Explicitly create the nodes required by the topology (shown above).
     1.5  //
     1.6    NS_LOG_INFO ("Create nodes.");
     1.7 -  NodeContainer c;
     1.8 -  c.Create (4);
     1.9 +  NodeContainer nodes;
    1.10 +  nodes.Create (4);
    1.11  
    1.12    NS_LOG_INFO ("Build Topology");
    1.13    CsmaHelper csma;
    1.14 @@ -70,24 +70,19 @@
    1.15    csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2)));
    1.16  //
    1.17  // Now fill out the topology by creating the net devices required to connect
    1.18 -// the nodes to the channels and hooking them up.  AddIpv4CsmaNetDevice will
    1.19 -// create a net device, add a MAC address (in memory of the pink flamingo) and
    1.20 -// connect the net device to a nodes and also to a channel. the 
    1.21 -// AddIpv4CsmaNetDevice method returns a net device index for the net device
    1.22 -// created on the node.  Interpret nd0 as the net device we created for node
    1.23 -// zero.
    1.24 +// the nodes to the channels and hooking them up.
    1.25  //
    1.26 -  NetDeviceContainer nd0 = csma.Install (c);
    1.27 +  NetDeviceContainer devices = csma.Install (nodes);
    1.28  
    1.29    InternetStackHelper internet;
    1.30 -  internet.Install (c);
    1.31 +  internet.Install (nodes);
    1.32  
    1.33  // We've got the "hardware" in place.  Now we need to add IP addresses.
    1.34  //
    1.35    NS_LOG_INFO ("Assign IP Addresses.");
    1.36    Ipv4AddressHelper ipv4;
    1.37    ipv4.SetBase ("10.1.1.0", "255.255.255.0");
    1.38 -  ipv4.Assign (nd0);
    1.39 +  Ipv4InterfaceContainer interfaces = ipv4.Assign (devices);
    1.40  
    1.41  //
    1.42  // Create an OnOff application to send UDP datagrams from node zero to node 1.
    1.43 @@ -96,11 +91,11 @@
    1.44    uint16_t port = 9;   // Discard port (RFC 863)
    1.45  
    1.46    OnOffHelper onoff ("ns3::UdpSocketFactory", 
    1.47 -    Address (InetSocketAddress (Ipv4Address ("10.1.1.2"), port)));
    1.48 +                     Address (InetSocketAddress (interfaces.GetAddress (1), port)));
    1.49    onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1)));
    1.50    onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
    1.51  
    1.52 -  ApplicationContainer app = onoff.Install (c.Get (0));
    1.53 +  ApplicationContainer app = onoff.Install (nodes.Get (0));
    1.54    // Start the application
    1.55    app.Start (Seconds (1.0));
    1.56    app.Stop (Seconds (10.0));
    1.57 @@ -108,16 +103,16 @@
    1.58    // Create an optional packet sink to receive these packets
    1.59    PacketSinkHelper sink ("ns3::UdpSocketFactory",
    1.60      Address (InetSocketAddress (Ipv4Address::GetAny (), port)));
    1.61 -  sink.Install (c.Get (1));
    1.62 +  sink.Install (nodes.Get (1));
    1.63  
    1.64  // 
    1.65  // Create a similar flow from n3 to n0, starting at time 1.1 seconds
    1.66  //
    1.67    onoff.SetAttribute ("Remote", 
    1.68 -                      AddressValue (InetSocketAddress (Ipv4Address ("10.1.1.1"), port)));
    1.69 -  ApplicationContainer app2 = onoff.Install (c.Get (3));
    1.70 +                      AddressValue (InetSocketAddress (interfaces.GetAddress (0), port)));
    1.71 +  ApplicationContainer app2 = onoff.Install (nodes.Get (3));
    1.72  
    1.73 -  sink.Install (c.Get (0));
    1.74 +  sink.Install (nodes.Get (0));
    1.75  
    1.76    app2.Start(Seconds (1.1));
    1.77    app2.Stop (Seconds (10.0));