examples/tutorial/third.cc
author Tom Henderson <tomh@tomh.org>
Fri, 04 May 2012 16:32:59 -0700
changeset 7879 0e14523a87fd
parent 7256 b04ba6772f8c
child 9112 ede7a74e7411
permissions -rw-r--r--
(bug 1404) Bound user input in tutorial third.cc program
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
     2
/*
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
     3
 * This program is free software; you can redistribute it and/or modify
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
     4
 * it under the terms of the GNU General Public License version 2 as
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
     5
 * published by the Free Software Foundation;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
     6
 *
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
     7
 * This program is distributed in the hope that it will be useful,
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
     8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
     9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    10
 * GNU General Public License for more details.
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    11
 *
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    12
 * You should have received a copy of the GNU General Public License
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    13
 * along with this program; if not, write to the Free Software
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    14
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    15
 */
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    16
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    17
#include "ns3/core-module.h"
6848
1f453ad50ef3 Converts csma, emu, tap-bridge, point-to-point, wifi and wimax modules into modular format
Lalith Suresh <suresh.lalith@gmail.com>
parents: 6847
diff changeset
    18
#include "ns3/point-to-point-module.h"
6823
a27f86fb4e55 Merge node and common modules into new network module
Tom Henderson <tomh@tomh.org>
parents: 6821
diff changeset
    19
#include "ns3/network-module.h"
6847
138f00c56381 Move applications to a single module
Mitch Watrous <watrous@u.washington.edu>
parents: 6845
diff changeset
    20
#include "ns3/applications-module.h"
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    21
#include "ns3/wifi-module.h"
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    22
#include "ns3/mobility-module.h"
6848
1f453ad50ef3 Converts csma, emu, tap-bridge, point-to-point, wifi and wimax modules into modular format
Lalith Suresh <suresh.lalith@gmail.com>
parents: 6847
diff changeset
    23
#include "ns3/csma-module.h"
7089
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents: 6865
diff changeset
    24
#include "ns3/internet-module.h"
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    25
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    26
// Default Network Topology
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    27
//
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    28
//   Wifi 10.1.3.0
6674
52f8688d6d01 Bug 978: Run check-style.py on files touched in the reorganisation
Dean Armstrong <deanarm@gmail.com>
parents: 6673
diff changeset
    29
//                 AP
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    30
//  *    *    *    *
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    31
//  |    |    |    |    10.1.1.0
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    32
// n5   n6   n7   n0 -------------- n1   n2   n3   n4
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    33
//                   point-to-point  |    |    |    |
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    34
//                                   ================
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    35
//                                     LAN 10.1.2.0
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    36
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    37
using namespace ns3;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    38
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    39
NS_LOG_COMPONENT_DEFINE ("ThirdScriptExample");
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    40
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    41
int 
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    42
main (int argc, char *argv[])
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    43
{
4199
761a6ee97850 quiet second.cc and third.cc when running as regression tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 4028
diff changeset
    44
  bool verbose = true;
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    45
  uint32_t nCsma = 3;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    46
  uint32_t nWifi = 3;
4294
ebb973fdb763 wrap up tutorial updates
Craig Dowell <craigdo@ee.washington.edu>
parents: 4264
diff changeset
    47
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    48
  CommandLine cmd;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    49
  cmd.AddValue ("nCsma", "Number of \"extra\" CSMA nodes/devices", nCsma);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    50
  cmd.AddValue ("nWifi", "Number of wifi STA devices", nWifi);
4199
761a6ee97850 quiet second.cc and third.cc when running as regression tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 4028
diff changeset
    51
  cmd.AddValue ("verbose", "Tell echo applications to log if true", verbose);
761a6ee97850 quiet second.cc and third.cc when running as regression tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 4028
diff changeset
    52
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    53
  cmd.Parse (argc,argv);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    54
7879
0e14523a87fd (bug 1404) Bound user input in tutorial third.cc program
Tom Henderson <tomh@tomh.org>
parents: 7256
diff changeset
    55
  if (nWifi > 18)
0e14523a87fd (bug 1404) Bound user input in tutorial third.cc program
Tom Henderson <tomh@tomh.org>
parents: 7256
diff changeset
    56
    {
0e14523a87fd (bug 1404) Bound user input in tutorial third.cc program
Tom Henderson <tomh@tomh.org>
parents: 7256
diff changeset
    57
      std::cout << "Number of wifi nodes " << nWifi << 
0e14523a87fd (bug 1404) Bound user input in tutorial third.cc program
Tom Henderson <tomh@tomh.org>
parents: 7256
diff changeset
    58
                   " specified exceeds the mobility bounding box" << std::endl;
0e14523a87fd (bug 1404) Bound user input in tutorial third.cc program
Tom Henderson <tomh@tomh.org>
parents: 7256
diff changeset
    59
      exit (1);
0e14523a87fd (bug 1404) Bound user input in tutorial third.cc program
Tom Henderson <tomh@tomh.org>
parents: 7256
diff changeset
    60
    }
0e14523a87fd (bug 1404) Bound user input in tutorial third.cc program
Tom Henderson <tomh@tomh.org>
parents: 7256
diff changeset
    61
4199
761a6ee97850 quiet second.cc and third.cc when running as regression tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 4028
diff changeset
    62
  if (verbose)
761a6ee97850 quiet second.cc and third.cc when running as regression tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 4028
diff changeset
    63
    {
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7089
diff changeset
    64
      LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO);
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7089
diff changeset
    65
      LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO);
