rename example from p2p to point-to-point
authorTom Henderson <tomh@tomh.org>
Fri, 27 Jul 2007 13:07:36 -0700
changeset 98889a9125a39c9
parent 987 3f469377ff30
child 989 baeb6102ea71
rename example from p2p to point-to-point
examples/simple-p2p.cc
examples/simple-point-to-point.cc
examples/wscript
     1.1 --- a/examples/simple-p2p.cc	Fri Jul 27 12:50:31 2007 -0700
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,191 +0,0 @@
     1.4 -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
     1.5 -/*
     1.6 - * This program is free software; you can redistribute it and/or modify
     1.7 - * it under the terms of the GNU General Public License version 2 as
     1.8 - * published by the Free Software Foundation;
     1.9 - *
    1.10 - * This program is distributed in the hope that it will be useful,
    1.11 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.12 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.13 - * GNU General Public License for more details.
    1.14 - *
    1.15 - * You should have received a copy of the GNU General Public License
    1.16 - * along with this program; if not, write to the Free Software
    1.17 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    1.18 - *
    1.19 - * ns-2 simple.tcl script (ported from ns-2)
    1.20 - * Originally authored by Steve McCanne, 12/19/1996
    1.21 - */
    1.22 -
    1.23 -// Port of ns-2/tcl/ex/simple.tcl to ns-3
    1.24 -//
    1.25 -// Network topology
    1.26 -//
    1.27 -//  n0
    1.28 -//     \ 5 Mb/s, 2ms
    1.29 -//      \          1.5Mb/s, 10ms
    1.30 -//       n2 -------------------------n3
    1.31 -//      /
    1.32 -//     / 5 Mb/s, 2ms
    1.33 -//   n1
    1.34 -//
    1.35 -// - all links are p2p links with indicated one-way BW/delay
    1.36 -// - CBR/UDP flows from n0 to n3, and from n3 to n1
    1.37 -// - FTP/TCP flow from n0 to n3, starting at time 1.2 to time 1.35 sec.
    1.38 -// - UDP packet size of 210 bytes, with per-packet interval 0.00375 sec.
    1.39 -//   (i.e., DataRate of 448,000 bps)
    1.40 -// - DropTail queues 
    1.41 -// - Tracing of queues and packet receptions to file "simple-p2p.tr"
    1.42 -
    1.43 -#include <iostream>
    1.44 -#include <fstream>
    1.45 -#include <string>
    1.46 -#include <cassert>
    1.47 -
    1.48 -#include "ns3/command-line.h"
    1.49 -#include "ns3/default-value.h"
    1.50 -#include "ns3/ptr.h"
    1.51 -#include "ns3/random-variable.h"
    1.52 -
    1.53 -#include "ns3/simulator.h"
    1.54 -#include "ns3/nstime.h"
    1.55 -#include "ns3/data-rate.h"
    1.56 -
    1.57 -#include "ns3/ascii-trace.h"
    1.58 -#include "ns3/pcap-trace.h"
    1.59 -#include "ns3/internet-node.h"
    1.60 -#include "ns3/point-to-point-channel.h"
    1.61 -#include "ns3/point-to-point-net-device.h"
    1.62 -#include "ns3/mac-address.h"
    1.63 -#include "ns3/ipv4-address.h"
    1.64 -#include "ns3/ipv4.h"
    1.65 -#include "ns3/socket.h"
    1.66 -#include "ns3/ipv4-route.h"
    1.67 -#include "ns3/point-to-point-topology.h"
    1.68 -#include "ns3/onoff-application.h"
    1.69 -
    1.70 -using namespace ns3;
    1.71 -
    1.72 -int main (int argc, char *argv[])
    1.73 -{
    1.74 -
    1.75 -  // Users may find it convenient to turn on explicit debugging
    1.76 -  // for selected modules; the below lines suggest how to do this
    1.77 -#if 0 
    1.78 -  DebugComponentEnable("Object");
    1.79 -  DebugComponentEnable("Queue");
    1.80 -  DebugComponentEnable("DropTailQueue");
    1.81 -  DebugComponentEnable("Channel");
    1.82 -  DebugComponentEnable("PointToPointChannel");
    1.83 -  DebugComponentEnable("PointToPointNetDevice");
    1.84 -#endif
    1.85 -
    1.86 -  // Set up some default values for the simulation.  Use the Bind()
    1.87 -  // technique to tell the system what subclass of Queue to use,
    1.88 -  // and what the queue limit is
    1.89 -
    1.90 -  // The below Bind command tells the queue factory which class to
    1.91 -  // instantiate, when the queue factory is invoked in the topology code
    1.92 -  Bind ("Queue", "DropTailQueue");
    1.93 -
    1.94 -  Bind ("OnOffApplicationPacketSize", "210");
    1.95 -  Bind ("OnOffApplicationDataRate", "448kb/s");
    1.96 -
    1.97 -  //Bind ("DropTailQueue::m_maxPackets", 30);   
    1.98 -
    1.99 -  // Allow the user to override any of the defaults and the above
   1.100 -  // Bind()s at run-time, via command-line arguments
   1.101 -  CommandLine::Parse (argc, argv);
   1.102 -
   1.103 -  // Here, we will explicitly create four nodes.  In more sophisticated
   1.104 -  // topologies, we could configure a node factory.
   1.105 -  Ptr<Node> n0 = Create<InternetNode> ();
   1.106 -  Ptr<Node> n1 = Create<InternetNode> (); 
   1.107 -  Ptr<Node> n2 = Create<InternetNode> (); 
   1.108 -  Ptr<Node> n3 = Create<InternetNode> ();
   1.109 -
   1.110 -  // We create the channels first without any IP addressing information
   1.111 -  Ptr<PointToPointChannel> channel0 = 
   1.112 -    PointToPointTopology::AddPointToPointLink (
   1.113 -      n0, n2, DataRate(5000000), MilliSeconds(2));
   1.114 -
   1.115 -  Ptr<PointToPointChannel> channel1 = 
   1.116 -    PointToPointTopology::AddPointToPointLink (
   1.117 -      n1, n2, DataRate(5000000), MilliSeconds(2));
   1.118 -  
   1.119 -  Ptr<PointToPointChannel> channel2 = 
   1.120 -    PointToPointTopology::AddPointToPointLink (
   1.121 -      n2, n3, DataRate(1500000), MilliSeconds(10));
   1.122 -  
   1.123 -  // Later, we add IP addresses.  
   1.124 -  PointToPointTopology::AddIpv4Addresses (
   1.125 -      channel0, n0, Ipv4Address("10.1.1.1"),
   1.126 -      n2, Ipv4Address("10.1.1.2"));
   1.127 -  
   1.128 -  PointToPointTopology::AddIpv4Addresses (
   1.129 -      channel1, n1, Ipv4Address("10.1.2.1"),
   1.130 -      n2, Ipv4Address("10.1.2.2"));
   1.131 -  
   1.132 -  PointToPointTopology::AddIpv4Addresses (
   1.133 -      channel2, n2, Ipv4Address("10.1.3.1"),
   1.134 -      n3, Ipv4Address("10.1.3.2"));
   1.135 -
   1.136 -  // Finally, we add static routes.  These three steps (Channel and
   1.137 -  // NetDevice creation, IP Address assignment, and routing) are 
   1.138 -  // separated because there may be a need to postpone IP Address
   1.139 -  // assignment (emulation) or modify to use dynamic routing
   1.140 -  PointToPointTopology::AddIpv4Routes(n0, n2, channel0);
   1.141 -  PointToPointTopology::AddIpv4Routes(n1, n2, channel1);
   1.142 -  PointToPointTopology::AddIpv4Routes(n2, n3, channel2);
   1.143 -
   1.144 -
   1.145 -  // Create the OnOff application to send UDP datagrams of size
   1.146 -  // 210 bytes at a rate of 448 Kb/s
   1.147 -  Ptr<OnOffApplication> ooff = Create<OnOffApplication> (
   1.148 -    n0, 
   1.149 -    Ipv4Address("10.1.3.2"), 
   1.150 -    80, 
   1.151 -    "Udp",
   1.152 -    ConstantVariable(1), 
   1.153 -    ConstantVariable(0));
   1.154 -  // Start the application
   1.155 -  ooff->Start(Seconds(1.0));
   1.156 -  ooff->Stop (Seconds(10.0));
   1.157 -
   1.158 -  // Create a similar flow from n3 to n1, starting at time 1.1 seconds
   1.159 -  ooff = Create<OnOffApplication> (
   1.160 -    n3, 
   1.161 -    Ipv4Address("10.1.2.1"), 
   1.162 -    80, 
   1.163 -    "Udp",
   1.164 -    ConstantVariable(1), 
   1.165 -    ConstantVariable(0));
   1.166 -  // Start the application
   1.167 -  ooff->Start(Seconds(1.1));
   1.168 -  ooff->Stop (Seconds(10.0));
   1.169 -
   1.170 -  // Here, finish off packet routing configuration
   1.171 -  // This will likely set by some global StaticRouting object in the future
   1.172 -  Ptr<Ipv4> ipv4;
   1.173 -  ipv4 = n0->QueryInterface<Ipv4> (Ipv4::iid);
   1.174 -  ipv4->SetDefaultRoute (Ipv4Address ("10.1.1.2"), 1);
   1.175 -  ipv4 = n3->QueryInterface<Ipv4> (Ipv4::iid);
   1.176 -  ipv4->SetDefaultRoute (Ipv4Address ("10.1.3.1"), 1);
   1.177 -  
   1.178 -  // Configure tracing of all enqueue, dequeue, and NetDevice receive events
   1.179 -  // Trace output will be sent to the simple-p2p.tr file
   1.180 -  AsciiTrace asciitrace ("simple-p2p.tr");
   1.181 -  asciitrace.TraceAllQueues ();
   1.182 -  asciitrace.TraceAllNetDeviceRx ();
   1.183 -
   1.184 -  // Also configure some tcpdump traces; each interface will be traced
   1.185 -  // The output files will be named simple-p2p.pcap-<nodeId>-<interfaceId>
   1.186 -  // and can be read by the "tcpdump -r" command (use "-tt" option to
   1.187 -  // display timestamps correctly)
   1.188 -  PcapTrace pcaptrace ("simple-p2p.pcap");
   1.189 -  pcaptrace.TraceAllIp ();
   1.190 -
   1.191 -  Simulator::Run ();
   1.192 -    
   1.193 -  Simulator::Destroy ();
   1.194 -}
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/examples/simple-point-to-point.cc	Fri Jul 27 13:07:36 2007 -0700
     2.3 @@ -0,0 +1,193 @@
     2.4 +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
     2.5 +/*
     2.6 + * This program is free software; you can redistribute it and/or modify
     2.7 + * it under the terms of the GNU General Public License version 2 as
     2.8 + * published by the Free Software Foundation;
     2.9 + *
    2.10 + * This program is distributed in the hope that it will be useful,
    2.11 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    2.12 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    2.13 + * GNU General Public License for more details.
    2.14 + *
    2.15 + * You should have received a copy of the GNU General Public License
    2.16 + * along with this program; if not, write to the Free Software
    2.17 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    2.18 + *
    2.19 + * ns-2 simple.tcl script (ported from ns-2)
    2.20 + * Originally authored by Steve McCanne, 12/19/1996
    2.21 + */
    2.22 +
    2.23 +// Port of ns-2/tcl/ex/simple.tcl to ns-3
    2.24 +//
    2.25 +// Network topology
    2.26 +//
    2.27 +//  n0
    2.28 +//     \ 5 Mb/s, 2ms
    2.29 +//      \          1.5Mb/s, 10ms
    2.30 +//       n2 -------------------------n3
    2.31 +//      /
    2.32 +//     / 5 Mb/s, 2ms
    2.33 +//   n1
    2.34 +//
    2.35 +// - all links are point-to-point links with indicated one-way BW/delay
    2.36 +// - CBR/UDP flows from n0 to n3, and from n3 to n1
    2.37 +// - FTP/TCP flow from n0 to n3, starting at time 1.2 to time 1.35 sec.
    2.38 +// - UDP packet size of 210 bytes, with per-packet interval 0.00375 sec.
    2.39 +//   (i.e., DataRate of 448,000 bps)
    2.40 +// - DropTail queues 
    2.41 +// - Tracing of queues and packet receptions to file 
    2.42 +//   "simple-point-to-point.tr"
    2.43 +
    2.44 +#include <iostream>
    2.45 +#include <fstream>
    2.46 +#include <string>
    2.47 +#include <cassert>
    2.48 +
    2.49 +#include "ns3/command-line.h"
    2.50 +#include "ns3/default-value.h"
    2.51 +#include "ns3/ptr.h"
    2.52 +#include "ns3/random-variable.h"
    2.53 +
    2.54 +#include "ns3/simulator.h"
    2.55 +#include "ns3/nstime.h"
    2.56 +#include "ns3/data-rate.h"
    2.57 +
    2.58 +#include "ns3/ascii-trace.h"
    2.59 +#include "ns3/pcap-trace.h"
    2.60 +#include "ns3/internet-node.h"
    2.61 +#include "ns3/point-to-point-channel.h"
    2.62 +#include "ns3/point-to-point-net-device.h"
    2.63 +#include "ns3/mac-address.h"
    2.64 +#include "ns3/ipv4-address.h"
    2.65 +#include "ns3/ipv4.h"
    2.66 +#include "ns3/socket.h"
    2.67 +#include "ns3/ipv4-route.h"
    2.68 +#include "ns3/point-to-point-topology.h"
    2.69 +#include "ns3/onoff-application.h"
    2.70 +
    2.71 +using namespace ns3;
    2.72 +
    2.73 +int main (int argc, char *argv[])
    2.74 +{
    2.75 +
    2.76 +  // Users may find it convenient to turn on explicit debugging
    2.77 +  // for selected modules; the below lines suggest how to do this
    2.78 +#if 0 
    2.79 +  DebugComponentEnable("Object");
    2.80 +  DebugComponentEnable("Queue");
    2.81 +  DebugComponentEnable("DropTailQueue");
    2.82 +  DebugComponentEnable("Channel");
    2.83 +  DebugComponentEnable("PointToPointChannel");
    2.84 +  DebugComponentEnable("PointToPointNetDevice");
    2.85 +#endif
    2.86 +
    2.87 +  // Set up some default values for the simulation.  Use the Bind()
    2.88 +  // technique to tell the system what subclass of Queue to use,
    2.89 +  // and what the queue limit is
    2.90 +
    2.91 +  // The below Bind command tells the queue factory which class to
    2.92 +  // instantiate, when the queue factory is invoked in the topology code
    2.93 +  Bind ("Queue", "DropTailQueue");
    2.94 +
    2.95 +  Bind ("OnOffApplicationPacketSize", "210");
    2.96 +  Bind ("OnOffApplicationDataRate", "448kb/s");
    2.97 +
    2.98 +  //Bind ("DropTailQueue::m_maxPackets", 30);   
    2.99 +
   2.100 +  // Allow the user to override any of the defaults and the above
   2.101 +  // Bind()s at run-time, via command-line arguments
   2.102 +  CommandLine::Parse (argc, argv);
   2.103 +
   2.104 +  // Here, we will explicitly create four nodes.  In more sophisticated
   2.105 +  // topologies, we could configure a node factory.
   2.106 +  Ptr<Node> n0 = Create<InternetNode> ();
   2.107 +  Ptr<Node> n1 = Create<InternetNode> (); 
   2.108 +  Ptr<Node> n2 = Create<InternetNode> (); 
   2.109 +  Ptr<Node> n3 = Create<InternetNode> ();
   2.110 +
   2.111 +  // We create the channels first without any IP addressing information
   2.112 +  Ptr<PointToPointChannel> channel0 = 
   2.113 +    PointToPointTopology::AddPointToPointLink (
   2.114 +      n0, n2, DataRate(5000000), MilliSeconds(2));
   2.115 +
   2.116 +  Ptr<PointToPointChannel> channel1 = 
   2.117 +    PointToPointTopology::AddPointToPointLink (
   2.118 +      n1, n2, DataRate(5000000), MilliSeconds(2));
   2.119 +  
   2.120 +  Ptr<PointToPointChannel> channel2 = 
   2.121 +    PointToPointTopology::AddPointToPointLink (
   2.122 +      n2, n3, DataRate(1500000), MilliSeconds(10));
   2.123 +  
   2.124 +  // Later, we add IP addresses.  
   2.125 +  PointToPointTopology::AddIpv4Addresses (
   2.126 +      channel0, n0, Ipv4Address("10.1.1.1"),
   2.127 +      n2, Ipv4Address("10.1.1.2"));
   2.128 +  
   2.129 +  PointToPointTopology::AddIpv4Addresses (
   2.130 +      channel1, n1, Ipv4Address("10.1.2.1"),
   2.131 +      n2, Ipv4Address("10.1.2.2"));
   2.132 +  
   2.133 +  PointToPointTopology::AddIpv4Addresses (
   2.134 +      channel2, n2, Ipv4Address("10.1.3.1"),
   2.135 +      n3, Ipv4Address("10.1.3.2"));
   2.136 +
   2.137 +  // Finally, we add static routes.  These three steps (Channel and
   2.138 +  // NetDevice creation, IP Address assignment, and routing) are 
   2.139 +  // separated because there may be a need to postpone IP Address
   2.140 +  // assignment (emulation) or modify to use dynamic routing
   2.141 +  PointToPointTopology::AddIpv4Routes(n0, n2, channel0);
   2.142 +  PointToPointTopology::AddIpv4Routes(n1, n2, channel1);
   2.143 +  PointToPointTopology::AddIpv4Routes(n2, n3, channel2);
   2.144 +
   2.145 +
   2.146 +  // Create the OnOff application to send UDP datagrams of size
   2.147 +  // 210 bytes at a rate of 448 Kb/s
   2.148 +  Ptr<OnOffApplication> ooff = Create<OnOffApplication> (
   2.149 +    n0, 
   2.150 +    Ipv4Address("10.1.3.2"), 
   2.151 +    80, 
   2.152 +    "Udp",
   2.153 +    ConstantVariable(1), 
   2.154 +    ConstantVariable(0));
   2.155 +  // Start the application
   2.156 +  ooff->Start(Seconds(1.0));
   2.157 +  ooff->Stop (Seconds(10.0));
   2.158 +
   2.159 +  // Create a similar flow from n3 to n1, starting at time 1.1 seconds
   2.160 +  ooff = Create<OnOffApplication> (
   2.161 +    n3, 
   2.162 +    Ipv4Address("10.1.2.1"), 
   2.163 +    80, 
   2.164 +    "Udp",
   2.165 +    ConstantVariable(1), 
   2.166 +    ConstantVariable(0));
   2.167 +  // Start the application
   2.168 +  ooff->Start(Seconds(1.1));
   2.169 +  ooff->Stop (Seconds(10.0));
   2.170 +
   2.171 +  // Here, finish off packet routing configuration
   2.172 +  // This will likely set by some global StaticRouting object in the future
   2.173 +  Ptr<Ipv4> ipv4;
   2.174 +  ipv4 = n0->QueryInterface<Ipv4> (Ipv4::iid);
   2.175 +  ipv4->SetDefaultRoute (Ipv4Address ("10.1.1.2"), 1);
   2.176 +  ipv4 = n3->QueryInterface<Ipv4> (Ipv4::iid);
   2.177 +  ipv4->SetDefaultRoute (Ipv4Address ("10.1.3.1"), 1);
   2.178 +  
   2.179 +  // Configure tracing of all enqueue, dequeue, and NetDevice receive events
   2.180 +  // Trace output will be sent to the simple-point-to-point.tr file
   2.181 +  AsciiTrace asciitrace ("simple-point-to-point.tr");
   2.182 +  asciitrace.TraceAllQueues ();
   2.183 +  asciitrace.TraceAllNetDeviceRx ();
   2.184 +
   2.185 +  // Also configure some tcpdump traces; each interface will be traced
   2.186 +  // The output files will be named 
   2.187 +  // simple-point-to-point.pcap-<nodeId>-<interfaceId>
   2.188 +  // and can be read by the "tcpdump -r" command (use "-tt" option to
   2.189 +  // display timestamps correctly)
   2.190 +  PcapTrace pcaptrace ("simple-point-to-point.pcap");
   2.191 +  pcaptrace.TraceAllIp ();
   2.192 +
   2.193 +  Simulator::Run ();
   2.194 +    
   2.195 +  Simulator::Destroy ();
   2.196 +}
     3.1 --- a/examples/wscript	Fri Jul 27 12:50:31 2007 -0700
     3.2 +++ b/examples/wscript	Fri Jul 27 13:07:36 2007 -0700
     3.3 @@ -9,6 +9,6 @@
     3.4          obj.source = source
     3.5          return obj
     3.6          
     3.7 -    obj = create_ns_prog('simple-p2p', 'simple-p2p.cc', deps=['point-to-point', 'internet-node'])
     3.8 +    obj = create_ns_prog('simple-point-to-point', 'simple-point-to-point.cc', deps=['point-to-point', 'internet-node'])
     3.9      obj = create_ns_prog('csma-cd-one-subnet', 'csma-cd-one-subnet.cc', deps=['csma-cd', 'internet-node'])
    3.10