5G-LENA nr-v3.0-33-g7aea1e4
The 5G/NR module for the ns-3 simulator
Loading...
Searching...
No Matches
realistic-beamforming-helper.cc
1/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2
3// Copyright (c) 2020 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
4//
5// SPDX-License-Identifier: GPL-2.0-only
6
7#include "realistic-beamforming-helper.h"
8
9#include <ns3/log.h>
10#include <ns3/lte-ue-rrc.h>
11#include <ns3/nr-gnb-net-device.h>
12#include <ns3/nr-gnb-phy.h>
13#include <ns3/nr-spectrum-phy.h>
14#include <ns3/nr-ue-net-device.h>
15#include <ns3/nr-ue-phy.h>
16#include <ns3/vector.h>
17
18namespace ns3
19{
20
21NS_LOG_COMPONENT_DEFINE("RealisticBeamformingHelper");
22NS_OBJECT_ENSURE_REGISTERED(RealisticBeamformingHelper);
23
24TypeId
26{
27 static TypeId tid = TypeId("ns3::RealisticBeamformingHelper")
28 .SetParent<BeamformingHelperBase>()
29 .AddConstructor<RealisticBeamformingHelper>();
30 return tid;
31}
32
33void
34RealisticBeamformingHelper::AddBeamformingTask(const Ptr<NrGnbNetDevice>& gNbDev,
35 const Ptr<NrUeNetDevice>& ueDev)
36{
37 NS_LOG_FUNCTION(this);
38 for (std::size_t ccId = 0; ccId < gNbDev->GetCcMapSize(); ccId++)
39 {
40 Ptr<NrSpectrumPhy> gnbSpectrumPhy = gNbDev->GetPhy(ccId)->GetSpectrumPhy();
41 Ptr<NrSpectrumPhy> ueSpectrumPhy = ueDev->GetPhy(ccId)->GetSpectrumPhy();
42
43 auto itAlgorithms =
44 m_spectrumPhyPairToAlgorithm.find(std::make_pair(gnbSpectrumPhy, ueSpectrumPhy));
45 NS_ABORT_MSG_IF(itAlgorithms != m_spectrumPhyPairToAlgorithm.end(),
46 "Realistic beamforming task already created for the provided devices");
47
48 // for each pair of antenna arrays of transmitter and receiver create an instance of
49 // beamforming algorithm
50 Ptr<RealisticBeamformingAlgorithm> beamformingAlgorithm =
52
53 beamformingAlgorithm->Install(gnbSpectrumPhy, ueSpectrumPhy, gNbDev->GetScheduler(ccId));
54
55 m_spectrumPhyPairToAlgorithm[std::make_pair(gnbSpectrumPhy, ueSpectrumPhy)] =
56 beamformingAlgorithm;
57 // connect trace of the corresponding gNB PHY to the RealisticBeamformingAlgorithm
58 // function
59 gnbSpectrumPhy->AddSrsSinrReportCallback(
61 beamformingAlgorithm));
62 gnbSpectrumPhy->AddSrsSnrReportCallback(
63 MakeCallback(&RealisticBeamformingAlgorithm::NotifySrsSnrReport, beamformingAlgorithm));
64 beamformingAlgorithm->SetTriggerCallback(
65 MakeCallback(&RealisticBeamformingHelper::RunTask, this));
66 }
67}
68
69BeamformingVectorPair
70RealisticBeamformingHelper::GetBeamformingVectors(const Ptr<NrSpectrumPhy>& gnbSpectrumPhy,
71 const Ptr<NrSpectrumPhy>& ueSpectrumPhy) const
72{
73 auto itAlgo = m_spectrumPhyPairToAlgorithm.find(std::make_pair(gnbSpectrumPhy, ueSpectrumPhy));
74 NS_ABORT_MSG_IF(itAlgo == m_spectrumPhyPairToAlgorithm.end(),
75 "There is no created task/algorithm for the specified pair of antenna arrays.");
76 return itAlgo->second->GetBeamformingVectors();
77}
78
79void
81{
82 NS_LOG_FUNCTION(this);
83 NS_ASSERT(beamformingMethod == RealisticBeamformingAlgorithm::GetTypeId() ||
84 beamformingMethod.IsChildOf(RealisticBeamformingAlgorithm::GetTypeId()));
85
86 m_algorithmFactory.SetTypeId(beamformingMethod);
87}
88
89} // namespace ns3
The BeamformingHelperBase class that is being used as the general interface for beamforming helper cl...
ObjectFactory m_algorithmFactory
Object factory that will be used to create beamforming algorithms.
virtual void RunTask(const Ptr< NrSpectrumPhy > &gnbSpectrumPhy, const Ptr< NrSpectrumPhy > &ueSpectrumPhy) const
This function runs the beamforming algorithm among the provided gNB and UE device,...
Generate "Real" beamforming vectors This class is inherited by all algorithms that do not assume the ...
void NotifySrsSnrReport(uint16_t cellId, uint16_t rnti, double srsSnr)
Saves SRS SNR report.
void NotifySrsSinrReport(uint16_t cellId, uint16_t rnti, double srsSinr)
Saves SRS SINR report.
void AddBeamformingTask(const Ptr< NrGnbNetDevice > &gNbDev, const Ptr< NrUeNetDevice > &ueDev) override
Adds the beamforming task to the list of tasks \gnbDev gNbDev pointer to gNB device \ueDev ueDev poin...
void SetBeamformingMethod(const TypeId &beamformingMethod) override
SetBeamformingMethod.
static TypeId GetTypeId()
Get the Type ID.