examples/wireless/mixed-wireless.py
author Mitch Watrous
Wed, 15 Aug 2012 14:28:33 -0700
changeset 8983 91d4c78133a8
parent 8966 060dba23e9bb
child 9000 3ec20a64fd08
permissions -rw-r--r--
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 1)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3422
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
     1
# /*
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
     2
#  * This program is free software; you can redistribute it and/or modify
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
     3
#  * it under the terms of the GNU General Public License version 2 as
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
     4
#  * published by the Free Software Foundation;
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
     5
#  *
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
     6
#  * This program is distributed in the hope that it will be useful,
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
     7
#  * but WITHOUT ANY WARRANTY; without even the implied warranty of
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
     8
#  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
     9
#  * GNU General Public License for more details.
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    10
#  *
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    11
#  * You should have received a copy of the GNU General Public License
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    12
#  * along with this program; if not, write to the Free Software
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    13
#  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    14
#  *
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    15
#  */
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    16
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    17
# 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    18
#  This ns-3 example demonstrates the use of helper functions to ease 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    19
#  the construction of simulation scenarios.  
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    20
#  
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    21
#  The simulation topology consists of a mixed wired and wireless
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    22
#  scenario in which a hierarchical mobility model is used.
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    23
# 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    24
#  The simulation layout consists of N backbone routers interconnected
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    25
#  by an ad hoc wifi network.
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    26
#  Each backbone router also has a local 802.11 network and is connected
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    27
#  to a local LAN.  An additional set of(K-1) nodes are connected to
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    28
#  this backbone.  Finally, a local LAN is connected to each router
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    29
#  on the backbone, with L-1 additional hosts.  
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    30
# 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    31
#  The nodes are populated with TCP/IP stacks, and OLSR unicast routing
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    32
#  on the backbone.  An example UDP transfer is shown.  The simulator
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    33
#  be configured to output tcpdumps or traces from different nodes.
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    34
# 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    35
# 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    36
#           +--------------------------------------------------------+
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    37
#           |                                                        |
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    38
#           |              802.11 ad hoc, ns-2 mobility              | 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    39
#           |                                                        |
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    40
#           +--------------------------------------------------------+
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    41
#                    |       o o o(N backbone routers)       |
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    42
#                +--------+                               +--------+
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    43
#      wired LAN | mobile |                     wired LAN | mobile |
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    44
#     -----------| router |                    -----------| router |
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    45
#                ---------                                ---------
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    46
#                    |                                        |
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    47
#           +----------------+                       +----------------+
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    48
#           |     802.11     |                       |     802.11     |
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    49
#           |      net       |                       |       net      |
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    50
#           |   K-1 hosts    |                       |   K-1 hosts    |
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    51
#           +----------------+                       +----------------+
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    52
# 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    53
7106
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
    54
import ns.applications
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
    55
import ns.core
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
    56
import ns.csma
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
    57
import ns.internet
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
    58
import ns.mobility
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
    59
import ns.network
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
    60
import ns.olsr
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
    61
import ns.wifi
3422
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    62
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    63
# # 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    64
# #  This function will be used below as a trace sink
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    65
# #  
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    66
# static void
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    67
# CourseChangeCallback(std.string path, Ptr<const MobilityModel> model)
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    68
# {
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    69
#   Vector position = model.GetPosition();
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    70
#   std.cout << "CourseChange " << path << " x=" << position.x << ", y=" << position.y << ", z=" << position.z << std.endl;
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    71
# }
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    72
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    73
def main(argv): 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    74
    # 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    75
    #  First, we declare and initialize a few local variables that control some 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    76
    #  simulation parameters.
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    77
    # 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    78
    backboneNodes = 10
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    79
    infraNodes = 5
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    80
    lanNodes = 5
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    81
    stopTime = 10
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    82
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    83
    # 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    84
    #  Simulation defaults are typically set next, before command line
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    85
    #  arguments are parsed.
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    86
    # 
7106
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
    87
    ns.core.Config.SetDefault("ns3::OnOffApplication::PacketSize", ns.core.StringValue("210"))
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
    88
    ns.core.Config.SetDefault("ns3::OnOffApplication::DataRate", ns.core.StringValue("448kb/s"))
3422
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    89
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    90
    # 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    91
    #  For convenience, we add the local variables to the command line argument
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    92
    #  system so that they can be overridden with flags such as 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    93
    #  "--backboneNodes=20"
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    94
    # 
7106
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
    95
    cmd = ns.core.CommandLine()
