examples/mixed-wireless.cc
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Mon, 23 Mar 2009 13:16:09 +0100
changeset 4360 bf9c03ebc855
parent 4264 9d2e96c4e6e4
child 4375 db81fdcb06e7
permissions -rw-r--r--
merge with olsr crap
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2896
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     2
/*
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     3
 * This program is free software; you can redistribute it and/or modify
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     4
 * it under the terms of the GNU General Public License version 2 as
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     5
 * published by the Free Software Foundation;
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     6
 *
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     7
 * This program is distributed in the hope that it will be useful,
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    10
 * GNU General Public License for more details.
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    11
 *
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    12
 * You should have received a copy of the GNU General Public License
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    13
 * along with this program; if not, write to the Free Software
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    14
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    15
 *
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    16
 */
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    17
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    18
//
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    19
// This ns-3 example demonstrates the use of helper functions to ease 
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    20
// the construction of simulation scenarios.  
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    21
// 
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    22
// The simulation topology consists of a mixed wired and wireless
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    23
// scenario in which a hierarchical mobility model is used.
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    24
//
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    25
// The simulation layout consists of N backbone routers interconnected
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    26
// by an ad hoc wifi network.
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    27
// Each backbone router also has a local 802.11 network and is connected
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    28
// to a local LAN.  An additional set of (K-1) nodes are connected to
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    29
// this backbone.  Finally, a local LAN is connected to each router
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    30
// on the backbone, with L-1 additional hosts.  
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    31
//
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    32
// The nodes are populated with TCP/IP stacks, and OLSR unicast routing
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    33
// on the backbone.  An example UDP transfer is shown.  The simulator
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    34
// be configured to output tcpdumps or traces from different nodes.
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    35
//
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    36
//
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    37
//          +--------------------------------------------------------+
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    38
//          |                                                        |
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    39
//          |              802.11 ad hoc, ns-2 mobility              | 
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    40
//          |                                                        |
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    41
//          +--------------------------------------------------------+
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    42
//                   |       o o o (N backbone routers)       |
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    43
//               +--------+                               +--------+
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    44
//     wired LAN | mobile |                     wired LAN | mobile |
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    45
//    -----------| router |                    -----------| router |
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    46
//               ---------                                ---------
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    47
//                   |                                        |
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    48
//          +----------------+                       +----------------+
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    49
//          |     802.11     |                       |     802.11     |
4037
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
    50
//          |   infra net    |                       |   infra net    |
2896
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    51
//          |   K-1 hosts    |                       |   K-1 hosts    |
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    52
//          +----------------+                       +----------------+
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    53
//
4037
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
    54
// We'll send data from the first wired LAN node on the first wired LAN
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
    55
// to the last wireless STA on the last infrastructure net, thereby
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
    56
// causing packets to traverse CSMA to adhoc to infrastructure links
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
    57
// 
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
    58
// Note that certain mobility patterns may cause packet forwarding
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
    59
// to fail (if nodes become disconnected) 
2896
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    60
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    61
#include <fstream>
4037
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
    62
#include <string>
2896
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    63
#include "ns3/core-module.h"
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    64
#include "ns3/common-module.h"
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    65
#include "ns3/node-module.h"
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    66
#include "ns3/helper-module.h"
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    67
#include "ns3/mobility-module.h"
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    68
#include "ns3/contrib-module.h"
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    69
#include "ns3/wifi-module.h"
4037
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
    70
#include "ns3/global-route-manager.h"
2896
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    71
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    72
using namespace ns3;
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    73
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    74
//
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    75
// Define logging keyword for this file
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    76
//
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    77
NS_LOG_COMPONENT_DEFINE ("MixedWireless");
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    78
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    79
//
4036
a17503f15f8c fix course change notification portion of the script
Tom Henderson <tomh@tomh.org>
parents: 4035
diff changeset
    80
