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.UDPReceiver System object

Package: dsp

Receive UDP packets from network


The UDPReceiver object receives UDP packets from the network.

To receive UDP packets from the network:

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

  2. Call step to receive the UDP packets according to the properties of dsp.UDPReceiver. 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) and y = obj() perform equivalent operations.


H = dsp.UDPReceiver returns a UDP receiver System object, H, that receives UDP packets from a specified port.

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



Local port on which to receive data

Specify the port on which to receive data. The default is 25000.


Address from which data was sent

Specify the remote IP address from which to receive data. The default is '', which indicates that data is accepted from any remote IP address.


Maximum size of internal buffer

Specify the size of the buffer that receives UDP packets, in bytes. The default is 8192.


Maximum size of output message

Specify the size of the output message. If received packets exceed the specified value, their contents are truncated. The default is 255.


Data type of the message

Specify the data type of the message as | double | single | int8 | uint8 | int16 | uint16 | int32 | uint32 | logical |. The default is uint8.


cloneCreate UDP receiver 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
stepReceive UDP packet


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 Receive block reference page. The object properties correspond to the block parameters, except:

  • The Output variable-size signal parameter is not included in the System object.

  • The Sample time parameter is not included in the System object.

Introduced in R2012a

Was this topic helpful?