3422
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    96
    #cmd.AddValue("backboneNodes", "number of backbone nodes", backboneNodes)
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    97
    #cmd.AddValue("infraNodes", "number of leaf nodes", infraNodes)
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    98
    #cmd.AddValue("lanNodes", "number of LAN nodes", lanNodes)
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    99
    #cmd.AddValue("stopTime", "simulation stop time(seconds)", stopTime)
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   100
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   101
    # 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   102
    #  The system global variables and the local values added to the argument
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   103
    #  system can be overridden by command line arguments by using this call.
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   104
    # 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   105
    cmd.Parse(argv)
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   106
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   107
    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # / 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   108
    #                                                                        # 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   109
    #  Construct the backbone                                                # 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   110
    #                                                                        # 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   111
    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # / 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   112
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   113
    # 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   114
    #  Create a container to manage the nodes of the adhoc(backbone) network.
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   115
    #  Later we'll create the rest of the nodes we'll need.
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   116
    # 
7106
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   117
    backbone = ns.network.NodeContainer()
3422
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   118
    backbone.Create(backboneNodes)
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   119
    # 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   120
    #  Create the backbone wifi net devices and install them into the nodes in 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   121
    #  our container
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   122
    # 
7106
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   123
    wifi = ns.wifi.WifiHelper()
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   124
    mac = ns.wifi.NqosWifiMacHelper.Default()
4754
77c878bc3e84 Fix Python coding style.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4752
diff changeset
   125
    mac.SetType("ns3::AdhocWifiMac")
77c878bc3e84 Fix Python coding style.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4752
diff changeset
   126
    wifi.SetRemoteStationManager("ns3::ConstantRateWifiManager",
7106
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   127
                                  "DataMode", ns.core.StringValue("OfdmRate54Mbps"))
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   128
    wifiPhy = ns.wifi.YansWifiPhyHelper.Default()
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   129
    wifiChannel = ns.wifi.YansWifiChannelHelper.Default()
4754
77c878bc3e84 Fix Python coding style.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4752
diff changeset
   130
    wifiPhy.SetChannel(wifiChannel.Create())
4752
3e26b3b2e3a8 Fix python examples.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4211
diff changeset
   131
    backboneDevices = wifi.Install(wifiPhy, mac, backbone)
3422
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   132
    # 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   133
    #  Add the IPv4 protocol stack to the nodes in our container
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   134
    # 
4752
3e26b3b2e3a8 Fix python examples.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4211
diff changeset
   135
    print "Enabling OLSR routing on all backbone nodes"
7106
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   136
    internet = ns.internet.InternetStackHelper()
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   137
    olsr = ns.olsr.OlsrHelper()
7157
43d2fb5bfb12 bug 1058: InternetStackHelper pitfall: calling Install before adding routing protocols
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7106
diff changeset
   138
    internet.SetRoutingHelper(olsr); # has effect on the next Install ()
4754
77c878bc3e84 Fix Python coding style.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4752
diff changeset
   139
    internet.Install(backbone);
5357
d8915edc639c make mixed-wireless examples use InternetStackHelper::Reset
Tom Henderson <tomh@tomh.org>
parents: 4754
diff changeset
   140
    # re-initialize for non-olsr routing.
d8915edc639c make mixed-wireless examples use InternetStackHelper::Reset
Tom Henderson <tomh@tomh.org>
parents: 4754
diff changeset
   141
    internet.Reset()
3422
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   142
    # 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   143
    #  Assign IPv4 addresses to the device drivers(actually to the associated
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   144
    #  IPv4 interfaces) we just created.
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   145
    # 
7106
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   146
    ipAddrs = ns.internet.Ipv4AddressHelper()
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   147
    ipAddrs.SetBase(ns.network.Ipv4Address("192.168.0.0"), ns.network.Ipv4Mask("255.255.255.0"))
3422
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   148
    ipAddrs.Assign(backboneDevices)
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   149
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   150
    # 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   151
    #  The ad-hoc network nodes need a mobility model so we aggregate one to 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   152
    #  each of the nodes we just finished building.  
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   153
    # 
7106
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   154
    mobility = ns.mobility.MobilityHelper()
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   155
    positionAlloc = ns.mobility.ListPositionAllocator()
3422
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   156
    x = 0.0
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   157
    for i in range(backboneNodes):
7106
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   158
        positionAlloc.Add(ns.core.Vector(x, 0.0, 0.0))
