LWIP UDP RAW - send many datagram

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

LWIP UDP RAW - send many datagram

PazDim
Hey. I port LWIP to my MCU using RAW interface. I implemented the functions
of receiving and sending data to the Ethernet. Everything works well - I
accept the datagram UDP and send the answer. But for the test, I decided to
send 10,000 datagrams of 1000 bytes each from the MCU. Wireshark showed only
5500 (approximately). I added the counter to the send to Ethernet function -
it turned out that the datagrams are lost inside the LWIP. Sending to
Ethernet is blocking. When writing to Ethernet frames without LWIP - 100%
reception. Increasing LWIP memory or packet size does not help. But if I
insert a delay between shipments, the number of received messages will
increase. Also helps to stop the execution of the program using the debugger
and then continue (one large pause in center of sending). Here is my code:

/* Creating netif */
struct netif netifUdp = {0};
ip_addr_t ipaddr;
IP4_ADDR(&ipaddr, 10, 10, 10, 123);
ip_addr_t iprem;
IP4_ADDR(&iprem, 10, 10, 10, 100);
ip_addr_t netmask;
IP4_ADDR(&netmask, 255, 255, 255, 0);
ip_addr_t gw;
IP4_ADDR(&gw, 10, 10, 10, 1);
netif_add(&netifUdp,
                        &ipaddr,
                        &netmask,
                        &gw,
                        0,
                        lwipDriverSetupNetif,
                        ethernet_input);
netif_set_default(&netifUdp);
netif_set_up(&netifUdp);

/* Creating UDP connection */
struct udp_pcb *udpConnection = udp_new();
if (ERR_OK != udp_bind(udpConnection, &ipaddr, 2302))
{
        while (1);
}
if (ERR_OK != udp_connect(udpConnection, &iprem, 2302))
{
        while (1);
}
udp_recv(udpConnection, udpConRecv, 0);

int i = 0;
volatile int t = 0;
struct pbuf *pb = 0;
while (1)
{
/* Only 10000 datagrams */
        if (i < 10000)
        {
                pb = pbuf_alloc(PBUF_TRANSPORT, 1000, PBUF_RAM);
                if (0 == pb)
                {
                        while (1);
                }
                memset(pb->payload, i % 256, 1000);
                if (ERR_OK != udp_send(udpConnection, pb))
                {
                        while (1);
                }
                pbuf_free(pb);
                i++;
                for (t = 0; t < 5000; t++);
        }
        if (ERR_OK != lwipDriverInput(&netifUdp))
        {
                while(1);
        }
       
        sys_check_timeouts();
};

What could be the problem? Thank.



--
Sent from: http://lwip.100.n7.nabble.com/lwip-users-f3.html

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users