author | Sébastien Deronne <sebastien.deronne@gmail.com> |
Sat, 31 Jan 2015 17:36:14 -0800 | |
changeset 11197 | e6c47334f36c |
parent 10963 | 44a4d3139cfa |
child 11203 | 17fff1a5030b |
permissions | -rw-r--r-- |
10139 | 1 |
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2 |
/* |
|
3 |
* Copyright (c) 2009 MIRKO BANCHI |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License version 2 as |
|
7 |
* published by the Free Software Foundation; |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 |
* |
|
11197
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
18 |
* Authors: Mirko Banchi <mk.banchi@gmail.com> |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
19 |
* Sebastien Deronne <sebastien.deronne@gmail.com> |
10139 | 20 |
*/ |
21 |
#include "ns3/core-module.h" |
|
22 |
#include "ns3/network-module.h" |
|
23 |
#include "ns3/applications-module.h" |
|
24 |
#include "ns3/wifi-module.h" |
|
25 |
#include "ns3/mobility-module.h" |
|
26 |
#include "ns3/ipv4-global-routing-helper.h" |
|
27 |
#include "ns3/internet-module.h" |
|
28 |
||
11197
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
29 |
//This is a simple example of an IEEE 802.11n Wi-Fi network. |
10139 | 30 |
// |
31 |
//Network topology: |
|
11197
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
32 |
// |
10139 | 33 |
// Wifi 192.168.1.0 |
11197
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
34 |
// |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
35 |
// AP |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
36 |
// * * |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
37 |
// | | |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
38 |
// n1 n2 |
10139 | 39 |
// |
40 |
//Packets in this simulation aren't marked with a QosTag so they are considered |
|
41 |
//belonging to BestEffort Access Class (AC_BE). |
|
42 |
||
43 |
using namespace ns3; |
|
44 |
||
11197
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
45 |
NS_LOG_COMPONENT_DEFINE ("ht-wifi-network"); |
10139 | 46 |
|
47 |
int main (int argc, char *argv[]) |
|
48 |
{ |
|
49 |
bool udp = true; |
|
11197
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
50 |
double simulationTime = 10; //seconds |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
51 |
CommandLine cmd; |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
52 |
cmd.AddValue ("simulationTime", "Simulation time in seconds", simulationTime); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
53 |
cmd.AddValue ("udp", "UDP if set to 1, TCP otherwise", udp); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
54 |
cmd.Parse (argc,argv); |
10139 | 55 |
|
11197
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
56 |
std::cout << "DataRate" << "\t" << "Throughput" << '\n'; |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
57 |
for (int mcs = 0; mcs <= 31; mcs++) |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
58 |
{ |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
59 |
uint32_t payloadSize; //1500 byte IP packet |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
60 |
if (udp) |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
61 |
{ |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
62 |
payloadSize = 1472; //bytes |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
63 |
} |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
64 |
else |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
65 |
{ |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
66 |
payloadSize = 1448; //bytes |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
67 |
Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (payloadSize)); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
68 |
} |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
69 |
|
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
70 |
NodeContainer wifiStaNode; |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
71 |
wifiStaNode.Create (1); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
72 |
NodeContainer wifiApNode; |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
73 |
wifiApNode.Create (1); |
10139 | 74 |
|
11197
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
75 |
YansWifiChannelHelper channel = YansWifiChannelHelper::Default (); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
76 |
YansWifiPhyHelper phy = YansWifiPhyHelper::Default (); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
77 |
phy.SetChannel (channel.Create ()); |
10139 | 78 |
|
11197
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
79 |
if (mcs <= 7) |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
80 |
{ |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
81 |
phy.Set ("ShortGuardEnabled", BooleanValue (false)); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
82 |
phy.Set ("ChannelBonding", BooleanValue (false)); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
83 |
} |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
84 |
else if (mcs > 7 && mcs <= 15) |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
85 |
{ |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
86 |
phy.Set ("ShortGuardEnabled", BooleanValue (true)); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
87 |
phy.Set ("ChannelBonding", BooleanValue (false)); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
88 |
} |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
89 |
else if (mcs > 15 && mcs <= 23) |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
90 |
{ |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
91 |
phy.Set ("ShortGuardEnabled", BooleanValue (false)); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
92 |
phy.Set ("ChannelBonding", BooleanValue (true)); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
93 |
} |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
94 |
else |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
95 |
{ |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
96 |
phy.Set ("ShortGuardEnabled", BooleanValue (true)); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
97 |
phy.Set ("ChannelBonding", BooleanValue (true)); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
98 |
} |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
99 |
|
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
100 |
WifiHelper wifi = WifiHelper::Default (); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
101 |
wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
102 |
HtWifiMacHelper mac = HtWifiMacHelper::Default (); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
103 |
|
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
104 |
Ssid ssid = Ssid ("ns380211n"); |
10139 | 105 |
|
11197
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
106 |
double datarate = 0; |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
107 |
StringValue DataRate; |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
108 |
if (mcs == 0) |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
109 |
{ |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
110 |
DataRate = StringValue ("OfdmRate6_5MbpsBW20MHz"); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
111 |
datarate = 6.5; |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
112 |
} |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
113 |
else if (mcs == 1) |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
114 |
{ |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
115 |
DataRate = StringValue ("OfdmRate13MbpsBW20MHz"); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
116 |
datarate = 13; |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
117 |
} |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
118 |
else if (mcs == 2) |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
119 |
{ |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
120 |
DataRate = StringValue ("OfdmRate19_5MbpsBW20MHz"); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
121 |
datarate = 19.5; |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
122 |
} |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
123 |
else if (mcs == 3) |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
124 |
{ |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
125 |
DataRate = StringValue ("OfdmRate26MbpsBW20MHz"); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
126 |
datarate = 26; |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
127 |
} |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
128 |
else if (mcs == 4) |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
129 |
{ |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
130 |
DataRate = StringValue ("OfdmRate39MbpsBW20MHz"); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
131 |
datarate = 39; |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
132 |
} |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
133 |
else if (mcs == 5) |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
134 |
{ |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
135 |
DataRate = StringValue ("OfdmRate52MbpsBW20MHz"); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
136 |
datarate = 52; |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
137 |
} |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
138 |
else if (mcs == 6) |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
139 |
{ |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
140 |
DataRate = StringValue ("OfdmRate58_5MbpsBW20MHz"); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
141 |
datarate = 58.5; |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
142 |
} |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
143 |
else if (mcs == 7) |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
144 |
{ |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
145 |
DataRate = StringValue ("OfdmRate65MbpsBW20MHz"); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
146 |
datarate = 65; |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
147 |
} |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
148 |
else if (mcs == 8) |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
149 |
{ |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
150 |
DataRate = StringValue ("OfdmRate7_2MbpsBW20MHz"); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
151 |
datarate = 7.2; |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
152 |
} |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
153 |
else if (mcs == 9) |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
154 |
{ |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
155 |
DataRate = StringValue ("OfdmRate14_4MbpsBW20MHz"); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
156 |
datarate = 14.4; |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
157 |
} |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
158 |
else if (mcs == 10) |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
159 |
{ |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
160 |
DataRate = StringValue ("OfdmRate21_7MbpsBW20MHz"); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
161 |
datarate = 21.7; |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
162 |
} |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
163 |
else if (mcs == 11) |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
164 |
{ |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
165 |
DataRate = StringValue ("OfdmRate28_9MbpsBW20MHz"); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
166 |
datarate = 28.9; |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
167 |
} |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
168 |
else if (mcs == 12) |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
169 |
{ |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
170 |
DataRate = StringValue ("OfdmRate43_3MbpsBW20MHz"); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
171 |
datarate = 43.3; |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
172 |
} |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
173 |
else if (mcs == 13) |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
174 |
{ |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
175 |
DataRate = StringValue ("OfdmRate57_8MbpsBW20MHz"); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
176 |
datarate = 57.8; |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
177 |
} |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
178 |
else if (mcs == 14) |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
179 |
{ |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
180 |
DataRate = StringValue ("OfdmRate65MbpsBW20MHzShGi"); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
181 |
datarate = 65; |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
182 |
} |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
183 |
else if (mcs == 15) |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
184 |
{ |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
185 |
DataRate = StringValue ("OfdmRate72_2MbpsBW20MHz"); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
186 |
datarate = 72.2; |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
187 |
} |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
188 |
else if (mcs == 16) |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
189 |
{ |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
190 |
DataRate = StringValue ("OfdmRate13_5MbpsBW40MHz"); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
191 |
datarate = 13.5; |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
192 |
} |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
193 |
else if (mcs == 17) |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
194 |
{ |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
195 |
DataRate = StringValue ("OfdmRate27MbpsBW40MHz"); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
196 |
datarate = 27; |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
197 |
} |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
198 |
else if (mcs == 18) |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
199 |
{ |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
200 |
DataRate = StringValue ("OfdmRate40_5MbpsBW40MHz"); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
201 |
datarate = 40.5; |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
202 |
} |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
203 |
else if (mcs == 19) |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
204 |
{ |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
205 |
DataRate = StringValue ("OfdmRate54MbpsBW40MHz"); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
206 |
datarate = 54; |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
207 |
} |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
208 |
else if (mcs == 20) |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
209 |
{ |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
210 |
DataRate = StringValue ("OfdmRate81MbpsBW40MHz"); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
211 |
datarate = 81; |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
212 |
} |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
213 |
else if (mcs == 21) |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
214 |
{ |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
215 |
DataRate = StringValue ("OfdmRate108MbpsBW40MHz"); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
216 |
datarate = 108; |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
217 |
} |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
218 |
else if (mcs == 22) |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
219 |
{ |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
220 |
DataRate = StringValue ("OfdmRate121_5MbpsBW40MHz"); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
221 |
datarate = 121.5; |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
222 |
} |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
223 |
else if (mcs == 23) |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
224 |
{ |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
225 |
DataRate = StringValue ("OfdmRate135MbpsBW40MHz"); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
226 |
datarate = 135; |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
227 |
} |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
228 |
else if (mcs == 24) |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
229 |
{ |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
230 |
DataRate = StringValue ("OfdmRate15MbpsBW40MHz"); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
231 |
datarate = 15; |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
232 |
} |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
233 |
else if (mcs == 25) |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
234 |
{ |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
235 |
DataRate = StringValue ("OfdmRate30MbpsBW40MHz"); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
236 |
datarate = 30; |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
237 |
} |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
238 |
else if (mcs == 26) |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
239 |
{ |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
240 |
DataRate = StringValue ("OfdmRate45MbpsBW40MHz"); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
241 |
datarate = 45; |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
242 |
} |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
243 |
else if (mcs == 27) |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
244 |
{ |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
245 |
DataRate = StringValue ("OfdmRate60MbpsBW40MHz"); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
246 |
datarate = 60; |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
247 |
} |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
248 |
else if (mcs == 28) |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
249 |
{ |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
250 |
DataRate = StringValue ("OfdmRate90MbpsBW40MHz"); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
251 |
datarate = 90; |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
252 |
} |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
253 |
else if (mcs == 29) |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
254 |
{ |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
255 |
DataRate = StringValue ("OfdmRate120MbpsBW40MHz"); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
256 |
datarate = 120; |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
257 |
} |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
258 |
else if (mcs == 30) |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
259 |
{ |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
260 |
DataRate = StringValue ("OfdmRate135MbpsBW40MHzShGi"); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
261 |
datarate = 135; |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
262 |
} |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
263 |
else |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
264 |
{ |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
265 |
DataRate = StringValue ("OfdmRate150MbpsBW40MHz"); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
266 |
datarate = 150; |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
267 |
} |
10139 | 268 |
|
11197
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
269 |
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager","DataMode", DataRate, |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
270 |
"ControlMode", DataRate); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
271 |
mac.SetType ("ns3::StaWifiMac", |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
272 |
"Ssid", SsidValue (ssid), |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
273 |
"ActiveProbing", BooleanValue (false)); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
274 |
|
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
275 |
NetDeviceContainer staDevice; |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
276 |
staDevice = wifi.Install (phy, mac, wifiStaNode); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
277 |
|
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
278 |
mac.SetType ("ns3::ApWifiMac", |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
279 |
"Ssid", SsidValue (ssid)); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
280 |
|
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
281 |
NetDeviceContainer apDevice; |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
282 |
apDevice = wifi.Install (phy, mac, wifiApNode); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
283 |
|
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
284 |
// mobility. |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
285 |
MobilityHelper mobility; |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
286 |
Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> (); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
287 |
|
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
288 |
positionAlloc->Add (Vector (0.0, 0.0, 0.0)); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
289 |
positionAlloc->Add (Vector (1.0, 0.0, 0.0)); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
290 |
mobility.SetPositionAllocator (positionAlloc); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
291 |
|
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
292 |
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); |
10139 | 293 |
|
11197
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
294 |
mobility.Install (wifiApNode); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
295 |
mobility.Install (wifiStaNode); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
296 |
|
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
297 |
/* Internet stack*/ |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
298 |
InternetStackHelper stack; |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
299 |
stack.Install (wifiApNode); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
300 |
stack.Install (wifiStaNode); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
301 |
|
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
302 |
Ipv4AddressHelper address; |
10139 | 303 |
|
11197
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
304 |
address.SetBase ("192.168.1.0", "255.255.255.0"); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
305 |
Ipv4InterfaceContainer staNodeInterface; |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
306 |
Ipv4InterfaceContainer apNodeInterface; |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
307 |
|
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
308 |
staNodeInterface = address.Assign (staDevice); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
309 |
apNodeInterface = address.Assign (apDevice); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
310 |
|
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
311 |
/* Setting applications */ |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
312 |
ApplicationContainer serverApp, sinkApp; |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
313 |
if (udp) |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
314 |
{ |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
315 |
//UDP flow |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
316 |
UdpServerHelper myServer (9); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
317 |
serverApp = myServer.Install (wifiStaNode.Get (0)); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
318 |
serverApp.Start (Seconds (0.0)); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
319 |
serverApp.Stop (Seconds (simulationTime+1)); |
10139 | 320 |
|
11197
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
321 |
UdpClientHelper myClient (staNodeInterface.GetAddress (0), 9); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
322 |
myClient.SetAttribute ("MaxPackets", UintegerValue (4294967295)); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
323 |
myClient.SetAttribute ("Interval", TimeValue (Time ("0.00002"))); //packets/s |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
324 |
myClient.SetAttribute ("PacketSize", UintegerValue (payloadSize)); |
10139 | 325 |
|
11197
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
326 |
ApplicationContainer clientApp = myClient.Install (wifiApNode.Get (0)); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
327 |
clientApp.Start (Seconds (1.0)); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
328 |
clientApp.Stop (Seconds (simulationTime+1)); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
329 |
} |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
330 |
else |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
331 |
{ |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
332 |
//TCP flow |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
333 |
uint16_t port = 50000; |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
334 |
Address apLocalAddress (InetSocketAddress (Ipv4Address::GetAny (), port)); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
335 |
PacketSinkHelper packetSinkHelper ("ns3::TcpSocketFactory", apLocalAddress); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
336 |
sinkApp = packetSinkHelper.Install (wifiStaNode.Get (0)); |
10139 | 337 |
|
11197
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
338 |
sinkApp.Start (Seconds (0.0)); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
339 |
sinkApp.Stop (Seconds (simulationTime+1)); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
340 |
|
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
341 |
OnOffHelper onoff ("ns3::TcpSocketFactory",Ipv4Address::GetAny ()); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
342 |
onoff.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]")); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
343 |
onoff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]")); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
344 |
onoff.SetAttribute ("PacketSize", UintegerValue (payloadSize)); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
345 |
onoff.SetAttribute ("DataRate", DataRateValue (1000000000)); //bit/s |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
346 |
ApplicationContainer apps; |
10139 | 347 |
|
11197
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
348 |
AddressValue remoteAddress (InetSocketAddress (staNodeInterface.GetAddress (0), port)); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
349 |
onoff.SetAttribute ("Remote", remoteAddress); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
350 |
apps.Add (onoff.Install (wifiApNode.Get (0))); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
351 |
apps.Start (Seconds (1.0)); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
352 |
apps.Stop (Seconds (simulationTime+1)); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
353 |
} |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
354 |
|
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
355 |
Ipv4GlobalRoutingHelper::PopulateRoutingTables (); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
356 |
|
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
357 |
Simulator::Stop (Seconds (simulationTime+1)); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
358 |
Simulator::Run (); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
359 |
Simulator::Destroy (); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
360 |
|
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
361 |
double throughput = 0; |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
362 |
if (udp) |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
363 |
{ |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
364 |
//UDP |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
365 |
uint32_t totalPacketsThrough = DynamicCast<UdpServer> (serverApp.Get (0))->GetReceived (); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
366 |
throughput = totalPacketsThrough * payloadSize * 8 / (simulationTime * 1000000.0); //Mbit/s |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
367 |
} |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
368 |
else |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
369 |
{ |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
370 |
//TCP |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
371 |
uint32_t totalPacketsThrough = DynamicCast<PacketSink> (sinkApp.Get (0))->GetTotalRx (); |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
372 |
throughput = totalPacketsThrough * 8 / (simulationTime * 1000000.0); //Mbit/s |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
373 |
} |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
374 |
std::cout << datarate << "\t\t" << throughput << " Mbit/s" << std::endl; |
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
375 |
} |
10139 | 376 |
return 0; |
11197
e6c47334f36c
improve ht-wifi-network example
Sébastien Deronne <sebastien.deronne@gmail.com>
parents:
10963
diff
changeset
|
377 |
} |