LEFT | RIGHT |
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) 2009 CTTC | 3 * Copyright (c) 2009 CTTC |
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 11 matching lines...) Expand all Loading... |
22 #define WAVEFORM_GENERATOR_H | 22 #define WAVEFORM_GENERATOR_H |
23 | 23 |
24 | 24 |
25 #include <ns3/spectrum-value.h> | 25 #include <ns3/spectrum-value.h> |
26 #include <ns3/mobility-model.h> | 26 #include <ns3/mobility-model.h> |
27 #include <ns3/packet.h> | 27 #include <ns3/packet.h> |
28 #include <ns3/nstime.h> | 28 #include <ns3/nstime.h> |
29 #include <ns3/net-device.h> | 29 #include <ns3/net-device.h> |
30 #include <ns3/spectrum-phy.h> | 30 #include <ns3/spectrum-phy.h> |
31 #include <ns3/spectrum-channel.h> | 31 #include <ns3/spectrum-channel.h> |
| 32 #include <ns3/spectrum-type.h> |
| 33 #include <ns3/trace-source-accessor.h> |
32 | 34 |
33 namespace ns3 { | 35 namespace ns3 { |
34 | 36 |
35 | 37 |
36 | 38 |
37 /** | 39 /** |
38 * Simple SpectrumPhy implementation that sends customizable waveform. | 40 * Simple SpectrumPhy implementation that sends customizable waveform. |
39 * The generated waveforms have a given Spectrum Power Density and | 41 * The generated waveforms have a given Spectrum Power Density and |
40 * duration (set with the SetResolution()) . The generator activates | 42 * duration (set with the SetResolution()) . The generator activates |
41 * and deactivates periodically with a given period and with a duty | 43 * and deactivates periodically with a given period and with a duty |
42 * cycle of 1/2. | 44 * cycle of 1/2. |
43 */ | 45 */ |
44 class WaveformGenerator : public SpectrumPhy | 46 class WaveformGenerator : public SpectrumPhy |
45 { | 47 { |
46 | 48 |
47 public: | 49 public: |
48 WaveformGenerator (); | 50 WaveformGenerator (); |
49 virtual ~WaveformGenerator (); | 51 virtual ~WaveformGenerator (); |
50 | 52 |
51 static TypeId GetTypeId (void); | 53 static TypeId GetTypeId (void); |
52 | 54 |
53 // inherited from SpectrumPhy | 55 // inherited from SpectrumPhy |
54 void SetChannel (Ptr<SpectrumChannel> c); | 56 void SetChannel (Ptr<SpectrumChannel> c); |
55 void SetMobility (Ptr<Object> m); | 57 void SetMobility (Ptr<Object> m); |
56 void SetDevice (Ptr<Object> d); | 58 void SetDevice (Ptr<Object> d); |
57 Ptr<Object> GetMobility (); | 59 Ptr<Object> GetMobility (); |
58 Ptr<Object> GetDevice (); | 60 Ptr<Object> GetDevice (); |
59 void StartRx (Ptr<Packet> p, Ptr <const SpectrumValue> rxPowerSpectrum, Spectr
umType st, Time duration); | 61 Ptr<const SpectrumModel> GetRxSpectrumModel () const; |
60 | 62 void StartRx (Ptr<Packet> p, Ptr <const SpectrumValue> rxPowerSpectrum, Spectr
umType st, Time duration); |
61 | |
62 /** | |
63 * Set the set of frequencies associated with this device. | |
64 * | |
65 * @param f the set of frequencies | |
66 */ | |
67 void SetSpectrumModel (Ptr<SpectrumModel> f); | |
68 | 63 |
69 | 64 |
70 /** | 65 /** |
71 * Set the Power Spectral Density used for outgoing waveforms | 66 * Set the Power Spectral Density used for outgoing waveforms |
72 * | 67 * |
73 * @param txs the Power Spectral Density | 68 * @param txs the Power Spectral Density |
74 */ | 69 */ |
75 void SetTxSpectrum (Ptr<SpectrumValue> txs); | 70 void SetTxPowerSpectralDensity (Ptr<SpectrumValue> txs); |
76 | 71 |
77 | 72 |
78 /** | 73 /** |
79 * Get the SpectrumType used by this PHY | 74 * Get the SpectrumType used by this PHY |
80 * | 75 * |
81 * @return | 76 * @return |
82 */ | 77 */ |
83 SpectrumType GetSpectrumType (); | 78 SpectrumType GetSpectrumType (); |
84 | 79 |
85 | 80 |
86 | 81 |
87 /** | 82 /** |
88 * Set the period according to which the WaveformGenerator switches | 83 * Set the period according to which the WaveformGenerator switches |
89 * on and off | 84 * on and off |
90 * | 85 * |
91 * @param period | 86 * @param period |
92 */ | 87 */ |
93 void SetPeriod (Time period); | 88 void SetPeriod (Time period); |
| 89 |
| 90 |
| 91 /**· |
| 92 *· |
| 93 * @return the value of the period according to which the WaveformGenerator sw
itches |
| 94 * on and off |
| 95 */ |
| 96 Time GetPeriod () const; |
| 97 ·· |
| 98 |
| 99 /**· |
| 100 *· |
| 101 * @param value the value of the duty cycle |
| 102 */ |
| 103 void SetDutyCycle (double value); |
| 104 |
| 105 /**· |
| 106 * |
| 107 * @return the value of the duty cycle |
| 108 */ |
| 109 double GetDutyCycle () const; |
| 110 |
| 111 |
94 | 112 |
95 | 113 |
96 /** | 114 /** |
97 * Set the time resolution of the generated waveforms. | 115 * Set the time resolution of the generated waveforms. |
98 * | 116 * |
99 * @param resolution time resolution of the generated | 117 * @param resolution time resolution of the generated |
100 * waveforms. This determines both the duration of waveforms, and | 118 * waveforms. This determines both the duration of waveforms, and |
101 * the time between subsequent waveforms (i.e., they are generated | 119 * the time between subsequent waveforms (i.e., they are generated |
102 * back to back during the active portion of the generator cycle). | 120 * back to back during the active portion of the generator cycle). |
103 */ | 121 */ |
(...skipping 12 matching lines...) Expand all Loading... |
116 virtual void Stop (); | 134 virtual void Stop (); |
117 | 135 |
118 | 136 |
119 private: | 137 private: |
120 Ptr<Object> m_mobility; | 138 Ptr<Object> m_mobility; |
121 Ptr<Object> m_netDevice; | 139 Ptr<Object> m_netDevice; |
122 Ptr<SpectrumChannel> m_channel; | 140 Ptr<SpectrumChannel> m_channel; |
123 | 141 |
124 virtual void GenerateWaveform (); | 142 virtual void GenerateWaveform (); |
125 | 143 |
126 Ptr<SpectrumModel> m_spectrumModel; | 144 Ptr<SpectrumValue> m_txPowerSpectralDensity; |
127 Ptr<SpectrumValue> m_txSpectrum; | 145 Time m_period; |
128 Time m_period; | 146 Scalar m_dutyCycle; |
129 Time m_startTime; | 147 Time m_startTime; |
130 Time m_resolution; | |
131 bool m_active; | 148 bool m_active; |
| 149 |
| 150 TracedCallback<Ptr<const Packet> > m_phyTxStartTrace; |
| 151 TracedCallback<Ptr<const Packet> > m_phyTxEndTrace; |
132 }; | 152 }; |
133 | 153 |
134 | 154 |
135 | 155 |
136 | 156 |
137 | 157 |
138 | 158 |
139 } | 159 } // namespace ns3 |
140 | 160 |
141 | 161 |
142 | 162 |
143 | 163 |
144 | 164 |
145 #endif /* WAVEFORM_GENERATOR_H */ | 165 #endif /* WAVEFORM_GENERATOR_H */ |
LEFT | RIGHT |