5#include "ns3/constant-position-mobility-model.h"
6#include "ns3/multi-model-spectrum-channel.h"
7#include "ns3/net-device.h"
8#include "ns3/phased-array-spectrum-propagation-loss-model.h"
9#include "ns3/propagation-delay-model.h"
10#include "ns3/simulator.h"
11#include "ns3/spectrum-phy.h"
12#include "ns3/spectrum-signal-parameters.h"
13#include "ns3/spectrum-value.h"
15#include "ns3/uinteger.h"
16#include "ns3/uniform-planar-array.h"
42 std::complex<double> sum{0.0, 0.0};
43 for (
size_t i = 0; i < aBeamformingVector.
GetSize(); ++i)
45 sum += aBeamformingVector(i);
47 auto rxParams = params->Copy();
48 *(rxParams->psd) *= std::norm(sum);
161 void DoRun()
override;
167 :
TestCase(
std::string(
"TX beamforming vector at transmission time, ") +
168 (withDelay ?
"with" :
"without") +
" propagation delay"),
177 bandInfo.
fl = 1.99e9;
179 bandInfo.
fh = 2.01e9;
180 Bands bands{bandInfo};
191 const size_t numElems = txAntenna->GetNumElems();
196 std::valarray<std::complex<double>>(std::complex<double>(1.0, 0.0), numElems));
197 std::valarray<std::complex<double>> alternating(numElems);
198 for (
size_t i = 0; i < numElems; ++i)
200 alternating[i] = (i % 2 == 0) ? 1.0 : -1.0;
203 txAntenna->SetBeamformingVector(txBeam);
204 rxAntenna->SetBeamformingVector(txBeam);
207 txMobility->SetPosition(Vector(0, 0, 0));
209 rxMobility->SetPosition(Vector(3000, 0, 0));
212 txPhy->SetMobility(txMobility);
214 rxPhy->SetMobility(rxMobility);
222 channel->AddRx(rxPhy);
223 txPhy->SetChannel(channel);
224 rxPhy->SetChannel(channel);
231 params->txPhy = txPhy;
244 static_cast<double>(numElems * numElems),
246 "Received PSD does not reflect the beamforming vector in use "
247 "when the transmission started");
250 "The channel modified the transmitter's current beamforming vector");
Check that a signal is received with the gain of the beamforming vector the transmitter had when the ...
SpectrumPhasedArrayTxBeamTestCase(bool withDelay)
Constructor.
void DoRun() override
Implementation to actually run this TestCase.
bool m_withDelay
Whether a propagation delay model is installed on the channel.
Test suite for the evaluation of the transmitter's beamforming vector at transmission time.
SpectrumPhasedArrayTxBeamTestSuite()
Phased-array loss model whose gain is the squared magnitude of the sum of the transmitter's beamformi...
int64_t DoAssignStreams(int64_t) override
Assign a fixed random variable stream number to the random variables used by this model.
Ptr< SpectrumSignalParameters > DoCalcRxPowerSpectralDensity(Ptr< const SpectrumSignalParameters > params, Ptr< const MobilityModel >, Ptr< const MobilityModel >, Ptr< const PhasedArrayModel >, Ptr< const PhasedArrayModel >, const PhasedArrayModel::ComplexVector &aBeamformingVector, const PhasedArrayModel::ComplexVector &) const override
Ptr< const SpectrumModel > GetRxSpectrumModel() const override
Ptr< MobilityModel > m_mobility
Mobility model.
Ptr< NetDevice > GetDevice() const override
Get the associated NetDevice instance.
Ptr< NetDevice > m_device
Device.
Ptr< SpectrumChannel > m_channel
Channel.
void SetDevice(Ptr< NetDevice > d) override
Set the associated NetDevice instance.
TxBeamTestPhy(Ptr< const SpectrumModel > spectrumModel, Ptr< PhasedArrayModel > antenna)
Constructor.
Ptr< PhasedArrayModel > m_antenna
Phased array.
Ptr< const SpectrumModel > m_spectrumModel
Receive spectrum model.
Ptr< MobilityModel > GetMobility() const override
Get the associated MobilityModel instance.
void SetMobility(Ptr< MobilityModel > m) override
Set the mobility model associated with this device.
void SetChannel(Ptr< SpectrumChannel > c) override
Set the channel attached to this device.
Ptr< SpectrumValue > m_rxPsd
PSD of the last received signal.
void StartRx(Ptr< SpectrumSignalParameters > params) override
Notify the SpectrumPhy instance of an incoming signal.
uint32_t m_rxCount
Number of received signals.
Ptr< Object > GetAntenna() const override
Get the AntennaModel used by this SpectrumPhy instance for transmission and/or reception.
ComplexMatrixArray ComplexVector
the underlying Valarray
PhasedArraySpectrumPropagationLossModel()
Smart pointer class similar to boost::intrusive_ptr.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static void Run()
Run the simulation.
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
TestCase(const TestCase &)=delete
Caller graph was not generated because of its size.
TestSuite(std::string name, Type type=Type::UNIT)
Construct a new test suite.
Simulation virtual time values and global simulation resolution.
Hold an unsigned integer type.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Ptr< T > CreateObjectWithAttributes(Args... args)
Allocate an Object on the heap and initialize with a set of attributes.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
#define NS_TEST_ASSERT_MSG_EQ_TOL(actual, limit, tol, msg)
Test that actual and expected (limit) values are equal to plus or minus some tolerance and report and...
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::vector< BandInfo > Bands
Container of BandInfo.
static SpectrumPhasedArrayTxBeamTestSuite g_spectrumPhasedArrayTxBeamTestSuite
Static variable for test initialization.
The building block of a SpectrumModel.
double fc
center frequency
double fl
lower limit of subband
double fh
upper limit of subband