Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

FreeRTOS+TCP will not reply ping after unplug/plug eth cable when sending data

Posted by gsing on August 21, 2017

I test the FreeRTOS+TCP, sending data from FreeRTOS to PC, FreeRTOS is the server side, minor change from example "SimpleTCPEchoServer.c", see attachment. PC side can receive data well. but have problem when I do below experiment: 1) run pc side program to receive data, data can receive smoothly; and run ping FreeRTOS in cycle 2) unplug eth cable 3) wait until timeout(5 sec) 4) plug in the eth cable, FreeRTOS will never reply ping any more.

In step3, if not wait timeout, quickly plug in the cable, ping will be replied. Where should I check for this problem? Thanks for any help!

test environment: 1) xilinx zynq zybo board 2) 160919FreeRTOSLabs 3) some minor change from 160919FreeRTOSLabs: a) disable DHCP, using static ip b) call "vStartSimple2TCPServerTasks( mainTCPSERVERSTACKSIZE, tskIDLEPRIORITY+2 );" before vTaskStartScheduler in main() c) EchoServer port set to 1000 in SimpleTCPEchoServer.c d) not receive data, just sending data in SimpleTCPEchoServer.c


FreeRTOS+TCP will not reply ping after unplug/plug eth cable when sending data

Posted by heinbali01 on August 23, 2017

Hi Guoxing Zhang,

In step3, if not wait timeout, quickly plug in the cable, ping will be replied. Where should I check for this problem?

I can reproduce this, thanks. I'm working on it and I will post a solution today.

Attachments

SimpleTCPEServer.c (11511 bytes)

FreeRTOS+TCP will not reply ping after unplug/plug eth cable when sending data

Posted by heinbali01 on August 23, 2017

Hi Guoxing Zhang,

There is one thing to realise while testing: when you run ping constantly while disconnecting your device, your OS may start forwarding the ping ICMP packets through a different ( gateway ) interface. You may see this happing by running WireShark.

And also like this:

~~~ Reply from 192.168.2.106: bytes=32 time<1ms TTL=128 Reply from 192.168.2.106: bytes=32 time<1ms TTL=128 Request timed out. Reply from 192.168.2.5: Destination host unreachable. Request timed out. Request timed out. Request timed out. Request timed out. Reply from 192.168.2.1: Destination host unreachable. ~~~

Here above, there is a shift from x.x.x.5 to x.x.x.1.

If that happens, you may want to try the following:

● Try a few pings ● Stop pinging and disconnect the device ● Wait 20 seconds and connect the device ● Wait a while and try ping again

Sometimes, when packets are forwarded to the wrong interface, it may help to clear the ARP cache.

The driver for Zynq/Zybo has changed a bit through time. I will attach the latest ( not-yet well-tested ) version ( see Zynq_Zybo_driver.zip, here below ). Please have a try with it.

I tested the demo application as follows:

● Disconnect device ● Start it up ● Wait 15 secs ● Connect it to the LAN ● See it working

And also I did your test:

● Start it up while connected ● See it working ● Disconnect it from the LAN ● Wait 15 secs ● Re-connect it ● See it working

These tests worked fine here.

What is new in this version: when the device notices a rise of the Link Status, a new Auto Negotiation will be started. Regards.

Attachments

Zynq_Zybo_driver.zip (23693 bytes)

FreeRTOS+TCP will not reply ping after unplug/plug eth cable when sending data

Posted by gsing on August 25, 2017

Hi Hein Tibosch, Thanks for your help! For your recommendation(try few pings, wait long time to ping), I have tried, but none can recover. I tried your updated driver, no success too. In your steps, do you have run socket receiving at PC(win7) side? There is 2 important conditions for this phenomenon: 1) unplug the cable when PC(win7) receiving data by socket. If not run receiving program in PC side, just unplug/plug cable, ping is OK. 2) after unplug cable, need to wait some time, several seconds, I guess this time related with FREERTOSSOSNDTIMEO, after timeout, socket task in freeRTOS will be deleted. if quickly unplug/plug cable, ping will come back. I captured the data by wireshark, see attachment. I know little about TCP stack, maybe you can help to check it. Here I also attach the socket receiving program in PC side, I compiled with VC. I do this test, because I want data receiving recover after cable plug in, to emulate the condition cable not stable.

Best Regards Guoxing

Attachments