// This function will be used below as a trace sink, if the command-line
a17503f15f8c fix course change notification portion of the script
Tom Henderson <tomh@tomh.org>
parents: 4035
diff changeset
    81
// argument or default value "useCourseChangeCallback" is set to true
2896
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    82
// 
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    83
static void
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    84
CourseChangeCallback (std::string path, Ptr<const MobilityModel> model)
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    85
{
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    86
  Vector position = model->GetPosition ();
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    87
  std::cout << "CourseChange " << path << " x=" << position.x << ", y=" << position.y << ", z=" << position.z << std::endl;
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    88
}
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    89
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    90
int 
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    91
main (int argc, char *argv[])
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    92
{
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    93
  //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    94
  // First, we declare and initialize a few local variables that control some 
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    95
  // simulation parameters.
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    96
  //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    97
  uint32_t backboneNodes = 10;
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    98
  uint32_t infraNodes = 5;
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    99
  uint32_t lanNodes = 5;
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   100
  uint32_t stopTime = 10;
4036
a17503f15f8c fix course change notification portion of the script
Tom Henderson <tomh@tomh.org>
parents: 4035
diff changeset
   101
  bool useCourseChangeCallback = false;
4037
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   102
  bool enableTracing = false;
2896
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   103
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   104
  //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   105
  // Simulation defaults are typically set next, before command line
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   106
  // arguments are parsed.
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   107
  //
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2896
diff changeset
   108
  Config::SetDefault ("ns3::OnOffApplication::PacketSize", StringValue ("210"));
4037
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   109
  Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue ("10kb/s"));
2896
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   110
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   111
  //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   112
  // For convenience, we add the local variables to the command line argument
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   113
  // system so that they can be overridden with flags such as 
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   114
  // "--backboneNodes=20"
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   115
  //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   116
  CommandLine cmd;
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   117
  cmd.AddValue("backboneNodes", "number of backbone nodes", backboneNodes);
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   118
  cmd.AddValue ("infraNodes", "number of leaf nodes", infraNodes);
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   119
  cmd.AddValue("lanNodes", "number of LAN nodes", lanNodes);
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   120
  cmd.AddValue("stopTime", "simulation stop time (seconds)", stopTime);
4036
a17503f15f8c fix course change notification portion of the script
Tom Henderson <tomh@tomh.org>
parents: 4035
diff changeset
   121
  cmd.AddValue("useCourseChangeCallback", "whether to enable course change tracing", useCourseChangeCallback);
4037
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   122
  cmd.AddValue("enableTracing", "enable tracing", enableTracing);
2896
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   123
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   124
  //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   125
  // The system global variables and the local values added to the argument
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   126
  // system can be overridden by command line arguments by using this call.
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   127
  //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   128
  cmd.Parse (argc, argv);
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   129
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   130
  /////////////////////////////////////////////////////////////////////////// 
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   131
  //                                                                       //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   132
  // Construct the backbone                                                //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   133
  //                                                                       //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   134
  /////////////////////////////////////////////////////////////////////////// 
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   135
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   136
  //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   137
  // Create a container to manage the nodes of the adhoc (backbone) network.
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   138
  // Later we'll create the rest of the nodes we'll need.
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   139
  //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   140
  NodeContainer backbone;
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   141
  backbone.Create (backboneNodes);
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   142
  //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   143
  // Create the backbone wifi net devices and install them into the nodes in 
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   144
  // our container
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   145
  //
4035
749cf964666a mixed-wireless was not instantiating a stationManager in helper
Tom Henderson <tomh@tomh.org>
parents: 3912
diff changeset
   146
  WifiHelper wifi;
749cf964666a mixed-wireless was not instantiating a stationManager in helper
Tom Henderson <tomh@tomh.org>
parents: 3912
diff changeset
   147
  wifi.SetMac ("ns3::AdhocWifiMac");
