networkTrafficOnOff
Download Required: To use networkTrafficOnOff
,
first download the Communications Toolbox Wireless Network Simulation Library add-on.
Description
The networkTrafficOnOff
object specifies the configuration parameters
to generate an On-Off application traffic pattern.
You can use the On-Off application traffic pattern in system-level simulations to model the real-world data traffic.
Creation
Description
creates a
default On-Off application traffic pattern object.cfgOnOff
= networkTrafficOnOff
sets
properties using one or more name-value arguments. For example,
cfgOnOff
= networkTrafficOnOff(Name=Value)GeneratePacket=true
generates an application packet.
Properties
OnTime
— On state duration
[ ] (default) | positive scalar
On state duration, specified as a positive scalar. Units are in seconds. To specify a customized value for the On time, specify this property. If you do not specify this property, the object uses the exponential distribution to calculate the On time.
Data Types: double
OffTime
— Off state duration
[ ] (default) | nonnegative scalar
Off state duration in seconds, specified as a nonnegative scalar. To specify a customized value for the Off time, specify this property. If you do not specify this property, the object uses the exponential distribution to calculate the Off time.
Data Types: double
OnExponentialMean
— Exponential distribution mean value to calculate On state duration
1
(default) | positive scalar
Exponential distribution mean value in seconds to calculate the On state duration, specified as a positive scalar.
Dependencies
To enable this property, set the
OnTime
property to [ ]
.
Data Types: double
OffExponentialMean
— Exponential distribution mean value to calculate Off state duration
2
(default) | nonnegative scalar
Exponential distribution mean value in seconds to calculate the Off state duration, specified as a nonnegative scalar.
Dependencies
To enable this property, set the
OffTime
property to [ ]
.
Data Types: double
DataRate
— Packet generation rate during On state
5
(default) | positive scalar
Packet generation rate in Kbps during the On state, specified as a positive scalar.
Note
If the value of this property is low and the PacketSize
property value is large, the object might not generate
packets in the On state.
Data Types: double
PacketSize
— Length of packet to be generated
1500
(default) | positive scalar
Length in bytes of the packet to be generated, specified as a positive scalar. If
the value of this property is greater than the DataRate
property value, the object accumulates the data across multiple On times to generate a
packet.
Data Types: double
GeneratePacket
— Flag to indicate whether to generate application packet
false
or 0
(default) | true
or 1
Flag to indicate whether the object generates an application packet, specified as a
logical 0
(false
) or 1
(true
).
Data Types: logical
ApplicationData
— Application data to be added in packet
1500-by-1 vector of 1s (default) | column vector of integers in the range [0, 255]
Application data to be added in the packet, specified as a column vector of integers
in the range [0, 255]. If the size of the application data is greater than the PacketSize
property value, the object truncates the application data. If the size of the
application data is less than the PacketSize
property value, the
object appends zeros.
Dependencies
To enable this property, set the
GeneratePacket
property to true
.
Data Types: double
Object Functions
Specific to This Object
generate | Generate next FTP, On-Off, VoIP, or video conference application traffic packet |
Examples
Generate On-Off Application Traffic Pattern
Create a default On-Off application traffic pattern object.
cfgOnOff = networkTrafficOnOff;
Generate an On-Off application traffic pattern.
[dt,packetSize] = generate(cfgOnOff);
Generate On-Off Application Traffic Pattern Using On State Mean Value
Create an On-Off application traffic pattern object, specifying the exponentially distributed mean value of the On state.
cfgOnOff = networkTrafficOnOff(OnExponentialMean=5);
Generate an On-Off application traffic pattern.
[dt,packetSize] = generate(cfgOnOff);
Generate On-Off Application Traffic Pattern and Data Packet
Create an On-Off application traffic pattern object to generate an On-Off data packet.
cfgOnOff = networkTrafficOnOff(GeneratePacket=true);
Generate an On-Off application traffic pattern and data packet.
[dt,packetSize,packet] = generate(cfgOnOff);
Generate On-Off Application Traffic Pattern to Visualize Packet Sizes and Intervals
Create a default On-Off application traffic pattern object.
cfgOnOff = networkTrafficOnOff;
Generate an On-Off application traffic pattern with 200 On-Off packets.
numPkts = 200; dt = zeros(1,numPkts); packetSize = zeros(1,numPkts); for packetCount = 1:numPkts [dt(packetCount),packetSize(packetCount)] = generate(cfgOnOff); end
Visualize the On-Off packet sizes.
stem(packetSize); title('Packet Size Versus Packet Number'); xlabel('Packet Number'); ylabel('Packet Size in Bytes');
Visualize the On-Off packet intervals.
figure; stem(dt); title('dt Versus Packet Number'); xlabel('Packet Number'); ylabel('dt in milliseconds');
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Version History
Introduced in R2022aR2023a: Moved to Communications Toolbox Wireless Network Simulation Library from 5G Toolbox, WLAN Toolbox, and Bluetooth Toolbox
Previously, networkTrafficOnOff
required 5G Toolbox™, WLAN Toolbox™, or Bluetooth® Toolbox.
Open Example
You have a modified version of this example. Do you want to open this example with your edits?
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)