Voice Over IP (VOIP)

This example shows how to use the UDP Send and UDP Receive System objects to transmit audio data over a network.

Introduction

User Datagram Protocol (UDP) is part of the Internet Protocol (IP) suite. UDP provides efficient transmission of data, but does not guarantee reliability, data order, or data integrity. These characteristics make UDP suitable for streaming audio and video data, but not for binary files and similar situations where data loss is unacceptable. The following block diagram shows the operations involved in this example:

You can run this example entirely on one system. However, to use UDP on a network, it is best to run the example on two networked computers. If the second computer has MATLAB® installed, you can run the example on it directly. Otherwise, use MATLAB® Coder™ to generate a stand-alone executable that can run on the second computer.

To start, run the following script on your computer. While the script is running, the UDPSender object transmits audio sine wave data to the UDPReceiver object via the localhost port, 127.0.0.1, and then outputs the signal on your audio speakers. If you have a microphone, you can change the value of useMicrophone to 'true' in order to transmit live audio instead of the sine wave.

Having run the script on a single computer, copy the script to the second computer. In both scripts, replace the IP address, 127.0.0.1, with the IP address of the opposite computer. When you run both scripts, the UDP objects transmit audio signals to each other across the network.