749cf964666a mixed-wireless was not instantiating a stationManager in helper
Tom Henderson <tomh@tomh.org>
parents: 3912
diff changeset
   148
  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
749cf964666a mixed-wireless was not instantiating a stationManager in helper
Tom Henderson <tomh@tomh.org>
parents: 3912
diff changeset
   149
                                "DataMode", StringValue ("wifia-54mbs"));
3912
4d1a61f80745 new wifi API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3906
diff changeset
   150
  YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
4d1a61f80745 new wifi API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3906
diff changeset
   151
  YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
4d1a61f80745 new wifi API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3906
diff changeset
   152
  wifiPhy.SetChannel (wifiChannel.Create ());
4d1a61f80745 new wifi API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3906
diff changeset
   153
  NetDeviceContainer backboneDevices = wifi.Install (wifiPhy, backbone);
2896
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   154
  //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   155
  // Add the IPv4 protocol stack to the nodes in our container
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   156
  //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   157
  InternetStackHelper internet;
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   158
  internet.Install (backbone);
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   159
  //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   160
  // Assign IPv4 addresses to the device drivers (actually to the associated
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   161
  // IPv4 interfaces) we just created.
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   162
  //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   163
  Ipv4AddressHelper ipAddrs;
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   164
  ipAddrs.SetBase ("192.168.0.0", "255.255.255.0");
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   165
  ipAddrs.Assign (backboneDevices);
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   166
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   167
  //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   168
  // The ad-hoc network nodes need a mobility model so we aggregate one to 
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   169
  // each of the nodes we just finished building.  
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   170
  //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   171
  MobilityHelper mobility;
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   172
  Ptr<ListPositionAllocator> positionAlloc = 
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   173
    CreateObject<ListPositionAllocator> ();
3079
68f79ef69388 ensure that the list of positions is long enough
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3015
diff changeset
   174
  double x = 0.0;
68f79ef69388 ensure that the list of positions is long enough
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3015
diff changeset
   175
  for (uint32_t i = 0; i < backboneNodes; ++i)
68f79ef69388 ensure that the list of positions is long enough
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3015
diff changeset
   176
    {
68f79ef69388 ensure that the list of positions is long enough
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3015
diff changeset
   177
      positionAlloc->Add (Vector (x, 0.0, 0.0));
68f79ef69388 ensure that the list of positions is long enough
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3015
diff changeset
   178
      x += 5.0;
68f79ef69388 ensure that the list of positions is long enough
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3015
diff changeset
   179
    }
2896
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   180
  mobility.SetPositionAllocator (positionAlloc);
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   181
  mobility.SetMobilityModel ("ns3::RandomDirection2dMobilityModel",
4037
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   182
                             "Bounds", RectangleValue (Rectangle (0, 20, 0, 20)),
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   183
                             "Speed", RandomVariableValue (ConstantVariable (2)),
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2896
diff changeset
   184
                             "Pause", RandomVariableValue (ConstantVariable (0.2)));
2998
b991704f870f Fix two nits that escaped checkin
Tom Henderson <tomh@tomh.org>
parents: 2997
diff changeset
   185
  mobility.Install (backbone);
2896
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   186
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   187
  /////////////////////////////////////////////////////////////////////////// 
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   188
  //                                                                       //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   189
  // Construct the LANs                                                    //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   190
  //                                                                       //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   191
  /////////////////////////////////////////////////////////////////////////// 
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   192
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   193
  // Reset the address base-- all of the CSMA networks will be in
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   194
  // the "172.16 address space
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   195
  ipAddrs.SetBase ("172.16.0.0", "255.255.255.0");
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   196
2995
b72805b3ca69 Align helper API use of Install()
Tom Henderson <tomh@tomh.org>
parents: 2896
diff changeset
   197
