examples/third.cc
author Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
Fri, 03 Jul 2009 14:12:28 +0100
changeset 4649 189238bfdc7f
parent 4616 a84f60b6cd12
permissions -rw-r--r--
Add doxygen for BridgeHelper
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"
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    18
#include "ns3/simulator-module.h"
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    19
#include "ns3/node-module.h"
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    20
#include "ns3/helper-module.h"
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"
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    23
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    24
// Default Network Topology
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
//   Wifi 10.1.3.0
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    27
//                 AP   
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    28
//  *    *    *    *
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    29
//  |    |    |    |    10.1.1.0
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    30
// 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
    31
//                   point-to-point  |    |    |    |
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    32
//                                   ================
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    33
//                                     LAN 10.1.2.0
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
using namespace ns3;
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
NS_LOG_COMPONENT_DEFINE ("ThirdScriptExample");
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
int 
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    40
main (int argc, char *argv[])
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    41
{
4199
761a6ee97850 quiet second.cc and third.cc when running as regression tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 4028
diff changeset
    42
  bool verbose = true;
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    43
  uint32_t nCsma = 3;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    44
  uint32_t nWifi = 3;
4294
ebb973fdb763 wrap up tutorial updates
Craig Dowell <craigdo@ee.washington.edu>
parents: 4264
diff changeset
    45
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    46
  CommandLine cmd;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    47
  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
    48
  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
    49
  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
    50
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    51
  cmd.Parse (argc,argv);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    52
4199
761a6ee97850 quiet second.cc and third.cc when running as regression tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 4028
diff changeset
    53
  if (verbose)
761a6ee97850 quiet second.cc and third.cc when running as regression tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 4028
diff changeset
    54
    {
761a6ee97850 quiet second.cc and third.cc when running as regression tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 4028
diff changeset
    55
      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
    56
      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
    57
    }
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
  NodeContainer p2pNodes;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    60
  p2pNodes.Create (2);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    61
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    62
  PointToPointHelper pointToPoint;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    63
  pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    64
  pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    65
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    66
  NetDeviceContainer p2pDevices;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    67
  p2pDevices = pointToPoint.Install (p2pNodes);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    68
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    69
  NodeContainer csmaNodes;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    70
  csmaNodes.Add (p2pNodes.Get (1));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    71
  csmaNodes.Create (nCsma);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    72
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    73
  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
    74
  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
    75
  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
    76
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    77
  NetDeviceContainer csmaDevices;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    78
  csmaDevices = csma.Install (csmaNodes);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    79
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    80
  NodeContainer wifiStaNodes;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    81
  wifiStaNodes.Create (nWifi);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    82
  NodeContainer wifiApNode = p2pNodes.Get (0);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    83
4004
b181e89d45f1 bug 440: fix build of tutorial example third.cc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3995
diff changeset
    84
  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
    85
  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
    86
  phy.SetChannel (channel.Create ());
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    87
4005
7ddad22e007a couple of small typos
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4004
diff changeset
    88
  WifiHelper wifi = WifiHelper::Default ();
7ddad22e007a couple of small typos
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4004
diff changeset
    89
  wifi.SetRemoteStationManager ("ns3::AarfWifiManager");
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    90
4406
39f119de91ef Add WifiMacHelper
Mirko Banchi <mk.banchi@gmail.com>
parents: 4294
diff changeset
    91
  NqosWifiMacHelper mac = NqosWifiMacHelper::Default ();
39f119de91ef Add WifiMacHelper
Mirko Banchi <mk.banchi@gmail.com>
parents: 4294
diff changeset
    92
  
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    93
  Ssid ssid = Ssid ("ns-3-ssid");
4406
39f119de91ef Add WifiMacHelper
Mirko Banchi <mk.banchi@gmail.com>
parents: 4294
diff changeset
    94
  mac.SetType ("ns3::NqstaWifiMac", 
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    95
    "Ssid", SsidValue (ssid),
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    96
    "ActiveProbing", BooleanValue (false));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    97
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    98
  NetDeviceContainer staDevices;
4406
39f119de91ef Add WifiMacHelper
Mirko Banchi <mk.banchi@gmail.com>
parents: 4294
diff changeset
    99
  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
   100
4406
39f119de91ef Add WifiMacHelper
Mirko Banchi <mk.banchi@gmail.com>
parents: 4294
diff changeset
   101
  mac.SetType ("ns3::NqapWifiMac", 
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   102
    "Ssid", SsidValue (ssid),
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   103
    "BeaconGeneration", BooleanValue (true),
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   104
    "BeaconInterval", TimeValue (Seconds (2.5)));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   105
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   106
  NetDeviceContainer apDevices;
4406
39f119de91ef Add WifiMacHelper
Mirko Banchi <mk.banchi@gmail.com>
parents: 4294
diff changeset
   107
  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
   108
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   109
  MobilityHelper mobility;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   110
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   111
  mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   112
    "MinX", DoubleValue (0.0),
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   113
    "MinY", DoubleValue (0.0),
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   114
    "DeltaX", DoubleValue (5.0),
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   115
    "DeltaY", DoubleValue (10.0),
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   116
    "GridWidth", UintegerValue (3),
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   117
    "LayoutType", StringValue ("RowFirst"));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   118
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   119
  mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel",
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   120
    "Bounds", RectangleValue (Rectangle (-50, 50, -50, 50)));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   121
  mobility.Install (wifiStaNodes);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   122
