associateStations
Download Required: To use associateStations
,
first download the Communications Toolbox Wireless Network Simulation Library add-on.
Description
associateStations(
associates the list of stations (STAs) specified in nodeObj
,associatedSTAs
)associatedSTAs
to
the access point (AP) that you specify in nodeObj
.
associateStations(___,
specifies options using one or more name-value arguments, in addition to the previous
syntax.Name=Value
)
Examples
Simulate a wireless local area network (WLAN) using WLAN Toolbox™ with the Communications Toolbox™ Wireless Network Simulation Library.
In this example, you:
Create and configure a WLAN with an access point (AP) node and a station (STA) node.
Add application traffic from the AP node to the STA node.
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.
traffic = networkTrafficOnOff(DataRate=100,PacketSize=10);
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.5; 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: 1243 TransmittedPayloadBytes: 58779 ReceivedPackets: 1146 ReceivedPayloadBytes: 16044 DroppedPackets: 0
disp(staStats.PHY)
TransmittedPackets: 1146 TransmittedPayloadBytes: 16044 ReceivedPackets: 1243 ReceivedPayloadBytes: 58779 DroppedPackets: 0
Since R2025a
Simulate an AP MLD and an STA MLD associated across multiple links, with each link having different operating frequencies for the associated AP and STA.
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
Initialize the wireless network simulator.
networksimulator = wirelessNetworkSimulator.init();
Create a wlanLinkConfig
object for each link of the AP MLD, specifying the BandAndChannel
, ChannelBandwidth
, PrimaryChannelIndex
, and InterferenceModeling
property values. Specify the MLD configuration parameters for the AP MLD by using the wlanMultilinkDeviceConfig
object. Create an AP MLD node from the specified MLD configuration by using the wlanNode
object.
apLinkConfig(1) = wlanLinkConfig(BandAndChannel=[2.4 7],ChannelBandwidth=40e6, ... PrimaryChannelIndex=2,InterferenceModeling="overlapping-adjacent-channel"); apLinkConfig(2) = wlanLinkConfig(BandAndChannel=[5 58],ChannelBandwidth=80e6, ... InterferenceModeling="overlapping-adjacent-channel"); apLinkConfig(3) = wlanLinkConfig(BandAndChannel=[6 15],ChannelBandwidth=160e6, ... InterferenceModeling="overlapping-adjacent-channel"); apDeviceCfg = wlanMultilinkDeviceConfig(Mode="AP",LinkConfig=apLinkConfig); apMLD = wlanNode(Name="AP",Position=[0 10 0],DeviceConfig=apDeviceCfg, ... MACFrameAbstraction=false,PHYAbstractionMethod="none");
Create a wlanLinkConfig
object for each link of the STA MLD, specifying the BandAndChannel
, ChannelBandwidth
, PrimaryChannelIndex
, and InterferenceModeling
property values. Specify the MLD configuration parameters for the STA MLD by using the wlanMultilinkDeviceConfig
object. Create an STA MLD node from the specified MLD configuration by using the wlanNode
object.
staLinkConfig(1) = wlanLinkConfig(BandAndChannel=[2.4 9],ChannelBandwidth=20e6, ... InterferenceModeling="overlapping-adjacent-channel"); staLinkConfig(2) = wlanLinkConfig(BandAndChannel=[5 54],ChannelBandwidth=40e6, ... InterferenceModeling="overlapping-adjacent-channel"); staLinkConfig(3) = wlanLinkConfig(BandAndChannel=[6 3],ChannelBandwidth=40e6, ... InterferenceModeling="overlapping-adjacent-channel"); staDeviceCfg = wlanMultilinkDeviceConfig(Mode="STA",LinkConfig=staLinkConfig); staMLD = wlanNode(Name="STA",Position=[5 0 0],DeviceConfig=staDeviceCfg, ... MACFrameAbstraction=false,PHYAbstractionMethod="none");
Associate the STA MLD node to the AP MLD by using the associateStations
object function. To configure DL application traffic between the AP MLD and the STA MLD, set the FullBufferTraffic
input of the associateStations
object function to "DL"
. An STA associates with an AP only if the AP's primary 20 MHz of the AP aligns with one of the 20 MHz subchannels of the STA.
associateStations(apMLD,staMLD,FullBufferTraffic="DL")
Add the nodes to the wireless network simulator.
addNodes(networksimulator,[apMLD, staMLD])
Specify the simulation time in seconds. Run the network simulation for the specified simulation time.
simulationTime = 0.5; run(networksimulator,simulationTime)
Retrieve the statistics at each node by using the statistics
object function of the wlanNode
object. You can also access the statistics for each link of the MLD node from within the PHY substructures of the statistics structure. For more information on the statistics, see WLAN System-Level Simulation Statistics.
apStats = statistics(apMLD,"all"); staStats = statistics(staMLD,"all"); disp(apStats.PHY.Link(1))
TransmittedPackets: 184 TransmittedPayloadBytes: 425776 ReceivedPackets: 183 ReceivedPayloadBytes: 4200 DroppedPackets: 0
disp(staStats.PHY.Link(1))
TransmittedPackets: 183 TransmittedPayloadBytes: 4200 ReceivedPackets: 183 ReceivedPayloadBytes: 421168 DroppedPackets: 0
Input Arguments
Access point, specified as a wlanNode
object. You must set the
Mode
property
of the access point's DeviceConfig
property to "AP"
. If you configure the access point for multiple
devices, you must set the Mode
property of at least one of the
wlanDeviceConfig
objects to
"AP"
.
Associated stations, specified as a wlanNode
object or a vector of
wlanNode
objects. You must set the Mode
property
of each object's DeviceConfig
property to "STA"
.
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: BandAndChannel=[2.4 13]
specifies that the AP uses the 2.4
GHz band and channel 13 to communicate with its stations.
Operating frequency band and channel number of AP, specified as a row vector of length 2 or an N-by-2 matrix. Specify this argument to choose the operating frequency band and channel number of the AP that forms the basic service set (BSS).
Associate AP non-multilink device (non-MLD) and STA non-MLDs — Specify this argument as a row vector with two elements. The first element specifies the band, with accepted values of 2.4 GHz, 5 GHz, and 6 GHz. The second element represents a valid channel number within the specified band. The
wlanNode
object automatically determines the default value by identifying the band and channel at AP such that the primary 20 MHz channel aligns with one of the 20 MHz subchannels of the STA.Associate AP MLD and STA non-MLD — Specify this argument as a row vector with two elements. The vector has the same meaning as in the case of an AP non-MLD and STA non-MLDs. (since R2024b)
Associate AP MLD and STA MLDs — Specify this argument as an N-by-2 matrix, where each row specifies a band and channel number. The default value is a matrix that the
wlanNode
object creates by incorporating the band and channel of each configured link into a row. Configure the band and channel values for all the links of STA nodes so that each link of the STA MLD associates with a unique link in the AP MLD. A STA link associates with an AP link when the primary 20 MHz of the AP link aligns with one of the 20 MHz subchannels of the STA link.
Data Types: double
Full buffer traffic options, specified as "off"
,
"on"
, "DL"
, or "UL"
. The
four options mean the following:
"off"
— Full buffer traffic is disabled."on"
— Two-way full buffer traffic is enabled."DL"
— Downlink full buffer traffic is enabled."UL"
— Uplink full buffer traffic is enabled.
Data Types: char
| string
Version History
Introduced in R2023a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)