4199
761a6ee97850 quiet second.cc and third.cc when running as regression tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 4028
diff changeset
    66
    }
761a6ee97850 quiet second.cc and third.cc when running as regression tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 4028
diff changeset
    67
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    68
  NodeContainer p2pNodes;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    69
  p2pNodes.Create (2);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    70
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    71
  PointToPointHelper pointToPoint;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    72
  pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    73
  pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    74
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    75
  NetDeviceContainer p2pDevices;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    76
  p2pDevices = pointToPoint.Install (p2pNodes);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    77
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    78
  NodeContainer csmaNodes;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    79
  csmaNodes.Add (p2pNodes.Get (1));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    80
  csmaNodes.Create (nCsma);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    81
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    82
  CsmaHelper csma;
3995
9bda1a9c0eb2 Add reasonable data rate and delay to csma channels; update tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 3994
diff changeset
    83
  csma.SetChannelAttribute ("DataRate", StringValue ("100Mbps"));
9bda1a9c0eb2 Add reasonable data rate and delay to csma channels; update tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 3994
diff changeset
    84
  csma.SetChannelAttribute ("Delay", TimeValue (NanoSeconds (6560)));
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    85
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    86
  NetDeviceContainer csmaDevices;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    87
  csmaDevices = csma.Install (csmaNodes);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    88
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    89
  NodeContainer wifiStaNodes;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    90
  wifiStaNodes.Create (nWifi);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    91
  NodeContainer wifiApNode = p2pNodes.Get (0);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    92
4004
b181e89d45f1 bug 440: fix build of tutorial example third.cc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3995
diff changeset
    93
  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
b181e89d45f1 bug 440: fix build of tutorial example third.cc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3995
diff changeset
    94
  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
b181e89d45f1 bug 440: fix build of tutorial example third.cc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3995
diff changeset
    95
  phy.SetChannel (channel.Create ());
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    96
4005
7ddad22e007a couple of small typos
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4004
diff changeset
    97
  WifiHelper wifi = WifiHelper::Default ();
7ddad22e007a couple of small typos
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4004
diff changeset
    98
  wifi.SetRemoteStationManager ("ns3::AarfWifiManager");
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    99
4406
39f119de91ef Add WifiMacHelper
Mirko Banchi <mk.banchi@gmail.com>
parents: 4294
diff changeset
   100
  NqosWifiMacHelper mac = NqosWifiMacHelper::Default ();
6674
52f8688d6d01 Bug 978: Run check-style.py on files touched in the reorganisation
Dean Armstrong <deanarm@gmail.com>
parents: 6673
diff changeset
   101
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   102
  Ssid ssid = Ssid ("ns-3-ssid");
6673
ec22aa763e2d Bug 978: Consolidate Wi-Fi MAC high functionality
Dean Armstrong <deanarm@gmail.com>
parents: 6649
diff changeset
   103
  mac.SetType ("ns3::StaWifiMac",
ec22aa763e2d Bug 978: Consolidate Wi-Fi MAC high functionality
Dean Armstrong <deanarm@gmail.com>
parents: 6649
diff changeset
   104
               "Ssid", SsidValue (ssid),
ec22aa763e2d Bug 978: Consolidate Wi-Fi MAC high functionality
Dean Armstrong <deanarm@gmail.com>
parents: 6649
diff changeset
   105
               "ActiveProbing", BooleanValue (false));
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   106
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   107
  NetDeviceContainer staDevices;
4406
39f119de91ef Add WifiMacHelper
Mirko Banchi <mk.banchi@gmail.com>
parents: 4294
diff changeset
   108
  staDevices = wifi.Install (phy, mac, wifiStaNodes);
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   109
6673
ec22aa763e2d Bug 978: Consolidate Wi-Fi MAC high functionality
Dean Armstrong <deanarm@gmail.com>
parents: 6649
diff changeset
   110
  mac.SetType ("ns3::ApWifiMac",
ec22aa763e2d Bug 978: Consolidate Wi-Fi MAC high functionality
Dean Armstrong <deanarm@gmail.com>
parents: 6649
diff changeset
   111
               "Ssid", SsidValue (ssid));
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   112
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   113
  NetDeviceContainer apDevices;
