Contenido principal

addNodes

Add nodes to simulator

Since R2022b

    Description

    addNodes(networkSimulator,nodes) adds the specified wireless nodes to the wirelessNetworkSimulator object. You must add the nodes to the simulator before running the simulation.

    example

    Examples

    collapse all

    Create a wirelessNetworkSimulator object by using the wirelessNetworkSimulator.init() function. By default, the wirelessNetworkSimulator object applies free-space path loss model for the channel effects.

    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, ...
        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]);

    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: [1×1 struct]
        Baseband: [1×1 struct]
             PHY: [1×1 struct]
    
    
    peripheralStats = statistics(peripheralNode)
    peripheralStats = struct with fields:
            Name: "Node2"
              ID: 2
             App: [1×1 struct]
        Baseband: [1×1 struct]
             PHY: [1×1 struct]
    
    

    Input Arguments

    collapse all

    Wireless network simulator, specified as a wirelessNetworkSimulator object.

    Nodes to transmit and receive data, specified as one of these options.

    Version History

    Introduced in R2022b

    expand all