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 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 /** Constructor |
| 78 * \param aps the collection of APs |
| 79 * \param stas tje collection of STAs |
| 80 */ |
77 NodeStatistics (NetDeviceContainer aps, NetDeviceContainer stas); | 81 NodeStatistics (NetDeviceContainer aps, NetDeviceContainer stas); |
78 | 82 |
| 83 /** |
| 84 * Check statistics function |
| 85 * \param time the time to collect at |
| 86 */ |
79 void CheckStatistics (double time); | 87 void CheckStatistics (double time); |
80 | 88 |
| 89 /** |
| 90 * Phy callback function |
| 91 * \param path the path name |
| 92 * \param packet the packet |
| 93 */ |
81 void PhyCallback (std::string path, Ptr<const Packet> packet); | 94 void PhyCallback (std::string path, Ptr<const Packet> packet); |
| 95 /** |
| 96 * Receive callback function |
| 97 * \param path the path name |
| 98 * \param packet the packet |
| 99 * \param from the from address |
| 100 */ |
82 void RxCallback (std::string path, Ptr<const Packet> packet, const Address &fr
om); | 101 void RxCallback (std::string path, Ptr<const Packet> packet, const Address &fr
om); |
| 102 /** |
| 103 * Power callback function |
| 104 * \param path the path name |
| 105 * \param oldPower the old power value |
| 106 * \param newPower the new power value |
| 107 * \param dest the destination MAC address |
| 108 */ |
83 void PowerCallback (std::string path, double oldPower, double newPower, Mac48A
ddress dest); | 109 void PowerCallback (std::string path, double oldPower, double newPower, Mac48A
ddress dest); |
| 110 /** |
| 111 * Rate callback function |
| 112 * \param path the path name |
| 113 * \param oldRate the old rate value |
| 114 * \param newRate the new rate value |
| 115 * \param dest the destination MAC address |
| 116 */ |
84 void RateCallback (std::string path, DataRate oldRate, DataRate newRate, Mac48
Address dest); | 117 void RateCallback (std::string path, DataRate oldRate, DataRate newRate, Mac48
Address dest); |
| 118 /** |
| 119 * State callback function |
| 120 * \param path the path name |
| 121 * \param init the initial time |
| 122 * \param duration the duration time |
| 123 * \param state the wifi state |
| 124 */ |
85 void StateCallback (std::string path, Time init, Time duration, enum WifiPhy::
State state); | 125 void StateCallback (std::string path, Time init, Time duration, enum WifiPhy::
State state); |
86 | 126 |
| 127 /** |
| 128 * Get data file function |
| 129 * \returns the dataset |
| 130 */ |
87 Gnuplot2dDataset GetDatafile (); | 131 Gnuplot2dDataset GetDatafile (); |
| 132 /** |
| 133 * Get power data file function |
| 134 * \returns the power dataset |
| 135 */ |
88 Gnuplot2dDataset GetPowerDatafile (); | 136 Gnuplot2dDataset GetPowerDatafile (); |
| 137 /** |
| 138 * Get idle data file function |
| 139 * \returns the idle dataset |
| 140 */ |
89 Gnuplot2dDataset GetIdleDatafile (); | 141 Gnuplot2dDataset GetIdleDatafile (); |
| 142 /** |
| 143 * Get busy data file function |
| 144 * \returns the busy dataset |
| 145 */ |
90 Gnuplot2dDataset GetBusyDatafile (); | 146 Gnuplot2dDataset GetBusyDatafile (); |
| 147 /** |
| 148 * Get transmit data file function |
| 149 * \returns the transmit dataset |
| 150 */ |
91 Gnuplot2dDataset GetTxDatafile (); | 151 Gnuplot2dDataset GetTxDatafile (); |
| 152 /** |
| 153 * Get Receive data file function |
| 154 * \returns the receive dataset |
| 155 */ |
92 Gnuplot2dDataset GetRxDatafile (); | 156 Gnuplot2dDataset GetRxDatafile (); |
93 | 157 |
| 158 /** |
| 159 * Get busy time function |
| 160 * \returns the bust time |
| 161 */ |
94 double GetBusyTime (); | 162 double GetBusyTime (); |
95 | 163 |
96 private: | 164 private: |
| 165 /// TxTime typedef |
97 typedef std::vector<std::pair<Time, DataRate> > TxTime; | 166 typedef std::vector<std::pair<Time, DataRate> > TxTime; |
| 167 /** |
| 168 * Setup phy layer |
| 169 * \param phy the phy layer |
| 170 */ |
98 void SetupPhy (Ptr<WifiPhy> phy); | 171 void SetupPhy (Ptr<WifiPhy> phy); |
| 172 /** |
| 173 * Calculate transmit time function |
| 174 * \param rate the mode |
| 175 * \returns the transmit time |
| 176 */ |
99 Time GetCalcTxTime (DataRate rate); | 177 Time GetCalcTxTime (DataRate rate); |
100 | 178 |
101 std::map<Mac48Address, double> currentPower; | 179 std::map<Mac48Address, double> currentPower; ///< current power |
102 std::map<Mac48Address, DataRate> currentRate; | 180 std::map<Mac48Address, DataRate> currentRate; ///< current rate |
103 uint32_t m_bytesTotal; | 181 uint32_t m_bytesTotal; ///< total bytes received |
104 double totalEnergy; | 182 double totalEnergy; ///< total transmit energy |
105 double totalTime; | 183 double totalTime; ///< total transmit time |
106 double busyTime; | 184 double busyTime; ///< busy time per period |
107 double idleTime; | 185 double idleTime; ///< idle time per period |
108 double txTime; | 186 double txTime; ///< transmit time per period |
109 double rxTime; | 187 double rxTime; ///< receive time per period |
110 double totalBusyTime; | 188 double totalBusyTime; ///< total busy time |
111 double totalIdleTime; | 189 double totalIdleTime; ///< total idle time |
112 double totalTxTime; | 190 double totalTxTime; ///< total transmit time |
113 double totalRxTime; | 191 double totalRxTime; ///< total receive time |
114 Ptr<WifiPhy> myPhy; | 192 Ptr<WifiPhy> myPhy; ///< Phy object |
115 TxTime timeTable; | 193 TxTime timeTable; ///< transmit time allocation |
116 Gnuplot2dDataset m_output; | 194 Gnuplot2dDataset m_output; ///< output dataset |
117 Gnuplot2dDataset m_output_power; | 195 Gnuplot2dDataset m_output_power; ///< output power dataset |
118 Gnuplot2dDataset m_output_idle; | 196 Gnuplot2dDataset m_output_idle; ///< output idle dataset |
119 Gnuplot2dDataset m_output_busy; | 197 Gnuplot2dDataset m_output_busy; ///< output busy dataset |
120 Gnuplot2dDataset m_output_rx; | 198 Gnuplot2dDataset m_output_rx; ///< output receive dataset |
121 Gnuplot2dDataset m_output_tx; | 199 Gnuplot2dDataset m_output_tx; ///< output transmit dataset |
122 }; | 200 }; |
123 | 201 |
124 NodeStatistics::NodeStatistics (NetDeviceContainer aps, NetDeviceContainer stas) | 202 NodeStatistics::NodeStatistics (NetDeviceContainer aps, NetDeviceContainer stas) |
125 { | 203 { |
126 Ptr<NetDevice> device = aps.Get (0); | 204 Ptr<NetDevice> device = aps.Get (0); |
127 Ptr<WifiNetDevice> wifiDevice = DynamicCast<WifiNetDevice> (device); | 205 Ptr<WifiNetDevice> wifiDevice = DynamicCast<WifiNetDevice> (device); |
128 Ptr<WifiPhy> phy = wifiDevice->GetPhy (); | 206 Ptr<WifiPhy> phy = wifiDevice->GetPhy (); |
129 myPhy = phy; | 207 myPhy = phy; |
130 SetupPhy (phy); | 208 SetupPhy (phy); |
131 DataRate dataRate = DataRate (phy->GetMode (0).GetDataRate (phy->GetChannelWid
th ())); | 209 DataRate dataRate = DataRate (phy->GetMode (0).GetDataRate (phy->GetChannelWid
th ())); |
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 gnuplot.SetTerminal ("post eps color enhanced"); | 729 gnuplot.SetTerminal ("post eps color enhanced"); |
652 gnuplot.SetLegend ("Time (seconds)", "Percent"); | 730 gnuplot.SetLegend ("Time (seconds)", "Percent"); |
653 gnuplot.SetTitle ("Percentage time AP1 in Idle state vs time"); | 731 gnuplot.SetTitle ("Percentage time AP1 in Idle state vs time"); |
654 gnuplot.AddDataset (statisticsAp1.GetIdleDatafile ()); | 732 gnuplot.AddDataset (statisticsAp1.GetIdleDatafile ()); |
655 gnuplot.GenerateOutput (outfileIdle1); | 733 gnuplot.GenerateOutput (outfileIdle1); |
656 | 734 |
657 Simulator::Destroy (); | 735 Simulator::Destroy (); |
658 | 736 |
659 return 0; | 737 return 0; |
660 } | 738 } |
OLD | NEW |