euadRecv.c (3111 bytes)
ping_break.pcapng (5109628 bytes)

FreeRTOS+TCP will not reply ping after unplug/plug eth cable when sending data

Posted by heinbali01 on August 25, 2017

HI Guoxing, thanks for the PCAP.

Are you connecting your embedded device to a switch or router, or directly to your laptop? If possible, use a LAN switch. When that works you can try other connection types.

I did not use the TCP connection during my tests, but today I will!

Both modules euadRecv.c and SimpleTCPEServer.c compiled well and run without a problem ( although the free() statement is erroneous, pBuf points to a static char buffer ).

Your VC application does not notice the disconnection. I changed it to call select() before calling recv().

If select() returns negative, the connection has gone.

But you may also notice that select() returns a positive value, while recv() returns zero. This is a sign that OOB ( out-of-band ) data has been received, most possibly an FD_CLOSE event, which means: connection closed.

I just tested with the adapted VC application ( attached as tcp_client.cpp ), and saw that the disconnection was noticed quite quickly after disconnecting:

~~~ Received 41 MB Received 41 MB Received 42 MB // still connected select returns -1 BufLen receive error recv failed (10022) // WSAEINVAL uCntRevTemp = (-1) ~~~

Under all circumstances, the ping worked fine as long as the device was connected.

Attachments

tcp_client.cpp (4612 bytes)

FreeRTOS+TCP will not reply ping after unplug/plug eth cable when sending data

Posted by heinbali01 on August 25, 2017

PS. when testing, please use the driver in SimpleTCPEServer.c that I posted here above. It has some minor changes in the PHY handling.

Attachments

SimpleTCPEServer.c (11511 bytes)

FreeRTOS+TCP will not reply ping after unplug/plug eth cable when sending data

Posted by heinbali01 on August 25, 2017

Sorry, I mean the driver in ZynqZybodriver.zip and not SimpleTCPEServer.c

Attachments

SimpleTCPEServer.c (11511 bytes)

FreeRTOS+TCP will not reply ping after unplug/plug eth cable when sending data

Posted by gsing on August 28, 2017

Hi Hein, Really appreciate for your help! After using a switch, no problem seen. The previous tests I have done does not use any switch or router, PC connected to ZYBO directly, not the crossed cable. So may I think this problem related with this directly connection? I think this is not a major problem, I am OK for freeRTOS+TCP with a switch. And thanks for your modified tcp_client.cpp. I have never use the select before, I will learn it. Thanks!

BR Guoxing

Attachments

SimpleTCPEServer.c (11511 bytes)

FreeRTOS+TCP will not reply ping after unplug/plug eth cable when sending data

Posted by gsing on August 28, 2017

Hi Hein, In today's test, I disconnect the connection between pc and switch. I am afraid, the sesult will fail if disconnect freeRTOS and switch. I will test this tommorrow. Thanks!

Attachments

SimpleTCPEServer.c (11511 bytes)

FreeRTOS+TCP will not reply ping after unplug/plug eth cable when sending data

Posted by gsing on August 28, 2017

Hi Hein, Sorry for my pervious statement. I just disconnect the connection between freeRTOS and switch. It has no problem too. Thanks for your help!

BR Guoxing

Attachments

SimpleTCPEServer.c (11511 bytes)

FreeRTOS+TCP will not reply ping after unplug/plug eth cable when sending data

Posted by heinbali01 on August 28, 2017

PC connected to ZYBO directly, not the crossed cable

Crossed versus straight: that should not be a problem. Most PHY's can negotiate about that and find a way to communicate. But what is a problem is that when you unplug the device, the Network Interface on your laptop goes down. When the laptop is connected to a switch or router, the Network Interface is up all the time because it is connected constantly.

So for testing, please disconnect and reconnect your device from the switch, and not your laptop.

When that all works well ( like it does here ), I don't mind checking the laptop-to-device connection.

Attachments

SimpleTCPEServer.c (11511 bytes)

FreeRTOS+TCP will not reply ping after unplug/plug eth cable when sending data

Posted by gsing on August 28, 2017

Hi Hein, > So for testing, please disconnect and reconnect your device from the switch, and not your laptop.

Yes, this test( disconnect and reconnect your device from the switch) have done, it's OK. Thanks!

Attachments

SimpleTCPEServer.c (11511 bytes)


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists