|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
24 #include <ns3/object-factory.h>
27 #include <ns3/simulator.h>
28 #include <ns3/trace-source-accessor.h>
29 #include <ns3/antenna-model.h>
36 #include <ns3/lte-mi-error-model.h>
37 #include <ns3/lte-radio-bearer-tag.h>
38 #include <ns3/boolean.h>
39 #include <ns3/double.h>
40 #include <ns3/config.h>
130 m_componentCarrierId (0),
131 m_transmissionMode (0),
135 m_random = CreateObject<UniformRandomVariable> ();
141 for (uint8_t i = 0; i < 7; i++)
216 .SetGroupName (
"Lte")
217 .AddTraceSource (
"TxStart",
218 "Trace fired when a new transmission is started",
220 "ns3::PacketBurst::TracedCallback")
221 .AddTraceSource (
"TxEnd",
222 "Trace fired when a previously started transmission is finished",
224 "ns3::PacketBurst::TracedCallback")
225 .AddTraceSource (
"RxStart",
226 "Trace fired when the start of a signal is detected",
228 "ns3::PacketBurst::TracedCallback")
229 .AddTraceSource (
"RxEndOk",
230 "Trace fired when a previously started RX terminates successfully",
232 "ns3::Packet::TracedCallback")
233 .AddTraceSource (
"RxEndError",
234 "Trace fired when a previously started RX terminates with an error",
236 "ns3::Packet::TracedCallback")
237 .AddAttribute (
"DataErrorModelEnabled",
238 "Activate/Deactivate the error model of data (TBs of PDSCH and PUSCH) [by default is active].",
242 .AddAttribute (
"CtrlErrorModelEnabled",
243 "Activate/Deactivate the error model of control (PCFICH-PDCCH decodification) [by default is active].",
247 .AddTraceSource (
"DlPhyReception",
248 "DL reception PHY layer statistics.",
250 "ns3::PhyReceptionStatParameters::TracedCallback")
251 .AddTraceSource (
"UlPhyReception",
252 "DL reception PHY layer statistics.",
254 "ns3::PhyReceptionStatParameters::TracedCallback")
456 NS_FATAL_ERROR (
"cannot TX while RX: according to FDD channel access, the physical layer for transmission cannot be used for reception");
462 NS_FATAL_ERROR (
"cannot TX while already TX: the MAC should avoid this");
482 txParams->duration = duration;
483 txParams->txPhy = GetObject<SpectrumPhy> ();
486 txParams->packetBurst = pb;
487 txParams->ctrlMsgList = ctrlMsgList;
513 NS_FATAL_ERROR (
"cannot TX while RX: according to FDD channel access, the physical layer for transmission cannot be used for reception");
519 NS_FATAL_ERROR (
"cannot TX while already TX: the MAC should avoid this");
540 txParams->txPhy = GetObject<SpectrumPhy> ();
545 txParams->ctrlMsgList = ctrlMsgList;
571 NS_FATAL_ERROR (
"cannot TX while RX: according to FDD channel access, the physical layer for transmission cannot be used for reception");
577 NS_FATAL_ERROR (
"cannot TX while already TX: the MAC should avoid this");
598 txParams->txPhy = GetObject<SpectrumPhy> ();
661 Time duration = spectrumRxParams->duration;
668 if (lteDataRxParams != 0)
673 else if (lteDlCtrlRxParams != 0)
678 else if (lteUlSrsRxParams != 0)
700 NS_FATAL_ERROR (
"cannot RX while TX: according to FDD channel access, the physical layer for transmission cannot be used for reception");
716 NS_LOG_LOGIC (
this <<
" synchronized with this signal (cellId=" << params->cellId <<
")");
739 if (params->packetBurst)
746 NS_LOG_DEBUG (
this <<
" insert msgs " << params->ctrlMsgList.size ());
753 NS_LOG_LOGIC (
this <<
" not in sync with this signal (cellId="
754 << params->cellId <<
", m_cellId=" <<
m_cellId <<
")");
779 cellId = lteDlCtrlRxParams->cellId;
796 if (lteDlCtrlRxParams->pss ==
true)
810 << cellId <<
", m_cellId=" <<
m_cellId <<
")");
816 NS_LOG_LOGIC (
this <<
" synchronized with this signal (cellId=" << cellId <<
")");
821 NS_LOG_LOGIC (
this <<
" scheduling EndRx with delay " << lteDlCtrlRxParams->duration);
831 NS_LOG_LOGIC (
this <<
" not synchronizing with this signal (cellId="
832 << cellId <<
", m_cellId=" <<
m_cellId <<
")");
862 NS_FATAL_ERROR (
"cannot RX while TX: according to FDD channel access, the physical layer for transmission cannot be used for reception");
880 cellId = lteUlSrsRxParams->cellId;
883 NS_LOG_LOGIC (
this <<
" synchronized with this signal (cellId=" << cellId <<
")");
891 NS_LOG_LOGIC (
this <<
" scheduling EndRx with delay " << lteUlSrsRxParams->duration);
909 NS_LOG_LOGIC (
this <<
" not in sync with this signal (cellId="
910 << cellId <<
", m_cellId=" <<
m_cellId <<
")");
933 LteSpectrumPhy::AddExpectedTb (uint16_t rnti, uint8_t ndi, uint16_t size, uint8_t mcs, std::vector<int> map, uint8_t layer, uint8_t harqId,uint8_t rv,
bool downlink)
935 NS_LOG_FUNCTION (
this <<
" rnti: " << rnti <<
" NDI " << (uint16_t)ndi <<
" size " << size <<
" mcs " << (uint16_t)mcs <<
" layer " << (uint16_t)layer <<
" rv " << (uint16_t)rv);
939 expectedTbs_t::iterator it;
947 tbInfo_t tbInfo = {ndi, size, mcs, map, harqId, rv, 0.0, downlink,
false,
false};
948 m_expectedTbs.insert (std::pair<TbId_t, tbInfo_t> (tbId,tbInfo));
958 for (uint8_t i = 0; i < 2; i++)
961 expectedTbs_t::iterator it;
999 if ((*itTb).second.ndi == 0)
1002 uint16_t ulHarqId = 0;
1003 if ((*itTb).second.downlink)
1005 harqInfoList =
m_harqPhyModule->GetHarqProcessInfoDl ((*itTb).second.harqProcessId, (*itTb).first.m_layer);
1009 harqInfoList =
m_harqPhyModule->GetHarqProcessInfoUl ((*itTb).first.m_rnti, ulHarqId);
1013 (*itTb).second.mi = tbStats.
mi;
1015 NS_LOG_DEBUG (
this <<
"RNTI " << (*itTb).first.m_rnti <<
" size " << (*itTb).second.size <<
" mcs " << (uint32_t)(*itTb).second.mcs <<
" bitmap " << (*itTb).second.rbBitmap.size () <<
" layer " << (uint16_t)(*itTb).first.m_layer <<
" TBLER " << tbStats.
tbler <<
" corrupted " << (*itTb).second.corrupt);
1021 params.
m_rnti = (*itTb).first.m_rnti;
1023 params.
m_layer = (*itTb).first.m_layer;
1024 params.
m_mcs = (*itTb).second.mcs;
1025 params.
m_size = (*itTb).second.size;
1026 params.
m_rv = (*itTb).second.rv;
1027 params.
m_ndi = (*itTb).second.ndi;
1030 if ((*itTb).second.downlink)
1038 params.
m_rv = harqInfoList.size ();
1045 std::map <uint16_t, DlInfoListElement_s> harqDlInfoMap;
1053 (*j)->PeekPacketTag (tag);
1061 if (!(*itTb).second.corrupt)
1077 if (!(*itTb).second.harqFeedbackSent)
1079 (*itTb).second.harqFeedbackSent =
true;
1080 if (!(*itTb).second.downlink)
1084 harqUlInfo.
m_tpc = 0;
1085 if ((*itTb).second.corrupt)
1104 std::map <uint16_t, DlInfoListElement_s>::iterator itHarq = harqDlInfoMap.find (tbId.
m_rnti);
1105 if (itHarq == harqDlInfoMap.end ())
1111 if ((*itTb).second.corrupt)
1114 NS_LOG_DEBUG (
this <<
" RNTI " << tbId.
m_rnti <<
" harqId " << (uint16_t)(*itTb).second.harqProcessId <<
" layer " << (uint16_t)tbId.
m_layer <<
" send DL-HARQ-NACK");
1121 NS_LOG_DEBUG (
this <<
" RNTI " << tbId.
m_rnti <<
" harqId " << (uint16_t)(*itTb).second.harqProcessId <<
" layer " << (uint16_t)tbId.
m_layer <<
" size " << (*itTb).second.size <<
" send DL-HARQ-ACK");
1122 m_harqPhyModule->ResetDlHarqProcessStatus ((*itTb).second.harqProcessId);
1124 harqDlInfoMap.insert (std::pair <uint16_t, DlInfoListElement_s> (tbId.
m_rnti, harqDlInfo));
1128 if ((*itTb).second.corrupt)
1131 NS_LOG_DEBUG (
this <<
" RNTI " << tbId.
m_rnti <<
" harqId " << (uint16_t)(*itTb).second.harqProcessId <<
" layer " << (uint16_t)tbId.
m_layer <<
" size " << (*itHarq).second.m_harqStatus.size () <<
" send DL-HARQ-NACK");
1138 NS_LOG_DEBUG (
this <<
" RNTI " << tbId.
m_rnti <<
" harqId " << (uint16_t)(*itTb).second.harqProcessId <<
" layer " << (uint16_t)tbId.
m_layer <<
" size " << (*itHarq).second.m_harqStatus.size () <<
" send DL-HARQ-ACK");
1139 m_harqPhyModule->ResetDlHarqProcessStatus ((*itTb).second.harqProcessId);
1149 std::map <uint16_t, DlInfoListElement_s>::iterator itHarq;
1150 for (itHarq = harqDlInfoMap.begin (); itHarq != harqDlInfoMap.end (); itHarq++)
1197 NS_LOG_DEBUG (
this <<
" PCFICH-PDCCH Decodification, errorRate " << errorRate <<
" error " << error);
1290 NS_LOG_FUNCTION (
this <<
" txmode " << (uint16_t)txMode <<
" gain " << gain);
1292 gain = std::pow (10.0, (gain / 10.0));
1297 std::vector <double> temp;
1300 for (uint8_t i = 0; i < temp.size (); i++)
1302 if (i == txMode - 1)
void SetHarqPhyModule(Ptr< LteHarqPhy > harq)
Set HARQ phy function.
Ptr< MobilityModel > m_mobility
the modility model
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
uint64_t m_imsi
IMSI of the scheduled UE.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
uint8_t m_rv
the redundancy version (HARQ)
std::list< Ptr< LteControlMessage > > m_txControlMessageList
the transmit control message list
AttributeValue implementation for Boolean.
TracedCallback< Ptr< const Packet > > m_phyRxEndErrorTrace
the phy receive end error trace callback
void SetLtePhyUlHarqFeedbackCallback(LtePhyUlHarqFeedbackCallback c)
set the callback for the UL HARQ feedback as part of the interconnections between the LteSpectrumPhy ...
LtePhyUlHarqFeedbackCallback m_ltePhyUlHarqFeedbackCallback
the LTE phy UL HARQ feedback callback
Tag used to define the RNTI and LC id for each MAC packet trasmitted.
bool StartTxDlCtrlFrame(std::list< Ptr< LteControlMessage > > ctrlMsgList, bool pss)
Start a transmission of control frame in DL.
static Time Now(void)
Return the current simulation virtual time.
void SetLtePhyDlHarqFeedbackCallback(LtePhyDlHarqFeedbackCallback c)
set the callback for the DL HARQ feedback as part of the interconnections between the LteSpectrumPhy ...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void AddInterferenceDataChunkProcessor(Ptr< LteChunkProcessor > p)
LteChunkProcessor devoted to evaluate interference + noise power in data symbols of the subframe.
SpectrumValue m_sinrPerceived
the preceived SINR
void RemoveExpectedTb(uint16_t rnti)
Remove expected transport block.
bool IsNull(void) const
Check for null implementation.
uint8_t m_mcs
MCS for transport block.
void StartRxDlCtrl(Ptr< LteSpectrumSignalParametersDlCtrlFrame > lteDlCtrlRxParams)
Start receive DL control function.
bool operator<(const EventId &a, const EventId &b)
void EndTxUlSrs()
End transmit UL SRS function.
Ptr< LteHarqPhy > m_harqPhyModule
the HARQ phy module
Ptr< SpectrumValue > m_txPsd
the transmit PSD
virtual ~LteSpectrumPhy()
void StartRxData(Ptr< LteSpectrumSignalParametersDataFrame > params)
Start receive data function.
uint16_t GetRnti(void) const
Get RNTI function.
void SetAntenna(Ptr< AntennaModel > a)
set the AntennaModel to be used
void SetLtePhyRxDataEndErrorCallback(LtePhyRxDataEndErrorCallback c)
set the callback for the end of a RX in error, as part of the interconnections between the PHY and th...
Ptr< AntennaModel > m_antenna
the antenna model
void SetLtePhyRxCtrlEndOkCallback(LtePhyRxCtrlEndOkCallback c)
set the callback for the successful end of a RX ctrl frame, as part of the interconnections between t...
void SetCellId(uint16_t cellId)
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
static TypeId GetTypeId(void)
Get the type ID.
Time m_firstRxDuration
the first receive duration
LtePhyRxCtrlEndOkCallback m_ltePhyRxCtrlEndOkCallback
the LTE phy receive control end ok callback
expectedTbs_t m_expectedTbs
the expected TBS
Ptr< PacketBurst > m_txPacketBurst
the transmit packet burst
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
void EndRxData()
End receive data function.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
std::vector< double > m_txModeGain
duplicate value of LteUePhy
TracedCallback< PhyReceptionStatParameters > m_dlPhyReception
Trace information regarding PHY stats from DL Rx perspective PhyReceptionStatParameters (see lte-comm...
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Ptr< const SpectrumModel > GetRxSpectrumModel() const
void AddDataSinrChunkProcessor(Ptr< LteChunkProcessor > p)
int64_t m_timestamp
in millisecond
uint8_t m_tpc
Tx power control command.
void SetChannel(Ptr< SpectrumChannel > c)
Set the channel attached to this device.
uint16_t m_cellId
the cell ID
void SetNoisePowerSpectralDensity(Ptr< const SpectrumValue > noisePsd)
set the noise power spectral density
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
static double GetPcfichPdcchError(const SpectrumValue &sinr)
run the error-model algorithm for the specified PCFICH+PDCCH channels
void SetTransmissionMode(uint8_t txMode)
Ptr< UniformRandomVariable > m_random
Provides uniform random variables.
Time m_firstRxStart
the first receive start
Ptr< LteInterference > m_interferenceData
the data interference
Ptr< SpectrumChannel > m_channel
the channel
void SetLtePhyRxPssCallback(LtePhyRxPssCallback c)
set the callback for the reception of the PSS as part of the interconnections between the LteSpectrum...
static const Time UL_SRS_DURATION
duration of SRS portion of UL subframe = 1 symbol for SRS -1ns as margin to avoid overlapping simulat...
@ IDLE
Channel is IDLE, no packet is being transmitted.
std::vector< enum HarqStatus_e > m_harqStatus
HARQ status.
virtual void DoDispose()
Destructor implementation.
uint8_t GetLayer(void) const
Get layer function.
void ChangeState(State newState)
Change state function.
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
void AddDataPowerChunkProcessor(Ptr< LteChunkProcessor > p)
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
uint8_t m_ndi
new data indicator flag
Abstract base class for Spectrum-aware PHY layers.
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
LtePhyRxCtrlEndErrorCallback m_ltePhyRxCtrlEndErrorCallback
the LTE phy receive control end error callback
LtePhyRxDataEndErrorCallback m_ltePhyRxDataEndErrorCallback
the LTE phy receive data end error callback
Ptr< const AttributeChecker > MakeBooleanChecker(void)
uint8_t m_layer
the layer (cw) of the transmission
Set of values corresponding to a given SpectrumModel.
LtePhyRxPssCallback m_ltePhyRxPssCallback
the LTE phy receive PSS callback
Simulation virtual time values and global simulation resolution.
void SetComponentCarrierId(uint8_t componentCarrierId)
void SetTxModeGain(uint8_t txMode, double gain)
Set transmit mode gain function.
void StartRx(Ptr< SpectrumSignalParameters > params)
Notify the SpectrumPhy instance of an incoming signal.
bool operator==(const EventId &a, const EventId &b)
std::list< Ptr< LteControlMessage > > m_rxControlMessageList
the receive control message list
void UpdateSinrPerceived(const SpectrumValue &sinr)
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
std::list< Ptr< PacketBurst > > m_rxPacketBurstList
the receive burst list
uint8_t m_ccId
component carrier id
std::vector< HarqProcessInfoElement_t > HarqProcessInfoList_t
HarqProcessInfoList_t typedef.
void AddCtrlSinrChunkProcessor(Ptr< LteChunkProcessor > p)
Ptr< AntennaModel > GetRxAntenna() const
Get the AntennaModel used by the NetDevice for reception.
See section 4.3.12 ulInfoListElement.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
void SetMobility(Ptr< MobilityModel > m)
Set the mobility model associated with this device.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
EventId m_endRxUlSrsEvent
end receive UL SRS event
TracedCallback< Ptr< const PacketBurst > > m_phyRxStartTrace
the phy receive start trace callback
Ptr< const SpectrumModel > m_rxSpectrumModel
the spectrum model
void EndRxUlSrs()
End receive UL SRS function.
TracedCallback< Ptr< const PacketBurst > > m_phyTxStartTrace
the phy transmit start trace callback
EventId m_endRxDlCtrlEvent
end receive DL control event
int64_t GetMilliSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
void EndTxDlCtrl()
End transmit DL control function.
bool StartTxDataFrame(Ptr< PacketBurst > pb, std::list< Ptr< LteControlMessage > > ctrlMsgList, Time duration)
Start a transmission of data frame in DL and UL.
uint16_t m_size
Size of transport block.
EventId m_endTxEvent
end transmit event
bool m_ctrlErrorModelEnabled
when true (default) the phy error model is enabled for DL ctrl frame
uint16_t m_rnti
C-RNTI scheduled.
double mi
Mutual information.
Ptr< NetDevice > GetDevice() const
Get the associated NetDevice instance.
uint8_t m_transmissionMode
for UEs: store the transmission mode
void Reset()
reset the internal state
double tbler
Transport block BLER.
uint8_t m_correctness
correctness of the TB received
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
TracedCallback< PhyReceptionStatParameters > m_ulPhyReception
Trace information regarding PHY stats from UL Rx perspective PhyReceptionStatParameters (see lte-comm...
bool m_dataErrorModelEnabled
when true (default) the phy error model is enabled
static TbStats_t GetTbDecodificationStats(const SpectrumValue &sinr, const std::vector< int > &map, uint16_t size, uint8_t mcs, HarqProcessInfoList_t miHistory)
run the error-model algorithm for the specified TB
TracedCallback< Ptr< const Packet > > m_phyRxEndOkTrace
the phy receive end ok trace callback
uint8_t m_componentCarrierId
the component carrier ID
uint8_t m_txMode
the transmission Mode
bool StartTxUlSrsFrame()
Start a transmission of control frame in UL.
void EndRxDlCtrl()
End receive DL control function.
TracedCallback< Ptr< const PacketBurst > > m_phyTxEndTrace
the phy transmit end trace callback
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
void AddRsPowerChunkProcessor(Ptr< LteChunkProcessor > p)
Ptr< LteInterference > m_interferenceCtrl
the control interference
Ptr< NetDevice > m_device
the device
uint8_t m_layersNum
layers num
void SetLtePhyRxCtrlEndErrorCallback(LtePhyRxCtrlEndErrorCallback c)
set the callback for the erroneous end of a RX ctrl frame, as part of the interconnections between th...
LtePhyRxDataEndOkCallback m_ltePhyRxDataEndOkCallback
the LTE phy receive data end ok callback
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
PhyReceptionStatParameters structure.
static const double EffectiveCodingRate[29]
Effective coding rate.
void SetTxPowerSpectralDensity(Ptr< SpectrumValue > txPsd)
set the Power Spectral Density of outgoing signals in W/Hz.
void SetLtePhyRxDataEndOkCallback(LtePhyRxDataEndOkCallback c)
set the callback for the successful end of a RX, as part of the interconnections between the PHY and ...
EventId m_endRxDataEvent
end receive data event
void EndTxData()
End transmit data function.
void AddExpectedTb(uint16_t rnti, uint8_t ndi, uint16_t size, uint8_t mcs, std::vector< int > map, uint8_t layer, uint8_t harqId, uint8_t rv, bool downlink)
See section 4.3.23 dlInfoListElement.
static const Time DL_CTRL_DURATION
duration of the control portion of a subframe = 0.001 / 14 * 3 (ctrl fixed to 3 symbols) -1ns as marg...
static uint8_t TxMode2LayerNum(uint8_t txMode)
Transmit mode 2 layer number.
std::ostream & operator<<(std::ostream &os, const Angles &a)
LtePhyDlHarqFeedbackCallback m_ltePhyDlHarqFeedbackCallback
the LTE phy DL HARQ feedback callback
Ptr< SpectrumChannel > GetChannel()
uint16_t m_cellId
Cell ID of the attached Enb.
virtual void DoDispose(void)
Destructor implementation.
void StartRxUlSrs(Ptr< LteSpectrumSignalParametersUlSrsFrame > lteUlSrsRxParams)
Start receive UL SRS function.
void SetDevice(Ptr< NetDevice > d)
Set the associated NetDevice instance.
uint8_t m_harqProcessId
HARQ process ID.
void SetState(State newState)
Set the state of the phy layer.
Ptr< MobilityModel > GetMobility() const
Get the associated MobilityModel instance.
void AddInterferenceCtrlChunkProcessor(Ptr< LteChunkProcessor > p)
LteChunkProcessor devoted to evaluate interference + noise power in control symbols of the subframe.