This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

dsp.UDPSender System object

Package: dsp

Send UDP packets to network


The UDPSender object sends UDP packets to the network.

To send UDP packets to the network:

  1. Define and set up your UDP sender. See Construction.

  2. Call step to send the packets according to the properties of dsp.UDPSender. The behavior of step is specific to each object in the toolbox.

    Note:   Starting in R2016b, instead of using the step method to perform the operation defined by the System object™, you can call the object with arguments, as if it were a function. For example, y = step(obj,x) and y = obj(x) perform equivalent operations.


H = dsp.UDPSender returns a UDP sender object, H, that sends UDP packets to a specified port.

H = dsp.UDPSender('PropertyName',PropertyValue, ...) returns a UDP sender object, H, with each property set to the specified value.



Remote address to which to send data

Specify the remote (i.e., host) IP address to which the data is sent. The default is '', which is the local host.


Remote port to which to send data

Specify the port at the remote IP address to which the data is sent. The default is 25000.


Source of the LocalIPPort property

Specify how to determine the port on the host as | Auto | Property |. If you specify Auto, the object selects the port dynamically from the available ports. If you specify Property, the object uses the source specified in the LocalIPPort property. The default is Auto.


Local port from which to send data

Specify the port from which to send data. This property applies when you set the LocalIPPortSource property to Auto. The default is 25000.


cloneCreate UDP sender object with same property values
getNumInputsNumber of expected inputs to step method
getNumOutputsNumber of outputs of step method
isLockedLocked status for input attributes and nontunable properties
releaseAllow property value and input characteristics changes
stepSend a UDP packet to network


expand all

Note: This example runs only in R2016b or later. If you are using an earlier release, replace each call to the function with the equivalent step syntax. For dsp.UDPReceiver System object™, myObject() becomes step(myObject). For all other objects, myObject(x) becomes step(myObject,x).

Send some UDP packets, and calculate the number of successfully transmitted bytes:

hudpr = dsp.UDPReceiver('LocalIPPort',31000);
hudps = dsp.UDPSender('RemoteIPPort',31000);
% To prevent the loss of packets, call the |setup| method
% on the object before the first call to the |step| method.

bytesSent = 0;
bytesReceived = 0;
dataLength = 128;

for k = 1:20
   dataSent = uint8(255*rand(1,dataLength));
   bytesSent = bytesSent + dataLength;
   dataReceived = hudpr();
   bytesReceived = bytesReceived + length(dataReceived);


fprintf('Bytes sent:     %d\n', bytesSent);
fprintf('Bytes received: %d\n', bytesReceived);
Bytes sent:     2560
Bytes received: 2560


This object implements the algorithm, inputs, and outputs described on the UDP Send block reference page. The object properties correspond to the block parameters.

Introduced in R2012a

Was this topic helpful?