examples/tutorial/third.cc
author Mitch Watrous <watrous@u.washington.edu>
Wed, 02 Mar 2011 13:42:28 -0800
changeset 6847 138f00c56381
parent 6845 7dc660ca04ff
child 6848 1f453ad50ef3
permissions -rw-r--r--
Move applications to a single module
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"
6823
a27f86fb4e55 Merge node and common modules into new network module
Tom Henderson <tomh@tomh.org>
parents: 6821
diff changeset
    18
#include "ns3/network-module.h"
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    19
#include "ns3/helper-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"
6649
f5413d463948 Missing ipv4-global-routing-helper.h include
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6309
diff changeset
    23
#include "ns3/ipv4-global-routing-helper.h"
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    24
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    25
// Default Network Topology
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    26
//
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    27
//   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
    28
//                 AP
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    29
//  *    *    *    *
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    30
//  |    |    |    |    10.1.1.0
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    31
// 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
    32
//                   point-to-point  |    |    |    |
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    33
//                                   ================
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    34
//                                     LAN 10.1.2.0
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    35
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    36
using namespace ns3;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    37
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    38
NS_LOG_COMPONENT_DEFINE ("ThirdScriptExample");
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    39
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    40
int 
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    41
main (int argc, char *argv[])
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    42
{
4199
761a6ee97850 quiet second.cc and third.cc when running as regression tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 4028
diff changeset
    43
  bool verbose = true;
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    44
  uint32_t nCsma = 3;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    45
  uint32_t nWifi = 3;
4294
ebb973fdb763 wrap up tutorial updates
Craig Dowell <craigdo@ee.washington.edu>
parents: 4264
diff changeset
    46
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    47
  CommandLine cmd;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    48
  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
    49
  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
    50
  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
    51
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    52
  cmd.Parse (argc,argv);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    53
4199
761a6ee97850 quiet second.cc and third.cc when running as regression tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 4028
diff changeset
    54
  if (verbose)
761a6ee97850 quiet second.cc and third.cc when running as regression tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 4028
diff changeset
    55
    {
761a6ee97850 quiet second.cc and third.cc when running as regression tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 4028
diff changeset
    56
      LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO);
761a6ee97850 quiet second.cc and third.cc when running as regression tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 4028
diff changeset
    57
      LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_INFO);
761a6ee97850 quiet second.cc and third.cc when running as regression tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 4028
diff changeset
    58
    }
761a6ee97850 quiet second.cc and third.cc when running as regression tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 4028
diff changeset
    59
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    60
  NodeContainer p2pNodes;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    61
  p2pNodes.Create (2);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    62
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    63
  PointToPointHelper pointToPoint;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    64
  pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    65
  pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    66
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    67
  NetDeviceContainer p2pDevices;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    68
  p2pDevices = pointToPoint.Install (p2pNodes);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    69
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    70
  NodeContainer csmaNodes;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    71
  csmaNodes.Add (p2pNodes.Get (1));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    72
  csmaNodes.Create (nCsma);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    73
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    74
  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
    75
  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
    76
  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
    77
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    78
  NetDeviceContainer csmaDevices;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    79
  csmaDevices = csma.Install (csmaNodes);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    80
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    81
  NodeContainer wifiStaNodes;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    82
  wifiStaNodes.Create (nWifi);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    83
  NodeContainer wifiApNode = p2pNodes.Get (0);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    84
4004
b181e89d45f1 bug 440: fix build of tutorial example third.cc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3995
diff changeset
    85
  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
    86
  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
    87
  phy.SetChannel (channel.Create ());
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    88
4005
7ddad22e007a couple of small typos
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4004
diff changeset
    89
  WifiHelper wifi = WifiHelper::Default ();
