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.
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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)