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