View | Details | Raw Unified | Return to bug 1271
Collapse All | Expand All

(-)a/CHANGES.html (+7 lines)
 Lines 86-91    Link Here 
86
<li> WIFI_PHY_STANDARD_80211_10Mhz was changed to WIFI_PHY_STANDARD_80211_10MHZ
86
<li> WIFI_PHY_STANDARD_80211_10Mhz was changed to WIFI_PHY_STANDARD_80211_10MHZ
87
<li> WIFI_PHY_STANDARD_80211_5Mhz was changed to WIFI_PHY_STANDARD_80211_5MHZ
87
<li> WIFI_PHY_STANDARD_80211_5Mhz was changed to WIFI_PHY_STANDARD_80211_5MHZ
88
</ul>
88
</ul>
89
<li> In the SpectrumPhy base class, the methods to get/set the
90
  MobilityModel and the NetDevice were previously working with
91
  opaque Ptr&#60;Object&#62;. Now all these methods have been
92
  changed so that they work with Ptr&#60;NetDevice&#62;
93
  and Ptr&#60;MobilityModel&#62; as appropriate. See <A href="https://www.nsnam.org/bugzilla/show_bug.cgi?id=1271">Bug 1271</A> on
94
  bugzilla for the motivation.
95
</li>
89
</ul>
96
</ul>
90
97
91
<h2>Changed behavior:</h2>
98
<h2>Changed behavior:</h2>
(-)a/src/lte/model/lte-spectrum-phy.cc (-4 / +4 lines)
 Lines 104-110    Link Here 
