author | Tom Henderson <tomh@tomh.org> |
Thu, 02 Jul 2009 21:57:00 -0700 | |
changeset 4646 | c25ca2e38845 |
parent 4196 | ed59d07c5373 |
permissions | -rw-r--r-- |
4100
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
1 |
# -*- Mode: Python; -*- |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
2 |
# /* |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
3 |
# * Copyright (c) 2005,2006,2007 INRIA |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
4 |
# * Copyright (c) 2009 INESC Porto |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
5 |
# * |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
6 |
# * This program is free software; you can redistribute it and/or modify |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
7 |
# * it under the terms of the GNU General Public License version 2 as |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
8 |
# * published by the Free Software Foundation; |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
9 |
# * |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
10 |
# * This program is distributed in the hope that it will be useful, |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
11 |
# * but WITHOUT ANY WARRANTY; without even the implied warranty of |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
12 |
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
13 |
# * GNU General Public License for more details. |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
14 |
# * |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
15 |
# * You should have received a copy of the GNU General Public License |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
16 |
# * along with this program; if not, write to the Free Software |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
17 |
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
18 |
# * |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
19 |
# * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
20 |
# * Gustavo Carneiro <gjc@inescporto.pt> |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
21 |
# */ |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
22 |
|
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
23 |
import sys |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
24 |
import ns3 |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
25 |
|
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
26 |
# void |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
27 |
# DevTxTrace (std::string context, Ptr<const Packet> p, Mac48Address address) |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
28 |
# { |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
29 |
# std::cout << " TX to=" << address << " p: " << *p << std::endl; |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
30 |
# } |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
31 |
# void |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
32 |
# DevRxTrace (std::string context, Ptr<const Packet> p, Mac48Address address) |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
33 |
# { |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
34 |
# std::cout << " RX from=" << address << " p: " << *p << std::endl; |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
35 |
# } |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
36 |
# void |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
37 |
# PhyRxOkTrace (std::string context, Ptr<const Packet> packet, double snr, WifiMode mode, enum WifiPreamble preamble) |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
38 |
# { |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
39 |
# std::cout << "PHYRXOK mode=" << mode << " snr=" << snr << " " << *packet << std::endl; |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
40 |
# } |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
41 |
# void |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
42 |
# PhyRxErrorTrace (std::string context, Ptr<const Packet> packet, double snr) |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
43 |
# { |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
44 |
# std::cout << "PHYRXERROR snr=" << snr << " " << *packet << std::endl; |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
45 |
# } |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
46 |
# void |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
47 |
# PhyTxTrace (std::string context, Ptr<const Packet> packet, WifiMode mode, WifiPreamble preamble, uint8_t txPower) |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
48 |
# { |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
49 |
# std::cout << "PHYTX mode=" << mode << " " << *packet << std::endl; |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
50 |
# } |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
51 |
# void |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
52 |
# PhyStateTrace (std::string context, Time start, Time duration, enum WifiPhy::State state) |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
53 |
# { |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
54 |
# std::cout << " state="; |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
55 |
# switch (state) { |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
56 |
# case WifiPhy::TX: |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
57 |
# std::cout << "tx "; |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
58 |
# break; |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
59 |
# case WifiPhy::SYNC: |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
60 |
# std::cout << "sync "; |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
61 |
# break; |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
62 |
# case WifiPhy::CCA_BUSY: |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
63 |
# std::cout << "cca-busy"; |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
64 |
# break; |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
65 |
# case WifiPhy::IDLE: |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
66 |
# std::cout << "idle "; |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
67 |
# break; |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
68 |
# } |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
69 |
# std::cout << " start="<<start<<" duration="<<duration<<std::endl; |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
70 |
# } |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
71 |
|
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
72 |
def SetPosition(node, position): |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
73 |
mobility = node.GetObject(ns3.MobilityModel.GetTypeId()) |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
74 |
mobility.SetPosition(position) |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
75 |
|
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
76 |
|
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
77 |
def GetPosition(node): |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
78 |
mobility = node.GetObject(ns3.MobilityModel.GetTypeId()) |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
79 |
return mobility.GetPosition() |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
80 |
|
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
81 |
def AdvancePosition(node): |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
82 |
pos = GetPosition (node); |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
83 |
pos.x += 5.0 |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
84 |
if pos.x >= 210.0: |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
85 |
return |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
86 |
SetPosition(node, pos) |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
87 |
ns3.Simulator.Schedule(ns3.Seconds(1.0), AdvancePosition, node) |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
88 |
|
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
89 |
|
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
90 |
def main(argv): |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
91 |
ns3.Packet.EnablePrinting (); |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
92 |
|
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
93 |
# enable rts cts all the time. |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
94 |
ns3.Config.SetDefault("ns3::WifiRemoteStationManager::RtsCtsThreshold", ns3.StringValue("0")) |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
95 |
# disable fragmentation |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
96 |
ns3.Config.SetDefault("ns3::WifiRemoteStationManager::FragmentationThreshold", ns3.StringValue ("2200")) |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
97 |
|
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
98 |
wifi = ns3.WifiHelper.Default() |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
99 |
mobility = ns3.MobilityHelper() |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
100 |
stas = ns3.NodeContainer() |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
101 |
ap = ns3.NodeContainer() |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
102 |
#NetDeviceContainer staDevs; |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
103 |
packetSocket = ns3.PacketSocketHelper() |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
104 |
|
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
105 |
stas.Create(2) |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
106 |
ap.Create(1) |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
107 |
|
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
108 |
# give packet socket powers to nodes. |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
109 |
packetSocket.Install(stas) |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
110 |
packetSocket.Install(ap) |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
111 |
|
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
112 |
wifiPhy = ns3.YansWifiPhyHelper.Default() |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
113 |
wifiChannel = ns3.YansWifiChannelHelper.Default() |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
114 |
wifiPhy.SetChannel(wifiChannel.Create()) |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
115 |
|
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
116 |
ssid = ns3.Ssid("wifi-default") |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
117 |
wifi.SetRemoteStationManager("ns3::ArfWifiManager") |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
118 |
# setup stas. |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
119 |
wifi.SetMac("ns3::NqstaWifiMac", |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
120 |
"Ssid", ns3.SsidValue(ssid), |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
121 |
"ActiveProbing", ns3.BooleanValue(False)) |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
122 |
staDevs = wifi.Install(wifiPhy, stas) |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
123 |
# setup ap. |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
124 |
wifi.SetMac("ns3::NqapWifiMac", "Ssid", ns3.SsidValue(ssid), |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
125 |
"BeaconGeneration", ns3.BooleanValue(True), |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
126 |
"BeaconInterval", ns3.TimeValue(ns3.Seconds(2.5))) |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
127 |
wifi.Install(wifiPhy, ap) |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
128 |
|
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
129 |
# mobility. |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
130 |
mobility.Install(stas) |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
131 |
mobility.Install(ap) |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
132 |
|
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
133 |
ns3.Simulator.Schedule(ns3.Seconds(1.0), AdvancePosition, ap.Get(0)) |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
134 |
|
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
135 |
socket = ns3.PacketSocketAddress() |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
136 |
socket.SetSingleDevice(staDevs.Get(0).GetIfIndex()) |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
137 |
socket.SetPhysicalAddress(staDevs.Get(1).GetAddress()) |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
138 |
socket.SetProtocol(1) |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
139 |
|
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
140 |
onoff = ns3.OnOffHelper("ns3::PacketSocketFactory", ns3.Address(socket)) |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
141 |
onoff.SetAttribute("OnTime", ns3.RandomVariableValue(ns3.ConstantVariable(42))) |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
142 |
onoff.SetAttribute("OffTime", ns3.RandomVariableValue(ns3.ConstantVariable(0))) |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
143 |
|
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
144 |
apps = onoff.Install(ns3.NodeContainer(stas.Get(0))) |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
145 |
apps.Start(ns3.Seconds(0.5)) |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
146 |
apps.Stop(ns3.Seconds(43.0)) |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
147 |
|
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
148 |
ns3.Simulator.Stop(ns3.Seconds(44.0)) |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
149 |
|
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
150 |
# Config::Connect ("/NodeList/*/DeviceList/*/Tx", MakeCallback (&DevTxTrace)); |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
151 |
# Config::Connect ("/NodeList/*/DeviceList/*/Rx", MakeCallback (&DevRxTrace)); |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
152 |
# Config::Connect ("/NodeList/*/DeviceList/*/Phy/RxOk", MakeCallback (&PhyRxOkTrace)); |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
153 |
# Config::Connect ("/NodeList/*/DeviceList/*/Phy/RxError", MakeCallback (&PhyRxErrorTrace)); |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
154 |
# Config::Connect ("/NodeList/*/DeviceList/*/Phy/Tx", MakeCallback (&PhyTxTrace)); |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
155 |
# Config::Connect ("/NodeList/*/DeviceList/*/Phy/State", MakeCallback (&PhyStateTrace)); |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
156 |
|
4196
ed59d07c5373
Python: wrap std::ostream/ofstream, for ascii tracing.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4100
diff
changeset
|
157 |
ascii = ns3.ofstream("wifi-ap.tr") |
ed59d07c5373
Python: wrap std::ostream/ofstream, for ascii tracing.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4100
diff
changeset
|
158 |
ns3.YansWifiPhyHelper.EnableAsciiAll(ascii) |
ed59d07c5373
Python: wrap std::ostream/ofstream, for ascii tracing.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4100
diff
changeset
|
159 |
|
4100
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
160 |
ns3.Simulator.Run() |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
161 |
|
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
162 |
ns3.Simulator.Destroy() |
4196
ed59d07c5373
Python: wrap std::ostream/ofstream, for ascii tracing.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4100
diff
changeset
|
163 |
ascii.close() |
4100
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
164 |
|
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
165 |
return 0 |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
166 |
|
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
167 |
|
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
168 |
if __name__ == '__main__': |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
169 |
sys.exit(main(sys.argv)) |
cf230d65623b
examples/wifi-ap.cc ported to Python (minus tracing)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff
changeset
|
170 |