2896
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   198
  for (uint32_t i = 0; i < backboneNodes; ++i)
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   199
    {
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   200
      NS_LOG_INFO ("Configuring local area network for backbone node " << i);
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   201
      //
2995
b72805b3ca69 Align helper API use of Install()
Tom Henderson <tomh@tomh.org>
parents: 2896
diff changeset
   202
      // Create a container to manage the nodes of the LAN.  We need
b72805b3ca69 Align helper API use of Install()
Tom Henderson <tomh@tomh.org>
parents: 2896
diff changeset
   203
      // two containers here; one with all of the new nodes, and one
b72805b3ca69 Align helper API use of Install()
Tom Henderson <tomh@tomh.org>
parents: 2896
diff changeset
   204
      // with all of the nodes including new and existing nodes
2896
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   205
      //
2995
b72805b3ca69 Align helper API use of Install()
Tom Henderson <tomh@tomh.org>
parents: 2896
diff changeset
   206
      NodeContainer newLanNodes;
b72805b3ca69 Align helper API use of Install()
Tom Henderson <tomh@tomh.org>
parents: 2896
diff changeset
   207
      newLanNodes.Create (lanNodes - 1);
b72805b3ca69 Align helper API use of Install()
Tom Henderson <tomh@tomh.org>
parents: 2896
diff changeset
   208
      // Now, create the container with all nodes on this link
b72805b3ca69 Align helper API use of Install()
Tom Henderson <tomh@tomh.org>
parents: 2896
diff changeset
   209
      NodeContainer lan (backbone.Get (i), newLanNodes);
2896
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   210
      //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   211
      // Create the CSMA net devices and install them into the nodes in our 
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   212
      // collection.
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   213
      //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   214
      CsmaHelper csma;
3381
3cdd9d60f7c7 bug 232, references to Parameter obsolete
Craig Dowell <craigdo@ee.washington.edu>
parents: 3257
diff changeset
   215
      csma.SetChannelAttribute ("DataRate", 
3257
ba198dad54a2 CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 3174
diff changeset
   216
        DataRateValue (DataRate (5000000)));
3381
3cdd9d60f7c7 bug 232, references to Parameter obsolete
Craig Dowell <craigdo@ee.washington.edu>
parents: 3257
diff changeset
   217
      csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2)));
2896
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   218
      NetDeviceContainer lanDevices = csma.Install (lan);
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   219
      //
2995
b72805b3ca69 Align helper API use of Install()
Tom Henderson <tomh@tomh.org>
parents: 2896
diff changeset
   220
      // Add the IPv4 protocol stack to the new LAN nodes
2896
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   221
      //
2995
b72805b3ca69 Align helper API use of Install()
Tom Henderson <tomh@tomh.org>
parents: 2896
diff changeset
   222
      internet.Install (newLanNodes);
