author | Tom Henderson <tomh@tomh.org> |
Thu, 01 Oct 2015 11:07:22 -0700 | |
changeset 11677 | 1e2add816314 |
parent 11461 | 1133a20204c6 |
permissions | -rw-r--r-- |
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 |
# |
11461
1133a20204c6
fix command-line argument handling in mixed-wireless.py example
Mohit P. Tahiliani <tahiliani.nitk@gmail.com>
parents:
10781
diff
changeset
|
75 |
# First, we initialize a few local variables that control some |
3422
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
76 |
# simulation parameters. |
11461
1133a20204c6
fix command-line argument handling in mixed-wireless.py example
Mohit P. Tahiliani <tahiliani.nitk@gmail.com>
parents:
10781
diff
changeset
|
77 |
# |
1133a20204c6
fix command-line argument handling in mixed-wireless.py example
Mohit P. Tahiliani <tahiliani.nitk@gmail.com>
parents:
10781
diff
changeset
|
78 |
|
1133a20204c6
fix command-line argument handling in mixed-wireless.py example
Mohit P. Tahiliani <tahiliani.nitk@gmail.com>
parents:
10781
diff
changeset
|
79 |
cmd = ns.core.CommandLine() |
1133a20204c6
fix command-line argument handling in mixed-wireless.py example
Mohit P. Tahiliani <tahiliani.nitk@gmail.com>
parents:
10781
diff
changeset
|
80 |
cmd.backboneNodes = 10 |
1133a20204c6
fix command-line argument handling in mixed-wireless.py example
Mohit P. Tahiliani <tahiliani.nitk@gmail.com>
parents:
10781
diff
changeset
|
81 |
cmd.infraNodes = 2 |
1133a20204c6
fix command-line argument handling in mixed-wireless.py example
Mohit P. Tahiliani <tahiliani.nitk@gmail.com>
parents:
10781
diff
changeset
|
82 |
cmd.lanNodes = 2 |
1133a20204c6
fix command-line argument handling in mixed-wireless.py example
Mohit P. Tahiliani <tahiliani.nitk@gmail.com>
parents:
10781
diff
changeset
|
83 |
cmd.stopTime = 20 |
3422
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
84 |
|
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
85 |
# |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
86 |
# 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
|
87 |
# arguments are parsed. |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
88 |
# |
10780
856d526d5f6d
re-align mixed-wireless C++ and Python example
Tom Henderson <tomh@tomh.org>
parents:
9000
diff
changeset
|
89 |
ns.core.Config.SetDefault("ns3::OnOffApplication::PacketSize", ns.core.StringValue("1472")) |
856d526d5f6d
re-align mixed-wireless C++ and Python example
Tom Henderson <tomh@tomh.org>
parents:
9000
diff
changeset
|
90 |
ns.core.Config.SetDefault("ns3::OnOffApplication::DataRate", ns.core.StringValue("100kb/s")) |
3422
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
91 |
|
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
92 |
# |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
93 |
# 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
|
94 |
# 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
|
95 |
# "--backboneNodes=20" |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
96 |
# |
11461
1133a20204c6
fix command-line argument handling in mixed-wireless.py example
Mohit P. Tahiliani <tahiliani.nitk@gmail.com>
parents:
10781
diff
changeset
|
97 |
|
1133a20204c6
fix command-line argument handling in mixed-wireless.py example
Mohit P. Tahiliani <tahiliani.nitk@gmail.com>
parents:
10781
diff
changeset
|
98 |
cmd.AddValue("backboneNodes", "number of backbone nodes") |
1133a20204c6
fix command-line argument handling in mixed-wireless.py example
Mohit P. Tahiliani <tahiliani.nitk@gmail.com>
parents:
10781
diff
changeset
|
99 |
cmd.AddValue("infraNodes", "number of leaf nodes") |
1133a20204c6
fix command-line argument handling in mixed-wireless.py example
Mohit P. Tahiliani <tahiliani.nitk@gmail.com>
parents:
10781
diff
changeset
|
100 |
cmd.AddValue("lanNodes", "number of LAN nodes") |
1133a20204c6
fix command-line argument handling in mixed-wireless.py example
Mohit P. Tahiliani <tahiliani.nitk@gmail.com>
parents:
10781
diff
changeset
|
101 |
cmd.AddValue("stopTime", "simulation stop time(seconds)") |
1133a20204c6
fix command-line argument handling in mixed-wireless.py example
Mohit P. Tahiliani <tahiliani.nitk@gmail.com>
parents:
10781
diff
changeset
|
102 |
|
3422
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
103 |
# |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
104 |
# 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
|
105 |
# 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
|
106 |
# |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
107 |
cmd.Parse(argv) |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
108 |
|
11461
1133a20204c6
fix command-line argument handling in mixed-wireless.py example
Mohit P. Tahiliani <tahiliani.nitk@gmail.com>
parents:
10781
diff
changeset
|
109 |
backboneNodes = int(cmd.backboneNodes) |
1133a20204c6
fix command-line argument handling in mixed-wireless.py example
Mohit P. Tahiliani <tahiliani.nitk@gmail.com>
parents:
10781
diff
changeset
|
110 |
infraNodes = int(cmd.infraNodes) |
1133a20204c6
fix command-line argument handling in mixed-wireless.py example
Mohit P. Tahiliani <tahiliani.nitk@gmail.com>
parents:
10781
diff
changeset
|
111 |
lanNodes = int(cmd.lanNodes) |
1133a20204c6
fix command-line argument handling in mixed-wireless.py example
Mohit P. Tahiliani <tahiliani.nitk@gmail.com>
parents:
10781
diff
changeset
|
112 |
stopTime = int(cmd.stopTime) |
1133a20204c6
fix command-line argument handling in mixed-wireless.py example
Mohit P. Tahiliani <tahiliani.nitk@gmail.com>
parents:
10781
diff
changeset
|
113 |
|
10780
856d526d5f6d
re-align mixed-wireless C++ and Python example
Tom Henderson <tomh@tomh.org>
parents:
9000
diff
changeset
|
114 |
if (stopTime < 10): |
856d526d5f6d
re-align mixed-wireless C++ and Python example
Tom Henderson <tomh@tomh.org>
parents:
9000
diff
changeset
|
115 |
print "Use a simulation stop time >= 10 seconds" |
856d526d5f6d
re-align mixed-wireless C++ and Python example
Tom Henderson <tomh@tomh.org>
parents:
9000
diff
changeset
|
116 |
exit(1) |
3422
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
117 |
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # / |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
118 |
# # |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
119 |
# Construct the backbone # |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
120 |
# # |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
121 |
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # / |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
122 |
|
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
123 |
# |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
124 |
# 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
|
125 |
# 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
|
126 |
# |
7106
2939fecb7029
Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents:
6673
diff
changeset
|
127 |
backbone = ns.network.NodeContainer() |
3422
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
128 |
backbone.Create(backboneNodes) |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
129 |
# |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
130 |
# 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
|
131 |
# our container |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
132 |
# |
7106
2939fecb7029
Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents:
6673
diff
changeset
|
133 |
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
|
134 |
mac = ns.wifi.NqosWifiMacHelper.Default() |
4754
77c878bc3e84
Fix Python coding style.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4752
diff
changeset
|
135 |
mac.SetType("ns3::AdhocWifiMac") |
77c878bc3e84
Fix Python coding style.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4752
diff
changeset
|
136 |
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
|
137 |
"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
|
138 |
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
|
139 |
wifiChannel = ns.wifi.YansWifiChannelHelper.Default() |
4754
77c878bc3e84
Fix Python coding style.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4752
diff
changeset
|
140 |
wifiPhy.SetChannel(wifiChannel.Create()) |
4752
3e26b3b2e3a8
Fix python examples.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4211
diff
changeset
|
141 |
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
|
142 |
# |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
143 |
# 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
|
144 |
# |
4752
3e26b3b2e3a8
Fix python examples.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4211
diff
changeset
|
145 |
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
|
146 |
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
|
147 |
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
|
148 |
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
|
149 |
internet.Install(backbone); |
5357
d8915edc639c
make mixed-wireless examples use InternetStackHelper::Reset
Tom Henderson <tomh@tomh.org>
parents:
4754
diff
changeset
|
150 |
# re-initialize for non-olsr routing. |
10780
856d526d5f6d
re-align mixed-wireless C++ and Python example
Tom Henderson <tomh@tomh.org>
parents:
9000
diff
changeset
|
151 |
# internet.Reset() |
3422
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
152 |
# |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
153 |
# 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
|
154 |
# IPv4 interfaces) we just created. |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
155 |
# |
7106
2939fecb7029
Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents:
6673
diff
changeset
|
156 |
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
|
157 |
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
|
158 |
ipAddrs.Assign(backboneDevices) |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
159 |
|
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
160 |
# |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
161 |
# 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
|
162 |
# 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
|
163 |
# |
7106
2939fecb7029
Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents:
6673
diff
changeset
|
164 |
mobility = ns.mobility.MobilityHelper() |
10781
c51514a999a4
make mobility and visualization more reasonable for example
Tom Henderson <tomh@tomh.org>
parents:
10780
diff
changeset
|
165 |
mobility.SetPositionAllocator("ns3::GridPositionAllocator", |
c51514a999a4
make mobility and visualization more reasonable for example
Tom Henderson <tomh@tomh.org>
parents:
10780
diff
changeset
|
166 |
"MinX", ns.core.DoubleValue(20.0), |
c51514a999a4
make mobility and visualization more reasonable for example
Tom Henderson <tomh@tomh.org>
parents:
10780
diff
changeset
|
167 |
"MinY", ns.core.DoubleValue(20.0), |
c51514a999a4
make mobility and visualization more reasonable for example
Tom Henderson <tomh@tomh.org>
parents:
10780
diff
changeset
|
168 |
"DeltaX", ns.core.DoubleValue(20.0), |
c51514a999a4
make mobility and visualization more reasonable for example
Tom Henderson <tomh@tomh.org>
parents:
10780
diff
changeset
|
169 |
"DeltaY", ns.core.DoubleValue(20.0), |
c51514a999a4
make mobility and visualization more reasonable for example
Tom Henderson <tomh@tomh.org>
parents:
10780
diff
changeset
|
170 |
"GridWidth", ns.core.UintegerValue(5), |
c51514a999a4
make mobility and visualization more reasonable for example
Tom Henderson <tomh@tomh.org>
parents:
10780
diff
changeset
|
171 |
"LayoutType", ns.core.StringValue("RowFirst")) |
3422
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
172 |
mobility.SetMobilityModel("ns3::RandomDirection2dMobilityModel", |
10781
c51514a999a4
make mobility and visualization more reasonable for example
Tom Henderson <tomh@tomh.org>
parents:
10780
diff
changeset
|
173 |
"Bounds", ns.mobility.RectangleValue(ns.mobility.Rectangle(-500, 500, -500, 500)), |
10780
856d526d5f6d
re-align mixed-wireless C++ and Python example
Tom Henderson <tomh@tomh.org>
parents:
9000
diff
changeset
|
174 |
"Speed", ns.core.StringValue ("ns3::ConstantRandomVariable[Constant=2]"), |
8983
91d4c78133a8
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 1)
Mitch Watrous
parents:
8966
diff
changeset
|
175 |
"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
|
176 |
mobility.Install(backbone) |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
177 |
|
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
178 |
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # / |
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 |
# Construct the LANs # |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
181 |
# # |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
182 |
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # / |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
183 |
|
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
184 |
# 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
|
185 |
# 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
|
186 |
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
|
187 |
|
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
188 |
for i in range(backboneNodes): |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
189 |
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
|
190 |
# |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
191 |
# 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
|
192 |
# 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
|
193 |
# 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
|
194 |
# |
7106
2939fecb7029
Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents:
6673
diff
changeset
|
195 |
newLanNodes = ns.network.NodeContainer() |
3422
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
196 |
newLanNodes.Create(lanNodes - 1) |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
197 |
# 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
|
198 |
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
|
199 |
# |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
200 |
# 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
|
201 |
# collection. |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
202 |
# |
7106
2939fecb7029
Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents:
6673
diff
changeset
|
203 |
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
|
204 |
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
|
205 |
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
|
206 |
lanDevices = csma.Install(lan) |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
207 |
# |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
208 |
# 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
|
209 |
# |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
210 |
internet.Install(newLanNodes) |
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 |
# 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
|
213 |
# 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
|
214 |
# |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
215 |
ipAddrs.Assign(lanDevices) |
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 |
# 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
|
218 |
# network mask initialized above |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
219 |
# |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
220 |
ipAddrs.NewNetwork() |
10781
c51514a999a4
make mobility and visualization more reasonable for example
Tom Henderson <tomh@tomh.org>
parents:
10780
diff
changeset
|
221 |
# |
c51514a999a4
make mobility and visualization more reasonable for example
Tom Henderson <tomh@tomh.org>
parents:
10780
diff
changeset
|
222 |
# The new LAN nodes need a mobility model so we aggregate one |
c51514a999a4
make mobility and visualization more reasonable for example
Tom Henderson <tomh@tomh.org>
parents:
10780
diff
changeset
|
223 |
# to each of the nodes we just finished building. |
c51514a999a4
make mobility and visualization more reasonable for example
Tom Henderson <tomh@tomh.org>
parents:
10780
diff
changeset
|
224 |
# |
c51514a999a4
make mobility and visualization more reasonable for example
Tom Henderson <tomh@tomh.org>
parents:
10780
diff
changeset
|
225 |
mobilityLan = ns.mobility.MobilityHelper() |
c51514a999a4
make mobility and visualization more reasonable for example
Tom Henderson <tomh@tomh.org>
parents:
10780
diff
changeset
|
226 |
positionAlloc = ns.mobility.ListPositionAllocator() |
c51514a999a4
make mobility and visualization more reasonable for example
Tom Henderson <tomh@tomh.org>
parents:
10780
diff
changeset
|
227 |
for j in range(newLanNodes.GetN()): |
c51514a999a4
make mobility and visualization more reasonable for example
Tom Henderson <tomh@tomh.org>
parents:
10780
diff
changeset
|
228 |
positionAlloc.Add(ns.core.Vector(0.0, (j*10 + 10), 0.0)) |
c51514a999a4
make mobility and visualization more reasonable for example
Tom Henderson <tomh@tomh.org>
parents:
10780
diff
changeset
|
229 |
|
c51514a999a4
make mobility and visualization more reasonable for example
Tom Henderson <tomh@tomh.org>
parents:
10780
diff
changeset
|
230 |
mobilityLan.SetPositionAllocator(positionAlloc) |
c51514a999a4
make mobility and visualization more reasonable for example
Tom Henderson <tomh@tomh.org>
parents:
10780
diff
changeset
|
231 |
mobilityLan.PushReferenceMobilityModel(backbone.Get(i)) |
c51514a999a4
make mobility and visualization more reasonable for example
Tom Henderson <tomh@tomh.org>
parents:
10780
diff
changeset
|
232 |
mobilityLan.SetMobilityModel("ns3::ConstantPositionMobilityModel") |
c51514a999a4
make mobility and visualization more reasonable for example
Tom Henderson <tomh@tomh.org>
parents:
10780
diff
changeset
|
233 |
mobilityLan.Install(newLanNodes); |
3422
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
234 |
|
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
235 |
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # / |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
236 |
# # |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
237 |
# Construct the mobile networks # |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
238 |
# # |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
239 |
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # / |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
240 |
|
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
241 |
# 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
|
242 |
# 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
|
243 |
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
|
244 |
|
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
245 |
for i in range(backboneNodes): |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
246 |
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
|
247 |
# |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
248 |
# 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
|
249 |
# 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
|
250 |
# 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
|
251 |
# |
7106
2939fecb7029
Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents:
6673
diff
changeset
|
252 |
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
|
253 |
stas.Create(infraNodes - 1) |
3422
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
254 |
# 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
|
255 |
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
|
256 |
# |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
257 |
# 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
|
258 |
# |
7106
2939fecb7029
Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents:
6673
diff
changeset
|
259 |
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
|
260 |
wifiInfra = ns.wifi.WifiHelper.Default() |
4754
77c878bc3e84
Fix Python coding style.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4752
diff
changeset
|
261 |
wifiPhy.SetChannel(wifiChannel.Create()) |
77c878bc3e84
Fix Python coding style.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4752
diff
changeset
|
262 |
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
|
263 |
macInfra = ns.wifi.NqosWifiMacHelper.Default(); |
6673
ec22aa763e2d
Bug 978: Consolidate Wi-Fi MAC high functionality
Dean Armstrong <deanarm@gmail.com>
parents:
6360
diff
changeset
|
264 |
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
|
265 |
"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
|
266 |
"ActiveProbing", ns.core.BooleanValue(False)) |
4752
3e26b3b2e3a8
Fix python examples.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4211
diff
changeset
|
267 |
|
3e26b3b2e3a8
Fix python examples.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4211
diff
changeset
|
268 |
# setup stas |
4754
77c878bc3e84
Fix Python coding style.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4752
diff
changeset
|
269 |
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
|
270 |
# setup ap. |
6673
ec22aa763e2d
Bug 978: Consolidate Wi-Fi MAC high functionality
Dean Armstrong <deanarm@gmail.com>
parents:
6360
diff
changeset
|
271 |
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
|
272 |
"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
|
273 |
"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
|
274 |
"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
|
275 |
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
|
276 |
# 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
|
277 |
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
|
278 |
|
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
279 |
# 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
|
280 |
# |
4211
11cae8936153
bug 465: mixed-wireless.py does not work anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3536
diff
changeset
|
281 |
internet.Install(stas) |
3422
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
282 |
# |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
283 |
# 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
|
284 |
# IPv4 interfaces) we just created. |
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 |
ipAddrs.Assign(infraDevices) |
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 |
# 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
|
289 |
# the network mask initialized above |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
290 |
# |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
291 |
ipAddrs.NewNetwork() |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
292 |
# |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
293 |
# 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
|
294 |
# 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
|
295 |
# |
7106
2939fecb7029
Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents:
6673
diff
changeset
|
296 |
subnetAlloc = ns.mobility.ListPositionAllocator() |
3422
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
297 |
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
|
298 |
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
|
299 |
|
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
300 |
mobility.PushReferenceMobilityModel(backbone.Get(i)) |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
301 |
mobility.SetPositionAllocator(subnetAlloc) |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
302 |
mobility.SetMobilityModel("ns3::RandomDirection2dMobilityModel", |
10780
856d526d5f6d
re-align mixed-wireless C++ and Python example
Tom Henderson <tomh@tomh.org>
parents:
9000
diff
changeset
|
303 |
"Bounds", ns.mobility.RectangleValue(ns.mobility.Rectangle(-10, 10, -10, 10)), |
856d526d5f6d
re-align mixed-wireless C++ and Python example
Tom Henderson <tomh@tomh.org>
parents:
9000
diff
changeset
|
304 |
"Speed", ns.core.StringValue ("ns3::ConstantRandomVariable[Constant=3]"), |
8983
91d4c78133a8
Replace src/mobility usage of RandomVariable with RandomVariableStream (Patch Set 1)
Mitch Watrous
parents:
8966
diff
changeset
|
305 |
"Pause", ns.core.StringValue ("ns3::ConstantRandomVariable[Constant=0.4]")) |
10781
c51514a999a4
make mobility and visualization more reasonable for example
Tom Henderson <tomh@tomh.org>
parents:
10780
diff
changeset
|
306 |
mobility.Install(stas) |
3422
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
307 |
|
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
308 |
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # / |
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 |
# Application configuration # |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
311 |
# # |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
312 |
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # / |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
313 |
|
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
314 |
# 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
|
315 |
# 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
|
316 |
print "Create Applications." |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
317 |
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
|
318 |
|
10780
856d526d5f6d
re-align mixed-wireless C++ and Python example
Tom Henderson <tomh@tomh.org>
parents:
9000
diff
changeset
|
319 |
appSource = ns.network.NodeList.GetNode(backboneNodes) |
856d526d5f6d
re-align mixed-wireless C++ and Python example
Tom Henderson <tomh@tomh.org>
parents:
9000
diff
changeset
|
320 |
lastNodeIndex = backboneNodes + backboneNodes*(lanNodes - 1) + backboneNodes*(infraNodes - 1) - 1 |
856d526d5f6d
re-align mixed-wireless C++ and Python example
Tom Henderson <tomh@tomh.org>
parents:
9000
diff
changeset
|
321 |
appSink = ns.network.NodeList.GetNode(lastNodeIndex) |
856d526d5f6d
re-align mixed-wireless C++ and Python example
Tom Henderson <tomh@tomh.org>
parents:
9000
diff
changeset
|
322 |
# Let's fetch the IP address of the last node, which is on Ipv4Interface 1 |
856d526d5f6d
re-align mixed-wireless C++ and Python example
Tom Henderson <tomh@tomh.org>
parents:
9000
diff
changeset
|
323 |
remoteAddr = appSink.GetObject(ns.internet.Ipv4.GetTypeId()).GetAddress(1,0).GetLocal() |
3422
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
324 |
|
7106
2939fecb7029
Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents:
6673
diff
changeset
|
325 |
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
|
326 |
ns.network.Address(ns.network.InetSocketAddress(remoteAddr, port))) |
2939fecb7029
Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents:
6673
diff
changeset
|
327 |
apps = onoff.Install(ns.network.NodeContainer(appSource)) |
10780
856d526d5f6d
re-align mixed-wireless C++ and Python example
Tom Henderson <tomh@tomh.org>
parents:
9000
diff
changeset
|
328 |
apps.Start(ns.core.Seconds(3)) |
856d526d5f6d
re-align mixed-wireless C++ and Python example
Tom Henderson <tomh@tomh.org>
parents:
9000
diff
changeset
|
329 |
apps.Stop(ns.core.Seconds(stopTime - 1)) |
3422
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
330 |
|
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
331 |
# 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
|
332 |
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
|
333 |
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
|
334 |
apps = sink.Install(ns.network.NodeContainer(appSink)) |
10780
856d526d5f6d
re-align mixed-wireless C++ and Python example
Tom Henderson <tomh@tomh.org>
parents:
9000
diff
changeset
|
335 |
apps.Start(ns.core.Seconds(3)) |
3422
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
336 |
|
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
337 |
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # / |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
338 |
# # |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
339 |
# Tracing configuration # |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
340 |
# # |
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 |
|
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
343 |
print "Configure Tracing." |
10780
856d526d5f6d
re-align mixed-wireless C++ and Python example
Tom Henderson <tomh@tomh.org>
parents:
9000
diff
changeset
|
344 |
csma = ns.csma.CsmaHelper() |
3422
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
345 |
# |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
346 |
# 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
|
347 |
# |
10780
856d526d5f6d
re-align mixed-wireless C++ and Python example
Tom Henderson <tomh@tomh.org>
parents:
9000
diff
changeset
|
348 |
ascii = ns.network.AsciiTraceHelper(); |
856d526d5f6d
re-align mixed-wireless C++ and Python example
Tom Henderson <tomh@tomh.org>
parents:
9000
diff
changeset
|
349 |
stream = ascii.CreateFileStream("mixed-wireless.tr"); |
856d526d5f6d
re-align mixed-wireless C++ and Python example
Tom Henderson <tomh@tomh.org>
parents:
9000
diff
changeset
|
350 |
wifiPhy.EnableAsciiAll(stream); |
856d526d5f6d
re-align mixed-wireless C++ and Python example
Tom Henderson <tomh@tomh.org>
parents:
9000
diff
changeset
|
351 |
csma.EnableAsciiAll(stream); |
856d526d5f6d
re-align mixed-wireless C++ and Python example
Tom Henderson <tomh@tomh.org>
parents:
9000
diff
changeset
|
352 |
internet.EnableAsciiIpv4All(stream); |
3422
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
353 |
|
10780
856d526d5f6d
re-align mixed-wireless C++ and Python example
Tom Henderson <tomh@tomh.org>
parents:
9000
diff
changeset
|
354 |
# Csma captures in non-promiscuous mode |
856d526d5f6d
re-align mixed-wireless C++ and Python example
Tom Henderson <tomh@tomh.org>
parents:
9000
diff
changeset
|
355 |
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
|
356 |
# 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
|
357 |
wifiPhy.EnablePcap("mixed-wireless", backboneDevices) |
10780
856d526d5f6d
re-align mixed-wireless C++ and Python example
Tom Henderson <tomh@tomh.org>
parents:
9000
diff
changeset
|
358 |
wifiPhy.EnablePcap("mixed-wireless", appSink.GetId(), 0) |
3422
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 |
# #ifdef ENABLE_FOR_TRACING_EXAMPLE |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
361 |
# Config.Connect("/NodeList/*/$MobilityModel/CourseChange", |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
362 |
# MakeCallback(&CourseChangeCallback)) |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
363 |
# #endif |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
364 |
|
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
365 |
|
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
366 |
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
367 |
# # |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
368 |
# Run simulation # |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
369 |
# # |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
370 |
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
371 |
|
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
372 |
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
|
373 |
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
|
374 |
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
|
375 |
ns.core.Simulator.Destroy() |
3422
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
376 |
|
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
377 |
|
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
378 |
if __name__ == '__main__': |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
379 |
import sys |
ad0c05e68792
Add mixed-wireless example ported to Python.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
380 |
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
|
381 |
|
2939fecb7029
Make Python examples use new modular bindings without importing everything
Mitch Watrous <watrous@u.washington.edu>
parents:
6673
diff
changeset
|
382 |