Main Content

addNodes

Add nodes to simulation

    Description

    example

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

    Examples

    collapse all

    Create a wirelessNetworkSimulator object. 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, ...
              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]);

    Specify the simulation time in seconds.

    simulationTime = 0.05;

    Run the simulation for the specified simulation time.

    run(networkSimulator,simulationTime);
    Custom channel model is not added. Using free space path loss (fspl) model as the default channel model.
    

    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]
    
    

    Input Arguments

    collapse all

    Wireless network simulator, specified as a wirelessNetworkSimulator object.

    Nodes to transmit and receive data, specified as a bluetoothLENode object or bluetoothNode object.

    Version History

    Introduced in R2022b