UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Adventurer
Adventurer
2,220 Views
Registered: ‎10-24-2016

DHCP connection release after short time (LWIP UDP raw mode)

Hi to all. 

 

I am facing problems with DHCP using LWIP raw mode with Ethernet lite core.

 

I am using the examples given in XAPP1026. To test the connection i continously send UDP packets (1472 bytes payload) to a PC with a UDP receiver created with LabVIEW. A router with DHCP is in between to assign an IP to the FPGA. To check the connection I am using Wireshark to detect packets. I call dhcp_fine_timer() and dhcp_coarse_timer() continously such as it is configured on XAPP1026 example, but after 1'30" aproximately I can see in wireshark how the connection is released by the FPGA.

 

dhcp release.png

 

So, what could cause this problem?? If I call continously these functions FPGA IP  should  be renewed correctly, shouldn't be?? What other thing can provoke this behaviour?? Is there some parameter in lwipopts.h or any other file that I am not taking into account??

 

This is the code on my main.c :

int main(){
	print("\n\r\n\r");
	print("..............Entering main...........\n\r\n\r");

	GenDummyData(); // Function to generate dummy data on DDR3 memory

	struct netif *netif, server_netif;
	struct ip_addr ipaddr, netmask, gw;

	// the mac address of the board. this should be unique per board
	unsigned char mac_ethernet_address[] = { 0x00, 0x0a, 0x35, 0x00, 0x01, 0x02 };

	netif = &server_netif;

	if (init_platform() < 0) {
		xil_printf("ERROR initializing platform.\r\n");
		return -1;
	}

	xil_printf("\r\n\r\n");
	xil_printf("-----lwIP RAW Mode Demo Application ------\r\n");
	// initliaze IP addresses to be used
#if (LWIP_DHCP==0)
	IP4_ADDR(&ipaddr,  192, 168,   1, 10);
	IP4_ADDR(&netmask, 255, 255, 255,  0);
	IP4_ADDR(&gw,      192, 168,   1,  1);
    print_ip_settings(&ipaddr, &netmask, &gw);
#endif
	xil_printf ("El programa llega a antes de la función lwip_init()\n\r");
	lwip_init();
	xil_printf ("El programa ha ejecutado la función lwip_init()\n\r");
#if (LWIP_DHCP==1)
	ipaddr.addr = 0;
	gw.addr = 0;
	netmask.addr = 0;
#endif

	// Add network interface to the netif_list, and set it as default
	if (!xemac_add(netif, &ipaddr, &netmask, &gw, mac_ethernet_address, PLATFORM_EMAC_BASEADDR)) {
		xil_printf("Error adding N/W interface\r\n");
		return -1;
	}
	netif_set_default(netif);

	// specify that the network if is up
	netif_set_up(netif);

	// now enable interrupts
	platform_enable_interrupts();

#if (LWIP_DHCP==1)
	// Create a new DHCP client for this interface.
	// Note: you must call dhcp_fine_tmr() and dhcp_coarse_tmr() at
	// the predefined regular intervals after starting the client.

	dhcp_start(netif);
	dhcp_timoutcntr = 50; 
	TxPerfConnMonCntr = 0;
	while(((netif->ip_addr.addr) == 0) && (dhcp_timoutcntr > 0)) {
		xemacif_input(netif);
		if (TcpFastTmrFlag) {
			tcp_fasttmr();
			TcpFastTmrFlag = 0;
		}
		if (TcpSlowTmrFlag) {
			tcp_slowtmr();
			TcpSlowTmrFlag = 0;
		}
	}
	if (dhcp_timoutcntr <= 0) {
		if ((netif->ip_addr.addr) == 0) {
			xil_printf("DHCP Timeout\r\n");
			xil_printf("Configuring default IP of 192.168.1.10\r\n");
			IP4_ADDR(&(netif->ip_addr),  192, 168,   1, 10);
			IP4_ADDR(&(netif->netmask), 255, 255, 255,  0);
			IP4_ADDR(&(netif->gw),      192, 168,   1,  1);
		}
	}
	// receive and process packets
	print_ip_settings(&(netif->ip_addr), &(netif->netmask), &(netif->gw));
#endif

	// start the application (web server, rxtest, txtest, etc..)
	//start_applications();
	print_headers();
	start_udp();

	while (1) {
		if (TcpFastTmrFlag) {
			tcp_fasttmr();
			TcpFastTmrFlag = 0;
		}
		if (TcpSlowTmrFlag) {
			tcp_slowtmr();
			TcpSlowTmrFlag = 0;
		}
		udp_sample();

	}

    // never reached
    cleanup_platform();

	return 0;
}

Any help is really appreciated. 

 

Kind regards.

0 Kudos
1 Reply
Adventurer
Adventurer
2,153 Views
Registered: ‎10-24-2016

Re: DHCP connection release after short time (LWIP UDP raw mode)

Any Idea????

 

Should I post this question in Embedded microprocessor forum??

 

Thanks for your reply

0 Kudos