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: 
Observer lampertg
Observer
315 Views
Registered: ‎02-12-2018

Ethernet disconnection detection

Hi,

I'm using LWIP 2.02, bare metal, with Microblaze on the Virtex Ulrascale 118.

I'm trying to figure out how do I detect disconnection in different cases:

1. when connected to Windows PC, and the client APP crushes, I can (usually) detect the disconnection when trying to send data (tcp_write) and get Err_Conn. but I'm not sure if there's a way to detect it when I'm not sending data.

2.when connected to a PC that is running UBUNTU, and the client closes the FD (without disconnecting), and then reconnect, and send a message, I cannot process this message since the "recv_callback" fails: " do not read the packet if we are not in ESTABLISHED state". when checking the state, it seems to be in "LAST_ACK" and never recovers, even though the callback calls in this case:  tcp_close(tpcb);  and tcp_recv(tpcb, NULL);

3. in some cases, it seems that the "pbuf" is full, and never empties, even when disconnecting and reconnecting. in this case i can get an "ERR_MEM" when calling "tcp_write", or in case I'll call "tcp_sndbuf(pcb);" the return value will always be too small and will always stay this way, even when calling  " tcp_output(pcb);"

4. detect Ethernet cable disconnection.

 

That was a long question, but I hope that you can assist me with these issues.

Thank you in advance,

Gilad

 

0 Kudos
1 Reply
Highlighted
Visitor hossam1984
Visitor
79 Views
Registered: ‎02-26-2019

Re: Ethernet disconnection detection

I was looking for the same thing. To solve this issue I have done the follwoing part to the while loop of each sending part of my design.

add this :

extern enum ethernet_link_status eth_link_status;

 

then in your function play with this:

if(send_pcb->state == CLOSED || (eth_link_status != ETH_LINK_UP))
{
active=false; // I use this to start and stop sending function
tcp_abort(send_pcb); // Abort the connection to be able to get rid of all sending buffers
break; // to break my while loop
}

 

Good Luck