2896
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   223
      //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   224
      // Assign IPv4 addresses to the device drivers (actually to the 
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   225
      // associated IPv4 interfaces) we just created.
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   226
      //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   227
      ipAddrs.Assign (lanDevices);
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   228
      //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   229
      // Assign a new network prefix for the next LAN, according to the
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   230
      // network mask initialized above
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   231
      //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   232
      ipAddrs.NewNetwork ();
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   233
    }
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   234
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   235
  /////////////////////////////////////////////////////////////////////////// 
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   236
  //                                                                       //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   237
  // Construct the mobile networks                                         //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   238
  //                                                                       //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   239
  /////////////////////////////////////////////////////////////////////////// 
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   240
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   241
  // Reset the address base-- all of the 802.11 networks will be in
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   242
  // the "10.0" address space
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   243
  ipAddrs.SetBase ("10.0.0.0", "255.255.255.0");
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   244
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   245
  for (uint32_t i = 0; i < backboneNodes; ++i)
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   246
    {
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   247
      NS_LOG_INFO ("Configuring wireless network for backbone node " << i);
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   248
      //
2995
b72805b3ca69 Align helper API use of Install()
Tom Henderson <tomh@tomh.org>
parents: 2896
diff changeset
   249
      // Create a container to manage the nodes of the LAN.  We need
b72805b3ca69 Align helper API use of Install()
Tom Henderson <tomh@tomh.org>
parents: 2896
diff changeset
   250
      // two containers here; one with all of the new nodes, and one
b72805b3ca69 Align helper API use of Install()
Tom Henderson <tomh@tomh.org>
parents: 2896
diff changeset
   251
      // with all of the nodes including new and existing nodes
2896
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   252
      //
4037
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   253
      NodeContainer stas;
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   254
      stas.Create (infraNodes - 1);
2995
b72805b3ca69 Align helper API use of Install()
Tom Henderson <tomh@tomh.org>
parents: 2896
diff changeset
   255
      // Now, create the container with all nodes on this link
4037
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   256
      NodeContainer infra (backbone.Get (i), stas);
2896
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   257
      //
4037
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   258
      // Create an infrastructure network
2896
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   259
      //
4035
749cf964666a mixed-wireless was not instantiating a stationManager in helper
Tom Henderson <tomh@tomh.org>
parents: 3912
diff changeset
   260
      WifiHelper wifiInfra = WifiHelper::Default ();
3912
4d1a61f80745 new wifi API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3906
diff changeset
   261
      wifiPhy.SetChannel (wifiChannel.Create ());
4037
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   262
      // Create unique ssids for these networks
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   263
      std::string ssidString("wifi-infra");
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   264
      std::stringstream ss;
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   265
      ss << i;
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   266
      ssidString += ss.str();
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   267
      Ssid ssid = Ssid (ssidString);
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   268
      wifiInfra.SetRemoteStationManager ("ns3::ArfWifiManager");
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   269
      // setup stas
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   270
      wifiInfra.SetMac ("ns3::NqstaWifiMac",
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   271
               "Ssid", SsidValue (ssid),
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   272
               "ActiveProbing", BooleanValue (false));
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   273
      NetDeviceContainer staDevices = wifiInfra.Install (wifiPhy, stas);
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   274
      // setup ap.
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   275
      wifiInfra.SetMac ("ns3::NqapWifiMac", "Ssid", SsidValue (ssid),
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   276
               "BeaconGeneration", BooleanValue (true),
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   277
               "BeaconInterval", TimeValue (Seconds (2.5)));
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   278
      NetDeviceContainer apDevices = wifiInfra.Install (wifiPhy, backbone.Get (i));
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   279
      // Collect all of these new devices
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   280
      NetDeviceContainer infraDevices (apDevices, staDevices);
2896
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   281
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   282
      // Add the IPv4 protocol stack to the nodes in our container
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   283
      //
4037
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   284
      internet.Install (stas);
2896
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   285
      //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   286
      // Assign IPv4 addresses to the device drivers (actually to the associated
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   287
      // IPv4 interfaces) we just created.
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   288
      //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   289
      ipAddrs.Assign (infraDevices);
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   290
      //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   291
      // Assign a new network prefix for each mobile network, according to 
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   292
      // the network mask initialized above
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   293
      //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   294
      ipAddrs.NewNetwork ();
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   295
      //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   296
      // The new wireless nodes need a mobility model so we aggregate one 
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   297
      // to each of the nodes we just finished building.
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   298
      //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   299
      Ptr<ListPositionAllocator> subnetAlloc = 
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   300
        CreateObject<ListPositionAllocator> ();
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   301
      for (uint32_t j = 0; j < infra.GetN (); ++j)
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   302
        {
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   303
          subnetAlloc->Add (Vector (0.0, j, 0.0));
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   304
        }
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   305
      mobility.PushReferenceMobilityModel (backbone.Get (i));
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   306
      mobility.SetPositionAllocator (subnetAlloc);
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   307
      mobility.SetMobilityModel ("ns3::RandomDirection2dMobilityModel",
4037
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   308
                                 "Bounds", RectangleValue (Rectangle (-10, 10, -10, 10)),
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   309
                                 "Speed", RandomVariableValue (ConstantVariable (3)),
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2896
diff changeset
   310
                                 "Pause", RandomVariableValue (ConstantVariable (0.4)));
2998
b991704f870f Fix two nits that escaped checkin
Tom Henderson <tomh@tomh.org>
parents: 2997
diff changeset
   311
      mobility.Install (infra);
2896
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   312
    }
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   313
  /////////////////////////////////////////////////////////////////////////// 
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   314
  //                                                                       //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   315
  // Routing configuration                                                 //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   316
  //                                                                       //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   317
  /////////////////////////////////////////////////////////////////////////// 
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   318
4037
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   319
  // The below global routing does not take into account wireless effects.
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   320
  // However, it is useful for setting default routes for all of the nodes
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   321
  // such as the LAN nodes.  
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   322
  NS_LOG_INFO ("Enabling global routing on all nodes");
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   323
  GlobalRouteManager::PopulateRoutingTables ();
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   324
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   325
  // We enable OLSR (which will be consulted at a higher priority than
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   326
  // the global routing above) on the backbone ad hoc nodes
