wirelessPacket
Syntax
Description
creates an empty
wireless packet structure.packet = wirelessPacket
This structure serves as a template for representing packets within the simulator.
wnet.Node uses this
packet in functions such as pullTransmittedPacket, pushReceivedPacket, and isPacketRelevant.
By default, the structure does not contain any information. You must assign values to the
fields of the structure using the syntax structure.field=value to define
packet properties as needed for their simulation.
Examples
Create and use a wireless packet within a custom wireless node class. This class demonstrates how a node generates a packet, fills in key transmission details, and stores the packet for use in a network simulation.
% CustomNode.m % Example MATLAB class: Demonstrates how a wireless node creates and uses a wireless packet structure. % This class simulates a simple wireless node that can transmit packets in a network simulation. classdef CustomNode < wnet.Node properties % IsTransmitter True if this node is a transmitter % Logical value. If true, node transmits packets. IsTransmitter = true end properties (SetAccess = private) % TransmitterBuffer Buffer that holds packet for transmission TransmitterBuffer end methods function nextInvokeTime = run(node,currentTime) % run Run the custom node. Main method called by the wirelessNetworkSimulator at each time step. % This custom node is a transmitter creating a wireless packet at each time step. if node.IsTransmitter packet = wirelessPacket; packet.TransmitterID = node.ID; packet.TransmitterPosition = node.Position; packet.TechnologyType = wnet.TechnologyType.Custom1; packet.Power = 23; packet.CenterFrequency = 2.4e9; packet.Bandwidth = 20e6; packet.SampleRate = 20e6; packet.StartTime = currentTime; packet.Duration = 0.1; packet.NumTransmitAntennas = 1; packet.Data = complex( ... rand(packet.Duration*packet.SampleRate,packet.NumTransmitAntennas,"single"), ... rand(packet.Duration*packet.SampleRate,1,"single")); node.TransmitterBuffer = packet; end nextInvokeTime = currentTime + 1; end function packet = pullTransmittedPacket(node) % pullTransmittedPacket Retrieve the packet ready for transmission packet = node.TransmitterBuffer; node.TransmitterBuffer = []; end end end
Output Arguments
Wireless packet, returned as a structure. The structure packet
contains these fields:
| Field Name | Description |
|---|---|
TechnologyType | Technology type of the packet. This field identifies the technology
associated with the packet. Accepted values are the constants present in
|
TransmitterID | Transmitter node identifier. The value of this field must be a
positive integer. The default value is |
TransmitterPosition | Position of the transmitter. The value of this field must be a
real-valued vector representing Cartesian x-,
y-, and z- coordinates in meters.
The default value is |
TransmitterVelocity | Velocity of the transmitter in the x-,
y-, and z-directions. The value of
this field must be a real-valued vector of the form
[vx
vy
vz], in meters per second. The
default value is |
NumTransmitAntennas | Number of antennas at the transmitter. The value of this field must
be a positive integer. The default value is |
StartTime | Packet transmission start time at the transmitter, or packet
arrival time at the receiver. Units are in seconds. The default value is
|
Duration | Duration of the packet. Units are in seconds. The default value is
|
Power | Power of the packet. Units are in dBm. The default value is
|
CenterFrequency | Center frequency of the carrier. Units are in Hz. The default value
is |
Bandwidth | Carrier bandwidth. Units are in Hz. This value is the bandwidth
around the center frequency. The default value is |
Abstraction | Abstraction type. The value of this field is a logical
|
SampleRate | Sample rate of the signal transmitted in the
|
DirectToDestination | Flag that controls whether to apply the channel. The value of this field must be one of the following options.
The default value is |
Data | Time samples (for full PHY) or frame information (for abstracted
PHY). If The default
value is |
Metadata | Information about the technology, abstraction, and channel of the packet, represented as a structure. The structure contains this field:
|
Tags | Optional information, represented as an array of structures, where each structure contains these fields:
Note The Tags field can contain any optional information about the whole
packet or about a sequence of contiguous bytes of the packet, as
indicated by
|
Data Types: struct
Version History
Introduced in R2026a
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.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- 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)