examples/tutorial/third.cc
author Tom Henderson <tomh@tomh.org>
Thu, 01 Oct 2015 11:07:22 -0700
changeset 11677 1e2add816314
parent 11466 d2d2cadf7a53
permissions -rw-r--r--
update RELEASE_NOTES and VERSION for ns-3.24.1
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
//
11466
d2d2cadf7a53 Revert unintentional change of third.cc trace file names, and remove execute bits.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11418
diff changeset
    28
// Number of wifi or csma nodes can be increased up to 250
d2d2cadf7a53 Revert unintentional change of third.cc trace file names, and remove execute bits.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11418
diff changeset
    29
//                          |
d2d2cadf7a53 Revert unintentional change of third.cc trace file names, and remove execute bits.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11418
diff changeset
    30
//                 Rank 0   |   Rank 1
d2d2cadf7a53 Revert unintentional change of third.cc trace file names, and remove execute bits.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11418
diff changeset
    31
// -------------------------|----------------------------
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    32
//   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
    33
//                 AP
3994
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
//  |    |    |    |    10.1.1.0
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    36
// 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
    37
//                   point-to-point  |    |    |    |
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
//                                     LAN 10.1.2.0
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
using namespace ns3;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    42
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    43
NS_LOG_COMPONENT_DEFINE ("ThirdScriptExample");
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    44
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    45
int 
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    46
main (int argc, char *argv[])
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    47
{
4199
761a6ee97850 quiet second.cc and third.cc when running as regression tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 4028
diff changeset
    48
  bool verbose = true;
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    49
  uint32_t nCsma = 3;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    50
  uint32_t nWifi = 3;
11418
4d6051f4166f Bring tutorial third.cc and mpi third-distributed.cc into alignment.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9112
diff changeset
    51
  bool tracing = false;
4294
ebb973fdb763 wrap up tutorial updates
Craig Dowell <craigdo@ee.washington.edu>
parents: 4264
diff changeset
    52
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    53
  CommandLine cmd;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    54
  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
    55
  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
    56
  cmd.AddValue ("verbose", "Tell echo applications to log if true", verbose);
11418
4d6051f4166f Bring tutorial third.cc and mpi third-distributed.cc into alignment.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9112
diff changeset
    57
  cmd.AddValue ("tracing", "Enable pcap tracing", tracing);
4199
761a6ee97850 quiet second.cc and third.cc when running as regression tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 4028
diff changeset
    58
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    59
  cmd.Parse (argc,argv);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    60
11418
4d6051f4166f Bring tutorial third.cc and mpi third-distributed.cc into alignment.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9112
diff changeset
    61
  // Check for valid number of csma or wifi nodes
4d6051f4166f Bring tutorial third.cc and mpi third-distributed.cc into alignment.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9112
diff changeset
    62
  // 250 should be enough, otherwise IP addresses 
4d6051f4166f Bring tutorial third.cc and mpi third-distributed.cc into alignment.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9112
diff changeset
    63
  // soon become an issue
4d6051f4166f Bring tutorial third.cc and mpi third-distributed.cc into alignment.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9112
diff changeset
    64
  if (nWifi > 250 || nCsma > 250)
7879
0e14523a87fd (bug 1404) Bound user input in tutorial third.cc program
Tom Henderson <tomh@tomh.org>
parents: 7256
diff changeset
    65
    {
11418
4d6051f4166f Bring tutorial third.cc and mpi third-distributed.cc into alignment.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9112
diff changeset
    66
      std::cout << "Too many wifi or csma nodes, no more than 250 each." << std::endl;
4d6051f4166f Bring tutorial third.cc and mpi third-distributed.cc into alignment.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9112
diff changeset
    67
      return 1;
7879
0e14523a87fd (bug 1404) Bound user input in tutorial third.cc program
Tom Henderson <tomh@tomh.org>
parents: 7256
diff changeset
    68
    }
0e14523a87fd (bug 1404) Bound user input in tutorial third.cc program
Tom Henderson <tomh@tomh.org>
parents: 7256
diff changeset
    69
4199
761a6ee97850 quiet second.cc and third.cc when running as regression tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 4028
diff changeset
    70
  if (verbose)
761a6ee97850 quiet second.cc and third.cc when running as regression tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 4028
diff changeset
    71
    {
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7089
diff changeset
    72
      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
    73
      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
    74
    }
761a6ee97850 quiet second.cc and third.cc when running as regression tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 4028
diff changeset
    75
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    76
  NodeContainer p2pNodes;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    77
  p2pNodes.Create (2);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    78
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    79
  PointToPointHelper pointToPoint;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    80
  pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    81
  pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    82
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    83
  NetDeviceContainer p2pDevices;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    84
  p2pDevices = pointToPoint.Install (p2pNodes);
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
  NodeContainer csmaNodes;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    87
  csmaNodes.Add (p2pNodes.Get (1));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    88
  csmaNodes.Create (nCsma);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    89
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    90
  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
    91
  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
    92
  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
    93
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    94
  NetDeviceContainer csmaDevices;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    95
  csmaDevices = csma.Install (csmaNodes);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    96
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    97
  NodeContainer wifiStaNodes;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    98
  wifiStaNodes.Create (nWifi);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    99
  NodeContainer wifiApNode = p2pNodes.Get (0);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   100
4004
b181e89d45f1 bug 440: fix build of tutorial example third.cc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3995
diff changeset
   101
  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
   102
  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
   103
  phy.SetChannel (channel.Create ());
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   104
4005
7ddad22e007a couple of small typos
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4004
diff changeset
   105
  WifiHelper wifi = WifiHelper::Default ();
7ddad22e007a couple of small typos
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4004
diff changeset
   106
  wifi.SetRemoteStationManager ("ns3::AarfWifiManager");
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   107
4406
39f119de91ef Add WifiMacHelper
Mirko Banchi <mk.banchi@gmail.com>
parents: 4294
diff changeset
   108
  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
   109
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   110
  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
   111
  mac.SetType ("ns3::StaWifiMac",
ec22aa763e2d Bug 978: Consolidate Wi-Fi MAC high functionality
Dean Armstrong <deanarm@gmail.com>
parents: 6649
diff changeset
   112
               "Ssid", SsidValue (ssid),
ec22aa763e2d Bug 978: Consolidate Wi-Fi MAC high functionality
Dean Armstrong <deanarm@gmail.com>
parents: 6649
diff changeset
   113
               "ActiveProbing", BooleanValue (false));
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   114
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   115
  NetDeviceContainer staDevices;
4406
39f119de91ef Add WifiMacHelper
Mirko Banchi <mk.banchi@gmail.com>
parents: 4294
diff changeset
   116
  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
   117
6673
ec22aa763e2d Bug 978: Consolidate Wi-Fi MAC high functionality
Dean Armstrong <deanarm@gmail.com>
parents: 6649
diff changeset
   118
  mac.SetType ("ns3::ApWifiMac",
ec22aa763e2d Bug 978: Consolidate Wi-Fi MAC high functionality
Dean Armstrong <deanarm@gmail.com>
parents: 6649
diff changeset
   119
               "Ssid", SsidValue (ssid));
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   120
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   121
  NetDeviceContainer apDevices;
4406
39f119de91ef Add WifiMacHelper
Mirko Banchi <mk.banchi@gmail.com>
parents: 4294
diff changeset
   122
  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
   123
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   124
  MobilityHelper mobility;
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.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
   127
                                 "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
   128
                                 "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
   129
                                 "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
   130
                                 "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
   131
                                 "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
   132
                                 "LayoutType", StringValue ("RowFirst"));
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   133
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   134
  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
   135
                             "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
   136
  mobility.Install (wifiStaNodes);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   137
