author | Tom Henderson <tomh@tomh.org> |
Thu, 01 Oct 2015 11:07:22 -0700 | |
changeset 11677 | 1e2add816314 |
parent 10968 | 2d29fee2b7b8 |
permissions | -rw-r--r-- |
5369
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
1 |
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
2 |
/* |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
3 |
* Copyright (c) 2009 The Boeing Company |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
4 |
* |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation; |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
8 |
* |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
13 |
* |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
17 |
* |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
18 |
*/ |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
19 |
|
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
20 |
// |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
21 |
// This script configures two nodes on an 802.11b physical layer, with |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
22 |
// 802.11b NICs in infrastructure mode, and by default, the station sends |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
23 |
// one packet of 1000 (application) bytes to the access point. The |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
24 |
// physical layer is configured |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
25 |
// to receive at a fixed RSS (regardless of the distance and transmit |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
26 |
// power); therefore, changing position of the nodes has no effect. |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
27 |
// |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
28 |
// There are a number of command-line options available to control |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
29 |
// the default behavior. The list of available command-line options |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
30 |
// can be listed with the following command: |
5884
46614fa27eae
remove reference to scratch/ directory in wireless examples
Tom Henderson <tomh@tomh.org>
parents:
5524
diff
changeset
|
31 |
// ./waf --run "wifi-simple-infra --help" |
5369
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
32 |
// |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
33 |
// For instance, for this configuration, the physical layer will |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
34 |
// stop successfully receiving packets when rss drops below -97 dBm. |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
35 |
// To see this effect, try running: |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
36 |
// |
5884
46614fa27eae
remove reference to scratch/ directory in wireless examples
Tom Henderson <tomh@tomh.org>
parents:
5524
diff
changeset
|
37 |
// ./waf --run "wifi-simple-infra --rss=-97 --numPackets=20" |
46614fa27eae
remove reference to scratch/ directory in wireless examples
Tom Henderson <tomh@tomh.org>
parents:
5524
diff
changeset
|
38 |
// ./waf --run "wifi-simple-infra --rss=-98 --numPackets=20" |
46614fa27eae
remove reference to scratch/ directory in wireless examples
Tom Henderson <tomh@tomh.org>
parents:
5524
diff
changeset
|
39 |
// ./waf --run "wifi-simple-infra --rss=-99 --numPackets=20" |
5369
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
40 |
// |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
41 |
// Note that all ns-3 attributes (not just the ones exposed in the below |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
42 |
// script) can be changed at command line; see the documentation. |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
43 |
// |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
44 |
// This script can also be helpful to put the Wifi layer into verbose |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
45 |
// logging mode; this command will turn on all wifi logging: |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
46 |
// |
5884
46614fa27eae
remove reference to scratch/ directory in wireless examples
Tom Henderson <tomh@tomh.org>
parents:
5524
diff
changeset
|
47 |
// ./waf --run "wifi-simple-infra --verbose=1" |
5369
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
48 |
// |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
49 |
// When you are done, you will notice two pcap trace files in your directory. |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
50 |
// If you have tcpdump installed, you can try this: |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
51 |
// |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
52 |
// tcpdump -r wifi-simple-infra-0-0.pcap -nn -tt |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
53 |
// |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
54 |
|
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
55 |
#include "ns3/core-module.h" |
6823
a27f86fb4e55
Merge node and common modules into new network module
Tom Henderson <tomh@tomh.org>
parents:
6674
diff
changeset
|
56 |
#include "ns3/network-module.h" |
5369
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
57 |
#include "ns3/mobility-module.h" |
6941
9d2c79c992d7
Split contrib module into config-store and tools
Mitch Watrous <watrous@u.washington.edu>
parents:
6865
diff
changeset
|
58 |
#include "ns3/config-store-module.h" |
5369
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
59 |
#include "ns3/wifi-module.h" |
6848
1f453ad50ef3
Converts csma, emu, tap-bridge, point-to-point, wifi and wimax modules into modular format
Lalith Suresh <suresh.lalith@gmail.com>
parents:
6823
diff
changeset
|
60 |
#include "ns3/internet-module.h" |
5369
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
61 |
|
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
62 |
#include <iostream> |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
63 |
#include <fstream> |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
64 |
#include <vector> |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
65 |
#include <string> |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
66 |
|
10968
2d29fee2b7b8
[Bug 1551] Redux: NS_LOG_COMPONENT_DEFINE inside or outside of ns3 namespace?
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10906
diff
changeset
|
67 |
using namespace ns3; |
5369
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
68 |
|
10968
2d29fee2b7b8
[Bug 1551] Redux: NS_LOG_COMPONENT_DEFINE inside or outside of ns3 namespace?
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10906
diff
changeset
|
69 |
NS_LOG_COMPONENT_DEFINE ("WifiSimpleInfra"); |
5369
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
70 |
|
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
71 |
void ReceivePacket (Ptr<Socket> socket) |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
72 |
{ |
10906
29ef028eae7b
Bug 1858 - wireless examples not correctly recording packet reception - reported by Scott Carpenter <scarpen_at_ncsu.edu>
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7256
diff
changeset
|
73 |
while (socket->Recv ()) |
29ef028eae7b
Bug 1858 - wireless examples not correctly recording packet reception - reported by Scott Carpenter <scarpen_at_ncsu.edu>
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7256
diff
changeset
|
74 |
{ |
29ef028eae7b
Bug 1858 - wireless examples not correctly recording packet reception - reported by Scott Carpenter <scarpen_at_ncsu.edu>
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7256
diff
changeset
|
75 |
NS_LOG_UNCOND ("Received one packet!"); |
29ef028eae7b
Bug 1858 - wireless examples not correctly recording packet reception - reported by Scott Carpenter <scarpen_at_ncsu.edu>
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7256
diff
changeset
|
76 |
} |
5369
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
77 |
} |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
78 |
|
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
79 |
static void GenerateTraffic (Ptr<Socket> socket, uint32_t pktSize, |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
80 |
uint32_t pktCount, Time pktInterval ) |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
81 |
{ |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
82 |
if (pktCount > 0) |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
83 |
{ |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
84 |
socket->Send (Create<Packet> (pktSize)); |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
85 |
Simulator::Schedule (pktInterval, &GenerateTraffic, |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
86 |
socket, pktSize,pktCount-1, pktInterval); |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
87 |
} |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
88 |
else |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
89 |
{ |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
90 |
socket->Close (); |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
91 |
} |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
92 |
} |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
93 |
|
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
94 |
|
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
95 |
int main (int argc, char *argv[]) |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
96 |
{ |
6360
d8975477ff6a
Bug 871: Rework construction of Wi-Fi rates
Dean Armstrong <deanarm@gmail.com>
parents:
6309
diff
changeset
|
97 |
std::string phyMode ("DsssRate1Mbps"); |
5369
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
98 |
double rss = -80; // -dBm |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
99 |
uint32_t packetSize = 1000; // bytes |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
100 |
uint32_t numPackets = 1; |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
101 |
double interval = 1.0; // seconds |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
102 |
bool verbose = false; |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
103 |
|
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
104 |
CommandLine cmd; |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
105 |
|
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
106 |
cmd.AddValue ("phyMode", "Wifi Phy mode", phyMode); |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
107 |
cmd.AddValue ("rss", "received signal strength", rss); |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
108 |
cmd.AddValue ("packetSize", "size of application packet sent", packetSize); |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
109 |
cmd.AddValue ("numPackets", "number of packets generated", numPackets); |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
110 |
cmd.AddValue ("interval", "interval (seconds) between packets", interval); |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
111 |
cmd.AddValue ("verbose", "turn on all WifiNetDevice log components", verbose); |
6674
52f8688d6d01
Bug 978: Run check-style.py on files touched in the reorganisation
Dean Armstrong <deanarm@gmail.com>
parents:
6673
diff
changeset
|
112 |
|
5369
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
113 |
cmd.Parse (argc, argv); |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
114 |
// Convert to time object |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
115 |
Time interPacketInterval = Seconds (interval); |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
116 |
|
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
117 |
// disable fragmentation for frames below 2200 bytes |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
118 |
Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2200")); |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
119 |
// turn off RTS/CTS for frames below 2200 bytes |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
120 |
Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("2200")); |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
121 |
// Fix non-unicast data rate to be the same as that of unicast |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
122 |
Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode", |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
123 |
StringValue (phyMode)); |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
124 |
|
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
125 |
NodeContainer c; |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
126 |
c.Create (2); |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
127 |
|
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
128 |
// The below set of helpers will help us to put together the wifi NICs we want |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
129 |
WifiHelper wifi; |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
130 |
if (verbose) |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
131 |
{ |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
132 |
wifi.EnableLogComponents (); // Turn on all Wifi logging |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
133 |
} |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
134 |
wifi.SetStandard (WIFI_PHY_STANDARD_80211b); |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
135 |
|
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
136 |
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
137 |
// This is one parameter that matters when using FixedRssLossModel |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
138 |
// set it to zero; otherwise, gain will be added |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
139 |
wifiPhy.Set ("RxGain", DoubleValue (0) ); |
6009
e1b696a1ed28
redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents:
5884
diff
changeset
|
140 |
// ns-3 supports RadioTap and Prism tracing extensions for 802.11b |
6041 | 141 |
wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO); |
5369
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
142 |
|
7252
c8200621e252
rerun check-style.py with uncrustify-0.58
Tom Henderson <tomh@tomh.org>
parents:
6941
diff
changeset
|
143 |
YansWifiChannelHelper wifiChannel; |
5369
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
144 |
wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel"); |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
145 |
// The below FixedRssLossModel will cause the rss to be fixed regardless |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
146 |
// of the distance between the two stations, and the transmit power |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
147 |
wifiChannel.AddPropagationLoss ("ns3::FixedRssLossModel","Rss",DoubleValue (rss)); |
5369
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
148 |
wifiPhy.SetChannel (wifiChannel.Create ()); |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
149 |
|
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
150 |
// Add a non-QoS upper mac, and disable rate control |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
151 |
NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
152 |
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
153 |
"DataMode",StringValue (phyMode), |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
154 |
"ControlMode",StringValue (phyMode)); |
5369
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
155 |
|
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
156 |
// Setup the rest of the upper mac |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
157 |
Ssid ssid = Ssid ("wifi-default"); |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
158 |
// setup sta. |
6673
ec22aa763e2d
Bug 978: Consolidate Wi-Fi MAC high functionality
Dean Armstrong <deanarm@gmail.com>
parents:
6452
diff
changeset
|
159 |
wifiMac.SetType ("ns3::StaWifiMac", |
5369
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
160 |
"Ssid", SsidValue (ssid), |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
161 |
"ActiveProbing", BooleanValue (false)); |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
162 |
NetDeviceContainer staDevice = wifi.Install (wifiPhy, wifiMac, c.Get (0)); |
5369
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
163 |
NetDeviceContainer devices = staDevice; |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
164 |
// setup ap. |
6673
ec22aa763e2d
Bug 978: Consolidate Wi-Fi MAC high functionality
Dean Armstrong <deanarm@gmail.com>
parents:
6452
diff
changeset
|
165 |
wifiMac.SetType ("ns3::ApWifiMac", |
ec22aa763e2d
Bug 978: Consolidate Wi-Fi MAC high functionality
Dean Armstrong <deanarm@gmail.com>
parents:
6452
diff
changeset
|
166 |
"Ssid", SsidValue (ssid)); |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
167 |
NetDeviceContainer apDevice = wifi.Install (wifiPhy, wifiMac, c.Get (1)); |
5369
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
168 |
devices.Add (apDevice); |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
169 |
|
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
170 |
// Note that with FixedRssLossModel, the positions below are not |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
171 |
// used for received signal strength. |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
172 |
MobilityHelper mobility; |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
173 |
Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> (); |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
174 |
positionAlloc->Add (Vector (0.0, 0.0, 0.0)); |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
175 |
positionAlloc->Add (Vector (5.0, 0.0, 0.0)); |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
176 |
mobility.SetPositionAllocator (positionAlloc); |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
177 |
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
178 |
mobility.Install (c); |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
179 |
|
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
180 |
InternetStackHelper internet; |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
181 |
internet.Install (c); |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
182 |
|
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
183 |
Ipv4AddressHelper ipv4; |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
184 |
NS_LOG_INFO ("Assign IP Addresses."); |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
185 |
ipv4.SetBase ("10.1.1.0", "255.255.255.0"); |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
186 |
Ipv4InterfaceContainer i = ipv4.Assign (devices); |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
187 |
|
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
188 |
TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory"); |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
189 |
Ptr<Socket> recvSink = Socket::CreateSocket (c.Get (0), tid); |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
190 |
InetSocketAddress local = InetSocketAddress (Ipv4Address::GetAny (), 80); |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
191 |
recvSink->Bind (local); |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
192 |
recvSink->SetRecvCallback (MakeCallback (&ReceivePacket)); |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
193 |
|
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
194 |
Ptr<Socket> source = Socket::CreateSocket (c.Get (1), tid); |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
195 |
InetSocketAddress remote = InetSocketAddress (Ipv4Address ("255.255.255.255"), 80); |
6452
c36b5cf35db2
SetAllowBroadcast(true) addition made to wifi-simple-infra.cc and wifi-simple-interference.cc
Gilaras Drakeson <gilaras@gmail.com>
parents:
6360
diff
changeset
|
196 |
source->SetAllowBroadcast (true); |
5369
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
197 |
source->Connect (remote); |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
198 |
|
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
199 |
// Tracing |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
200 |
wifiPhy.EnablePcap ("wifi-simple-infra", devices); |
6674
52f8688d6d01
Bug 978: Run check-style.py on files touched in the reorganisation
Dean Armstrong <deanarm@gmail.com>
parents:
6673
diff
changeset
|
201 |
|
5369
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
202 |
// Output what we are doing |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
203 |
NS_LOG_UNCOND ("Testing " << numPackets << " packets sent with receiver rss " << rss ); |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
204 |
|
5524
efed7493f2c1
Make applications generate traffic within their associated context/node
Guillaume Seguin <guillaume@segu.in>
parents:
5369
diff
changeset
|
205 |
Simulator::ScheduleWithContext (source->GetNode ()->GetId (), |
efed7493f2c1
Make applications generate traffic within their associated context/node
Guillaume Seguin <guillaume@segu.in>
parents:
5369
diff
changeset
|
206 |
Seconds (1.0), &GenerateTraffic, |
efed7493f2c1
Make applications generate traffic within their associated context/node
Guillaume Seguin <guillaume@segu.in>
parents:
5369
diff
changeset
|
207 |
source, packetSize, numPackets, interPacketInterval); |
5369
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
208 |
|
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
209 |
Simulator::Stop (Seconds (30.0)); |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
210 |
Simulator::Run (); |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
211 |
Simulator::Destroy (); |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
212 |
|
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
213 |
return 0; |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
214 |
} |
86beb5869f67
split examples, add examples, tweak test.py to minimize builds
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
215 |