4406
39f119de91ef Add WifiMacHelper
Mirko Banchi <mk.banchi@gmail.com>
parents: 4294
diff changeset
   114
  apDevices = wifi.Install (phy, mac, wifiApNode);
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   115
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   116
  MobilityHelper mobility;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   117
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   118
  mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
6674
52f8688d6d01 Bug 978: Run check-style.py on files touched in the reorganisation
Dean Armstrong <deanarm@gmail.com>
parents: 6673
diff changeset
   119
                                 "MinX", DoubleValue (0.0),
52f8688d6d01 Bug 978: Run check-style.py on files touched in the reorganisation
Dean Armstrong <deanarm@gmail.com>
parents: 6673
diff changeset
   120
                                 "MinY", DoubleValue (0.0),
52f8688d6d01 Bug 978: Run check-style.py on files touched in the reorganisation
Dean Armstrong <deanarm@gmail.com>
parents: 6673
diff changeset
   121
                                 "DeltaX", DoubleValue (5.0),
52f8688d6d01 Bug 978: Run check-style.py on files touched in the reorganisation
Dean Armstrong <deanarm@gmail.com>
parents: 6673
diff changeset
   122
                                 "DeltaY", DoubleValue (10.0),
52f8688d6d01 Bug 978: Run check-style.py on files touched in the reorganisation
Dean Armstrong <deanarm@gmail.com>
parents: 6673
diff changeset
   123
                                 "GridWidth", UintegerValue (3),
52f8688d6d01 Bug 978: Run check-style.py on files touched in the reorganisation
Dean Armstrong <deanarm@gmail.com>
parents: 6673
diff changeset
   124
                                 "LayoutType", StringValue ("RowFirst"));
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   125
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   126
  mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel",
6674
52f8688d6d01 Bug 978: Run check-style.py on files touched in the reorganisation
Dean Armstrong <deanarm@gmail.com>
parents: 6673
diff changeset
   127
                             "Bounds", RectangleValue (Rectangle (-50, 50, -50, 50)));
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   128
  mobility.Install (wifiStaNodes);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   129
4257
3e8f8052e155 StaticMobilityModel -> ConstantPositionMobilityModel, StaticSpeedMobilityModel -> ConstantVelocityMobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4236
diff changeset
   130
  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   131
  mobility.Install (wifiApNode);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   132
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   133
  InternetStackHelper stack;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   134
  stack.Install (csmaNodes);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   135
  stack.Install (wifiApNode);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   136
  stack.Install (wifiStaNodes);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   137
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   138
  Ipv4AddressHelper address;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   139
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   140
  address.SetBase ("10.1.1.0", "255.255.255.0");
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   141
  Ipv4InterfaceContainer p2pInterfaces;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   142
  p2pInterfaces = address.Assign (p2pDevices);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   143
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   144
  address.SetBase ("10.1.2.0", "255.255.255.0");
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   145
  Ipv4InterfaceContainer csmaInterfaces;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   146
  csmaInterfaces = address.Assign (csmaDevices);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   147
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   148
  address.SetBase ("10.1.3.0", "255.255.255.0");
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   149
  address.Assign (staDevices);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   150
  address.Assign (apDevices);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   151
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   152
  UdpEchoServerHelper echoServer (9);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   153
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   154
  ApplicationContainer serverApps = echoServer.Install (csmaNodes.Get (nCsma));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   155
  serverApps.Start (Seconds (1.0));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   156
  serverApps.Stop (Seconds (10.0));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   157
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   158
  UdpEchoClientHelper echoClient (csmaInterfaces.GetAddress (nCsma), 9);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   159
  echoClient.SetAttribute ("MaxPackets", UintegerValue (1));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   160
  echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.)));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   161
  echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   162
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   163
  ApplicationContainer clientApps = 
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   164
    echoClient.Install (wifiStaNodes.Get (nWifi - 1));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   165
  clientApps.Start (Seconds (2.0));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   166
  clientApps.Stop (Seconds (10.0));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   167
4616
a84f60b6cd12 bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4492
diff changeset
   168
  Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   169
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   170
  Simulator::Stop (Seconds (10.0));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   171
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
   172
  pointToPoint.EnablePcapAll ("third");
4492
3ebeb7bf3c15 added support for radiotap and prism headers
Nicola Baldo <nbaldo@cttc.es>
parents: 4406
diff changeset
   173
  phy.EnablePcap ("third", apDevices.Get (0));
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
   174
  csma.EnablePcap ("third", csmaDevices.Get (0), true);
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   175
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   176
  Simulator::Run ();
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   177
  Simulator::Destroy ();
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   178
  return 0;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   179
}