Contenu principal

addTrafficSource

Add data traffic source to WLAN node

Since R2023a

Description

This feature also requires the Wireless Network Toolbox™ product.

addTrafficSource(nodeObj,trafficSource) copies the data traffic source object trafficSource and adds it to the WLAN node object nodeObj.

example

addTrafficSource(___,Name=Value) specifies options using one or more name-value arguments in addition to the previous syntax.

Note

  • Each time you call this object function, you add a traffic generator (source) to a WLAN node. You can add multiple traffic sources to a node, directing them to the same or different destination nodes.

  • Reusing the same traffic source object in another addTrafficSource object function call results in an error.

example

Examples

collapse all

This example enables you to:

  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.

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

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",RefreshInterval=0.1)

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

associateStations(apNode,staNode);

Create a networkTrafficOnOff (Wireless Network Toolbox) 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

Initialize the wireless network simulator.

networksimulator = wirelessNetworkSimulator.init();

Create a device configuration object for a WLAN node, specifying the operating mode as "AP" and beacon interval in time units.

deviceCfg = wlanDeviceConfig(Mode="AP",BeaconInterval=5);

Using the specified device configuration, create a WLAN AP. Specify the name and position of the AP node.

apNode = wlanNode(Name="AP",Position=[0 0 0],DeviceConfig=deviceCfg);

Create four WLAN STA nodes with the default device configuration. Specify the positions of each STA in 3-D Cartesian coordinates.

staNodes = wlanNode(Name=["STA1" "STA2" "STA3" "STA4"],Position=[0 1 0; 1 1 0; 0 1 1; 1 1 1]);

Associate the STA nodes with the AP node.

associateStations(apNode,staNodes);

Create a On-Off application traffic pattern object, specifying the data rate (in Kbps) and packet size (in bytes). Add application traffic from the AP node (source) to the four STA nodes (destination).

traffic = networkTrafficOnOff(DataRate=100,PacketSize=10);
addTrafficSource(apNode,networkTrafficOnOff,DestinationNode=staNodes,AccessCategory=0)

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

addNodes(networksimulator,[apNode staNodes]);

Specify the simulation time (in seconds) and run the simulation.

simulationTime = 1;
run(networksimulator,simulationTime);

Retrieve and display the statistics corresponding to the AP node and STA nodes.

apStats = statistics(apNode)
apStats = struct with fields:
    Name: "AP"
      ID: 1
     App: [1×1 struct]
     MAC: [1×1 struct]
     PHY: [1×1 struct]
    Mesh: [1×1 struct]

staStats = statistics(staNodes)
staStats=1×4 struct array with fields:
    Name
    ID
    App
    MAC
    PHY
    Mesh

Input Arguments

collapse all

WLAN node, specified as a wlanNode object, or a vector of wlanNode objects. The object function adds a data traffic source to this node. When you specify this value as a vector, you must leave the DestinationNode name-value argument unspecified or set it to a scalar.

Data traffic source, specified as an object of a subclass of the wnet.Traffic (Wireless Network Toolbox) class, networkTrafficOnOff object, networkTrafficFTP object, networkTrafficVideoConference object, or networkTrafficVoIP object. To add On-Off, file transfer protocol (FTP), video conference, or voice over internet protocol (VoIP) traffic, configure the networkTrafficOnOff (Wireless Network Toolbox), networkTrafficFTP (Wireless Network Toolbox), networkTrafficVideoConference (Wireless Network Toolbox), or networkTrafficVoIP (Wireless Network Toolbox) objects of the wnet.Traffic class. The object function adds this data traffic source to the WLAN node that you specify for the nodeObj argument.

You can also create a custom traffic source using the wnet.Traffic class.

When you add traffic to a WLAN node using this object function, the nodeObj object creates a copy of the trafficSource object and adds it to the node, ensuring that subsequent changes to the original trafficSource object do not affect the traffic already added. For more information, see the copy (Wireless Network Toolbox) object function. The nodeObj automatically calls the generate (Wireless Network Toolbox) object function of the wnet.Traffic class to create the corresponding application traffic packets. The generate object function generates application traffic packets only when the MACModel property of the WLAN node is set to "full-mac".

Name-Value Arguments

collapse all

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.

Destination node of the traffic, specified as a wlanNode object or a vector of wlanNode objects. If you do not specify this argument, the source node broadcasts its traffic. If you specify this name-value argument as a vector, the nodeObj input argument must be a scalar.

If the source node is a STA multilink device (MLD) operating in EMLSR mode or an AP MLD with at least one associated EMLSR STA, you must specify this argument. (since R2024b)

Access category, specified as a scalar 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

expand all

See Also

Objects