Main Content


Add data traffic source to 5G NR node

Since R2023a

    Download Required: To use addTrafficSource, first download the Communications Toolbox Wireless Network Simulation Library add-on.


    addTrafficSource(nrNode,trafficSource) adds a data traffic source, trafficSource, to a new radio (NR) node, nrNode. Note that nrNode automatically calls the generate object function associated with the specified traffic pattern object to generate the corresponding application traffic.


    addTrafficSource(___,Name=Value) specifies additional options by using name-value arguments, in addition to the input arguments in the previous syntax. For example, LogicalChannelID=5 sets the logical channel identifier to 5.


    Reusing the same traffic source object in another addTrafficSource function call results in an error.


    collapse all

    Initialize wireless network simulator.

    networkSimulator = wirelessNetworkSimulator.init;

    Create a gNB node with these specifications.

    • Duplex mode — Time division duplex

    • Channel bandwidth — 20 MHz

    • Subcarrier spacing — 30 KHz

    gnb = nrGNB(ChannelBandwidth=20e6,DuplexMode="TDD",SubcarrierSpacing=30e3);

    Create a UE node with a transmit power of 20 dBm.

    ue = nrUE(TransmitPower=20);

    Configure these uplink power control parameters at the gNB node.

    • Nominal transmit power of UE per resource block — 7 dBm

    • Fractional power control multiplier— 2


    Add a random way point mobility model to the UE node.


    Establish a connection between the UE and gNB nodes.


    Create a voice over Internet protocol (VoIP) application traffic pattern object.

    traffic = networkTrafficVoIP(GeneratePacket=true);

    Add the data traffic source to the gNB node. Set the destination node as the UE node.


    Add the gNB node to the wireless network simulator.


    Add the UE node to the wireless network simulator.


    Specify the simulation time, in seconds.

    simulationTime = 0.3;

    Run the simulation for the specified simulation time.


    Obtain the statistics for the gNB and UE nodes.

    gnbStats = statistics(gnb);
    ueStats = statistics(ue);

    Input Arguments

    collapse all

    5G NR node, specified as an nrGNB object or nrUE object.

    Traffic pattern object, specified as one of these options.

    Note that the GeneratePacket property of the traffic objects does not apply to the NR nodes because the NR nodes always generates an application packet with payload.

    Name-Value Arguments

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Example: addTrafficSource(nrNode,trafficSource,LogicalChannelID=5) adds a traffic source to logical channel 5 of the specified NR node

    Destination node, specified as an nrUE object or nrGNB object. If nrNode is an nrGNB, you must set the destination node to an nrUE object. If nrNode is an nrUE object, setting this name-value argument is optional. If you do not specify this name-value argument in the case nrNode is annrUE object, the object function automatically sets DestinationNode to the nrGNB object with which the UE has already established a connection.

    Logical channel identifier, specified as an integer in the range [4, 32]. The function maps the added traffic to the specified logical channel.

    If you do not specify LogicalChannelID, the function maps the added traffic to the established logical channel with the smallest ID number.

    Data Types: double


    [1] 3GPP TS 38.321. “NR; Medium Access Control (MAC) protocol specification.” 3rd Generation Partnership Project; Technical Specification Group Radio Access Network.

    Version History

    Introduced in R2023a