1.2.3.2.1 Abstraction Model
This module provides software abstraction of the UDP module existent in any TCP/IP Stack implementation. It allows a user to UDP network traffic by opening and using UDP sockets
How the Library Works
Connections over UDP should be thought of as data-gram based transfers. Each packet is a separate entity, the application should expect some packets to arrive out-of-order or even fail to reach the destination node. This is in contrast to TCP, in which the connection is thought of as a stream and network errors are automatically corrected. These tradeoffs in reliability are made for an increase in throughput. In general, UDP transfers operate two to three times faster than those made over TCP.
UDP sockets have their own TX buffers. Once the transmit buffer has valid data it is the socket_user's responsibility to send the data over the network , calling the corresponding TCPIP_UDP_Flush function.
There is no state machine within the UDP module to automatically take care of the data transmission.
On the receive side, a UDP socket_does not have its own RX buffer; however, it will use the RX buffer that was allocated by the corresponding MAC driver for receiving a network packet. What this means is that the user of the UDP socket_will have to consume that pending RX data (or discard it), because eventually, the stack will run out of memory for other incoming traffic.
The following flow diagram provides an overview for the use of the UDP module:
Server/listening sockets are opened using TCPIP_UDP_ServerOpen. Client sockets are opened using TCPIP_UDP_ClientOpen. A client socket_needs to have a remote address specified before it can transmit data.
Once the socket_is opened, you can immediately begin transmitting data. To transmit a segment, call TCPIP_UDP_PutIsReady to determine how many bytes can be written. Then, use any of the TCPIP_UDP_ArrayPut family of functions to write data to the_socket. Once all data has been written, call TCPIP_UDP_Flush to build and transmit the packet. Since each UDP socket_has its own TX buffer, the sequence previously described can be executed in multiple steps. That data that is written in the socket_is persistent and it will be stored until TCPIP_UDP_Flush is called.