diff --git a/src/spectrum/model/spectrum-transmit-filter.cc b/src/spectrum/model/spectrum-transmit-filter.cc index 076285d6f..5a353c344 100644 --- a/src/spectrum/model/spectrum-transmit-filter.cc +++ b/src/spectrum/model/spectrum-transmit-filter.cc @@ -87,4 +87,23 @@ SpectrumTransmitFilter::Filter(Ptr params, } } +int64_t +SpectrumTransmitFilter::AssignStreams(int64_t stream) +{ + auto currentStream = stream; + currentStream += DoAssignStreams(stream); + if (m_next) + { + currentStream += m_next->AssignStreams(currentStream); + } + NS_LOG_DEBUG("SpectrumTransmitFilter objects used " << currentStream - stream << " streams"); + return (currentStream - stream); +} + +int64_t +SpectrumTransmitFilter::DoAssignStreams(int64_t stream) +{ + return 0; +} + } // namespace ns3 diff --git a/src/spectrum/model/spectrum-transmit-filter.h b/src/spectrum/model/spectrum-transmit-filter.h index b004f7102..3eab75ebf 100644 --- a/src/spectrum/model/spectrum-transmit-filter.h +++ b/src/spectrum/model/spectrum-transmit-filter.h @@ -74,8 +74,30 @@ class SpectrumTransmitFilter : public Object */ bool Filter(Ptr params, Ptr receiverPhy); + /** + * If this loss model uses objects of type RandomVariableStream, + * set the stream numbers to the integers starting with the offset + * 'stream'. Return the number of streams (possibly zero) that + * have been assigned. If there are SpectrumTransmitFilters chained + * together, this method will also assign streams to the + * downstream models. + * + * \param stream the stream index offset start + * \return the number of stream indices assigned by this model + */ + int64_t AssignStreams(int64_t stream); + protected: void DoDispose() override; + /** + * Assign a fixed random variable stream number to the random variables used by this model. + * + * This should be overridden by subclasses that use random variables. + * + * \param stream first stream index to use + * \return the number of stream indices assigned by this model + */ + virtual int64_t DoAssignStreams(int64_t stream); private: /**