4257
3e8f8052e155 StaticMobilityModel -> ConstantPositionMobilityModel, StaticSpeedMobilityModel -> ConstantVelocityMobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4236
diff changeset
   138
  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   139
  mobility.Install (wifiApNode);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   140
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   141
  InternetStackHelper stack;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   142
  stack.Install (csmaNodes);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   143
  stack.Install (wifiApNode);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   144
  stack.Install (wifiStaNodes);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   145
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   146
  Ipv4AddressHelper address;
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.1.0", "255.255.255.0");
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   149
  Ipv4InterfaceContainer p2pInterfaces;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   150
  p2pInterfaces = address.Assign (p2pDevices);
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
  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
   153
  Ipv4InterfaceContainer csmaInterfaces;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   154
  csmaInterfaces = address.Assign (csmaDevices);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   155
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   156
  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
   157
  address.Assign (staDevices);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   158
  address.Assign (apDevices);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   159
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   160
  UdpEchoServerHelper echoServer (9);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   161
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   162
  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
   163
  serverApps.Start (Seconds (1.0));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   164
  serverApps.Stop (Seconds (10.0));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   165
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   166
  UdpEchoClientHelper echoClient (csmaInterfaces.GetAddress (nCsma), 9);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   167
  echoClient.SetAttribute ("MaxPackets", UintegerValue (1));
9112
ede7a74e7411 bug 1514: make TimeValue usage consistent in the tutorial
Tom Henderson <tomh@tomh.org>
parents: 7879
diff changeset
   168
  echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.0)));
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   169
  echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   170
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   171
  ApplicationContainer clientApps = 
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   172
    echoClient.Install (wifiStaNodes.Get (nWifi - 1));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   173
  clientApps.Start (Seconds (2.0));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   174
  clientApps.Stop (Seconds (10.0));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   175
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
   176
  Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   177
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   178
  Simulator::Stop (Seconds (10.0));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   179
11418
4d6051f4166f Bring tutorial third.cc and mpi third-distributed.cc into alignment.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9112
diff changeset
   180
  if (tracing == true)
4d6051f4166f Bring tutorial third.cc and mpi third-distributed.cc into alignment.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9112
diff changeset
   181
    {
11466
d2d2cadf7a53 Revert unintentional change of third.cc trace file names, and remove execute bits.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11418
diff changeset
   182
      pointToPoint.EnablePcapAll ("third");
d2d2cadf7a53 Revert unintentional change of third.cc trace file names, and remove execute bits.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11418
diff changeset
   183
      phy.EnablePcap ("third", apDevices.Get (0));
d2d2cadf7a53 Revert unintentional change of third.cc trace file names, and remove execute bits.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11418
diff changeset
   184
      csma.EnablePcap ("third", csmaDevices.Get (0), true);
11418
4d6051f4166f Bring tutorial third.cc and mpi third-distributed.cc into alignment.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9112
diff changeset
   185
    }
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   186
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   187
  Simulator::Run ();
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   188
  Simulator::Destroy ();
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   189
  return 0;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   190
}