Main Content

networkTrafficOnOff

On-Off application traffic pattern generator

Since R2022a

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. The On-Off traffic model, as depicted in the figure, consists of two states: on and off. This model generates packets with fixed inter-arrival time during on-state. The on-state and off-state durations follow an exponential distribution with mean OnExponentialMean and OffExponentialMean, respectively.

On-Off Model

You can use the On-Off application traffic pattern in system-level simulations to model the real-world data traffic.

Creation

Description

example

cfgOnOff = networkTrafficOnOff creates a default On-Off application traffic pattern object.

cfgOnOff = networkTrafficOnOff(Name=Value) sets properties using one or more name-value arguments. For example, GeneratePacket=true generates an application packet.

Properties

expand all

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

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

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

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

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

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

Flag to indicate whether the object generates an application packet, specified as a logical 0 (false) or 1 (true).

Data Types: logical

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

expand all

generateGenerate next FTP, On-Off, VoIP, or video conference application traffic packet

Examples

collapse all

Create a default On-Off application traffic pattern object.

cfgOnOff = networkTrafficOnOff;

Generate an On-Off application traffic pattern.

[dt,packetSize] = generate(cfgOnOff);

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

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

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

Figure contains an axes object. The axes object with title Packet Size Versus Packet Number, xlabel Packet Number, ylabel Packet Size in Bytes contains an object of type stem.

Visualize the On-Off packet intervals.

figure;
stem(dt); 
title('dt Versus Packet Number');
xlabel('Packet Number');
ylabel('dt in milliseconds');

Figure contains an axes object. The axes object with title dt Versus Packet Number, xlabel Packet Number, ylabel dt in milliseconds contains an object of type stem.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced in R2022a

expand all