3422
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   159
        x += 5.0
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   160
    mobility.SetPositionAllocator(positionAlloc)
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   161
    mobility.SetMobilityModel("ns3::RandomDirection2dMobilityModel",
7106
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   162
                               "Bounds", ns.mobility.RectangleValue(ns.mobility.Rectangle(0, 1000, 0, 1000)),
8983
91d4c78133a8 Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 1)
Mitch Watrous
parents: 8966
diff changeset
   163
                               "Speed", ns.core.StringValue ("ns3::ConstantRandomVariable[Constant=2000]"),
91d4c78133a8 Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 1)
Mitch Watrous
parents: 8966
diff changeset
   164
                               "Pause", ns.core.StringValue ("ns3::ConstantRandomVariable[Constant=0.2]"))
3422
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   165
    mobility.Install(backbone)
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   166
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   167
    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # / 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   168
    #                                                                        # 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   169
    #  Construct the LANs                                                    # 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   170
    #                                                                        # 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   171
    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # / 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   172
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   173
    #  Reset the address base-- all of the CSMA networks will be in
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   174
    #  the "172.16 address space
7106
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   175
    ipAddrs.SetBase(ns.network.Ipv4Address("172.16.0.0"), ns.network.Ipv4Mask("255.255.255.0"))
3422
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   176
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   177
    for i in range(backboneNodes):
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   178
        print "Configuring local area network for backbone node ", i
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   179
        # 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   180
        #  Create a container to manage the nodes of the LAN.  We need
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   181
        #  two containers here; one with all of the new nodes, and one
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   182
        #  with all of the nodes including new and existing nodes
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   183
        # 
7106
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   184
        newLanNodes = ns.network.NodeContainer()
3422
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   185
        newLanNodes.Create(lanNodes - 1)
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   186
        #  Now, create the container with all nodes on this link
7106
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   187
        lan = ns.network.NodeContainer(ns.network.NodeContainer(backbone.Get(i)), newLanNodes)
3422
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   188
        # 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   189
        #  Create the CSMA net devices and install them into the nodes in our 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   190
        #  collection.
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   191
        # 
7106
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   192
        csma = ns.csma.CsmaHelper()
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   193
        csma.SetChannelAttribute("DataRate", ns.network.DataRateValue(ns.network.DataRate(5000000)))
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   194
        csma.SetChannelAttribute("Delay", ns.core.TimeValue(ns.core.MilliSeconds(2)))
3422
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   195
        lanDevices = csma.Install(lan)
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   196
        # 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   197
        #  Add the IPv4 protocol stack to the new LAN nodes
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   198
        # 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   199
        internet.Install(newLanNodes)
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   200
        # 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   201
        #  Assign IPv4 addresses to the device drivers(actually to the 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   202
        #  associated IPv4 interfaces) we just created.
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   203
        # 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   204
        ipAddrs.Assign(lanDevices)
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   205
        # 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   206
        #  Assign a new network prefix for the next LAN, according to the
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   207
        #  network mask initialized above
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   208
        # 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   209
        ipAddrs.NewNetwork()
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   210
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   211
    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # / 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   212
    #                                                                        # 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   213
    #  Construct the mobile networks                                         # 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   214
    #                                                                        # 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   215
    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # / 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   216
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   217
    #  Reset the address base-- all of the 802.11 networks will be in
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   218
    #  the "10.0" address space
7106
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   219
    ipAddrs.SetBase(ns.network.Ipv4Address("10.0.0.0"), ns.network.Ipv4Mask("255.255.255.0"))
3422
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   220
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   221
    for i in range(backboneNodes):
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   222
        print "Configuring wireless network for backbone node ", i
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   223
        # 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   224
        #  Create a container to manage the nodes of the LAN.  We need
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   225
        #  two containers here; one with all of the new nodes, and one
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   226
        #  with all of the nodes including new and existing nodes
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   227
        # 
7106
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   228
        stas = ns.network.NodeContainer()
4211
11cae8936153 bug 465: mixed-wireless.py does not work anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3536
diff changeset
   229
        stas.Create(infraNodes - 1)
3422
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   230
        #  Now, create the container with all nodes on this link
7106
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   231
        infra = ns.network.NodeContainer(ns.network.NodeContainer(backbone.Get(i)), stas)
3422
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   232
        # 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   233
        #  Create another ad hoc network and devices
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   234
        # 
7106
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   235
        ssid = ns.wifi.Ssid('wifi-infra' + str(i))
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   236
        wifiInfra = ns.wifi.WifiHelper.Default()
4754
77c878bc3e84 Fix Python coding style.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4752
diff changeset
   237
        wifiPhy.SetChannel(wifiChannel.Create())