7ddad22e007a couple of small typos
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4004
diff changeset
    90
  wifi.SetRemoteStationManager ("ns3::AarfWifiManager");
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    91
4406
39f119de91ef Add WifiMacHelper
Mirko Banchi <mk.banchi@gmail.com>
parents: 4294
diff changeset
    92
  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
    93
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    94
  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
    95
  mac.SetType ("ns3::StaWifiMac",
ec22aa763e2d Bug 978: Consolidate Wi-Fi MAC high functionality
Dean Armstrong <deanarm@gmail.com>
parents: 6649
diff changeset
    96
               "Ssid", SsidValue (ssid),
ec22aa763e2d Bug 978: Consolidate Wi-Fi MAC high functionality
Dean Armstrong <deanarm@gmail.com>
parents: 6649
diff changeset
    97
               "ActiveProbing", BooleanValue (false));
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    98
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    99
  NetDeviceContainer staDevices;
4406
39f119de91ef Add WifiMacHelper
Mirko Banchi <mk.banchi@gmail.com>
parents: 4294
diff changeset
   100
  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
   101
6673
ec22aa763e2d Bug 978: Consolidate Wi-Fi MAC high functionality
Dean Armstrong <deanarm@gmail.com>
parents: 6649
diff changeset
   102
  mac.SetType ("ns3::ApWifiMac",
ec22aa763e2d Bug 978: Consolidate Wi-Fi MAC high functionality
Dean Armstrong <deanarm@gmail.com>
parents: 6649
diff changeset
   103
               "Ssid", SsidValue (ssid));
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   104
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   105
  NetDeviceContainer apDevices;
4406
39f119de91ef Add WifiMacHelper
Mirko Banchi <mk.banchi@gmail.com>
parents: 4294
diff changeset
   106
  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
   107
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   108
  MobilityHelper mobility;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   109
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   110
  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
   111
                                 "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
   112
                                 "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
   113
                                 "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
   114
                                 "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
   115
                                 "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
   116
                                 "LayoutType", StringValue ("RowFirst"));
3994
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.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
   119
                             "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
   120
  mobility.Install (wifiStaNodes);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   121
4257
3e8f8052e155 StaticMobilityModel -> ConstantPositionMobilityModel, StaticSpeedMobilityModel -> ConstantVelocityMobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4236
diff changeset
   122
  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   123
  mobility.Install (wifiApNode);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   124
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   125
  InternetStackHelper stack;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   126
  stack.Install (csmaNodes);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   127
  stack.Install (wifiApNode);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   128
  stack.Install (wifiStaNodes);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   129
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   130
  Ipv4AddressHelper address;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   131
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   132
  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
   133
  Ipv4InterfaceContainer p2pInterfaces;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   134
  p2pInterfaces = address.Assign (p2pDevices);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   135
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   136
  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
   137
  Ipv4InterfaceContainer csmaInterfaces;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   138
  csmaInterfaces = address.Assign (csmaDevices);
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.3.0", "255.255.255.0");
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   141
  address.Assign (staDevices);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   142
  address.Assign (apDevices);
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
  UdpEchoServerHelper echoServer (9);
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
  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
   147
  serverApps.Start (Seconds (1.0));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   148
  serverApps.Stop (Seconds (10.0));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   149
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   150
  UdpEchoClientHelper echoClient (csmaInterfaces.GetAddress (nCsma), 9);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   151
  echoClient.SetAttribute ("MaxPackets", UintegerValue (1));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   152
  echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.)));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   153
  echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   154
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   155
  ApplicationContainer clientApps = 
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   156
    echoClient.Install (wifiStaNodes.Get (nWifi - 1));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   157
  clientApps.Start (Seconds (2.0));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   158
  clientApps.Stop (Seconds (10.0));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   159
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
   160
  Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
3994
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
  Simulator::Stop (Seconds (10.0));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   163
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
   164
  pointToPoint.EnablePcapAll ("third");
4492
3ebeb7bf3c15 added support for radiotap and prism headers
Nicola Baldo <nbaldo@cttc.es>
parents: 4406
diff changeset
   165
  phy.EnablePcap ("third", apDevices.Get (0));
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
   166
  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
   167
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   168
  Simulator::Run ();
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   169
  Simulator::Destroy ();
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   170
  return 0;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   171
}