Main Content

TCP/IP Communication Overview

Transmission Control Protocol (TCP) is a transport protocol layered on top of the Internet Protocol (IP) and is one of the most used networking protocols. The MATLAB® TCP/IP client support uses raw socket communication and lets you connect to remote hosts from MATLAB for reading and writing data. For example, you can connect to a remote weather station, acquire data, and plot the data.

  • Connection-based protocol — The two ends of the communication link must be connected at all times during the communication.

  • Streaming protocol — TCP/IP has a long stream of data that is transmitted from one end of the connection to the other end, and another long stream of data flowing in the opposite direction. The TCP/IP stack at one end is responsible for breaking the stream of data into packets and sending those packets, while the stack at the other end is responsible for reassembling the packets into a data stream using information in the packet headers.

  • Reliable protocol — The packets sent by TCP/IP contain a unique sequence number. The starting sequence number is communicated to the other side at the beginning of communication. The receiver acknowledges each packet, and the acknowledgment contains the sequence number so that the sender knows which packet was acknowledged. Because the sender gets an acknowledgement for each packet received, the sender knows when packets do not arrive and can retransmit them. Also, packets that arrive out of sequence can be reassembled in the proper order by the receiver.

    Timeouts can be established because the sender knows (from the first few packets) how long it takes on average for a packet to be sent and its acknowledgment received.

You can create a TCP/IP connection to a server or hardware and perform read/write operations. Use the tcpclient function to create the connection, and the write and read functions for synchronously reading and writing data.

See Also

|

Related Topics