2896
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   327
  NS_LOG_INFO ("Enabling OLSR routing on all backbone nodes");
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   328
  OlsrHelper olsr;
2995
b72805b3ca69 Align helper API use of Install()
Tom Henderson <tomh@tomh.org>
parents: 2896
diff changeset
   329
  olsr.Install (backbone);
2896
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   330
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   331
  /////////////////////////////////////////////////////////////////////////// 
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   332
  //                                                                       //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   333
  // Application configuration                                             //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   334
  //                                                                       //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   335
  /////////////////////////////////////////////////////////////////////////// 
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   336
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   337
  // Create the OnOff application to send UDP datagrams of size
4037
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   338
  // 210 bytes at a rate of 10 Kb/s, between two nodes
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   339
  // We'll send data from the first wired LAN node on the first wired LAN
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   340
  // to the last wireless STA on the last infrastructure net, thereby
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   341
  // causing packets to traverse CSMA to adhoc to infrastructure links
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   342
2896
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   343
  NS_LOG_INFO ("Create Applications.");
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   344
  uint16_t port = 9;   // Discard port (RFC 863)
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   345
4037
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   346
  // Let's make sure that the user does not define too few nodes
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   347
  // to make this example work.  We need lanNodes > 1  and infraNodes > 1
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   348
  NS_ASSERT (lanNodes > 1 && infraNodes > 1);
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   349
  // We want the source to be the first node created outside of the backbone
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   350
  // Conveniently, the variable "backboneNodes" holds this node index value
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   351
  Ptr<Node> appSource = NodeList::GetNode (backboneNodes);  
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   352
  // We want the sink to be the last node created in the topology.  
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   353
  uint32_t lastNodeIndex = backboneNodes + backboneNodes*(lanNodes - 1) + backboneNodes*(infraNodes - 1) - 1;
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   354
  Ptr<Node> appSink = NodeList::GetNode (lastNodeIndex);  
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   355
  // Let's fetch the IP address of the last node, which is on Ipv4Interface 1
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   356
  Ipv4Address remoteAddr = appSink->GetObject<Ipv4> ()->GetAddress(1);
2896
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   357
3125
d2d8a36cfd23 s/ns3::Udp/ns3::UdpSocketFactory
Tom Henderson <tomh@tomh.org>
parents: 3015
diff changeset
   358
  OnOffHelper onoff ("ns3::UdpSocketFactory", 
2896
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   359
                     Address (InetSocketAddress (remoteAddr, port)));
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2896
diff changeset
   360
  onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1)));
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2896
diff changeset
   361
  onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
2896
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   362
  ApplicationContainer apps = onoff.Install (appSource);
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   363
  apps.Start (Seconds (3.0));
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   364
  apps.Stop (Seconds (20.0));
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   365
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   366
  // Create a packet sink to receive these packets
