5G-LENA nr-v3.3-81-g75c7590d
The 5G/NR module for the ns-3 simulator
Loading...
Searching...
No Matches
nr-phy.cc
1// Copyright (c) 2019 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
2//
3// SPDX-License-Identifier: GPL-2.0-only
4
5#define NS_LOG_APPEND_CONTEXT \
6 do \
7 { \
8 std::clog << " [ CellId " << GetCellId() << ", bwpId " << GetBwpId() << "] "; \
9 } while (false);
10
11#include "nr-phy.h"
12
13#include "beam-manager.h"
14#include "nr-net-device.h"
15#include "nr-spectrum-phy.h"
16
17#include "ns3/pointer.h"
18#include "ns3/uniform-planar-array.h"
19#include <ns3/boolean.h>
20
21#include <algorithm>
22
23namespace ns3
24{
25
26NS_LOG_COMPONENT_DEFINE("NrPhy");
27
28NS_OBJECT_ENSURE_REGISTERED(NrPhy);
29
30/* SAP */
31class NrMemberPhySapProvider : public NrPhySapProvider
32{
33 public:
34 NrMemberPhySapProvider(NrPhy* phy);
35
36 void SendMacPdu(const Ptr<Packet>& p,
37 const SfnSf& sfn,
38 uint8_t symStart,
39 uint16_t rnti) override;
40
41 void SendControlMessage(Ptr<NrControlMessage> msg) override;
42
43 void SendRachPreamble(uint8_t PreambleId, uint8_t Rnti) override;
44
45 void SetSlotAllocInfo(const SlotAllocInfo& slotAllocInfo) override;
46
47 BeamId GetBeamId(uint8_t rnti) const override;
48
49 Ptr<const SpectrumModel> GetSpectrumModel() override;
50
51 void NotifyConnectionSuccessful() override;
52
53 uint16_t GetBwpId() const override;
54
55 uint16_t GetCellId() const override;
56
57 uint32_t GetSymbolsPerSlot() const override;
58
59 Time GetSlotPeriod() const override;
60
61 uint32_t GetRbNum() const override;
62
63 private:
64 NrPhy* m_phy;
65};
66
67NrMemberPhySapProvider::NrMemberPhySapProvider(NrPhy* phy)
68 : m_phy(phy)
69{
70 // Nothing more to do
71}
72
73void
74NrMemberPhySapProvider::SendMacPdu(const Ptr<Packet>& p,
75 const SfnSf& sfn,
76 uint8_t symStart,
77 uint16_t rnti)
78{
79 m_phy->SetMacPdu(p, sfn, symStart, rnti);
80}
81
82void
83NrMemberPhySapProvider::SendControlMessage(Ptr<NrControlMessage> msg)
84{
85 m_phy->EnqueueCtrlMessage(msg); // May need to change
86}
87
88void
89NrMemberPhySapProvider::SendRachPreamble(uint8_t PreambleId, uint8_t Rnti)
90{
91 m_phy->SendRachPreamble(PreambleId, Rnti);
92}
93
94void
95NrMemberPhySapProvider::SetSlotAllocInfo(const SlotAllocInfo& slotAllocInfo)
96{
97 m_phy->PushBackSlotAllocInfo(slotAllocInfo);
98}
99
100BeamId
101NrMemberPhySapProvider::GetBeamId(uint8_t rnti) const
102{
103 return m_phy->GetBeamId(rnti);
104}
105
106Ptr<const SpectrumModel>
107NrMemberPhySapProvider::GetSpectrumModel()
108{
109 return m_phy->GetSpectrumModel();
110}
111
112void
113NrMemberPhySapProvider::NotifyConnectionSuccessful()
114{
115 m_phy->NotifyConnectionSuccessful();
116}
117
118uint16_t
119NrMemberPhySapProvider::GetBwpId() const
120{
121 return m_phy->GetBwpId();
122}
123
124uint16_t
125NrMemberPhySapProvider::GetCellId() const
126{
127 return m_phy->GetCellId();
128}
129
130uint32_t
131NrMemberPhySapProvider::GetSymbolsPerSlot() const
132{
133 return m_phy->GetSymbolsPerSlot();
134}
135
136Time
137NrMemberPhySapProvider::GetSlotPeriod() const
138{
139 return m_phy->GetSlotPeriod();
140}
141
142uint32_t
143NrMemberPhySapProvider::GetRbNum() const
144{
145 return m_phy->GetRbNum();
146}
147
148/* ======= */
149
150TypeId
151NrPhy::GetTypeId()
152{
153 static TypeId tid = TypeId("ns3::NrPhy")
154 .SetParent<Object>()
155 .AddAttribute("NrSpectrumPhy",
156 "NrSpectrumPhy instance",
157 PointerValue(),
158 MakePointerAccessor(&NrPhy::m_spectrumPhy),
159 MakePointerChecker<NrSpectrumPhy>());
160
161 return tid;
162}
163
164std::vector<int>
165NrPhy::FromRBGBitmaskToRBAssignment(const std::vector<bool> rbgBitmask) const
166{
167 std::vector<int> ret;
168
169 for (uint32_t i = 0; i < rbgBitmask.size(); ++i)
170 {
171 if (rbgBitmask.at(i) == 1)
172 {
173 for (uint32_t k = 0; k < GetNumRbPerRbg(); ++k)
174 {
175 ret.push_back((i * GetNumRbPerRbg()) + k);
176 }
177 }
178 }
179
180 NS_ASSERT(static_cast<uint32_t>(std::count(rbgBitmask.begin(), rbgBitmask.end(), 1) *
181 GetNumRbPerRbg()) == ret.size());
182 return ret;
183}
184
185NrPhy::NrPhy()
186 : m_currSlotAllocInfo(SfnSf(0, 0, 0, 0)),
187 m_tbDecodeLatencyUs(100.0)
188{
189 NS_LOG_FUNCTION(this);
190 m_phySapProvider = new NrMemberPhySapProvider(this);
191 SetNumerology(0); // Initialize sub-carrier spacing assuming numerology 0
192}
193
195{
196 NS_LOG_FUNCTION(this);
197}
198
199void
201{
202 NS_LOG_FUNCTION(this);
203 m_slotAllocInfo.clear();
204 m_controlMessageQueue.clear();
205 m_packetBurstMap.clear();
206 m_ctrlMsgs.clear();
207 m_tddPattern.clear();
208 m_netDevice = nullptr;
209 if (m_spectrumPhy)
210 {
211 m_spectrumPhy->Dispose();
212 }
213 m_spectrumPhy = nullptr;
214 delete m_phySapProvider;
215}
216
217void
219{
220 NS_LOG_FUNCTION(this);
221 if (m_spectrumPhy)
222 {
223 m_spectrumPhy->Initialize();
224 }
225}
226
227void
228NrPhy::SetDevice(Ptr<NrNetDevice> d)
229{
230 NS_LOG_FUNCTION(this);
231 m_netDevice = d;
232}
233
234void
236{
237 NS_LOG_FUNCTION(this);
238 NS_ABORT_IF(m_centralFrequency >= 0.0);
239 m_centralFrequency = f;
240}
241
242void
243NrPhy::SetChannelBandwidth(uint16_t channelBandwidth)
244{
245 NS_LOG_FUNCTION(this);
246
247 NS_LOG_DEBUG("SetChannelBandwidth called with channel bandwidth value: "
248 << channelBandwidth * 100 * 1000
249 << "Hz, "
250 "and the previous value of channel bandwidth was: "
251 << GetChannelBandwidth() << " Hz");
252
253 if (m_channelBandwidth != channelBandwidth)
254 {
255 m_channelBandwidth = channelBandwidth;
256 // number of RB and noise PSD must be updated when bandwidth or numerology gets changed
258 }
259}
260
261void
262NrPhy::SetNumerology(uint16_t numerology)
263{
264 NS_LOG_FUNCTION(this);
265 m_numerology = numerology;
266 m_slotsPerSubframe = static_cast<uint16_t>(std::pow(2, numerology));
267 m_slotPeriod = Seconds(0.001 / m_slotsPerSubframe);
268 m_subcarrierSpacing = 15000 * static_cast<uint32_t>(std::pow(2, numerology));
269 m_symbolPeriod = (m_slotPeriod / m_symbolsPerSlot);
270
271 // number of RB and noise PSD must be updated when bandwidth or numerology gets changed
272 if (m_channelBandwidth != 0)
273 {
275
276 NS_LOG_INFO(" Numerology configured:"
277 << GetNumerology() << " slots per subframe: " << m_slotsPerSubframe
278 << " slot period:" << GetSlotPeriod() << " symbol period:" << GetSymbolPeriod()
279 << " subcarrier spacing: " << GetSubcarrierSpacing()
280 << " number of RBs: " << GetRbNum());
281 }
282 else
283 {
284 NS_LOG_DEBUG("Numerology is set, but the channel bandwidth not yet, so the number of RBs "
285 "cannot be updated now.");
286 }
287}
288
289uint16_t
291{
292 return m_numerology;
293}
294
295void
296NrPhy::SetSymbolsPerSlot(uint16_t symbolsPerSlot)
297{
298 NS_LOG_FUNCTION(this);
299 m_symbolsPerSlot = symbolsPerSlot;
300 m_symbolPeriod = (m_slotPeriod / m_symbolsPerSlot);
301}
302
303void
305{
306 m_rbOh = oh;
307}
308
309double
311{
312 return m_rbOh;
313}
314
315uint32_t
317{
318 return m_symbolsPerSlot;
319}
320
321Time
323{
324 NS_ABORT_IF(m_slotPeriod.IsNegative());
325 return m_slotPeriod;
326}
327
328void
329NrPhy::DoSetCellId(uint16_t cellId)
330{
331 NS_LOG_FUNCTION(this);
332 m_cellId = cellId;
333}
334
335void
336NrPhy::SendRachPreamble(uint32_t PreambleId, uint32_t Rnti)
337{
338 NS_LOG_FUNCTION(this); // overridden only in nr-ue-phy
339}
340
341void
342NrPhy::SetMacPdu(const Ptr<Packet>& p, const SfnSf& sfn, uint8_t symStart, uint16_t rnti)
343{
344 NS_LOG_FUNCTION(this);
345 NS_ASSERT(sfn.GetNumerology() == GetNumerology());
346 uint64_t key = sfn.GetEncodingWithSymStartRnti(symStart, rnti);
347 auto it = m_packetBurstMap.find(key);
348
349 if (it == m_packetBurstMap.end())
350 {
351 it = m_packetBurstMap.insert(std::make_pair(key, CreateObject<PacketBurst>())).first;
352 }
353 it->second->AddPacket(p);
354 NS_LOG_INFO("Adding a packet for the Packet Burst of " << sfn << " at sym " << +symStart
355 << std::endl);
356}
357
358void
360{
361 NS_LOG_FUNCTION(this);
362}
363
364Ptr<PacketBurst>
365NrPhy::GetPacketBurst(SfnSf sfn, uint8_t sym, uint16_t rnti)
366{
367 NS_LOG_FUNCTION(this);
368 NS_ASSERT(sfn.GetNumerology() == GetNumerology());
369 Ptr<PacketBurst> pburst;
370 auto it = m_packetBurstMap.find(sfn.GetEncodingWithSymStartRnti(sym, rnti));
371
372 if (it == m_packetBurstMap.end())
373 {
374 // For instance, this can happen with low BW and low MCS: The MAC
375 // ignores the txOpportunity.
376 NS_LOG_WARN("Packet burst not found for " << sfn << " at sym " << +sym);
377 return pburst;
378 }
379 else
380 {
381 pburst = it->second;
382 m_packetBurstMap.erase(it);
383 }
384 return pburst;
385}
386
387Ptr<SpectrumValue>
393
394Ptr<SpectrumValue>
395NrPhy::GetTxPowerSpectralDensity(const std::vector<int>& rbIndexVector)
396{
397 Ptr<const SpectrumModel> sm = GetSpectrumModel();
398
400 rbIndexVector,
401 sm,
402 m_powerAllocationType);
403}
404
405double
407{
408 NS_LOG_FUNCTION(this);
409 NS_ABORT_IF(m_centralFrequency < 0.0);
410 return m_centralFrequency;
411}
412
413std::string
414NrPhy::GetPattern(const std::vector<LteNrTddSlotType>& pattern)
415{
416 static std::unordered_map<LteNrTddSlotType, std::string, std::hash<int>> lookupTable = {
417 {LteNrTddSlotType::DL, "DL"},
418 {LteNrTddSlotType::UL, "UL"},
419 {LteNrTddSlotType::S, "S"},
420 {LteNrTddSlotType::F, "F"}};
421
422 std::stringstream ss;
423
424 for (const auto& v : pattern)
425 {
426 ss << lookupTable[v] << "|";
427 }
428
429 return ss.str();
430}
431
432void
433NrPhy::SetPowerAllocationType(enum NrSpectrumValueHelper::PowerAllocationType powerAllocationType)
434{
435 m_powerAllocationType = powerAllocationType;
436}
437
438enum NrSpectrumValueHelper::PowerAllocationType
440{
441 return m_powerAllocationType;
442}
443
444void
445NrPhy::EnqueueCtrlMessage(const Ptr<NrControlMessage>& m)
446{
447 NS_LOG_FUNCTION(this);
448
449 m_controlMessageQueue.at(m_controlMessageQueue.size() - 1).push_back(m);
450}
451
452void
453NrPhy::EnqueueCtrlMsgNow(const Ptr<NrControlMessage>& msg)
454{
455 NS_LOG_FUNCTION(this);
456
457 m_controlMessageQueue.at(0).push_back(msg);
458}
459
460void
461NrPhy::EnqueueCtrlMsgNow(const std::list<Ptr<NrControlMessage>>& listOfMsgs)
462{
463 for (const auto& msg : listOfMsgs)
464 {
465 m_controlMessageQueue.at(0).push_back(msg);
466 }
467}
468
469void
470NrPhy::EncodeCtrlMsg(const Ptr<NrControlMessage>& msg)
471{
472 NS_LOG_FUNCTION(this);
473 m_ctrlMsgs.push_back(msg);
474}
475
476bool
478{
480}
481
482bool
484{
486}
487
488bool
489NrPhy::HasDlSlot(const std::vector<LteNrTddSlotType>& pattern)
490{
491 for (const auto& v : pattern)
492 {
494 {
495 return true;
496 }
497 }
498 return false;
499}
500
501bool
502NrPhy::HasUlSlot(const std::vector<LteNrTddSlotType>& pattern)
503{
504 for (const auto& v : pattern)
505 {
507 {
508 return true;
509 }
510 }
511 return false;
512}
513
514uint32_t
516{
517 return m_rbNum;
518}
519
520uint32_t
522{
523 // m_channelBandwidth is in kHz * 100
524 return m_channelBandwidth * 1000 * 100;
525}
526
527uint32_t
529{
530 return m_subcarrierSpacing;
531}
532
533void
535{
536 NS_LOG_FUNCTION(this);
537 NS_ABORT_MSG_IF(m_channelBandwidth == 0, "Channel bandwidth not set");
538
539 double realBw = GetChannelBandwidth() * (1 - m_rbOh);
540 uint32_t rbWidth = m_subcarrierSpacing * NrSpectrumValueHelper::SUBCARRIERS_PER_RB;
541
542 NS_ABORT_MSG_IF(
543 rbWidth > realBw,
544 "Bandwidth and numerology not correctly set. Bandwidth after reduction of overhead is :"
545 << realBw << ", while RB width is: " << rbWidth);
546
547 m_rbNum = static_cast<uint32_t>(realBw / rbWidth);
548 NS_ASSERT(GetRbNum() > 0);
549
550 NS_LOG_INFO("Updated RbNum to " << GetRbNum());
551
552 NS_ASSERT(m_spectrumPhy);
553
554 // Update the noisePowerSpectralDensity, as it depends on m_rbNum
555 m_spectrumPhy->SetNoisePowerSpectralDensity(GetNoisePowerSpectralDensity());
556
557 // once we have set noise power spectral density which will
558 // initialize SpectrumModel of our SpectrumPhy, we can
559 // call AddRx function of the SpectrumChannel
560 if (m_spectrumPhy->GetSpectrumChannel())
561 {
562 m_spectrumPhy->GetSpectrumChannel()->AddRx(m_spectrumPhy);
563 }
564 else
565 {
566 NS_LOG_WARN("Working without channel (i.e., under test)");
567 }
568 NS_LOG_DEBUG("Noise Power Spectral Density updated");
569}
570
571bool
572NrPhy::IsTdd(const std::vector<LteNrTddSlotType>& pattern)
573{
574 bool anUl = false;
575 bool aDl = false;
576
577 for (const auto& v : pattern)
578 {
579 // An F slot: we are TDD
580 if (v == LteNrTddSlotType::F)
581 {
582 return true;
583 }
584
585 if (v == LteNrTddSlotType::UL)
586 {
587 anUl = true;
588 }
589 else if (v == LteNrTddSlotType::DL)
590 {
591 aDl = true;
592 }
593 }
594
595 return !(anUl ^ aDl);
596}
597
598void
600{
601 NS_LOG_FUNCTION(this);
602 m_controlMessageQueue.clear();
603
604 for (unsigned i = 0; i <= GetL1L2CtrlLatency(); i++)
605 {
606 m_controlMessageQueue.emplace_back();
607 }
608}
609
610std::list<Ptr<NrControlMessage>>
612{
613 NS_LOG_FUNCTION(this);
614 if (m_controlMessageQueue.empty())
615 {
616 std::list<Ptr<NrControlMessage>> emptylist;
617 return (emptylist);
618 }
619
620 if (!m_controlMessageQueue.at(0).empty())
621 {
622 std::list<Ptr<NrControlMessage>> ret = m_controlMessageQueue.front();
623 m_controlMessageQueue.erase(m_controlMessageQueue.begin());
624 std::list<Ptr<NrControlMessage>> newlist;
625 m_controlMessageQueue.push_back(newlist);
626 return (ret);
627 }
628 else
629 {
630 m_controlMessageQueue.erase(m_controlMessageQueue.begin());
631 std::list<Ptr<NrControlMessage>> newlist;
632 m_controlMessageQueue.push_back(newlist);
633 std::list<Ptr<NrControlMessage>> emptylist;
634 return (emptylist);
635 }
636}
637
638void
639NrPhy::InstallSpectrumPhy(const Ptr<NrSpectrumPhy>& spectrumPhy)
640{
641 NS_LOG_FUNCTION(this);
642 m_spectrumPhy = spectrumPhy;
643}
644
645void
646NrPhy::SetBwpId(uint16_t bwpId)
647{
648 m_bwpId = bwpId;
649}
650
651uint16_t
653{
654 return m_bwpId;
655}
656
657uint16_t
659{
660 return m_cellId;
661}
662
663uint32_t
665{
666 return 2;
667}
668
669Ptr<NrSpectrumPhy>
671{
672 return m_spectrumPhy;
673}
674
677{
678 NS_LOG_FUNCTION(this);
679 return m_phySapProvider;
680}
681
682void
684{
685 NS_LOG_FUNCTION(this);
686
687 NS_LOG_DEBUG("setting info for slot " << slotAllocInfo.m_sfnSf);
688
689 // That's not so complex, as the list would typically be of 2 or 3 elements.
690 bool updated = false;
691 for (auto& alloc : m_slotAllocInfo)
692 {
693 if (alloc.m_sfnSf == slotAllocInfo.m_sfnSf)
694 {
695 NS_LOG_DEBUG("Merging inside existing allocation");
696 alloc.Merge(slotAllocInfo);
697 updated = true;
698 break;
699 }
700 }
701 if (!updated)
702 {
703 m_slotAllocInfo.push_back(slotAllocInfo);
704 m_slotAllocInfo.sort();
705 NS_LOG_DEBUG("Pushing allocation at the end of the list");
706 }
707
708 std::stringstream output;
709
710 for (const auto& alloc : m_slotAllocInfo)
711 {
712 output << alloc;
713 }
714 NS_LOG_DEBUG(output.str());
715}
716
717void
718NrPhy::PushFrontSlotAllocInfo(const SfnSf& newSfnSf, const SlotAllocInfo& slotAllocInfo)
719{
720 NS_LOG_FUNCTION(this);
721
722 m_slotAllocInfo.push_front(slotAllocInfo);
723 SfnSf currentSfn = newSfnSf;
724 std::unordered_map<uint64_t, Ptr<PacketBurst>>
725 newBursts; // map between new sfn and the packet burst
726 std::unordered_map<uint64_t, uint64_t> sfnMap; // map between new and old sfn, for debugging
727
728 // all the slot allocations (and their packet burst) have to be "adjusted":
729 // directly modify the sfn for the allocation, and temporarily store the
730 // burst (along with the new sfn) into newBursts.
731 for (auto it = m_slotAllocInfo.begin(); it != m_slotAllocInfo.end(); ++it)
732 {
733 auto slotSfn = it->m_sfnSf;
734 for (const auto& alloc : it->m_varTtiAllocInfo)
735 {
736 if (alloc.m_dci->m_type == DciInfoElementTdma::DATA)
737 {
738 Ptr<PacketBurst> pburst =
739 GetPacketBurst(slotSfn, alloc.m_dci->m_symStart, alloc.m_dci->m_rnti);
740 if (pburst && pburst->GetNPackets() > 0)
741 {
742 auto newKey = currentSfn.GetEncodingWithSymStartRnti(alloc.m_dci->m_symStart,
743 alloc.m_dci->m_rnti);
744 auto oldKey = it->m_sfnSf.GetEncodingWithSymStartRnti(alloc.m_dci->m_symStart,
745 alloc.m_dci->m_rnti);
746 newBursts.insert({newKey, pburst});
747 sfnMap.insert({newKey, oldKey});
748 }
749 else
750 {
751 NS_LOG_INFO("No packet burst found for " << slotSfn);
752 }
753 }
754 }
755
756 NS_LOG_INFO("Set slot allocation for " << it->m_sfnSf << " to " << currentSfn);
757 it->m_sfnSf = currentSfn;
758 currentSfn.Add(1);
759 }
760
761 for (const auto& burstPair : newBursts)
762 {
763 SfnSf old;
764 SfnSf latest;
765 ns3::SfnSf::Decode(sfnMap.at(burstPair.first));
766 ns3::SfnSf::Decode(burstPair.first);
767 m_packetBurstMap.insert(std::make_pair(burstPair.first, burstPair.second));
768 NS_LOG_INFO("PacketBurst with " << burstPair.second->GetNPackets() << "packets for SFN "
769 << old << " now moved to SFN " << latest);
770 }
771}
772
773bool
775{
776 NS_LOG_FUNCTION(this);
777 NS_ASSERT(retVal.GetNumerology() == GetNumerology());
778 for (const auto& alloc : m_slotAllocInfo)
779 {
780 if (alloc.m_sfnSf == retVal)
781 {
782 return true;
783 }
784 }
785 return false;
786}
787
790{
791 NS_LOG_FUNCTION(this);
792 SlotAllocInfo ret = *m_slotAllocInfo.begin();
793 m_slotAllocInfo.erase(m_slotAllocInfo.begin());
794 return ret;
795}
796
799{
800 NS_LOG_FUNCTION(" slot " << sfnsf);
801 NS_ASSERT(sfnsf.GetNumerology() == GetNumerology());
802
803 for (auto allocIt = m_slotAllocInfo.begin(); allocIt != m_slotAllocInfo.end(); ++allocIt)
804 {
805 if (allocIt->m_sfnSf == sfnsf)
806 {
807 SlotAllocInfo ret = *allocIt;
808 m_slotAllocInfo.erase(allocIt);
809 return ret;
810 }
811 }
812
813 NS_FATAL_ERROR("Didn't found the slot");
814 return SlotAllocInfo(sfnsf);
815}
816
819{
820 NS_LOG_FUNCTION(this);
821 NS_ASSERT(sfnsf.GetNumerology() == GetNumerology());
822 for (auto& alloc : m_slotAllocInfo)
823 {
824 if (alloc.m_sfnSf == sfnsf)
825 {
826 return alloc;
827 }
828 }
829
830 NS_FATAL_ERROR("Didn't found the slot");
831}
832
833size_t
835{
836 NS_LOG_FUNCTION(this);
837 return m_slotAllocInfo.size();
838}
839
840bool
842{
843 NS_LOG_FUNCTION(this);
844 return m_controlMessageQueue.empty() || m_controlMessageQueue.at(0).empty();
845}
846
847Ptr<const SpectrumModel>
849{
850 NS_LOG_FUNCTION(this);
851 NS_ABORT_MSG_IF(GetSubcarrierSpacing() < 0.0, "Set a valid numerology");
852 NS_ABORT_MSG_IF(m_channelBandwidth == 0, "Channel bandwidth not set.");
856}
857
858Time
860{
861 NS_LOG_FUNCTION(this);
862 return m_symbolPeriod;
863}
864
865void
867{
868 m_noiseFigure = d;
869 // as we don't know the order in which will be configured the parameters
870 if (m_spectrumPhy && GetRbNum())
871 {
872 m_spectrumPhy->SetNoisePowerSpectralDensity(GetNoisePowerSpectralDensity());
873 }
874}
875
876double
878{
879 return m_noiseFigure;
880}
881
882void
884{
885 m_tbDecodeLatencyUs = us;
886}
887
888Time
890{
891 return m_tbDecodeLatencyUs;
892}
893
894} // namespace ns3
Time GetSymbolPeriod() const
Get SymbolPeriod.
Definition nr-phy.cc:859
Ptr< NrSpectrumPhy > m_spectrumPhy
Pointer to the (owned) spectrum phy.
Definition nr-phy.h:558
SlotAllocInfo RetrieveSlotAllocInfo()
Get the head for the slot allocation info, and delete it from the internal list.
Definition nr-phy.cc:789
uint16_t GetCellId() const
Definition nr-phy.cc:658
uint16_t GetNumerology() const
Get the configured numerology.
Definition nr-phy.cc:290
Ptr< NrSpectrumPhy > GetSpectrumPhy() const
Retrieve the SpectrumPhy pointer.
Definition nr-phy.cc:670
void EncodeCtrlMsg(const Ptr< NrControlMessage > &msg)
Take the control messages, and put it in a list that will be sent at the first occasion.
Definition nr-phy.cc:470
void SetNumerology(uint16_t numerology)
Set GNB or UE numerology.
Definition nr-phy.cc:262
virtual void SetTbDecodeLatency(const Time &us)
Configures TB decode latency.
Definition nr-phy.cc:883
std::list< Ptr< NrControlMessage > > m_ctrlMsgs
CTRL messages to be sent.
Definition nr-phy.h:571
void DoInitialize() override
DoInitialize method inherited from Object.
Definition nr-phy.cc:218
void SetRbOverhead(double oh)
Set the bandwidth overhead for calculating the usable RB number.
Definition nr-phy.cc:304
void PushBackSlotAllocInfo(const SlotAllocInfo &slotAllocInfo)
Store the slot allocation info.
Definition nr-phy.cc:683
void NotifyConnectionSuccessful()
Notify PHY about the successful RRC connection establishment.
Definition nr-phy.cc:359
void InstallCentralFrequency(double f)
Install the PHY over a particular central frequency.
Definition nr-phy.cc:235
~NrPhy() override
~NrPhy
Definition nr-phy.cc:194
Ptr< PacketBurst > GetPacketBurst(SfnSf sf, uint8_t sym, uint16_t rnti)
Retrieve the PacketBurst at the slot/symbol specified.
Definition nr-phy.cc:365
void SetPowerAllocationType(enum NrSpectrumValueHelper::PowerAllocationType powerAllocationType)
Set power allocation type. There are currently supported two types: one that distributes uniformly en...
Definition nr-phy.cc:433
static std::string GetPattern(const std::vector< LteNrTddSlotType > &pattern)
Get a string representation of a pattern.
Definition nr-phy.cc:414
void InstallSpectrumPhy(const Ptr< NrSpectrumPhy > &spectrumPhy)
Set the SpectrumPhy associated with this PHY.
Definition nr-phy.cc:639
Time GetSlotPeriod() const
Get the slot period.
Definition nr-phy.cc:322
virtual std::list< Ptr< NrControlMessage > > PopCurrentSlotCtrlMsgs()
Extract and return the message list that is at the beginning of the queue.
Definition nr-phy.cc:611
virtual void SendRachPreamble(uint32_t PreambleId, uint32_t Rnti)
Send the RachPreamble.
Definition nr-phy.cc:336
enum NrSpectrumValueHelper::PowerAllocationType GetPowerAllocationType() const
Get the power allocation type.
Definition nr-phy.cc:439
void EnqueueCtrlMsgNow(const Ptr< NrControlMessage > &msg)
Enqueue a CTRL message without considering L1L2CtrlLatency.
Definition nr-phy.cc:453
uint32_t GetChannelBandwidth() const
Retrieve the channel bandwidth, in Hz.
Definition nr-phy.cc:521
virtual Time GetTbDecodeLatency() const
Returns Transport Block decode latency.
Definition nr-phy.cc:889
SlotAllocInfo & PeekSlotAllocInfo(const SfnSf &sfnsf)
Peek the SlotAllocInfo at the SfnSf specified.
Definition nr-phy.cc:818
double GetCentralFrequency() const
Retrieve the frequency (in Hz) of this PHY's channel.
Definition nr-phy.cc:406
void SetMacPdu(const Ptr< Packet > &p, const SfnSf &sfn, uint8_t symStart, uint16_t rnti)
Store a MAC PDU.
Definition nr-phy.cc:342
double m_noiseFigure
Noise figure (attribute)
Definition nr-phy.h:561
void SetSymbolsPerSlot(uint16_t symbolsPerSlot)
Set the number of symbol per slot.
Definition nr-phy.cc:296
void SetDevice(Ptr< NrNetDevice > d)
Set the owner device.
Definition nr-phy.cc:228
Ptr< const SpectrumModel > GetSpectrumModel()
Get the spectrum model of the PHY.
Definition nr-phy.cc:848
size_t SlotAllocInfoSize() const
Retrieve the size of the SlotAllocInfo list.
Definition nr-phy.cc:834
double GetNoiseFigure() const
Get the NoiseFigure value.
Definition nr-phy.cc:877
void SetNoiseFigure(double d)
Set the NoiseFigure value.
Definition nr-phy.cc:866
double m_txPower
Transmission power (attribute)
Definition nr-phy.h:560
void InitializeMessageList()
Initialize the message list.
Definition nr-phy.cc:599
void DoUpdateRbNum()
Update the number of RB. Usually called after bandwidth changes.
Definition nr-phy.cc:534
Ptr< SpectrumValue > GetTxPowerSpectralDensity(const std::vector< int > &rbIndexVector)
Definition nr-phy.cc:395
void SetChannelBandwidth(uint16_t bandwidth)
Function to set the channel bandwidth, used also by child classes, i.e., see functions DoSetDlBanwidt...
Definition nr-phy.cc:243
uint16_t GetBwpId() const
Definition nr-phy.cc:652
void PushFrontSlotAllocInfo(const SfnSf &newSfnSf, const SlotAllocInfo &slotAllocInfo)
Store the slot allocation info at the front.
Definition nr-phy.cc:718
Ptr< NrNetDevice > m_netDevice
Pointer to the owner netDevice.
Definition nr-phy.h:557
uint32_t GetL1L2CtrlLatency() const
Definition nr-phy.cc:664
bool HasDlSlot() const
Go through the current pattern and see if at least one slot is DL, F or S.
Definition nr-phy.cc:477
bool SlotAllocInfoExists(const SfnSf &sfnsf) const
Check if the SlotAllocationInfo for that slot exists.
Definition nr-phy.cc:774
std::unordered_map< uint64_t, Ptr< PacketBurst > > m_packetBurstMap
Map between SfnSf and PacketBurst.
Definition nr-phy.h:564
uint32_t GetSubcarrierSpacing() const
Retrieve the subcarrier spacing in Hz. Subcarrier spacing is updated when the numerology is being upd...
Definition nr-phy.cc:528
uint32_t GetSymbolsPerSlot() const
Get the number of symbols in a slot.
Definition nr-phy.cc:316
std::vector< LteNrTddSlotType > m_tddPattern
Pattern.
Definition nr-phy.h:573
Ptr< SpectrumValue > GetNoisePowerSpectralDensity()
Create Noise Power Spectral density.
Definition nr-phy.cc:388
bool IsCtrlMsgListEmpty() const
Check if there are no control messages queued for this slot.
Definition nr-phy.cc:841
NrPhySapProvider * m_phySapProvider
Pointer to the MAC.
Definition nr-phy.h:568
double GetRbOverhead() const
Get the bandwidth overhead used when calculating the usable RB number.
Definition nr-phy.cc:310
bool HasUlSlot() const
Go through the current pattern and see if at least one slot is UL, F or S.
Definition nr-phy.cc:483
void SetBwpId(uint16_t bwpId)
Set the bwp id. Called by helper.
Definition nr-phy.cc:646
uint32_t GetRbNum() const
Get the number of Resource block configured.
Definition nr-phy.cc:515
void EnqueueCtrlMessage(const Ptr< NrControlMessage > &m)
Enqueue a ctrl message, keeping in consideration L1L2CtrlDelay.
Definition nr-phy.cc:445
static bool IsTdd(const std::vector< LteNrTddSlotType > &pattern)
Check if a pattern is TDD.
Definition nr-phy.cc:572
NrPhySapProvider * GetPhySapProvider()
Retrieve a pointer to an instance of NrPhySapProvider.
Definition nr-phy.cc:676
void DoDispose() override
DoDispose method inherited from Object.
Definition nr-phy.cc:200
void DoSetCellId(uint16_t cellId)
Set the cell ID.
Definition nr-phy.cc:329
SAP interface between the MAC and the PHY.
Definition nr-phy-sap.h:36
static Ptr< const SpectrumModel > GetSpectrumModel(uint32_t numRbs, double centerFrequency, double subcarrierSpacing)
Creates or obtains from a global map a spectrum model with a given number of RBs, center frequency an...
static Ptr< SpectrumValue > CreateNoisePowerSpectralDensity(double noiseFigure, const Ptr< const SpectrumModel > &spectrumModel)
Create a SpectrumValue that models the power spectral density of AWGN.
static Ptr< SpectrumValue > CreateTxPowerSpectralDensity(double powerTx, const std::vector< int > &rbIndexVector, const Ptr< const SpectrumModel > &txSm, enum PowerAllocationType allocationType)
Create SpectrumValue that will represent transmit power spectral density, and assuming that all RBs a...
static const uint8_t SUBCARRIERS_PER_RB
subcarriers per resource block
The SfnSf class.
Definition sfnsf.h:32
static SfnSf Decode(uint64_t sfn)
Decode the parameter and return a SfnSf.
Definition sfnsf.cc:91
uint8_t GetNumerology() const
GetNumerology.
Definition sfnsf.cc:182
void Add(uint32_t slotN)
Add to this SfnSf a number of slot indicated by the first parameter.
Definition sfnsf.cc:117
uint64_t GetEncodingWithSymStartRnti(uint8_t symStart, uint16_t rnti) const
Get an encoding of frame & slot number, plus starting OFDM symbol and RNTI.
Definition sfnsf.cc:42
@ F
DL CTRL + DL DATA + UL DATA + UL CTRL.
@ S
DL CTRL + DL DATA + UL CTRL.
@ DL
DL CTRL + DL DATA.
@ UL
UL DATA + UL CTRL.
@ DATA
Used for DL/UL DATA.
The SlotAllocInfo struct.
SfnSf m_sfnSf
SfnSf of this allocation.