addTrafficSource
Download Required: To use addTrafficSource
,
first download the Communications Toolbox Wireless Network Simulation Library add-on.
Description
addTrafficSource(
adds the data traffic source nodeObj
,trafficSource
)trafficSource
to the WLAN node
nodeObj
.
addTrafficSource(___,
specifies options using one or more name-value arguments in addition to the previous syntax.Name=Value
)
Note
Reusing the same traffic source object in another
addTrafficSource
function call results in an error.
Examples
Create, Configure, and Simulate Wireless Local Area Network
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. 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
nodeObj
— WLAN node
wlanNode
object
WLAN node, specified as a wlanNode
object. The function adds a
data traffic source to this node.
trafficSource
— Data traffic source
networkTrafficOnOff
object | networkTrafficFTP
object | networkTrafficVideoConference
object | networkTrafficVoIP
object
Data traffic source, specified as a networkTrafficOnOff
, networkTrafficFTP
, networkTrafficVideoConference
, or networkTrafficVoIP
object. The function adds this data traffic source to the
WLAN node that you specify for the nodeObj
argument.
When you add the application traffic to a WLAN node by using this object function,
the nodeObj
automatically calls the generate
object function associated with the networkTrafficOnOff
, networkTrafficFTP
, networkTrafficVideoConference
, or networkTrafficVoIP
objects to generate the corresponding application traffic
packet, respectively.
If you enable the MACFrameAbstraction
property of the nodeObj
input, the GeneratePacket
property of this input is not
applicable.
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: AccessCategory = 1
specifies that the access category of the
generated traffic is from the Background category.
DestinationNode
— Destination node of traffic
wlanNode
object
Destination node of the traffic, specified as a wlanNode
object. If you do not
specify this argument, the source node broadcasts its traffic.
AccessCategory
— Access category
0
(default) | integer in the range [0, 3]
Access category, specified as an integer in the range [0, 3]. The four possible values respectively correspond to the Best Effort, Background, Video, and Voice access categories.
Data Types: single
| double
Version History
Introduced in R2023a
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
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)