3125
d2d8a36cfd23 s/ns3::Udp/ns3::UdpSocketFactory
Tom Henderson <tomh@tomh.org>
parents: 3015
diff changeset
   367
  PacketSinkHelper sink ("ns3::UdpSocketFactory", 
2896
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   368
                         InetSocketAddress (Ipv4Address::GetAny (), port));
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   369
  apps = sink.Install (appSink);
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   370
  apps.Start (Seconds (3.0));
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   371
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   372
  /////////////////////////////////////////////////////////////////////////// 
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   373
  //                                                                       //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   374
  // Tracing configuration                                                 //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   375
  //                                                                       //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   376
  /////////////////////////////////////////////////////////////////////////// 
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   377
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   378
  NS_LOG_INFO ("Configure Tracing.");
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   379
  std::ofstream ascii;
4037
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   380
  if (enableTracing == true)
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   381
   {
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   382
      //
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   383
      // Let's set up some ns-2-like ascii traces, using another helper class
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   384
      //
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   385
      ascii.open ("mixed-wireless.tr");
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   386
      YansWifiPhyHelper::EnableAsciiAll (ascii);
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   387
      CsmaHelper::EnableAsciiAll (ascii);
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   388
      InternetStackHelper::EnableAsciiAll (ascii);
2896
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   389
4037
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   390
      // Let's do a pcap trace on the application source and sink, ifIndex 0
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4037
diff changeset
   391
      // Csma captures in non-promiscuous mode
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4037
diff changeset
   392
      CsmaHelper::EnablePcap ("mixed-wireless", appSource->GetId (), 0, false);
4037
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   393
      YansWifiPhyHelper::EnablePcap ("mixed-wireless", appSink->GetId (), 0);
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   394
      YansWifiPhyHelper::EnablePcap ("mixed-wireless", 9, 2);
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   395
      YansWifiPhyHelper::EnablePcap ("mixed-wireless", 9, 0);
a8f42518c058 Additional cleanup of mixed-wireless; get packets to flow across different device technologies
Tom Henderson <tomh@tomh.org>
parents: 4036
diff changeset
   396
    }
2896
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   397
4036
a17503f15f8c fix course change notification portion of the script
Tom Henderson <tomh@tomh.org>
parents: 4035
diff changeset
   398
  if (useCourseChangeCallback == true)
a17503f15f8c fix course change notification portion of the script
Tom Henderson <tomh@tomh.org>
parents: 4035
diff changeset
   399
    {
a17503f15f8c fix course change notification portion of the script
Tom Henderson <tomh@tomh.org>
parents: 4035
diff changeset
   400
      Config::Connect ("/NodeList/*/$ns3::MobilityModel/CourseChange", MakeCallback (&CourseChangeCallback));
a17503f15f8c fix course change notification portion of the script
Tom Henderson <tomh@tomh.org>
parents: 4035
diff changeset
   401
    }
3080
030e4a88c6d7 remove XXX
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3079
diff changeset
   402
2896
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   403
  /////////////////////////////////////////////////////////////////////////// 
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   404
  //                                                                       //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   405
  // Run simulation                                                        //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   406
  //                                                                       //
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   407
  /////////////////////////////////////////////////////////////////////////// 
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   408
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   409
  NS_LOG_INFO ("Run Simulation.");
3174
efeb6e5c276d Make Application::Start/Stop times relative, Simulator::StopAt(time) renamed to Simulator::Stop(time) and time also made relative, to improve consistency of the API which uses relative times everywhere else. Closes bug #191.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3137
diff changeset
   410
  Simulator::Stop (Seconds (stopTime));
2896
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   411
  Simulator::Run ();    
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   412
  Simulator::Destroy ();
cb77c96e6149 revive mixed-wireless example from Simutools tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   413
}