Carriers and Bandwidth Parts
The module carrier.py
implements the classes Carrier
and BandwidthPart
.
Each Carrier
class can be associated with several BandwidthPart
objects.
This implementation is based on 3GPP TR 38.211.
- class neoradium.carrier.BandwidthPart(carrier, **kwargs)
This class implements the functionality of a bandwidth part. A bandwidth part is a subset of contiguous common resource blocks for a given numerology on a given carrier. For more information please refer to 3GPP TR 38.211, section 4.4.5
- Parameters:
carrier (Carrier object) –
kwargs (dict) –
A set of optional arguments.
- startRb:
The starting resource block (RB). This is the number of RBs from CRB 0. The default is 0.
- numRbs:
The number of RBs included in the bandwidth part. The default is 50.
- spacing:
The subcarrier spacing in KHz. This also specifies the Numerology used. To specify the subcarrier spacing, you can use 15, 30, 60, 120, 240, 480, or 960. To specify the Numerology, you can use 0, 1, …, 6. Please refer to 3GPP TR 38.211, section 4.2 for more details.
- cpType:
Cyclic Prefix type. It can be either “Normal” or “Extended”. The “Extended” type is only available for 60 KHz subcarrier spacing.
- nFFT:
The FFT Size used for OFDM modulation of the resource grids (see
Grid
) which are created based on this bandwidth part. If not specified, nFFT is calcualted based on the number of subcarriers (\(K\)) as follows:nFFT must be a power of 2 which is larger than the number of subcarriers
At least 1/8 of FFT size must be unused (Guard bands with zero power subcarriers). This means: \(\frac {nFFT-K} {nFFT} \ge \frac 1 8\).
Other Properties:
Here is a list of additional properties:
- u:
The Numerology value. It is one of (0, 1, …, 6).
- bandwidth:
The bandwidth of this bandwidth part in Hz.
- symbolsPerSlot:
The number of OFDM symbols in each slot. This is equal to 14 and 12 for “Normal” and “Extended” Cyclic Prefix types correspondingly.
- slotsPerSubFrame:
The number of slots per subframe based on current Numerology.
- symbolLens:
A list of symbol length values in number of time samples. It contains the symbol lengths for every symbol in a subframe.
- slotsPerFrame:
The number of slots per frame based on current Numerology.
- symbolsPerSubFrame:
The number of OFDM Symbols per subframe based on current Numerology.
- slotNoInFrame:
The slot number in current frame.
- slotNoInSubFrame:
The slot number in current subframe.
- cellId:
The Cell identifier of the Carrier containing this bandwidth part.
- slotNo:
Current slot number. A counter that can be used in simulation.
- frameNo:
Current frame number. A counter that can be used in simulation. This is incremented every
slotsPerFrame
slots.- sampleRate:
The sample rate. For 3GPP, this is set to 30,720,000 samples per second.
- dataTimeRatio:
The average ratio of the amount of time in an OFDM symbol spent transmitting user data to total OFDM symbol time. This is always less than one because some duration of time is spend transmitting the Cyclic Prefix which doesn’t carry useful information.
- print(indent=0, title='Bandwidth Part Properties:', getStr=False)
Prints the properties of this
BandwidthPart
object.- Parameters:
indent (int (default: 0)) – The number of indentation characters.
title (str or None (default: None)) – If specified, it is used as a title for the printed information.
getStr (Boolean (default: False)) – If
True
, it returns the information in a text string instead of printing the information.
- Returns:
If the
getStr
parameter isTrue
, then this function returns the information in a text string. Otherwise, nothing is returned.- Return type:
None or str
- createGrid(numPlanes, useReDesc=False)
Creates a resource grid and returns an empty
Grid
object based on this bandwidth part.- Parameters:
numPlanes (int) – The number of “planes” in the resource grid. See the
Grid
class for more information.useReDesc (Boolean (default: False)) – If
True
, the resource grid created will also include additional fields that describe the content of each resource element (RE). This can be used during the debugging to make sure the resources are allocated correctly. See theGrid
class for more information.
- Returns:
An empty
Grid
object based on this bandwidth part object.- Return type:
- getCpTime(symIdxInSubframe)
Returns the duration of Cyclic Prefix in seconds for the OFDM symbol specified by
symIdxInSubframe
.- Parameters:
symIdxInSubframe (int) – The index of symbol from the beginning of subFrame.
- Returns:
The duration of Cyclic Prefix in seconds for the OFDM symbol specified by
symIdxInSubframe
.- Return type:
floating point number
- getCpLen(symIdxInSubframe)
Returns the number of time samples in Cyclic Prefix for the OFDM symbol specified by
symIdxInSubframe
. This is based on TS 38.211, Section 5.3.1.- Parameters:
symIdxInSubframe (int) – The index of symbol from the beginning of subFrame.
- Returns:
The number of time samples in Cyclic Prefix for the OFDM symbol specified by
symIdxInSubframe
. .- Return type:
int
- getSymTime(symIdxInSubframe)
Returns the duration of the OFDM symbol specified by
symIdxInSubframe
in seconds.- Parameters:
symIdxInSubframe (int) – The index of symbol from the beginning of subFrame.
- Returns:
The duration of the OFDM symbol specified by
symIdxInSubframe
in seconds.- Return type:
floating point number
- getSlotTime(slotIndex=None)
Returns the duration of the slot specified by
slotIndex
in seconds.- Parameters:
slotIndex (int (default: None)) – The index of slot from the beginning of subFrame. If this is None, current slot (
slotNoInSubFrame
) is used.- Returns:
The duration of the slot specified by
slotIndex
in seconds.- Return type:
floating point number
- getSlotLen(slotIndex=None)
Returns the total number of time samples in the slot specified by
slotIndex
.- Parameters:
symIdxInSubframe (int (default: 0)) – The index of symbol from the beginning of subFrame.
- Returns:
The number of time samples in Cyclic Prefix for the OFDM symbol specified by
symIdxInSubframe
. .- Return type:
int
- getSlotsDuration(numSlots)
Returns the total durations in seconds for the next
numSlots
slots, starting from current slot in current subframe (slotNoInSubFrame
).- Parameters:
numSlots (int) – The number of next slots to include.
- Returns:
The total durations in seconds for the next
numSlots
slots.- Return type:
floating point number
- getSlotsSamples(numSlots)
Returns total number of samples in the next
numSlots
slots, starting from current slot in current subframe (slotNoInSubFrame
).- Parameters:
numSlots (int) – The number of next slots to include.
- Returns:
The total number of samples in the next
numSlots
slots.- Return type:
int
- getNumSlotsForSamples(ns)
Returns the number of slots that are completely covered by the next
ns
samples, starting from current slot in current subframe (slotNoInSubFrame
).- Parameters:
ns (int) – The number time samples.
- Returns:
The number of slots that are completely covered by the next
ns
samples.- Return type:
int
- getNumSymbolsForSamples(ns)
Returns the number of OFDM symbols that are completely covered by the next
ns
samples, starting from the beginning of current slot in current subframe (slotNoInSubFrame
).- Parameters:
ns (int) – The number time samples.
- Returns:
The number of OFDM symbols that are completely covered by the next
ns
samples.- Return type:
int
- class neoradium.carrier.Carrier(**kwargs)
This class implements the functionality of a Carrier. A Carrier object is used to specify a group of resource blocks used for uplink or downlink communication. A Carrier object can be associated with several
BandwidthPart
objects but only one can be active at any time.- Parameters:
kwargs (dict) –
A set of optional arguments.
- startRb:
The starting resource block (RB). This is the number of RBs from CRB 0. The default is 0.
- numRbs:
The number of RBs included in the bandwidth part. The default is 50.
- bwps:
A list of
BandwidthPart
objects associated with this Carrier. If this is not specified, a single bandwidth part is automatically created which covers the whole carrier.- cellId:
The Cell identifier of this Carrier. The default is 1.
- curBwpIndex:
The index of current bandwidth part. The default is 0.
Other Properties:
Here is a list of additional properties:
- slotNo:
Current slot number. A counter that can be used in simulation.
- frameNo:
Current frame number. A counter that can be used in simulation. This is incremented every
slotsPerFrame
slots.- curBwp:
The currently active
BandwidthPart
object.- frameNoRel:
The remainder of current frame number divided by 1024.
- slotNoInFrame:
The slot number in current frame.
- symbolsPerSlot:
The number of OFDM symbols in each slot based on the Numerology of the currently active
BandwidthPart
.- slotsPerSubFrame:
The number of slots per subframe based on the Numerology of the currently active
BandwidthPart
.- slotsPerFrame:
The number of slots per frame based on the Numerology of the currently active
BandwidthPart
.- symbolsPerSubFrame:
The number of OFDM Symbols per subframe based on the Numerology of the currently active
BandwidthPart
.
- print(indent=0, title='Carrier Properties:', getStr=False)
Prints the properties of this
Carrier
object.- Parameters:
indent (int (default: 0)) – The number of indentation characters.
title (str (default: None)) – If specified, it is used as a title for the printed information.
getStr (Boolean (default: False)) – If
True
, it returns the information in a text string instead of printing the information.
- Returns:
If the
getStr
parameter isTrue
, then this function returns the information in a text string. Otherwise, nothing is returned.- Return type:
None or str
- goNext()
Increments current slot number in this carrier (
slotNo
). If the slot number passes the boundary of a frame, the a frame number (frameNo
) is also incremented.
- createGrid(numPorts, useReDesc=False)
Creates a resource grid and returns an empty
Grid
object based on the currently activeBandwidthPart
. SeeBandwidthPart.createGrid()
for more details.