OLD | NEW |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2014 Universidad de la República - Uruguay | 3 * Copyright (c) 2014 Universidad de la República - Uruguay |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 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 | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 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 | 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 | 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 * | 17 * |
18 * Author: Matias Richart <mrichart@fing.edu.uy> | 18 * Author: Matias Richart <mrichart@fing.edu.uy> |
19 */ | 19 */ |
20 | 20 |
21 /** | 21 /** |
22 * This example program is designed to illustrate the behavior of two | 22 * This example program is designed to illustrate the behavior of three |
23 * power/rate-adaptive WiFi rate controls; namely, ns3::ParfWifiManager | 23 * power/rate-adaptive WiFi rate controls; namely, ns3::ParfWifiManager, |
24 * and ns3::AparfWifiManager. | 24 * ns3::AparfWifiManager and ns3::RrpaaWifiManager. |
25 * | 25 * |
26 * This simulation consist of 4 nodes, two APs and two STAs. | 26 * This simulation consist of 4 nodes, two APs and two STAs. |
27 * The APs generates UDP traffic with a CBR of 54 Mbps to the STAs. | 27 * The APs generates UDP traffic with a CBR of 54 Mbps to the STAs. |
28 * The APa use any power and rate control mechanism, and the STAs use only | 28 * The APa use any power and rate control mechanism, and the STAs use only |
29 * Minstrel rate control. | 29 * Minstrel rate control. |
30 * The STAs can be configured to be at any distance from the APs. | 30 * The STAs can be configured to be at any distance from the APs. |
31 * | 31 * |
32 * The objective is to test power and rate control in the links with | 32 * The objective is to test power and rate control in the links with |
33 * interference from the other link. | 33 * interference from the other link. |
34 * | 34 * |
(...skipping 26 matching lines...) Expand all Loading... |
61 #include "ns3/wifi-module.h" | 61 #include "ns3/wifi-module.h" |
62 #include "ns3/applications-module.h" | 62 #include "ns3/applications-module.h" |
63 #include "ns3/stats-module.h" | 63 #include "ns3/stats-module.h" |
64 #include "ns3/flow-monitor-module.h" | 64 #include "ns3/flow-monitor-module.h" |
65 | 65 |
66 using namespace ns3; | 66 using namespace ns3; |
67 using namespace std; | 67 using namespace std; |
68 | 68 |
69 NS_LOG_COMPONENT_DEFINE ("PowerAdaptationInterference"); | 69 NS_LOG_COMPONENT_DEFINE ("PowerAdaptationInterference"); |
70 | 70 |
71 // packet size generated at the AP | 71 //Packet size generated at the AP. |
72 static const uint32_t packetSize = 1420; | 72 static const uint32_t packetSize = 1420; |
73 | 73 |
74 class NodeStatistics | 74 class NodeStatistics |
75 { | 75 { |
76 public: | 76 public: |
77 NodeStatistics (NetDeviceContainer aps, NetDeviceContainer stas); | 77 NodeStatistics (NetDeviceContainer aps, NetDeviceContainer stas); |
78 | 78 |
79 void CheckStatistics (double time); | 79 void CheckStatistics (double time); |
80 | 80 |
81 void PhyCallback (std::string path, Ptr<const Packet> packet); | 81 void PhyCallback (std::string path, Ptr<const Packet> packet); |
82 void RxCallback (std::string path, Ptr<const Packet> packet, const Address &fr
om); | 82 void RxCallback (std::string path, Ptr<const Packet> packet, const Address &fr
om); |
83 void PowerCallback (std::string path, uint8_t power, Mac48Address dest); | 83 void PowerCallback (std::string path, double oldPower, double newPower, Mac48A
ddress dest); |
84 void RateCallback (std::string path, uint32_t rate, Mac48Address dest); | 84 void RateCallback (std::string path, DataRate oldRate, DataRate newRate, Mac48
Address dest); |
85 void StateCallback (std::string path, Time init, Time duration, enum WifiPhy::
State state); | 85 void StateCallback (std::string path, Time init, Time duration, enum WifiPhy::
State state); |
86 | 86 |
87 Gnuplot2dDataset GetDatafile (); | 87 Gnuplot2dDataset GetDatafile (); |
88 Gnuplot2dDataset GetPowerDatafile (); | 88 Gnuplot2dDataset GetPowerDatafile (); |
89 Gnuplot2dDataset GetIdleDatafile (); | 89 Gnuplot2dDataset GetIdleDatafile (); |
90 Gnuplot2dDataset GetBusyDatafile (); | 90 Gnuplot2dDataset GetBusyDatafile (); |
91 Gnuplot2dDataset GetTxDatafile (); | 91 Gnuplot2dDataset GetTxDatafile (); |
92 Gnuplot2dDataset GetRxDatafile (); | 92 Gnuplot2dDataset GetRxDatafile (); |
93 | 93 |
94 double GetBusyTime (); | 94 double GetBusyTime (); |
95 | 95 |
96 private: | 96 private: |
97 typedef std::vector<std::pair<Time,WifiMode> > TxTime; | 97 typedef std::vector<std::pair<Time, DataRate> > TxTime; |
98 void SetupPhy (Ptr<WifiPhy> phy); | 98 void SetupPhy (Ptr<WifiPhy> phy); |
99 Time GetCalcTxTime (WifiMode mode); | 99 Time GetCalcTxTime (DataRate rate); |
100 | 100 |
101 std::map<Mac48Address, double> actualPower; | 101 std::map<Mac48Address, double> currentPower; |
102 std::map<Mac48Address, WifiMode> actualMode; | 102 std::map<Mac48Address, DataRate> currentRate; |
103 uint32_t m_bytesTotal; | 103 uint32_t m_bytesTotal; |
104 double totalEnergy; | 104 double totalEnergy; |
105 double totalTime; | 105 double totalTime; |
106 double busyTime; | 106 double busyTime; |
107 double idleTime; | 107 double idleTime; |
108 double txTime; | 108 double txTime; |
109 double rxTime; | 109 double rxTime; |
110 double totalBusyTime; | 110 double totalBusyTime; |
111 double totalIdleTime; | 111 double totalIdleTime; |
112 double totalTxTime; | 112 double totalTxTime; |
113 double totalRxTime; | 113 double totalRxTime; |
114 Ptr<WifiPhy> myPhy; | 114 Ptr<WifiPhy> myPhy; |
115 TxTime timeTable; | 115 TxTime timeTable; |
116 Gnuplot2dDataset m_output; | 116 Gnuplot2dDataset m_output; |
117 Gnuplot2dDataset m_output_power; | 117 Gnuplot2dDataset m_output_power; |
118 Gnuplot2dDataset m_output_idle; | 118 Gnuplot2dDataset m_output_idle; |
119 Gnuplot2dDataset m_output_busy; | 119 Gnuplot2dDataset m_output_busy; |
120 Gnuplot2dDataset m_output_rx; | 120 Gnuplot2dDataset m_output_rx; |
121 Gnuplot2dDataset m_output_tx; | 121 Gnuplot2dDataset m_output_tx; |
122 }; | 122 }; |
123 | 123 |
124 NodeStatistics::NodeStatistics (NetDeviceContainer aps, NetDeviceContainer stas) | 124 NodeStatistics::NodeStatistics (NetDeviceContainer aps, NetDeviceContainer stas) |
125 { | 125 { |
126 Ptr<NetDevice> device = aps.Get (0); | 126 Ptr<NetDevice> device = aps.Get (0); |
127 Ptr<WifiNetDevice> wifiDevice = DynamicCast<WifiNetDevice> (device); | 127 Ptr<WifiNetDevice> wifiDevice = DynamicCast<WifiNetDevice> (device); |
128 Ptr<WifiPhy> phy = wifiDevice->GetPhy (); | 128 Ptr<WifiPhy> phy = wifiDevice->GetPhy (); |
129 myPhy = phy; | 129 myPhy = phy; |
130 SetupPhy (phy); | 130 SetupPhy (phy); |
| 131 DataRate dataRate = DataRate (phy->GetMode (0).GetDataRate(phy->GetChannelWidt
h())); |
| 132 double power = phy->GetTxPowerEnd(); |
131 for (uint32_t j = 0; j < stas.GetN (); j++) | 133 for (uint32_t j = 0; j < stas.GetN (); j++) |
132 { | 134 { |
133 Ptr<NetDevice> staDevice = stas.Get (j); | 135 Ptr<NetDevice> staDevice = stas.Get (j); |
134 Ptr<WifiNetDevice> wifiStaDevice = DynamicCast<WifiNetDevice> (staDevice); | 136 Ptr<WifiNetDevice> wifiStaDevice = DynamicCast<WifiNetDevice> (staDevice); |
135 Mac48Address addr = wifiStaDevice->GetMac ()->GetAddress (); | 137 Mac48Address addr = wifiStaDevice->GetMac ()->GetAddress (); |
136 actualPower[addr] = 17; | 138 currentPower[addr] = power; |
137 actualMode[addr] = phy->GetMode (0); | 139 currentRate[addr] = dataRate; |
138 } | 140 } |
139 actualMode[Mac48Address ("ff:ff:ff:ff:ff:ff")] = phy->GetMode (0); | 141 currentRate[Mac48Address ("ff:ff:ff:ff:ff:ff")] = dataRate; |
140 totalEnergy = 0; | 142 totalEnergy = 0; |
141 totalTime = 0; | 143 totalTime = 0; |
142 busyTime = 0; | 144 busyTime = 0; |
143 idleTime = 0; | 145 idleTime = 0; |
144 txTime = 0; | 146 txTime = 0; |
145 rxTime = 0; | 147 rxTime = 0; |
146 totalBusyTime = 0; | 148 totalBusyTime = 0; |
147 totalIdleTime = 0; | 149 totalIdleTime = 0; |
148 totalTxTime = 0; | 150 totalTxTime = 0; |
149 totalRxTime = 0; | 151 totalRxTime = 0; |
150 m_bytesTotal = 0; | 152 m_bytesTotal = 0; |
151 m_output.SetTitle ("Throughput Mbits/s"); | 153 m_output.SetTitle ("Throughput Mbits/s"); |
152 m_output_idle.SetTitle ("Idle Time"); | 154 m_output_idle.SetTitle ("Idle Time"); |
153 m_output_busy.SetTitle ("Busy Time"); | 155 m_output_busy.SetTitle ("Busy Time"); |
154 m_output_rx.SetTitle ("RX Time"); | 156 m_output_rx.SetTitle ("RX Time"); |
155 m_output_tx.SetTitle ("TX Time"); | 157 m_output_tx.SetTitle ("TX Time"); |
156 } | 158 } |
157 | 159 |
158 void | 160 void |
159 NodeStatistics::SetupPhy (Ptr<WifiPhy> phy) | 161 NodeStatistics::SetupPhy (Ptr<WifiPhy> phy) |
160 { | 162 { |
161 uint32_t nModes = phy->GetNModes (); | 163 uint32_t nModes = phy->GetNModes (); |
162 for (uint32_t i = 0; i < nModes; i++) | 164 for (uint32_t i = 0; i < nModes; i++) |
163 { | 165 { |
164 WifiMode mode = phy->GetMode (i); | 166 WifiMode mode = phy->GetMode (i); |
165 WifiTxVector txVector; | 167 WifiTxVector txVector; |
166 txVector.SetMode (mode); | 168 txVector.SetMode (mode); |
167 txVector.SetPreambleType (WIFI_PREAMBLE_LONG); | 169 txVector.SetPreambleType (WIFI_PREAMBLE_LONG); |
168 timeTable.push_back (std::make_pair (phy->CalculateTxDuration (packetSize,
txVector, phy->GetFrequency ()), mode)); | 170 txVector.SetChannelWidth(phy->GetChannelWidth()); |
| 171 DataRate dataRate = DataRate (mode.GetDataRate(phy->GetChannelWidth())); |
| 172 Time time = phy->CalculateTxDuration (packetSize, txVector, phy->GetFreque
ncy ()); |
| 173 NS_LOG_DEBUG (i << " " << time.GetSeconds() << " " << dataRate); |
| 174 timeTable.push_back (std::make_pair (time, dataRate)); |
169 } | 175 } |
170 } | 176 } |
171 | 177 |
172 Time | 178 Time |
173 NodeStatistics::GetCalcTxTime (WifiMode mode) | 179 NodeStatistics::GetCalcTxTime (DataRate rate) |
174 { | 180 { |
175 for (TxTime::const_iterator i = timeTable.begin (); i != timeTable.end (); i++
) | 181 for (TxTime::const_iterator i = timeTable.begin (); i != timeTable.end (); i++
) |
176 { | 182 { |
177 if (mode == i->second) | 183 if (rate == i->second) |
178 { | 184 { |
179 return i->first; | 185 return i->first; |
180 } | 186 } |
181 } | 187 } |
182 NS_ASSERT (false); | 188 NS_ASSERT (false); |
183 return Seconds (0); | 189 return Seconds (0); |
184 } | 190 } |
185 | 191 |
186 void | 192 void |
187 NodeStatistics::PhyCallback (std::string path, Ptr<const Packet> packet) | 193 NodeStatistics::PhyCallback (std::string path, Ptr<const Packet> packet) |
188 { | 194 { |
189 WifiMacHeader head; | 195 WifiMacHeader head; |
190 packet->PeekHeader (head); | 196 packet->PeekHeader (head); |
191 Mac48Address dest = head.GetAddr1 (); | 197 Mac48Address dest = head.GetAddr1 (); |
192 | 198 |
193 if (head.GetType () == WIFI_MAC_DATA) | 199 if (head.GetType () == WIFI_MAC_DATA) |
194 { | 200 { |
195 totalEnergy += pow (10.0, actualPower[dest] / 10.0) * GetCalcTxTime (actua
lMode[dest]).GetSeconds (); | 201 totalEnergy += pow (10.0, currentPower[dest] / 10.0) * GetCalcTxTime (curr
entRate[dest]).GetSeconds (); |
196 totalTime += GetCalcTxTime (actualMode[dest]).GetSeconds (); | 202 totalTime += GetCalcTxTime (currentRate[dest]).GetSeconds (); |
197 } | 203 } |
198 } | 204 } |
199 | 205 |
200 void | 206 void |
201 NodeStatistics::PowerCallback (std::string path, uint8_t power, Mac48Address des
t) | 207 NodeStatistics::PowerCallback (std::string path, double oldPower, double newPowe
r, Mac48Address dest) |
202 { | 208 { |
203 double txPowerBaseDbm = myPhy->GetTxPowerStart (); | 209 currentPower[dest] = newPower; |
204 double txPowerEndDbm = myPhy->GetTxPowerEnd (); | |
205 uint32_t nTxPower = myPhy->GetNTxPower (); | |
206 double dbm; | |
207 if (nTxPower > 1) | |
208 { | |
209 dbm = txPowerBaseDbm + power * (txPowerEndDbm - txPowerBaseDbm) / (nTxPowe
r - 1); | |
210 } | |
211 else | |
212 { | |
213 NS_ASSERT_MSG (txPowerBaseDbm == txPowerEndDbm, "cannot have TxPowerEnd !=
TxPowerStart with TxPowerLevels == 1"); | |
214 dbm = txPowerBaseDbm; | |
215 } | |
216 actualPower[dest] = dbm; | |
217 } | 210 } |
218 | 211 |
219 void | 212 void |
220 NodeStatistics::RateCallback (std::string path, uint32_t rate, Mac48Address dest
) | 213 NodeStatistics::RateCallback (std::string path, DataRate oldRate, DataRate newRa
te, Mac48Address dest) |
221 { | 214 { |
222 actualMode[dest] = myPhy->GetMode (rate); | 215 currentRate[dest] = newRate; |
223 } | 216 } |
224 | 217 |
225 void | 218 void |
226 NodeStatistics::StateCallback (std::string path, Time init, Time duration, enum
WifiPhy::State state) | 219 NodeStatistics::StateCallback (std::string path, Time init, Time duration, enum
WifiPhy::State state) |
227 { | 220 { |
228 if (state == WifiPhy::CCA_BUSY) | 221 if (state == WifiPhy::CCA_BUSY) |
229 { | 222 { |
230 busyTime += duration.GetSeconds (); | 223 busyTime += duration.GetSeconds (); |
231 totalBusyTime += duration.GetSeconds (); | 224 totalBusyTime += duration.GetSeconds (); |
232 } | 225 } |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 { | 304 { |
312 return m_output_tx; | 305 return m_output_tx; |
313 } | 306 } |
314 | 307 |
315 double | 308 double |
316 NodeStatistics::GetBusyTime () | 309 NodeStatistics::GetBusyTime () |
317 { | 310 { |
318 return totalBusyTime + totalRxTime; | 311 return totalBusyTime + totalRxTime; |
319 } | 312 } |
320 | 313 |
321 void PowerCallback (std::string path, uint8_t power, Mac48Address dest) | 314 void PowerCallback (std::string path, double oldPower, double newPower, Mac48Add
ress dest) |
322 { | 315 { |
323 NS_LOG_INFO ((Simulator::Now ()).GetSeconds () << " " << dest << " Power " <<
(int)power); | 316 NS_LOG_INFO ((Simulator::Now ()).GetSeconds () << " " << dest << " Old power="
<< oldPower << " New power=" << newPower); |
324 // end PowerCallback | |
325 } | 317 } |
326 | 318 |
327 void RateCallback (std::string path, uint32_t rate, Mac48Address dest) | 319 void RateCallback (std::string path, DataRate oldRate, DataRate newRate, Mac48Ad
dress dest) |
328 { | 320 { |
329 NS_LOG_INFO ((Simulator::Now ()).GetSeconds () << " " << dest << " Rate " <<
rate); | 321 NS_LOG_INFO ((Simulator::Now ()).GetSeconds () << " " << dest << " Old rate="
<< oldRate << " New rate=" << newRate); |
330 // end PowerCallback | |
331 } | 322 } |
332 | 323 |
333 int main (int argc, char *argv[]) | 324 int main (int argc, char *argv[]) |
334 { | 325 { |
335 //LogComponentEnable("ConstantRateWifiManager", LOG_LEVEL_FUNCTION); | 326 //LogComponentEnable("ConstantRateWifiManager", LOG_LEVEL_FUNCTION); |
336 | 327 |
337 double maxPower = 17; | 328 double maxPower = 17; |
338 double minPower = 0; | 329 double minPower = 0; |
339 uint32_t powerLevels = 18; | 330 uint32_t powerLevels = 18; |
340 | 331 |
(...skipping 22 matching lines...) Expand all Loading... |
363 cmd.AddValue ("AP1_x", "Position of AP1 in x coordinate", ap1_x); | 354 cmd.AddValue ("AP1_x", "Position of AP1 in x coordinate", ap1_x); |
364 cmd.AddValue ("AP1_y", "Position of AP1 in y coordinate", ap1_y); | 355 cmd.AddValue ("AP1_y", "Position of AP1 in y coordinate", ap1_y); |
365 cmd.AddValue ("STA1_x", "Position of STA1 in x coordinate", sta1_x); | 356 cmd.AddValue ("STA1_x", "Position of STA1 in x coordinate", sta1_x); |
366 cmd.AddValue ("STA1_y", "Position of STA1 in y coordinate", sta1_y); | 357 cmd.AddValue ("STA1_y", "Position of STA1 in y coordinate", sta1_y); |
367 cmd.AddValue ("AP2_x", "Position of AP2 in x coordinate", ap2_x); | 358 cmd.AddValue ("AP2_x", "Position of AP2 in x coordinate", ap2_x); |
368 cmd.AddValue ("AP2_y", "Position of AP2 in y coordinate", ap2_y); | 359 cmd.AddValue ("AP2_y", "Position of AP2 in y coordinate", ap2_y); |
369 cmd.AddValue ("STA2_x", "Position of STA2 in x coordinate", sta2_x); | 360 cmd.AddValue ("STA2_x", "Position of STA2 in x coordinate", sta2_x); |
370 cmd.AddValue ("STA2_y", "Position of STA2 in y coordinate", sta2_y); | 361 cmd.AddValue ("STA2_y", "Position of STA2 in y coordinate", sta2_y); |
371 cmd.Parse (argc, argv); | 362 cmd.Parse (argc, argv); |
372 | 363 |
373 // Define the APs | 364 //Define the APs |
374 NodeContainer wifiApNodes; | 365 NodeContainer wifiApNodes; |
375 wifiApNodes.Create (2); | 366 wifiApNodes.Create (2); |
376 | 367 |
377 //Define the STAs | 368 //Define the STAs |
378 NodeContainer wifiStaNodes; | 369 NodeContainer wifiStaNodes; |
379 wifiStaNodes.Create (2); | 370 wifiStaNodes.Create (2); |
380 | 371 |
381 WifiHelper wifi; | 372 WifiHelper wifi; |
382 wifi.SetStandard (WIFI_PHY_STANDARD_80211a); | 373 wifi.SetStandard (WIFI_PHY_STANDARD_80211a); |
383 WifiMacHelper wifiMac; | 374 WifiMacHelper wifiMac; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 | 411 |
421 ssid = Ssid ("AP1"); | 412 ssid = Ssid ("AP1"); |
422 wifiMac.SetType ("ns3::ApWifiMac", | 413 wifiMac.SetType ("ns3::ApWifiMac", |
423 "Ssid", SsidValue (ssid), | 414 "Ssid", SsidValue (ssid), |
424 "BeaconInterval", TimeValue (MicroSeconds (103424))); //for a
voiding collisions); | 415 "BeaconInterval", TimeValue (MicroSeconds (103424))); //for a
voiding collisions); |
425 wifiApDevices.Add (wifi.Install (wifiPhy, wifiMac, wifiApNodes.Get (1))); | 416 wifiApDevices.Add (wifi.Install (wifiPhy, wifiMac, wifiApNodes.Get (1))); |
426 | 417 |
427 wifiDevices.Add (wifiStaDevices); | 418 wifiDevices.Add (wifiStaDevices); |
428 wifiDevices.Add (wifiApDevices); | 419 wifiDevices.Add (wifiApDevices); |
429 | 420 |
430 // Configure the mobility. | 421 //Configure the mobility. |
431 MobilityHelper mobility; | 422 MobilityHelper mobility; |
432 Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator>
(); | 423 Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator>
(); |
433 positionAlloc->Add (Vector (ap1_x, ap1_y, 0.0)); | 424 positionAlloc->Add (Vector (ap1_x, ap1_y, 0.0)); |
434 positionAlloc->Add (Vector (sta1_x, sta1_y, 0.0)); | 425 positionAlloc->Add (Vector (sta1_x, sta1_y, 0.0)); |
435 positionAlloc->Add (Vector (ap2_x, ap2_y, 0.0)); | 426 positionAlloc->Add (Vector (ap2_x, ap2_y, 0.0)); |
436 positionAlloc->Add (Vector (sta2_x, sta2_y, 0.0)); | 427 positionAlloc->Add (Vector (sta2_x, sta2_y, 0.0)); |
437 mobility.SetPositionAllocator (positionAlloc); | 428 mobility.SetPositionAllocator (positionAlloc); |
438 mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); | 429 mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); |
439 mobility.Install (wifiApNodes.Get (0)); | 430 mobility.Install (wifiApNodes.Get (0)); |
440 mobility.Install (wifiStaNodes.Get (0)); | 431 mobility.Install (wifiStaNodes.Get (0)); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 statisticsAp0.CheckStatistics (1); | 504 statisticsAp0.CheckStatistics (1); |
514 statisticsAp1.CheckStatistics (1); | 505 statisticsAp1.CheckStatistics (1); |
515 | 506 |
516 //Callbacks to print every change of power and rate | 507 //Callbacks to print every change of power and rate |
517 Config::Connect ("/NodeList/[0-1]/DeviceList/*/$ns3::WifiNetDevice/RemoteStati
onManager/$" + manager + "/PowerChange", | 508 Config::Connect ("/NodeList/[0-1]/DeviceList/*/$ns3::WifiNetDevice/RemoteStati
onManager/$" + manager + "/PowerChange", |
518 MakeCallback (PowerCallback)); | 509 MakeCallback (PowerCallback)); |
519 Config::Connect ("/NodeList/[0-1]/DeviceList/*/$ns3::WifiNetDevice/RemoteStati
onManager/$" + manager + "/RateChange", | 510 Config::Connect ("/NodeList/[0-1]/DeviceList/*/$ns3::WifiNetDevice/RemoteStati
onManager/$" + manager + "/RateChange", |
520 MakeCallback (RateCallback)); | 511 MakeCallback (RateCallback)); |
521 | 512 |
522 | 513 |
523 // Calculate Throughput using Flowmonitor | 514 //Calculate Throughput using Flowmonitor |
524 // | |
525 | 515 |
526 FlowMonitorHelper flowmon; | 516 FlowMonitorHelper flowmon; |
527 Ptr<FlowMonitor> monitor = flowmon.InstallAll (); | 517 Ptr<FlowMonitor> monitor = flowmon.InstallAll (); |
528 | 518 |
529 Simulator::Stop (Seconds (simuTime)); | 519 Simulator::Stop (Seconds (simuTime)); |
530 Simulator::Run (); | 520 Simulator::Run (); |
531 | 521 |
532 Ptr<Ipv4FlowClassifier> classifier = DynamicCast<Ipv4FlowClassifier> (flowmon.
GetClassifier ()); | 522 Ptr<Ipv4FlowClassifier> classifier = DynamicCast<Ipv4FlowClassifier> (flowmon.
GetClassifier ()); |
533 std::map<FlowId, FlowMonitor::FlowStats> stats = monitor->GetFlowStats (); | 523 std::map<FlowId, FlowMonitor::FlowStats> stats = monitor->GetFlowStats (); |
534 for (std::map<FlowId, FlowMonitor::FlowStats>::const_iterator i = stats.begin
(); i != stats.end (); ++i) | 524 for (std::map<FlowId, FlowMonitor::FlowStats>::const_iterator i = stats.begin
(); i != stats.end (); ++i) |
(...skipping 24 matching lines...) Expand all Loading... |
559 //Plots for AP0 | 549 //Plots for AP0 |
560 std::ofstream outfileTh0 (("throughput-" + outputFileName + "-0.plt").c_str ()
); | 550 std::ofstream outfileTh0 (("throughput-" + outputFileName + "-0.plt").c_str ()
); |
561 Gnuplot gnuplot = Gnuplot (("throughput-" + outputFileName + "-0.eps").c_str (
), "Throughput"); | 551 Gnuplot gnuplot = Gnuplot (("throughput-" + outputFileName + "-0.eps").c_str (
), "Throughput"); |
562 gnuplot.SetTerminal ("post eps color enhanced"); | 552 gnuplot.SetTerminal ("post eps color enhanced"); |
563 gnuplot.SetLegend ("Time (seconds)", "Throughput (Mb/s)"); | 553 gnuplot.SetLegend ("Time (seconds)", "Throughput (Mb/s)"); |
564 gnuplot.SetTitle ("Throughput (AP0 to STA) vs time"); | 554 gnuplot.SetTitle ("Throughput (AP0 to STA) vs time"); |
565 gnuplot.AddDataset (statisticsAp0.GetDatafile ()); | 555 gnuplot.AddDataset (statisticsAp0.GetDatafile ()); |
566 gnuplot.GenerateOutput (outfileTh0); | 556 gnuplot.GenerateOutput (outfileTh0); |
567 | 557 |
568 if (manager.compare ("ns3::ParfWifiManager") == 0 | 558 if (manager.compare ("ns3::ParfWifiManager") == 0 |
569 || manager.compare ("ns3::AparfWifiManager") == 0) | 559 || manager.compare ("ns3::AparfWifiManager") == 0 |
| 560 || manager.compare ("ns3::RrpaaWifiManager") == 0) |
570 { | 561 { |
571 std::ofstream outfilePower0 (("power-" + outputFileName + "-0.plt").c_str
()); | 562 std::ofstream outfilePower0 (("power-" + outputFileName + "-0.plt").c_str
()); |
572 gnuplot = Gnuplot (("power-" + outputFileName + "-0.eps").c_str (), "Avera
ge Transmit Power"); | 563 gnuplot = Gnuplot (("power-" + outputFileName + "-0.eps").c_str (), "Avera
ge Transmit Power"); |
573 gnuplot.SetTerminal ("post eps color enhanced"); | 564 gnuplot.SetTerminal ("post eps color enhanced"); |
574 gnuplot.SetLegend ("Time (seconds)", "Power (mW)"); | 565 gnuplot.SetLegend ("Time (seconds)", "Power (mW)"); |
575 gnuplot.SetTitle ("Average transmit power (AP0 to STA) vs time"); | 566 gnuplot.SetTitle ("Average transmit power (AP0 to STA) vs time"); |
576 gnuplot.AddDataset (statisticsAp0.GetPowerDatafile ()); | 567 gnuplot.AddDataset (statisticsAp0.GetPowerDatafile ()); |
577 gnuplot.GenerateOutput (outfilePower0); | 568 gnuplot.GenerateOutput (outfilePower0); |
578 } | 569 } |
579 | 570 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 //Plots for AP1 | 603 //Plots for AP1 |
613 std::ofstream outfileTh1 (("throughput-" + outputFileName + "-1.plt").c_str ()
); | 604 std::ofstream outfileTh1 (("throughput-" + outputFileName + "-1.plt").c_str ()
); |
614 gnuplot = Gnuplot (("throughput-" + outputFileName + "-1.eps").c_str (), "Thro
ughput"); | 605 gnuplot = Gnuplot (("throughput-" + outputFileName + "-1.eps").c_str (), "Thro
ughput"); |
615 gnuplot.SetTerminal ("post eps color enhanced"); | 606 gnuplot.SetTerminal ("post eps color enhanced"); |
616 gnuplot.SetLegend ("Time (seconds)", "Throughput (Mb/s)"); | 607 gnuplot.SetLegend ("Time (seconds)", "Throughput (Mb/s)"); |
617 gnuplot.SetTitle ("Throughput (AP1 to STA) vs time"); | 608 gnuplot.SetTitle ("Throughput (AP1 to STA) vs time"); |
618 gnuplot.AddDataset (statisticsAp1.GetDatafile ()); | 609 gnuplot.AddDataset (statisticsAp1.GetDatafile ()); |
619 gnuplot.GenerateOutput (outfileTh1); | 610 gnuplot.GenerateOutput (outfileTh1); |
620 | 611 |
621 if (manager.compare ("ns3::ParfWifiManager") == 0 | 612 if (manager.compare ("ns3::ParfWifiManager") == 0 |
622 || manager.compare ("ns3::AparfWifiManager") == 0) | 613 || manager.compare ("ns3::AparfWifiManager") == 0 |
| 614 || manager.compare ("ns3::RrpaaWifiManager") == 0) |
623 { | 615 { |
624 std::ofstream outfilePower1 (("power-" + outputFileName + "-1.plt").c_str
()); | 616 std::ofstream outfilePower1 (("power-" + outputFileName + "-1.plt").c_str
()); |
625 gnuplot = Gnuplot (("power-" + outputFileName + "-1.eps").c_str (), "Avera
ge Transmit Power"); | 617 gnuplot = Gnuplot (("power-" + outputFileName + "-1.eps").c_str (), "Avera
ge Transmit Power"); |
626 gnuplot.SetTerminal ("post eps color enhanced"); | 618 gnuplot.SetTerminal ("post eps color enhanced"); |
627 gnuplot.SetLegend ("Time (seconds)", "Power (mW)"); | 619 gnuplot.SetLegend ("Time (seconds)", "Power (mW)"); |
628 gnuplot.SetTitle ("Average transmit power (AP1 to STA) vs time"); | 620 gnuplot.SetTitle ("Average transmit power (AP1 to STA) vs time"); |
629 gnuplot.AddDataset (statisticsAp1.GetPowerDatafile ()); | 621 gnuplot.AddDataset (statisticsAp1.GetPowerDatafile ()); |
630 gnuplot.GenerateOutput (outfilePower1); | 622 gnuplot.GenerateOutput (outfilePower1); |
631 } | 623 } |
632 | 624 |
(...skipping 26 matching lines...) Expand all Loading... |
659 gnuplot.SetTerminal ("post eps color enhanced"); | 651 gnuplot.SetTerminal ("post eps color enhanced"); |
660 gnuplot.SetLegend ("Time (seconds)", "Percent"); | 652 gnuplot.SetLegend ("Time (seconds)", "Percent"); |
661 gnuplot.SetTitle ("Percentage time AP1 in Idle state vs time"); | 653 gnuplot.SetTitle ("Percentage time AP1 in Idle state vs time"); |
662 gnuplot.AddDataset (statisticsAp1.GetIdleDatafile ()); | 654 gnuplot.AddDataset (statisticsAp1.GetIdleDatafile ()); |
663 gnuplot.GenerateOutput (outfileIdle1); | 655 gnuplot.GenerateOutput (outfileIdle1); |
664 | 656 |
665 Simulator::Destroy (); | 657 Simulator::Destroy (); |
666 | 658 |
667 return 0; | 659 return 0; |
668 } | 660 } |
OLD | NEW |