77c878bc3e84 Fix Python coding style.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4752
diff changeset
   238
        wifiInfra.SetRemoteStationManager('ns3::ArfWifiManager')
7106
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   239
        macInfra = ns.wifi.NqosWifiMacHelper.Default();
6673
ec22aa763e2d Bug 978: Consolidate Wi-Fi MAC high functionality
Dean Armstrong <deanarm@gmail.com>
parents: 6360
diff changeset
   240
        macInfra.SetType("ns3::StaWifiMac",
7106
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   241
                         "Ssid", ns.wifi.SsidValue(ssid),
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   242
                         "ActiveProbing", ns.core.BooleanValue(False))
4752
3e26b3b2e3a8 Fix python examples.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4211
diff changeset
   243
3e26b3b2e3a8 Fix python examples.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4211
diff changeset
   244
        # setup stas
4754
77c878bc3e84 Fix Python coding style.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4752
diff changeset
   245
        staDevices = wifiInfra.Install(wifiPhy, macInfra, stas)
4211
11cae8936153 bug 465: mixed-wireless.py does not work anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3536
diff changeset
   246
        # setup ap.
6673
ec22aa763e2d Bug 978: Consolidate Wi-Fi MAC high functionality
Dean Armstrong <deanarm@gmail.com>
parents: 6360
diff changeset
   247
        macInfra.SetType("ns3::ApWifiMac",
7106
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   248
                         "Ssid", ns.wifi.SsidValue(ssid),
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   249
                         "BeaconGeneration", ns.core.BooleanValue(True),
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   250
                         "BeaconInterval", ns.core.TimeValue(ns.core.Seconds(2.5)))
4754
77c878bc3e84 Fix Python coding style.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4752
diff changeset
   251
        apDevices = wifiInfra.Install(wifiPhy, macInfra, backbone.Get(i))
4211
11cae8936153 bug 465: mixed-wireless.py does not work anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3536
diff changeset
   252
        # Collect all of these new devices
7106
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   253
        infraDevices = ns.network.NetDeviceContainer(apDevices, staDevices)
3422
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   254
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   255
        #  Add the IPv4 protocol stack to the nodes in our container
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   256
        # 
4211
11cae8936153 bug 465: mixed-wireless.py does not work anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3536
diff changeset
   257
        internet.Install(stas)
3422
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   258
        # 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   259
        #  Assign IPv4 addresses to the device drivers(actually to the associated
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   260
        #  IPv4 interfaces) we just created.
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   261
        # 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   262
        ipAddrs.Assign(infraDevices)
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   263
        # 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   264
        #  Assign a new network prefix for each mobile network, according to 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   265
        #  the network mask initialized above
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   266
        # 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   267
        ipAddrs.NewNetwork()
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   268
        # 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   269
        #  The new wireless nodes need a mobility model so we aggregate one 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   270
        #  to each of the nodes we just finished building.
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   271
        # 
7106
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   272
        subnetAlloc = ns.mobility.ListPositionAllocator()
3422
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   273
        for j in range(infra.GetN()):
7106
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   274
            subnetAlloc.Add(ns.core.Vector(0.0, j, 0.0))
3422
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   275
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   276
        mobility.PushReferenceMobilityModel(backbone.Get(i))
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   277
        mobility.SetPositionAllocator(subnetAlloc)
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   278
        mobility.SetMobilityModel("ns3::RandomDirection2dMobilityModel",
7106
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   279
                                  "Bounds", ns.mobility.RectangleValue(ns.mobility.Rectangle(-25, 25, -25, 25)),
8983
91d4c78133a8 Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 1)
Mitch Watrous
parents: 8966
diff changeset
   280
                                  "Speed", ns.core.StringValue ("ns3::ConstantRandomVariable[Constant=30]"),
91d4c78133a8 Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 1)
Mitch Watrous
parents: 8966
diff changeset
   281
                                  "Pause", ns.core.StringValue ("ns3::ConstantRandomVariable[Constant=0.4]"))
3422
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   282
        mobility.Install(infra)
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   283
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   284
    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # / 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   285
    #                                                                        # 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   286
    #  Application configuration                                             # 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   287
    #                                                                        # 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   288
    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # / 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   289
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   290
    #  Create the OnOff application to send UDP datagrams of size
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   291
    #  210 bytes at a rate of 448 Kb/s, between two nodes
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   292
    print "Create Applications."
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   293
    port = 9   #  Discard port(RFC 863)
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   294
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   295
    #  Let's make sure that the user does not define too few LAN nodes
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   296
    #  to make this example work.  We need lanNodes >= 5
