Carriers and Bandwidth Parts

The module carrier.py implements the classes Carrier and BandwidthPart. Each Carrier can be associated with several BandwidthPart objects. This implementation is based on 3GPP TS 38.211.

class neoradium.carrier.BandwidthPart(carrier=None, **kwargs)

This class encapsulates the functionality of a bandwidth part. A bandwidth part is a subset of contiguous common resource blocks for a specific numerology on a given carrier. For more detailed information, please refer to 3GPP TS 38.211, section 4.4.5. You typically create a Carrier object and retrieve its current BandwidthPart using its curBwp property. Since we usually work with bandwidth parts in simulations, you can also instantiate a BandwidthPart object directly passing both numerology and carrier information. For example, the following line create both a BandwidthPart and a Carrier object. A reference to the carrier objects is available as bwp.carrier.

# Create a BandwidthPart. This internally creates a carrier with 24 resource blocks.
bwp = BandwidthPart(numRbs=24, spacing=30, interleavingBundleSize=2)
Parameters:
  • carrier (Carrier or None) –

    The carrier associated with this bandwidth part. If None, a new carrier is created with only one bandwidth part (this object) and its properties can be set using the parameters passed in kwargs. For example:

    # Create a BandwidthPart. This internally creates a carrier with 24 resource blocks.
    bwp = BandwidthPart(numRbs=24, spacing=30, interleavingBundleSize=2)
    

  • 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 TS 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.

    interleavingBundleSize:

    The bundle size of the interleaving process. It can be one of 0 (default), 2, or 4. The value 0 means interleaving is disabled (default). See 3GPP TS 38.211, Section 7.3.1.6 for more information.

Other Properties:

Here is a list of additional properties:

u:

The numerology value, which falls within the range of 0 to 6 (\(\mu\)). See 3GPP TS 38.211, table 4.2-1.

bandwidth:

The bandwidth of this bandwidth part in Hz.

nFFT:

The FFT size used for OFDM modulation of the resource grids (See Grid), which are created based on this bandwidth part. It is calculated as follows:

\[N_{FFT} = \big [\frac {\frac {f_s} {1000} - \sum_{l=0}^{N_{symb}^{slot}-1} N_{CP,l}^{\mu}} {N_{symb}^{subframe,\mu}} \big ]\]

where \(f_s=\frac 1 {T_s}\), is the 5G sample rate (\(f_s=30,720,000\) Hz), \(N_{symb}^{slot}\) is the number of symbols per slot, \(N_{CP,l}^{\mu}\) is the number of samples in the cyclic prefix of symbol \(l\) based on numerology \(\mu\), and \(N_{symb}^{subframe,\mu}\) is the number of symbols in each subframe for numerology \(\mu\).

symbolsPerSlot:

The number of OFDM symbols in each slot (\(N_{symb}^{slot}\)). This is equal to 14 and 12 for “Normal” and “Extended” Cyclic Prefix types, respectively.

slotsPerSubFrame:

The number of slots per subframe based on the current numerology (\(N_{slot}^{subframe,\mu}\)).

symbolLens:

A list of symbol length values in number of time samples for every symbol in a subframe. The symbol length for symbol l, symbolLens[l], is the sum of \(N_{FFT}\) and \(N_{CP,l}^{\mu}\).

slotsPerFrame:

The number of slots per frame based on current numerology (\(N_{slot}^{frame,\mu}\)).

symbolsPerSubFrame:

The number of OFDM Symbols per subframe based on current numerology (\(N_{symb}^{subframe,\mu}\)).

slotNoInFrame:

The slot number in the current frame (\(n_{s,f}^{\mu}\)).

slotNoInSubFrame:

The slot number in the current subframe (\(n_{s}^{\mu}\)).

avgSlotDuration:

The average slot duration in seconds.

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 (\(f_s=\frac 1 {T_s}\)).

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 spent transmitting the Cyclic Prefix, which does not carry useful information.

print(indent=0, title=None, getStr=False)

Prints the properties of this BandwidthPart object.

Parameters:
  • indent (int) – The number of indentation characters.

  • title (str or None) – If specified, it is used as the title for the printed information. If None (the default), the text “Bandwidth Part Properties:” is used for the title.

  • getStr (bool) – If True, returns a string instead of printing it.

Returns:

If the getStr parameter is True, then this function returns the information in a string. Otherwise, nothing is returned.

Return type:

None or str

createGrid(numPorts=1, numPlanes=None)

Creates a resource grid and returns an empty Grid object based on this bandwidth part.

Parameters:

numPorts (int) – The number of “ports” in the resource grid. See the Grid class for more information.

Returns:

An empty Grid object based on this bandwidth part object.

Return type:

Grid

getCpLen(symIdxInSubFrame)

Returns the number of time samples in the 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 the symbol from the beginning of the subframe.

Returns:

The number of time samples in the cyclic prefix for the OFDM symbol specified by symIdxInSubFrame.

Return type:

int

getSlotLen(slotIndex=None)

Returns the total number of time samples in the slot specified by slotIndex.

Parameters:

slotIndex (int) – The index of the slot from the beginning of subframe.

Returns:

The total number of time samples in the slot specified by slotIndex.

Return type:

int

getSymLens()

Returns an array containing the symbol lengths for the symbols in the current slot, plus the first symbol of the next slot. The symbol length represents the total number of samples (at a sampling rate of 30,720,000 samples per second) for each symbol.

Returns:

