Main Content

addMobility

Add random waypoint mobility model to WLAN node

Since R2023b

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

    Description

    addMobility(wnode) adds a random waypoint mobility model to one or more wireless local-area network (WLAN) nodes, wnode. In the random waypoint model, a wireless node pauses for some duration at a location before moving towards its next random destination (waypoint) with a random speed. The node repeats this process at each waypoint.

    example

    addMobility(wnode,Name=Value)sets the random waypoint mobility configuration parameters using one or more optional name-value arguments. For example, PauseDuration=0.02 sets the pause duration of a WLAN node to 0.02 seconds. If you add random waypoint mobility models to multiple wireless nodes in a single addMobility function call, all the nodes use the mobility parameter values specified by the name-value arguments.

    Examples

    collapse all

    Simulate a wireless local area network (WLAN) using WLAN Toolbox™ with the Communications Toolbox™ Wireless Network Simulation Library.

    In this example, you:

    1. Create and configure a WLAN with an access point (AP) node and a station (STA) node.

    2. Add application traffic from the AP node to the STA node.

    3. Simulate the WLAN and retrieve the statistics of the AP node and the STA node.

    Check if the Communications Toolbox™ Wireless Network Simulation Library support package is installed. If the support package is not installed, MATLAB® returns an error with a link to download and install the support package.

    wirelessnetworkSupportPackageCheck;

    Create a wireless network simulator.

    networksimulator = wirelessNetworkSimulator.init();

    Create a wlanDeviceConfig object, specifying the operating mode and beacon interval. Use this configuration to create a WLAN node and specify its name and position.

    deviceCfg = wlanDeviceConfig(Mode="AP",BeaconInterval=5);
    apNode = wlanNode(Name="AP",Position=[0 10 0],DeviceConfig=deviceCfg);

    Create a WLAN node with the default device configuration. Confirm that the default mode is STA.

    staNode = wlanNode(Name="STA",Position=[5 0 0]);
    disp(staNode.DeviceConfig.Mode)
    STA
    

    Add a random waypoint mobility model to the WLAN node with the default device configuration. Set the shape of the node's mobility area to "circle".

    addMobility(staNode,BoundaryShape="circle");

    Associate the STA node with the AP node using the associateStations function.

    associateStations(apNode,staNode);

    Create a networkTrafficOnOff object to generate an On-Off application traffic pattern. Specify the data rate in kilobits per second and the packet size in bytes. Enable packet generation to generate an application packet with a payload.

    traffic = networkTrafficOnOff(DataRate=100,PacketSize=10,GeneratePacket=true);

    Add application traffic from the AP node to the STA node.

    addTrafficSource(apNode,traffic,DestinationNode=staNode);

    Add the AP node and STA node to the wireless network simulator.

    addNodes(networksimulator,{apNode,staNode});

    Set the simulation time in seconds and run the simulation.

    simulationTime = 0.05;
    run(networksimulator,simulationTime);

    Get and display the physical layer (PHY) statistics that correspond to the AP node and STA node.

    apStats = statistics(apNode);
    staStats = statistics(staNode);
    disp(apStats.PHY)
             TransmittedPackets: 135
        TransmittedPayloadBytes: 6165
                ReceivedPackets: 126
           ReceivedPayloadBytes: 1764
                 DroppedPackets: 0
    
    disp(staStats.PHY)
             TransmittedPackets: 126
        TransmittedPayloadBytes: 1764
                ReceivedPackets: 135
           ReceivedPayloadBytes: 6165
                 DroppedPackets: 0
    

    Input Arguments

    collapse all

    WLAN node, specified as a wlanNode object or an array of wlanNode objects.

    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: addMobility(wnode,PauseDuration=0.02) sets the pause duration for a WLAN node, after it reaches a target waypoint, to 0.02 seconds.

    Speed range, specified as a two-element numeric vector. The function sets the speed of the WLAN node according to a continuous uniform distribution based on this range. The first element of the vector specifies the minimum speed of the node, while the second specifies the maximum speed, in meters per second.

    Data Types: double

    Pause duration of the WLAN node after reaching a target waypoint, specified as a nonnegative scalar. Units are in seconds.

    Data Types: double

    Shape of the node mobility area, specified as "rectangle" or "circle".

    Data Types: char | string

    Center coordinates and dimensions of the mobility area, specified as a three-element or four-element numeric vector, depending on the value of the BoundaryShape argument.

    • "rectangle" — Specify a four-element numeric vector of the form [xcenter ycenter length width]. The default value is [xcurrent ycurrent 10 10], where the first two elements specify the xy-coordinates of current node position.

    • "circle" — Specify a three-element numeric vector of the form [xcenter ycenter radious]. The default value is [xcurrent ycurrent 10], where the first two elements specify the xy-coordinates of current node position.

    Data Types: double

    Version History

    Introduced in R2023b