4754
77c878bc3e84 Fix Python coding style.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4752
diff changeset
   297
    assert(lanNodes >= 5)
7106
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   298
    appSource = ns.network.NodeList.GetNode(11)
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   299
    appSink = ns.network.NodeList.GetNode(13)
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   300
    remoteAddr = ns.network.Ipv4Address("172.16.0.5")
3422
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   301
7106
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   302
    onoff = ns.applications.OnOffHelper("ns3::UdpSocketFactory", 
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   303
                            ns.network.Address(ns.network.InetSocketAddress(remoteAddr, port)))
8966
060dba23e9bb Replace src/application usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7157
diff changeset
   304
    onoff.SetAttribute("OnTime", ns.core.StringValue ("ns3::ConstantRandomVariable[Constant=1]"))
060dba23e9bb Replace src/application usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7157
diff changeset
   305
    onoff.SetAttribute("OffTime", ns.core.StringValue ("ns3::ConstantRandomVariable[Constant=0]"))
7106
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   306
    apps = onoff.Install(ns.network.NodeContainer(appSource))
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   307
    apps.Start(ns.core.Seconds(3.0))
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   308
    apps.Stop(ns.core.Seconds(20.0))
3422
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   309
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   310
    #  Create a packet sink to receive these packets
7106
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   311
    sink = ns.applications.PacketSinkHelper("ns3::UdpSocketFactory", 
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   312
                                ns.network.InetSocketAddress(ns.network.Ipv4Address.GetAny(), port))
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   313
    apps = sink.Install(ns.network.NodeContainer(appSink))
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   314
    apps.Start(ns.core.Seconds(3.0))
3422
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   315
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   316
    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # / 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   317
    #                                                                        # 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   318
    #  Tracing configuration                                                 # 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   319
    #                                                                        # 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   320
    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # / 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   321
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   322
    print "Configure Tracing."
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   323
    # 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   324
    #  Let's set up some ns-2-like ascii traces, using another helper class
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   325
    # 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   326
    #std.ofstream ascii
7106
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   327
    #ascii = ns.core.AsciiTraceHelper();
6256
a02c44146209 Bug 885 - Error in Ascii tracing in Python examples
Kim Højgaard-Hansen <kimrhh@gmail.com>
parents: 6208
diff changeset
   328
    #stream = ascii.CreateFileStream("mixed-wireless.tr");
a02c44146209 Bug 885 - Error in Ascii tracing in Python examples
Kim Højgaard-Hansen <kimrhh@gmail.com>
parents: 6208
diff changeset
   329
    #wifiPhy.EnableAsciiAll(stream);
a02c44146209 Bug 885 - Error in Ascii tracing in Python examples
Kim Højgaard-Hansen <kimrhh@gmail.com>
parents: 6208
diff changeset
   330
    #csma.EnableAsciiAll(stream);
3422
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   331
    print "(tracing not done for Python)"
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   332
    #  Look at nodes 11, 13 only
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   333
    # WifiHelper.EnableAscii(ascii, 11, 0); 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   334
    # WifiHelper.EnableAscii(ascii, 13, 0); 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   335
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   336
    #  Let's do a pcap trace on the backbone devices
4752
3e26b3b2e3a8 Fix python examples.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4211
diff changeset
   337
    wifiPhy.EnablePcap("mixed-wireless", backboneDevices)
3422
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   338
    #  Let's additionally trace the application Sink, ifIndex 0
7106
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   339
    csma = ns.csma.CsmaHelper()
6208
5a0c48fd9efa Fix tracing part of the mixed-wireless.py example
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5369
diff changeset
   340
    csma.EnablePcapAll("mixed-wireless", False)
3422
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   341
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   342
#   #ifdef ENABLE_FOR_TRACING_EXAMPLE
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   343
#     Config.Connect("/NodeList/*/$MobilityModel/CourseChange",
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   344
#       MakeCallback(&CourseChangeCallback))
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   345
#   #endif
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   346
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   347
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   348
    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #  
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   349
    #                                                                        # 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   350
    #  Run simulation                                                        # 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   351
    #                                                                        # 
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   352
    # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #  
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   353
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   354
    print "Run Simulation."
7106
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   355
    ns.core.Simulator.Stop(ns.core.Seconds(stopTime))
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   356
    ns.core.Simulator.Run()
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   357
    ns.core.Simulator.Destroy()
3422
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   358
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   359
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   360
if __name__ == '__main__':
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   361
    import sys
ad0c05e68792 Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   362
    main(sys.argv)
7106
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   363
2939fecb7029 Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents: 6673
diff changeset
   364