Main Content

addChannelModel

Add custom channel or path loss model

Since R2022b

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

    Description

    example

    addChannelModel(networkSimulator,customMdl) adds a custom channel model or path loss model to the wireless network simulation. The addChannelModel function sets the ChannelFunction property of the wirelessNetworkSimulator object to the custom model that you specified by customMdl.

    Examples

    collapse all

    Create a wirelessNetworkSimulator object.

    networkSimulator = wirelessNetworkSimulator.init();

    Create two Bluetooth BR nodes, one with the "central" role and other with the "peripheral" role. Specify the position of the Peripheral node in meters.

    centralNode = bluetoothNode("central");
    peripheralNode = bluetoothNode("peripheral",Position=[1 0 0]);

    Create a default Bluetooth BR connection configuration object to configure and share a connection between Bluetooth BR Central and Peripheral nodes.

    cfgConnection = bluetoothConnectionConfig;

    Configure connection between the Central and the Peripheral nodes.

    connection = configureConnection(cfgConnection,centralNode,peripheralNode);

    Create and configure a networkTrafficOnOff object to generate an On-Off application traffic pattern.

    traffic = networkTrafficOnOff(DataRate=200,PacketSize=27, ...
        GeneratePacket=true,OnTime=inf);

    Add application traffic from the Central to the Peripheral node.

    addTrafficSource(centralNode,traffic, ...
        DestinationNode=peripheralNode);

    Add the Central and Peripheral nodes to the wireless network simulator.

    addNodes(networkSimulator,[centralNode peripheralNode]);

    By default, the wirelessNetworkSimulator object applies free-space path loss model for the channel effects. You can add custom channel effects by using the addChannelModel function. However, to model the channel without any channel effects, specify a custom MATLAB™ function, removeChannelEffect, in which the input transmitted packets are returned at the output without any changes.

    addChannelModel(networkSimulator,@removeChannelEffect);

    Specify the simulation time in seconds.

    simulationTime = 0.05;

    Run the simulation for the specified simulation time.

    run(networkSimulator,simulationTime);

    Retrieve application, baseband, and physical layer (PHY) statistics corresponding to the Central and Peripheral nodes.

    centralStats = statistics(centralNode)
    centralStats = struct with fields:
            Name: "Node1"
              ID: 1
             App: [1x1 struct]
        Baseband: [1x1 struct]
             PHY: [1x1 struct]
    
    
    peripheralStats = statistics(peripheralNode)
    peripheralStats = struct with fields:
            Name: "Node2"
              ID: 2
             App: [1x1 struct]
        Baseband: [1x1 struct]
             PHY: [1x1 struct]
    
    
    function outputData = removeChannelEffect(~,txData)
    outputData = txData;
    end

    Input Arguments

    collapse all

    Wireless network simulator, specified as a wirelessNetworkSimulator object.

    Function for computing the custom channel or path loss model, specified as a function handle. The syntax for the custom function must be of the format:

    rxData = customFcnName(rxInfo,txData)

    The rxInfo input is the receiver node information, and the txData input specifies the transmitted packets. The simulator automatically passes information about the receiver node and the packets transmitted by a transmitter node as inputs to the custom function.

    The receiver node information is a structure with these fields.

    FieldDescription
    IDUnique receiver node identifier.
    PositionPosition of the receiver node in 3-D Cartesian coordinates (x, y, z). Units are in meters.
    VelocityVelocity of the receiver node (Vrx, Vry, Vrz) in the x-, y-, and z-directions. Units are in meters per second.
    NumReceiveAntennasNumber of antennas at the receiver.

    The packets from the transmitter node is a structure with these fields.

    FieldDescription
    Type

    Type of input signal packet, specified as one of these values: 0, 1, 2, 3, and 4.

    • 0 — Invalid packet

    • 1 — WLAN packet

    • 2 — 5G packet

    • 3 — Bluetooth LE packet

    • 4 — Bluetooth BR/EDR packet

    TransmitterIDUnique transmitter node identifier, specified as a positive scalar integer.
    TransmitterPositionPosition of the transmitter node in 3-D Cartesian coordinates (x, y, z). Units are in meters.
    TransmitterVelocityVelocity of the transmitter node (Vtx, Vty, Vtz) in the x-, y-, and z-directions. Units are in meters per second.
    StartTimeTime at which the transmitter starts transmitting the packets, specified as a nonnegative scalar. Units are in seconds.
    DurationDuration of the transmitter packet, specified as a positive scalar. Units are in seconds.
    PowerPower of the waveform. Units are in dBm.
    CenterFrequencyCenter frequency of the carrier signal. Units are in Hz.
    BandwidthCarrier signal bandwidth. Units are in Hz.
    Abstraction

    Type of abstraction, specified as a logical scalar.

    • 1 — Abstracted physical layer

    • 0 — Full physical layer

    The default value is 0.

    SampleRateSample rate of the packet, specified as a numeric scalar in samples per second. This field is applicable only if the value of the Abstraction field is set to 0. The default value is [ ].
    DirectToDestination

    Information about the transmitted packet, specified as a numeric scalar integer.

    • The value is 0 if a normal packet is transmitted over the channel.

    • The value is a nonzero scalar integer if the packet bypasses the channel model and is transmitted directly to the destination node. In this case, this field value specifies the destination node identifier.

    Data

    Time-domain samples or frame information.

    • The field contains time-domain samples of the transmitted packet for the full physical layer. In this case, the value of the Abstraction field is 0.

    • The field contains frame information for the abstracted physical layer. In this case, the value of the Abstraction field is 1.

    Metadata

    A structure representing the technology-specific and abstraction-specific information of the packet. The structure contains this field.

    • Channel — A structure representing the information about the channel. The structure contains these fields.

      • PathGains — Complex path gains at each snapshot in time. It is a matrix of size Ncs-by-Np-by-Nt-by-Nr.

      • PathDelays — Delays corresponding to each path, in seconds. It is a vector of size 1-by-Np.

      • PathFilters — Filter coefficients for each path. It is a matrix of size Np-by-Nf.

      • SampleTimes — Simulation time corresponding to each path gains snapshot, in seconds. It is a vector of size Ncs-by-1.

      The variables Ncs, Np, Nt, Nr, and Nf represents the number of channel snapshots, number of paths, the number of transmit antennas, the number of receive antennas, and the number of filter coefficients, respectively.

    The custom channel model function applies channel effects to the packets transmitted by the simulator. The modified packets are then sent back to the simulator. The packets returned at the output must be a structure with same fields as those of the transmitted packets.

    The custom channel model function must update these fields in the transmitted packet to include channel effects.

    • Power — Include large-scale effects.

    • Data — Include small and large-scale effects by scaling the data if the value of Abstraction is false.

    • Metadata.Channel — Update this field when you use a channel estimation algorithm that requires perfect channel information. If the value of Abstraction is true, you must update this field.

    • Duration — Include the final transient in the calculation of the duration of the channel-impaired packet, which equals actual packet duration + final transient. The final transient equals delay spread + filter length – implementation delay. Updating this field is optional.

    Data Types: function_handle

    Version History

    Introduced in R2022b

    expand all