Netx packet pool depletion.

Hi all,

I am using Netx duo IP instance for TCP and UDP communication on synergy SK-S7G2 board. After a lot of packet transmission i have observed that associated packet pool gets depleted and hence my communication stops. In the packets pool configuration i have set Packet Size(in bytes) = 1568, Number of Packets in pool = 80.

Initially Number of Packets in pool were 32 which i increased to 80. Doing this the program is able to communicate fro a longer time but still the pool gets depleted.

After every UDP and TCP receive i am releasing the packet, and i understand there is no need to release the packet when we send. But to send a packet out i need to Allocate memory from the pool and then append the data, so during allocation the pool gets depleted. Am ultimately becomes empty.

Is there any way to solve this issue? Am i doing something wrong? Any technical help would be very helpful. 

  • I think the problem is in receive process, is important that:

    *** nx_udp_socket_receive - If status is NX_SUCCESS, the received UDP packet is pointed to by packet_ptr. the application is responsible for releasing the received packet when it is no longer needed ***

    /* Receive a packet from a previously created and bound UDP socket. If no packets are currently available, wait for 500 timer ticks before giving up. */

    status = nx_udp_socket_receive(&udp_receive_socket, &packet_ptr, NX_WAIT_FOREVER);
    /* If status is NX_SUCCESS, the received UDP packet is pointed to by packet_ptr. the application is responsible for releasing the received packet when it is no longer needed*/

    if (status == NX_SUCCESS)
    /* Retrieve data from packet pointed to by "packet_ptr". */
    status = nx_packet_data_retrieve(packet_ptr, udpBufferMsg, &bytesRx);

    /* This service copies data from the supplied packet into the supplied buffer.
    The actual number of bytes copied is returned in the destination pointed to by bytes_copied */

    if ((status == NX_SUCCESS) && (bytesRx == ****DESIRED****)

    ***** PROCESS PAYLOAD *****

    if (answer)
    **** REPLY ****

    /* Check for UDP enable errors. */

    nx_packet_release(packet_ptr); <-------- *** IMPORTANT *****

    I hope to be proved helpful,
  • Hi simone, thanks for the response.
    I am releasing the packet after receive is successful, nx_udp_socket_receive , nx_udp_source_extract and nx_packet_release are being called respectively when UDP packet is received. The problem i faced while debugging in e2 studio was that the Packet Pool associated with Netx duo IP instance gets depleted such there is no more memory available when nx_packet_allocate is trying to allocate some memory for outgoing UDP socket.
    For sending i am using nx_packet_allocate , nx_packet_data_append , nx_udp_socket_send api's respectively. Hope my question is clear.
  • This is an example of the function I use for transmission. At the beginning I also had a similar problem but then using the structure of the functions indicated to receive and transmit the problem was solved.
    Do you manage the release of the package in the event of a transmission error?

    My Function to send data :

    UINT UDP_MulticastSendData(uint8_t* bufferData, ULONG lenData, ULONG addressIP, UINT port)
    UINT status;
    NX_PACKET *packet_ptr;
    NXD_ADDRESS debug_slave_address;

    /* Imposto indirizzo di destinazione del pacchetto da inviare */
    debug_slave_address.nxd_ip_address.v4 = addressIP;
    debug_slave_address.nxd_ip_version = NX_IP_VERSION_V4;

    /* Allocate a packet. */
    status = nx_packet_allocate(&g_packet_pool1, &packet_ptr, NX_UDP_PACKET, 200); // NX_WAIT_FOREVER

    /* Check for error. */
    if (status == SSP_SUCCESS)
    /* Place data in the packet. */
    status = nx_packet_data_append(packet_ptr, bufferData, lenData, &g_packet_pool1, NX_WAIT_FOREVER);

    if (status == SSP_SUCCESS)
    status = nxd_udp_socket_send(&udp_multicast_socket, packet_ptr, &debug_slave_address, port);
    /* Check for UDP enable errors. */
    if (status)

    return status;
  • If Simone's logic doesn't nail doesn't the problem, a useful debugging technique is to use separate packet pools for receiving and transmitting packets. This will isolate which one is getting depleted. Proper handling of packets (and correct driver logic) should ensure neither pool is depleted.

    How large is the data you are appending to outgoing packets?

  • Hi Janet, thanks for the suggestion. For Receiving udp packets i am not using any packet pool , just a Packet pointer is being used. Is this correct ??? As soon as i receive the packet i am extracting it and releasing the packet, no packet pool is used here. Am i ryt !!!! Should i change something???
  • Thank you Simone, if u share the code snippet for UDP receive as well,it would be very helpful.
Reply Children
No Data