An array containing the symbol lengths for all the symbols in the current slot, plus the first symbol of the next slot. Therefore, the length of the returned array is symbolsPerSlot+1.

Return type:

NumPy array

class neoradium.carrier.Carrier(**kwargs)

This class encapsulates the functionality of a Carrier. A Carrier object serves as a container for a group of resource blocks dedicated to either uplink or downlink communication. It is possible to associate a Carrier object with multiple instances of the BandwidthPart class, but only one instance 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 carrier. The default is 52.

bwps:

A list of BandwidthPart objects associated with this Carrier. If this is not specified, a single bandwidth part is automatically created covering the whole carrier. In this case, the following additional BandwidthPart parameters can also be specified when creating the Carrier object:

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 TS 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.

interleavingBundleSize:

The bundle size of the interleaving process. It can be one of 0 (default), 2, or 4. The value 0 means interleaving is disabled (default). See 3GPP TS 38.211 Section 7.3.1.6 for more information.

cellId:

The cell identifier of this carrier. The default is 1.

curBwpIndex:

The index of the 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 the current frame number divided by 1024.

slotNoInFrame:

The slot number in the current frame (\(n_{s,f}^{\mu}\)).

symbolsPerSlot:

The number of OFDM symbols in each slot (\(N_{symb}^{slot}\)) based on the numerology of the currently active BandwidthPart. This is equal to 14 and 12 for “Normal” and “Extended” Cyclic Prefix types, respectively.

slotsPerSubFrame:

The number of slots per subframe based on the numerology of the currently active BandwidthPart (\(N_{slot}^{subframe,\mu}\)).

slotsPerFrame:

The number of slots per frame based on the numerology of the currently active BandwidthPart (\(N_{slot}^{frame,\mu}\)).

symbolsPerSubFrame:

The number of OFDM symbols per subframe based on the numerology of the currently active BandwidthPart (\(N_{symb}^{subframe,\mu}\)).

Example:

# Create a carrier with a single BandwidthPart:
carrier = Carrier(startRb=0, numRbs=25, spacing=30, cpType="Normal")
print(indent=0, title=None, getStr=False)

Prints the properties of this Carrier object.

Parameters:
  • indent (int) – The number of indentation characters.

  • title (str or None) – If specified, it is used as the title for the printed information. If None (the default), the text “Carrier Properties:” is used for the title.

  • getStr (bool) – If True, returns a string instead of printing it.

Returns:

If the getStr parameter is True, then this function returns the information in a string. Otherwise, nothing is returned.

Return type:

None or str

restart()

Resets this carrier’s slot and frame counters to zero. Use this to rewind the carrier’s timing state to the beginning of a simulation run (e.g., between Monte-Carlo trials). The counterpart goNext() advances the counters by one slot.

goNext()

Increments the current slot number in this carrier (slotNo). If the slot number crosses a frame boundary, the frame number (frameNo) is also incremented.

createGrid(numPorts)

Creates a resource grid and returns an empty Grid object based on the currently active BandwidthPart. See BandwidthPart.createGrid() for more details.

class neoradium.carrier.ReservedPrbSet(bwp, prbs, symbols, pattern='1')

Represents a set of reserved resource blocks and OFDM symbols within a BWP, as defined in 3GPP TS 38.214 Section 5.1.4.1. A reserved resource set is used to mark time-frequency resources that should not be used for PDSCH transmission. The reservation is defined by:

  • a set of reserved PRB indices,

  • a set of reserved OFDM symbol indices within one or two slots, and

  • a periodic activity pattern.

The RB and symbol reservations may be provided either as bitmaps or as lists of indices. The activity pattern is provided as a bitmap string, where a ‘1’ indicates that the corresponding reservation unit is active.

Notes

  • Bitmap strings use the least significant bit (LSB) on the right, i.e. the last character in the string corresponds to bit 0.

  • The symbol bitmap may describe one slot or two consecutive slots.

  • The pattern length must be one of the values allowed by 3GPP TS 38.214 Section 5.1.4.1.

Parameters:
  • bwp (BandwidthPart) – The bandwidth part to which this reservation applies.

  • prbs (str or list of int) –

    Reserved physical resource blocks, corresponding to resourceBlocks in 3GPP TS 38.214.

    • If a string is provided, it is interpreted as a bitmap of ‘0’s and ‘1’s, with the LSB on the right. A ‘1’ means the corresponding RB is reserved.

    • If a list is provided, it is interpreted as the reserved symbol indices.

  • symbols (str or list of int) –

    Reserved OFDM symbols, corresponding to symbolsInResourceBlock in 3GPP TS 38.214.

    • If a string is provided, it is interpreted as a bitmap of ‘0’s and ‘1’s, with the LSB on the right. A ‘1’ means the corresponding OFDM symbol is reserved.

    • The bitmap length must be either symbolsPerSlot or 2*symbolsPerSlot.

    • If a list is provided, it is interpreted as the list of reserved symbol indices. If any index is greater than or equal to the slot length, the reservation is assumed to span two slots.

  • pattern (str, optional) – Periodicity and activity pattern, corresponding to periodicityAndPattern in 3GPP TS 38.214. This must be a bitmap string of ‘0’s and ‘1’s, with the LSB on the right. A ‘1’ means the corresponding reservation unit is active. The pattern length must be one of: 1, 2, 4, 5, 8, 10, 20, 40. A unit corresponds to one slot or two slots, depending on the symbol configuration. The maximum pattern duration is 40 ms.