Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
16 years ago

stand-alone lwip ARP problem

Dear all !

I have downloaded stand-alone lwip from our forum "Test IP" .My design is to build a simple udp-client that sending data to PC with stand-alone lwip .But this version seems too old (version 0.7.1,developped on 2005 ,now the lastest version is 1.3.0)I guess MAYBE there is a bug in ARP modle ,here is the problem i hit:

If i run my application, it does not send any UDP packets ( see that in Ethereal ).

However ,after runing anther application udp_echo (data send and return ) ,stop it and run my application ,my app runs very well .I 'm very confused !

So i guess MAYBE there is a bug in our stand-alone lwip .Here is my reason.

when i run the UDP_ECHO app, PC send a udp packet to board ,so our board konw the IP address and MAC addess of PC ,and update it to ARP cache . Then run my app ,the app konws the destination host ' IP address and MAC addess (PC),so it works well. If i run my app only ,it does not konw the PC 's MAC addess , therefore it work fail.Though PC send gratuitous arps ,but the lwip can't update it to the ARP cache .

Am i right ? And how to resolve it ?

Is there someone work similar with me ? or could send a simple udp-client example (stand-alone lwip version) to me !

Thank you ! My MSN and my email is the_gadfly@163.com

----------my app-------------

...

...

P4_ADDR(&udpDestIpAddr, 10, 1 ,1, 52);

p = pbuf_alloc(PBUF_TRANSPORT,sizeof(Test),PBUF_RAM);

memcpy(p->payload, Test, sizeof(Test));

pcb = udp_new();

udp_bind(pcb, IP_ADDR_ANY, 60000);

udp_connect(pcb, &udpDestIpAddr, 60000);

for(i=0;i<1000;i++)

{

udp_send(pcb,p);

}

pbuf_free(p);

udp_remove(pcb);

--------udp_echo app------------

void udp_echo_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16_t port)

{ struct ip_addr ipaddr;

IP4_ADDR(&ipaddr,10,1,1,52);

if (p != NULL)

{

udp_connect(pcb,&ipaddr,60000);

udp_send(pcb, p);

pbuf_free(p);

}

}

void udp_echo_init(void)

{

struct udp_pcb * pcb;

pcb = udp_new();

udp_bind(pcb, IP_ADDR_ANY, 60000) ;

udp_recv(pcb, udp_echo_recv, NULL);

}

-------------------------------------------

Best regards

the_gadfly

1 Reply