1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 /* 3 * Copyright (c) 2009 University of Washington 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 * 18 * Author: Leonard Tracy <lentracy@gmail.com> 19 */ 20 21 #ifndef UAN_CW_EXAMPLE_H 22 #define UAN_CW_EXAMPLE_H 23 24 #include "ns3/network-module.h" 25 #include "ns3/stats-module.h" 26 #include "ns3/uan-module.h" 27 28 using namespace ns3; 29 30 /** 31 * \ingroup uan 32 * \brief Helper class for UAN CW MAC example. 33 * 34 * An experiment measures the average throughput for a series of CW values. 35 * 36 * \see uan-cw-example.cc 37 */ 38 class Experiment 39 { 40 public: 41 /** 42 * Run an experiment across a range of congestion window values. 43 * 44 * \param uan The Uan stack helper to configure nodes in the model. 45 * \return The data set of CW values and measured throughput 46 */ 47 Gnuplot2dDataset Run (UanHelper &uan); 48 /** 49 * Receive all available packets from a socket. 50 * 51 * \param socket The receive socket. 52 */ 53 void ReceivePacket (Ptr<Socket> socket); 54 /** 55 * Assign new random positions to a set of nodes. New positions 56 * are randomly assigned within the bounding box. 57 * 58 * \param nodes The nodes to reposition. 59 */ 60 void UpdatePositions (NodeContainer &nodes); 61 /** Save the throughput from a single run. */ 62 void ResetData (); 63 /** 64 * Compute average throughput for a set of runs, then increment CW. 65 * 66 * \param cw CW value for completed runs. 67 */ 68 void IncrementCw (uint32_t cw); 69 70 uint32_t m_numNodes; //!< Number of transmitting nodes. 71 uint32_t m_dataRate; //!< DataRate in bps. 72 double m_depth; //!< Depth of transmitting and sink nodes. 73 double m_boundary; //!< Size of boundary in meters. 74 uint32_t m_packetSize; //!< Generated packet size in bytes. 75 uint32_t m_bytesTotal; //!< Total bytes received. 76 uint32_t m_cwMin; //!< Min CW to simulate. 77 uint32_t m_cwMax; //!< Max CW to simulate. 78 uint32_t m_cwStep; //!< CW step size, default 10. 79 uint32_t m_avgs; //!< Number of topologies to test for each cw point. 80 81 Time m_slotTime; //!< Slot time duration. 82 Time m_simTime; //!< Simulation run time, default 1000 s. 83 84 std::string m_gnudatfile; //!< Name for GNU Plot output, default uan-cw-example.gpl. 85 std::string m_asciitracefile; //!< Name for ascii trace file, default uan-cw-example.asc. 86 std::string m_bhCfgFile; //!< (Unused) 87 88 Gnuplot2dDataset m_data; //!< Container for the simulation data. 89 std::vector<double> m_throughputs; //!< Throughput for each run. 90 91 /** Default constructor. */ 92 Experiment (); 93 }; 94 95 #endif /* UAN_CW_EXAMPLE_H */ 96