OLD | NEW |
(Empty) | |
| 1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
| 2 // |
| 3 // Copyright (c) 2009 Universita' di Firenze |
| 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: Tommaso Pecorella <tommaso.pecorella@unifi.it> |
| 19 // |
| 20 |
| 21 #ifndef __wimax_2irp_application_h__ |
| 22 #define __wimax_2irp_application_h__ |
| 23 |
| 24 #include "ns3/address.h" |
| 25 #include "ns3/application.h" |
| 26 #include "ns3/event-id.h" |
| 27 #include "ns3/ptr.h" |
| 28 #include "ns3/data-rate.h" |
| 29 #include "ns3/random-variable.h" |
| 30 #include "ns3/traced-callback.h" |
| 31 |
| 32 namespace ns3 { |
| 33 |
| 34 class Address; |
| 35 class RandomVariable; |
| 36 class Socket; |
| 37 |
| 38 /** |
| 39 * \ingroup wimax |
| 40 * |
| 41 * \brief Generate traffic to a single destination according to a |
| 42 * 2IRP pattern. |
| 43 * |
| 44 * The model is based on two Interrupted Renewal Process (IRP). |
| 45 * 2IRP represent one packet video source. |
| 46 * Each 2IRP generates traffic between the hub and the subscriber unit. |
| 47 |
| 48 * This traffic generator follows an On/Off pattern: after Application::StartApp
lication |
| 49 * is called, "On" and "Off" states alternate. The duration of each of |
| 50 * these states follow an Pareto distribution. |
| 51 * During the "Off" state, no traffic is generated. |
| 52 * During the "On" state, traffic is generated with a Poisson distribution. This
traffic is |
| 53 * characterized by the specified "data rate" and "packet size". |
| 54 * |
| 55 * Please read "Traffic Model for 802.16 TG3 MAC/PHY Simulations" |
| 56 * http://www.ieee802.org/16/tg3/contrib/802163c-01_30r1.pdf |
| 57 * for further details. |
| 58 */ |
| 59 class Wimax2irpApplication : public Application |
| 60 { |
| 61 public: |
| 62 static TypeId GetTypeId (void); |
| 63 |
| 64 Wimax2irpApplication (); |
| 65 |
| 66 virtual ~Wimax2irpApplication (); |
| 67 |
| 68 void SetMaxBytes (uint32_t maxBytes); |
| 69 |
| 70 protected: |
| 71 virtual void DoDispose (void); |
| 72 private: |
| 73 // inherited from Application base class. |
| 74 virtual void StartApplication (void); // Called at time specified by Start |
| 75 virtual void StopApplication (void); // Called at time specified by Stop |
| 76 |
| 77 // helpers |
| 78 void CancelEvents (int genID); |
| 79 |
| 80 void Construct (Ptr<Node> n, |
| 81 const Address &remote, |
| 82 std::string tid, |
| 83 uint32_t size); |
| 84 |
| 85 |
| 86 // Event handlers |
| 87 void StartSending (int genID); |
| 88 void StopSending (int genID); |
| 89 void SendPacket (int genID); |
| 90 |
| 91 Ptr<Socket> m_socket; // Associated socket |
| 92 Address m_peer; // Peer address |
| 93 bool m_connected; // True if connected |
| 94 ParetoVariable m_onTime[2]; // rng for On Time |
| 95 ParetoVariable m_offTime[2]; // rng for Off Time |
| 96 ExponentialVariable m_pktTime[2]; // rng for Packet Time |
| 97 double m_basicOnRate[2]; // basic On rate, to be rescaled |
| 98 double m_basicOffRate[2]; // basic Off rate, to be rescaled |
| 99 double m_basicPktRate[2]; // basic packet rate, to be rescaled |
| 100 DataRate m_rate; // Rate that data is generated |
| 101 uint32_t m_pktSize; // Size of packets |
| 102 uint32_t m_maxBytes; // Limit total number of bytes sent |
| 103 uint32_t m_totBytes; // Total bytes sent so far |
| 104 EventId m_startStopEvent[2]; // Event id for next start or stop ev
ent |
| 105 EventId m_sendEvent[2]; // Eventid of pending "send packet" event |
| 106 bool m_sending[2]; // True if currently in sending state |
| 107 TypeId m_tid; |
| 108 TracedCallback<Ptr<const Packet> > m_txTrace; |
| 109 |
| 110 private: |
| 111 void ScheduleNextTx (int genID); |
| 112 void ScheduleStartEvent (int genID); |
| 113 void ScheduleStopEvent (int genID); |
| 114 void ConnectionSucceeded (Ptr<Socket>); |
| 115 void ConnectionFailed (Ptr<Socket>); |
| 116 void Ignore (Ptr<Socket>); |
| 117 }; |
| 118 |
| 119 } // namespace ns3 |
| 120 |
| 121 #endif |
| 122 |
OLD | NEW |