lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] how to send udp messages circularly ?


From: the_gadfly
Subject: Re: [lwip-users] how to send udp messages circularly ?
Date: Tue, 7 Jul 2009 05:56:08 -0700 (PDT)

Hi: Kieran ,Simon and Bill

According your replys , I modified my code.However ,it went to the old
problem that not sending UDP packets.I checked the 

etherarp.c , it said that the etharp_tmr should be called every
ARP_TMR_INTERVAL(10 seconds e.g).So i added the etharp_tmr in 

the main loop and etharp_init() in lwip_init().But it seems useless...
(wrong way ?)
In the Ethereal , i can see arps : the board asked and PC answerd.I don't
konw why the board hold them.
is there anything (*_tmr or other things ) i missing? is there any mistake
with my code ?

PS: i use altera stratia II and Nios ii IDE without OS.

Best Regards
the_gadfly 
-------------------------------------------
int main(void)
{
//0.6.4 struct netif *netif;
struct netif netif;
struct ip_addr ipaddr, netmask, gw;
struct ip_addr udpDestIpAddr; 
struct pbuf  *p; 
struct udp_pcb *pcb; 
err_t err;
char Test[]="hello world !";
unsigned int now, lasttime;
int j=0;


alt_avalon_lan91c111_if* dev_list_ptr =
(alt_avalon_lan91c111_if*)alt_ethernet_device_list.next;

printf("UDP-server using Light-weight IP (LWIP)\n\n");

/* Initialize lwip */
lwip_init();

printf ("Setting IP address to: %d.%d.%d.%d\n", IPADDR0, IPADDR1, IPADDR2,
IPADDR3);
printf ("Setting netmask to: %d.%d.%d.%d\n", NETMASK0, NETMASK1, NETMASK2,
NETMASK3);
printf ("Setting gateway address to: %d.%d.%d.%d\n\n\n", GWADDR0, GWADDR1,
GWADDR2, GWADDR3);
IP4_ADDR(&ipaddr, IPADDR0, IPADDR1, IPADDR2, IPADDR3);
IP4_ADDR(&netmask, NETMASK0, NETMASK1, NETMASK2, NETMASK3);
IP4_ADDR(&gw, GWADDR0, GWADDR1, GWADDR2, GWADDR3);

//0.6.4 netif = netif_add(&ipaddr, &netmask, &gw,
netif_add(&netif, &ipaddr, &netmask,
&gw,(void*)dev_list_ptr,lan91c111if_init, ip_input);
//0.6.4 netif_set_default(&netif);
netif_set_default(&netif);

IP4_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); 

err=udp_send(pcb,p);
if(err==ERR_OK)
{printf("send ok !\n");}
pbuf_free(p);
udp_remove(pcb);


lasttime = get_milliseconds();
while(1)
{

//0.6.4 lan91c111if_service(netif);
  lan91c111if_service(&netif);
  now = get_milliseconds();
    if ((now - lasttime)*1000/alt_ticks_per_second()  > ARP_TMR_INTERVAL) 
    {
      lasttime = now;
      etharp_tmr(); // Every 10 s execute etharp_tmr()
    }


      if (++j==1000) {
        ip_reass_timer();
        j=0;
      }       

  
} 


}


-- 
View this message in context: 
http://www.nabble.com/how-to-send-udp-messages-circularly---tp24321123p24372824.html
Sent from the lwip-users mailing list archive at Nabble.com.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]