examples/third.cc
author Raj Bhattacharjea <raj.b@gatech.edu>
Tue, 13 Jan 2009 17:15:44 -0500
changeset 4218 debf1a8a96d3
parent 4028 13c1916747f2
child 4225 f1d873a81159
permissions -rw-r--r--
Proposed RNG API changes
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/global-routing-module.h"
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    22
#include "ns3/wifi-module.h"
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    23
#include "ns3/mobility-module.h"
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
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    28
//                 AP   
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
{
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    43
  LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    44
  LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_INFO);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    45
4218
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 4028
diff changeset
    46
  uint32_t seed[6] = {1, 1, 2, 3, 5, 8};
debf1a8a96d3 Proposed RNG API changes
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 4028
diff changeset
    47
  SeedManager::SetSeed(seed);
4028
13c1916747f2 fixed seeds for tutorial examples and updates to tutorial to match
Craig Dowell <craigdo@ee.washington.edu>
parents: 4005
diff changeset
    48
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;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    51
  CommandLine cmd;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    52
  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
    53
  cmd.AddValue ("nWifi", "Number of wifi STA devices", nWifi);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    54
  cmd.Parse (argc,argv);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    55
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    56
  NodeContainer p2pNodes;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    57
  p2pNodes.Create (2);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    58
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    59
  PointToPointHelper pointToPoint;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    60
  pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    61
  pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));
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
  NetDeviceContainer p2pDevices;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    64
  p2pDevices = pointToPoint.Install (p2pNodes);
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
  NodeContainer csmaNodes;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    67
  csmaNodes.Add (p2pNodes.Get (1));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    68
  csmaNodes.Create (nCsma);
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
  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
    71
  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
    72
  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
    73
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    74
  NetDeviceContainer csmaDevices;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    75
  csmaDevices = csma.Install (csmaNodes);
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
  NodeContainer wifiStaNodes;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    78
  wifiStaNodes.Create (nWifi);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    79
  NodeContainer wifiApNode = p2pNodes.Get (0);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    80
4004
b181e89d45f1 bug 440: fix build of tutorial example third.cc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3995
diff changeset
    81
  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
    82
  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
    83
  phy.SetChannel (channel.Create ());
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    84
4005
7ddad22e007a couple of small typos
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4004
diff changeset
    85
  WifiHelper wifi = WifiHelper::Default ();
7ddad22e007a couple of small typos
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4004
diff changeset
    86
  wifi.SetRemoteStationManager ("ns3::AarfWifiManager");
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    87
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    88
  Ssid ssid = Ssid ("ns-3-ssid");
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    89
  wifi.SetMac ("ns3::NqstaWifiMac", 
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    90
    "Ssid", SsidValue (ssid),
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    91
    "ActiveProbing", BooleanValue (false));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    92
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    93
  NetDeviceContainer staDevices;
4004
b181e89d45f1 bug 440: fix build of tutorial example third.cc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3995
diff changeset
    94
  staDevices = wifi.Install (phy, wifiStaNodes);
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    95
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    96
  wifi.SetMac ("ns3::NqapWifiMac", 
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    97
    "Ssid", SsidValue (ssid),
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    98
    "BeaconGeneration", BooleanValue (true),
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
    99
    "BeaconInterval", TimeValue (Seconds (2.5)));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   100
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   101
  NetDeviceContainer apDevices;
4004
b181e89d45f1 bug 440: fix build of tutorial example third.cc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3995
diff changeset
   102
  apDevices = wifi.Install (phy, wifiApNode);
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   103
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   104
  MobilityHelper mobility;
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
  mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   107
    "MinX", DoubleValue (0.0),
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   108
    "MinY", DoubleValue (0.0),
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   109
    "DeltaX", DoubleValue (5.0),
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   110
    "DeltaY", DoubleValue (10.0),
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   111
    "GridWidth", UintegerValue (3),
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   112
    "LayoutType", StringValue ("RowFirst"));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   113
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   114
  mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel",
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   115
    "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
   116
  mobility.Install (wifiStaNodes);
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::StaticMobilityModel");
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   119
  mobility.Install (wifiApNode);
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
  InternetStackHelper stack;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   122
  stack.Install (csmaNodes);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   123
  stack.Install (wifiApNode);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   124
  stack.Install (wifiStaNodes);
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
  Ipv4AddressHelper address;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   127
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   128
  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
   129
  Ipv4InterfaceContainer p2pInterfaces;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   130
  p2pInterfaces = address.Assign (p2pDevices);
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.2.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 csmaInterfaces;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   134
  csmaInterfaces = address.Assign (csmaDevices);
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.3.0", "255.255.255.0");
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   137
  address.Assign (staDevices);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   138
  address.Assign (apDevices);
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
  UdpEchoServerHelper echoServer (9);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   141
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   142
  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
   143
  serverApps.Start (Seconds (1.0));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   144
  serverApps.Stop (Seconds (10.0));
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
  UdpEchoClientHelper echoClient (csmaInterfaces.GetAddress (nCsma), 9);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   147
  echoClient.SetAttribute ("MaxPackets", UintegerValue (1));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   148
  echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.)));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   149
  echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
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
  ApplicationContainer clientApps = 
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   152
    echoClient.Install (wifiStaNodes.Get (nWifi - 1));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   153
  clientApps.Start (Seconds (2.0));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   154
  clientApps.Stop (Seconds (10.0));
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
  GlobalRouteManager::PopulateRoutingTables ();
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
  Simulator::Stop (Seconds (10.0));
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   159
4004
b181e89d45f1 bug 440: fix build of tutorial example third.cc
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3995
diff changeset
   160
  YansWifiPhyHelper::EnablePcap ("third", 
3994
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   161
    wifiStaNodes.Get (nWifi - 1)->GetId (), 0);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   162
  CsmaHelper::EnablePcap ("third", 
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   163
    csmaNodes.Get (nCsma)->GetId (), 0);
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   164
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   165
  Simulator::Run ();
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   166
  Simulator::Destroy ();
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   167
  return 0;
6cc096bc0761 Remove stray ^M that snuck into examples
Craig Dowell <craigdo@ee.washington.edu>
parents: 3382
diff changeset
   168
}