104
104
105
105
106
106
107
Ptr<Object>
107
Ptr<NetDevice>
108
LteSpectrumPhy::GetDevice ()
108
LteSpectrumPhy::GetDevice ()
109
{
109
{
110
  NS_LOG_FUNCTION (this);
110
  NS_LOG_FUNCTION (this);
 Lines 112-118    Link Here 
112
}
112
}
113
113
114
114
115
Ptr<Object>
115
Ptr<MobilityModel>
116
LteSpectrumPhy::GetMobility ()
116
LteSpectrumPhy::GetMobility ()
117
{
117
{
118
  NS_LOG_FUNCTION (this);
118
  NS_LOG_FUNCTION (this);
 Lines 121-127    Link Here 
121
121
122
122
123
void
123
void
124
LteSpectrumPhy::SetDevice (Ptr<Object> d)
124
LteSpectrumPhy::SetDevice (Ptr<NetDevice> d)
125
{
125
{
126
  NS_LOG_FUNCTION (this << d);
126
  NS_LOG_FUNCTION (this << d);
127
  m_device = d;
127
  m_device = d;
 Lines 129-135    Link Here 
129
129
130
130
131
void
131
void
132
LteSpectrumPhy::SetMobility (Ptr<Object> m)
132
LteSpectrumPhy::SetMobility (Ptr<MobilityModel> m)
133
{
133
{
134
  NS_LOG_FUNCTION (this << m);
134
  NS_LOG_FUNCTION (this << m);
135
  m_mobility = m;
135
  m_mobility = m;
(-)a/src/lte/model/lte-spectrum-phy.h (-6 / +6 lines)
 Lines 65-74    Link Here 
65
65
66
  // inherited from SpectrumPhy
66
  // inherited from SpectrumPhy
67
  void SetChannel (Ptr<SpectrumChannel> c);
67
  void SetChannel (Ptr<SpectrumChannel> c);
68
  void SetMobility (Ptr<Object> m);
68
  void SetMobility (Ptr<MobilityModel> m);
69
  void SetDevice (Ptr<Object> d);
69
  void SetDevice (Ptr<NetDevice> d);
70
  Ptr<Object> GetMobility ();
70
  Ptr<MobilityModel> GetMobility ();
71
  Ptr<Object> GetDevice ();
71
  Ptr<NetDevice> GetDevice ();
72
  Ptr<const SpectrumModel> GetRxSpectrumModel () const;
72
  Ptr<const SpectrumModel> GetRxSpectrumModel () const;
73
73
74
  /**
74
  /**
 Lines 182-190    Link Here 
182
182
183
  EventId m_endRxEventId;
183
  EventId m_endRxEventId;
184
184
185
  Ptr<Object> m_mobility;
185
  Ptr<MobilityModel> m_mobility;
186
186
187
  Ptr<Object> m_device;
187
  Ptr<NetDevice> m_device;
188
188
189
  Ptr<SpectrumChannel> m_channel;
189
  Ptr<SpectrumChannel> m_channel;
190
190
(-)a/src/spectrum/helper/adhoc-aloha-noack-ideal-phy-helper.cc (-1 / +1 lines)
 Lines 113-119    Link Here 
113
      dev->SetPhy (phy);
113
      dev->SetPhy (phy);
114
114
115
      NS_ASSERT (node);
115
      NS_ASSERT (node);
116
      phy->SetMobility (node);
116
      phy->SetMobility (node->GetObject<MobilityModel> ());
117
117
118
      NS_ASSERT (dev);
118
      NS_ASSERT (dev);
119
      phy->SetDevice (dev);
119
      phy->SetDevice (dev);
(-)a/src/spectrum/helper/spectrum-analyzer-helper.cc (-1 / +1 lines)
 Lines 142-148    Link Here 
142
      dev->SetPhy (phy);
142
      dev->SetPhy (phy);
143
143
144
      NS_ASSERT (node);
144
      NS_ASSERT (node);
145
      phy->SetMobility (node);
145
      phy->SetMobility (node->GetObject<MobilityModel> ());
146
146
147
      NS_ASSERT (dev);
147
      NS_ASSERT (dev);
148
      phy->SetDevice (dev);
148
      phy->SetDevice (dev);
(-)a/src/spectrum/helper/spectrum-helper.cc (-1 / +1 lines)
 Lines 215-221    Link Here 
215
  NS_ASSERT (m_channel);
215
  NS_ASSERT (m_channel);
216
  Ptr<SpectrumPhy> phy = (m_phy.Create ())->GetObject<SpectrumPhy> ();
216
  Ptr<SpectrumPhy> phy = (m_phy.Create ())->GetObject<SpectrumPhy> ();
217
  phy->SetChannel (m_channel);
217
  phy->SetChannel (m_channel);
218
  phy->SetMobility (node);
218
  phy->SetMobility (node->GetObject<MobilityModel> ());
219
  phy->SetDevice (device);
219
  phy->SetDevice (device);
220
  return phy;
220
  return phy;
221
}
221
}
(-)a/src/spectrum/helper/waveform-generator-helper.cc (-1 / +1 lines)
 Lines 98-104    Link Here 
98
      dev->SetPhy (phy);
98
      dev->SetPhy (phy);
99
99
100
      NS_ASSERT (node);
100
      NS_ASSERT (node);
101
      phy->SetMobility (node);
101
      phy->SetMobility (node->GetObject<MobilityModel> ());
102
102
103
      NS_ASSERT (dev);
103
      NS_ASSERT (dev);
104
      phy->SetDevice (dev);
104
      phy->SetDevice (dev);
(-)a/src/spectrum/model/half-duplex-ideal-phy.cc (-4 / +4 lines)
 Lines 126-132    Link Here 
126
126
127
127
128
128
129
Ptr<Object>
129
Ptr<NetDevice>
130
HalfDuplexIdealPhy::GetDevice ()
130
HalfDuplexIdealPhy::GetDevice ()
131
{
131
{
132
  NS_LOG_FUNCTION (this);
132
  NS_LOG_FUNCTION (this);
 Lines 134-140    Link Here 
134
}
134
}
135
135
136
136
137
Ptr<Object>
137
Ptr<MobilityModel>
138
HalfDuplexIdealPhy::GetMobility ()
138
HalfDuplexIdealPhy::GetMobility ()
139
{
139
{
140
  NS_LOG_FUNCTION (this);
140
  NS_LOG_FUNCTION (this);
 Lines 143-149    Link Here 
143
143
144
144
145
void
145
void
146
HalfDuplexIdealPhy::SetDevice (Ptr<Object> d)
146
HalfDuplexIdealPhy::SetDevice (Ptr<NetDevice> d)
147
{
147
{
148
  NS_LOG_FUNCTION (this << d);
148
  NS_LOG_FUNCTION (this << d);
149
  m_netDevice = d;
149
  m_netDevice = d;
 Lines 151-157    Link Here 
151
151
152
152
153
void
153
void
154
HalfDuplexIdealPhy::SetMobility (Ptr<Object> m)
154
HalfDuplexIdealPhy::SetMobility (Ptr<MobilityModel> m)
155
{
155
{
156
  NS_LOG_FUNCTION (this << m);
156
  NS_LOG_FUNCTION (this << m);
157
  m_mobility = m;
157
  m_mobility = m;
(-)a/src/spectrum/model/half-duplex-ideal-phy.h (-6 / +6 lines)
 Lines 94-103    Link Here 
94
94
95
  // inherited from SpectrumPhy
95
  // inherited from SpectrumPhy
96
  void SetChannel (Ptr<SpectrumChannel> c);
96
  void SetChannel (Ptr<SpectrumChannel> c);
97
  void SetMobility (Ptr<Object> m);
97
  void SetMobility (Ptr<MobilityModel> m);
98
  void SetDevice (Ptr<Object> d);
98
  void SetDevice (Ptr<NetDevice> d);
99
  Ptr<Object> GetMobility ();
99
  Ptr<MobilityModel> GetMobility ();
100
  Ptr<Object> GetDevice ();
100
  Ptr<NetDevice> GetDevice ();
101
  Ptr<const SpectrumModel> GetRxSpectrumModel () const;
101
  Ptr<const SpectrumModel> GetRxSpectrumModel () const;
102
  void StartRx (Ptr<PacketBurst> p, Ptr <const SpectrumValue> rxPsd, SpectrumType st, Time duration);
102
  void StartRx (Ptr<PacketBurst> p, Ptr <const SpectrumValue> rxPsd, SpectrumType st, Time duration);
103
103
 Lines 195-202    Link Here 
195
195
196
  EventId m_endRxEventId;
196
  EventId m_endRxEventId;
197
197
198
  Ptr<Object> m_mobility;
198
  Ptr<MobilityModel> m_mobility;
199
  Ptr<Object> m_netDevice;
199
  Ptr<NetDevice> m_netDevice;
200
  Ptr<SpectrumChannel> m_channel;
200
  Ptr<SpectrumChannel> m_channel;
201
201
202
  Ptr<SpectrumValue> m_txPsd;
202
  Ptr<SpectrumValue> m_txPsd;
(-)a/src/spectrum/model/multi-model-spectrum-channel.cc (-6 / +6 lines)
 Lines 222-228    Link Here 
222
  NS_ASSERT (originalTxPowerSpectrum);
222
  NS_ASSERT (originalTxPowerSpectrum);
223
223
224
224
225
  Ptr<MobilityModel> txMobility = txPhy->GetMobility ()->GetObject<MobilityModel> ();
225
  Ptr<MobilityModel> txMobility = txPhy->GetMobility ();
226
  SpectrumModelUid_t txSpectrumModelUid = originalTxPowerSpectrum->GetSpectrumModelUid ();
226
  SpectrumModelUid_t txSpectrumModelUid = originalTxPowerSpectrum->GetSpectrumModelUid ();
227
  NS_LOG_LOGIC (" txSpectrumModelUid " << txSpectrumModelUid);
227
  NS_LOG_LOGIC (" txSpectrumModelUid " << txSpectrumModelUid);
228
228
 Lines 268-274    Link Here 
268
              Ptr <SpectrumValue> rxPowerSpectrum = convertedTxPowerSpectrum->Copy ();
268
              Ptr <SpectrumValue> rxPowerSpectrum = convertedTxPowerSpectrum->Copy ();
269
              Time delay = MicroSeconds (0); 
269
              Time delay = MicroSeconds (0); 
270
270
271
              Ptr<MobilityModel> receiverMobility = (*rxPhyIterator)->GetMobility ()->GetObject<MobilityModel> ();
271
              Ptr<MobilityModel> receiverMobility = (*rxPhyIterator)->GetMobility ();
272
272
273
              if (txMobility && receiverMobility)
273
              if (txMobility && receiverMobility)
274
                {
274
                {
 Lines 296-306    Link Here 
296
                }
296
                }
297
297
298
              Ptr<PacketBurst> pktBurstCopy = p->Copy ();
298
              Ptr<PacketBurst> pktBurstCopy = p->Copy ();
299
              Ptr<Object> netDevObj = (*rxPhyIterator)->GetDevice ();
299
              Ptr<NetDevice> netDev = (*rxPhyIterator)->GetDevice ();
300
              if (netDevObj)
300
              if (netDev)
301
                {
301
                {
302
                  // the receiver has a NetDevice, so we expect that it is attached to a Node
302
                  // the receiver has a NetDevice, so we expect that it is attached to a Node
303
                  uint32_t dstNode =  netDevObj->GetObject<NetDevice> ()->GetNode ()->GetId ();
303
                  uint32_t dstNode =  netDev->GetNode ()->GetId ();
304
                  Simulator::ScheduleWithContext (dstNode, delay, &MultiModelSpectrumChannel::StartRx, this,
304
                  Simulator::ScheduleWithContext (dstNode, delay, &MultiModelSpectrumChannel::StartRx, this,
305
                                                  pktBurstCopy, rxPowerSpectrum, st, duration, *rxPhyIterator);
305
                                                  pktBurstCopy, rxPowerSpectrum, st, duration, *rxPhyIterator);
306
                }
306
                }
 Lines 337-343    Link Here 
337
Ptr<NetDevice>
337
Ptr<NetDevice>
338
MultiModelSpectrumChannel::GetDevice (uint32_t i) const
338
MultiModelSpectrumChannel::GetDevice (uint32_t i) const
339
{
339
{
340
  return m_phyVector.at (i)->GetDevice ()->GetObject<NetDevice> ();
340
  return m_phyVector.at (i)->GetDevice ();
341
}
341
}
342
342
343
343
(-)a/src/spectrum/model/single-model-spectrum-channel.cc (-5 / +5 lines)
 Lines 116-122    Link Here 
116
116
117
117
118
118
119
  Ptr<MobilityModel> senderMobility = txPhy->GetMobility ()->GetObject<MobilityModel> ();
119
  Ptr<MobilityModel> senderMobility = txPhy->GetMobility ();
120
120
121
  for (PhyList::const_iterator rxPhyIterator = m_phyList.begin ();
121
  for (PhyList::const_iterator rxPhyIterator = m_phyList.begin ();
122
       rxPhyIterator != m_phyList.end ();
122
       rxPhyIterator != m_phyList.end ();
 Lines 127-133    Link Here 
127
          Ptr <SpectrumValue> rxPsd = Copy<SpectrumValue> (txPsd);
127
          Ptr <SpectrumValue> rxPsd = Copy<SpectrumValue> (txPsd);
128
          Time delay  = MicroSeconds (0);
128
          Time delay  = MicroSeconds (0);
129
129
130
          Ptr<MobilityModel> receiverMobility = (*rxPhyIterator)->GetMobility ()->GetObject<MobilityModel> ();
130
          Ptr<MobilityModel> receiverMobility = (*rxPhyIterator)->GetMobility ();
131
131
132
          if (senderMobility && receiverMobility)
132
          if (senderMobility && receiverMobility)
133
            {
133
            {
 Lines 155-165    Link Here 
155
            }
155
            }
156
156
157
          Ptr<PacketBurst> pktBurstCopy = p->Copy ();
157
          Ptr<PacketBurst> pktBurstCopy = p->Copy ();
158
          Ptr<Object> netDevObj = (*rxPhyIterator)->GetDevice ();
158
          Ptr<NetDevice> netDev = (*rxPhyIterator)->GetDevice ();
159
          if (netDevObj)
159
          if (netDev)
160
            {
160
            {
161
              // the receiver has a NetDevice, so we expect that it is attached to a Node
161
              // the receiver has a NetDevice, so we expect that it is attached to a Node
162
              uint32_t dstNode =  netDevObj->GetObject<NetDevice> ()->GetNode ()->GetId ();
162
              uint32_t dstNode =  netDev->GetNode ()->GetId ();
163
              Simulator::ScheduleWithContext (dstNode, delay, &SingleModelSpectrumChannel::StartRx, this,
163
              Simulator::ScheduleWithContext (dstNode, delay, &SingleModelSpectrumChannel::StartRx, this,
164
                                              pktBurstCopy, rxPsd, st, duration, *rxPhyIterator);
164
                                              pktBurstCopy, rxPsd, st, duration, *rxPhyIterator);
165
            }
165
            }
(-)a/src/spectrum/model/spectrum-analyzer.cc (-4 / +4 lines)
 Lines 89-102    Link Here 
89
89
90
90
91
91
92
Ptr<Object>
92
Ptr<NetDevice>
93
SpectrumAnalyzer::GetDevice ()
93
SpectrumAnalyzer::GetDevice ()
94
{
94
{
95
  return m_netDevice;
95
  return m_netDevice;
96
}
96
}
97
97
98
98
99
Ptr<Object>
99
Ptr<MobilityModel>
100
SpectrumAnalyzer::GetMobility ()
100
SpectrumAnalyzer::GetMobility ()
101
{
101
{
102
  return m_mobility;
102
  return m_mobility;
 Lines 110-116    Link Here 
110
}
110
}
111
111
112
void
112
void
113
SpectrumAnalyzer::SetDevice (Ptr<Object> d)
113
SpectrumAnalyzer::SetDevice (Ptr<NetDevice> d)
114
{
114
{
115
  NS_LOG_FUNCTION (this << d);
115
  NS_LOG_FUNCTION (this << d);
116
  m_netDevice = d;
116
  m_netDevice = d;
 Lines 118-124    Link Here 
118
118
119
119
120
void
120
void
121
SpectrumAnalyzer::SetMobility (Ptr<Object> m)
121
SpectrumAnalyzer::SetMobility (Ptr<MobilityModel> m)
122
{
122
{
123
  NS_LOG_FUNCTION (this << m);
123
  NS_LOG_FUNCTION (this << m);
124
  m_mobility = m;
124
  m_mobility = m;
(-)a/src/spectrum/model/spectrum-analyzer.h (-6 / +6 lines)
 Lines 53-62    Link Here 
53
53
54
// inherited from SpectrumPhy
54
// inherited from SpectrumPhy
55
  void SetChannel (Ptr<SpectrumChannel> c);
55
  void SetChannel (Ptr<SpectrumChannel> c);
56
  void SetMobility (Ptr<Object> m);
56
  void SetMobility (Ptr<MobilityModel> m);
57
  void SetDevice (Ptr<Object> d);
57
  void SetDevice (Ptr<NetDevice> d);
58
  Ptr<Object> GetMobility ();
58
  Ptr<MobilityModel> GetMobility ();
59
  Ptr<Object> GetDevice ();
59
  Ptr<NetDevice> GetDevice ();
60
  Ptr<const SpectrumModel> GetRxSpectrumModel () const;
60
  Ptr<const SpectrumModel> GetRxSpectrumModel () const;
61
  void StartRx (Ptr<PacketBurst> pb, Ptr <const SpectrumValue> rxPowerSpectralDensity, SpectrumType st, Time duration);
61
  void StartRx (Ptr<PacketBurst> pb, Ptr <const SpectrumValue> rxPowerSpectralDensity, SpectrumType st, Time duration);
62
62
 Lines 86-93    Link Here 
86
  void DoDispose ();
86
  void DoDispose ();
87
87
88
private:
88
private:
89
  Ptr<Object> m_mobility;
89
  Ptr<MobilityModel> m_mobility;
90
  Ptr<Object> m_netDevice;
90
  Ptr<NetDevice> m_netDevice;
91
  Ptr<SpectrumChannel> m_channel;
91
  Ptr<SpectrumChannel> m_channel;
92
92
93
  virtual void GenerateReport ();
93
  virtual void GenerateReport ();
(-)a/src/spectrum/model/spectrum-phy.h (-4 / +4 lines)
 Lines 54-81    Link Here 
54
   *
54
   *
55
   * @param d the NetDevice instance
55
   * @param d the NetDevice instance
56
   */
56
   */
57
  virtual void SetDevice (Ptr<Object> d) = 0;
57
  virtual void SetDevice (Ptr<NetDevice> d) = 0;
58
58
59
  /**
59
  /**
60
   * get the associated NetDevice instance
60
   * get the associated NetDevice instance
61
   *
61
   *
62
   * @return a Ptr to the associated NetDevice instance
62
   * @return a Ptr to the associated NetDevice instance
63
   */
63
   */
64
  virtual Ptr<Object> GetDevice () = 0;
64
  virtual Ptr<NetDevice> GetDevice () = 0;
65
65
66
  /**
66
  /**
67
   * Set the mobility model associated with this device.
67
   * Set the mobility model associated with this device.
68
   *
68
   *
69
   * @param m the mobility model
69
   * @param m the mobility model
70
   */
70
   */
71
  virtual void SetMobility (Ptr<Object> m) = 0;
71
  virtual void SetMobility (Ptr<MobilityModel> m) = 0;
72
72
73
  /**
73
  /**
74
   * get the associated MobilityModel instance
74
   * get the associated MobilityModel instance
75
   *
75
   *
76
   * @return a Ptr to the associated NetDevice instance
76
   * @return a Ptr to the associated NetDevice instance
77
   */
77
   */
78
  virtual Ptr<Object> GetMobility () = 0;
78
  virtual Ptr<MobilityModel> GetMobility () = 0;
79
79
80
80
81
  /**
81
  /**
(-)a/src/spectrum/model/waveform-generator.cc (-4 / +4 lines)
 Lines 89-102    Link Here 
89
89
90
90
91
91
92
Ptr<Object>
92
Ptr<NetDevice>
93
WaveformGenerator::GetDevice ()
93
WaveformGenerator::GetDevice ()
94
{
94
{
95
  return m_netDevice;
95
  return m_netDevice;
96
}
96
}
97
97
98
98
99
Ptr<Object>
99
Ptr<MobilityModel>
100
WaveformGenerator::GetMobility ()
100
WaveformGenerator::GetMobility ()
101
{
101
{
102
  return m_mobility;
102
  return m_mobility;
 Lines 111-124    Link Here 
111
}
111
}
112
112
113
void
113
void
114
WaveformGenerator::SetDevice (Ptr<Object> d)
114
WaveformGenerator::SetDevice (Ptr<NetDevice> d)
115
{
115
{
116
  m_netDevice = d;
116
  m_netDevice = d;
117
}
117
}
118
118
119
119
120
void
120
void
121
WaveformGenerator::SetMobility (Ptr<Object> m)
121
WaveformGenerator::SetMobility (Ptr<MobilityModel> m)
122
{
122
{
123
  m_mobility = m;
123
  m_mobility = m;
124
}
124
}
(-)a/src/spectrum/model/waveform-generator.h (-6 / +6 lines)
 Lines 56-65    Link Here 
56
56
57
  // inherited from SpectrumPhy
57
  // inherited from SpectrumPhy
58
  void SetChannel (Ptr<SpectrumChannel> c);
58
  void SetChannel (Ptr<SpectrumChannel> c);
59
  void SetMobility (Ptr<Object> m);
59
  void SetMobility (Ptr<MobilityModel> m);
60
  void SetDevice (Ptr<Object> d);
60
  void SetDevice (Ptr<NetDevice> d);
61
  Ptr<Object> GetMobility ();
61
  Ptr<MobilityModel> GetMobility ();
62
  Ptr<Object> GetDevice ();
62
  Ptr<NetDevice> GetDevice ();
63
  Ptr<const SpectrumModel> GetRxSpectrumModel () const;
63
  Ptr<const SpectrumModel> GetRxSpectrumModel () const;
64
  void StartRx (Ptr<PacketBurst> p, Ptr <const SpectrumValue> rxPsd, SpectrumType st, Time duration);
64
  void StartRx (Ptr<PacketBurst> p, Ptr <const SpectrumValue> rxPsd, SpectrumType st, Time duration);
65
65
 Lines 129-136    Link Here 
129
private:
129
private:
130
  virtual void DoDispose (void);
130
  virtual void DoDispose (void);
131
131
132
  Ptr<Object> m_mobility;
132
  Ptr<MobilityModel> m_mobility;
133
  Ptr<Object> m_netDevice;
133
  Ptr<NetDevice> m_netDevice;
134
  Ptr<SpectrumChannel> m_channel;
134
  Ptr<SpectrumChannel> m_channel;
135
135
136
  virtual void GenerateWaveform ();
136
  virtual void GenerateWaveform ();

Return to bug 1271