4257
3e8f8052e155 StaticMobilityModel -> ConstantPositionMobilityModel, StaticSpeedMobilityModel -> ConstantVelocityMobilityModel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4236
diff changeset
   123
  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   124
  mobility.Install (wifiApNode);
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
  InternetStackHelper stack;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   127
  stack.Install (csmaNodes);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   128
  stack.Install (wifiApNode);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   129
  stack.Install (wifiStaNodes);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   130
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   131
  Ipv4AddressHelper address;
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
  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
   134
  Ipv4InterfaceContainer p2pInterfaces;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   135
  p2pInterfaces = address.Assign (p2pDevices);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   136
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   137
  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
   138
  Ipv4InterfaceContainer csmaInterfaces;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   139
  csmaInterfaces = address.Assign (csmaDevices);
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
  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
   142
  address.Assign (staDevices);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   143
  address.Assign (apDevices);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   144
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   145
  UdpEchoServerHelper echoServer (9);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   146
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   147
  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
   148
  serverApps.Start (Seconds (1.0));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   149
  serverApps.Stop (Seconds (10.0));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   150
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   151
  UdpEchoClientHelper echoClient (csmaInterfaces.GetAddress (nCsma), 9);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   152
  echoClient.SetAttribute ("MaxPackets", UintegerValue (1));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   153
  echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.)));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   154
  echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
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
  ApplicationContainer clientApps = 
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   157
    echoClient.Install (wifiStaNodes.Get (nWifi - 1));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   158
  clientApps.Start (Seconds (2.0));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   159
  clientApps.Stop (Seconds (10.0));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   160
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
   161
  Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
3994
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
  Simulator::Stop (Seconds (10.0));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   164
4294
ebb973fdb763 wrap up tutorial updates
Craig Dowell <craigdo@ee.washington.edu>
parents: 4264
diff changeset
   165
  PointToPointHelper::EnablePcapAll ("third");
4492
3ebeb7bf3c15 added support for radiotap and prism headers
Nicola Baldo <nbaldo@cttc.es>
parents: 4406
diff changeset
   166
  phy.EnablePcap ("third", apDevices.Get (0));
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4257
diff changeset
   167
  CsmaHelper::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
   168
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   169
  Simulator::Run ();
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   170
  Simulator::Destroy ();
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   171
  return 0;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   172
}