Author Topic: Will a TCP session disconnect as soon as it detects physical link lost?  (Read 4191 times)

Offline thamanjd

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
does pulling the cat 5 cable out of a utasker project prompt a utasker TCP session to disconnect? I'd like to make this happen if it is not the case. What should i poll to see if link is still there?


Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3068
    • View Profile
    • uTasker
Hi

The TCP protocol is not aware of the link status and will still try to transmit. Of course after a few repeats the connection will be closed.

When the link state changes, there is an event generated:
- define INTERRUPT_TASK_PHY to be the name of the task wich you would like to receive the event
- 3 Interrupt events will then be sent to this task (LAN_LINK_DOWN, LAN_LINK_UP_100 and LAN_LINK_UP_10)

In th edemo project this is optionally sent to TASK_NETWORK_INDICATOR and used to control the link LED (LED colour set to indicate link up with a specific speed).

By retaining a variable which is changed depending on these events you will always have a reference to the link's state and so it will not be necessary to poll. When the link goes down (LAN_LINK_DOWN) you can immediately undertake your active connection close.

Regards

Mark

Offline Lukas

  • Newbie
  • *
  • Posts: 11
    • View Profile
Hi Mark.

I want to implement in my project an event when the link state change.
Whre are these Interrupts Events from? I looked through your code, but can't find it anywhere.

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3068
    • View Profile
    • uTasker
Lukas

I was a bit too general with my statement about these events.

They are defined in driver.h
#define LAN_LINK_UP_100             0xff
#define LAN_LINK_UP_10              0xfe
#define LAN_LINK_DOWN               0xfd


but they are not used in all projects. The reason is that some of the evaluation boards do not connect the PHY interrupt line so it really has not been implemented.

I did a quick search of all projects and am sure that this is available in the following:
- M5223X, NE64, SAM7X
I think that it is available in the Luminary project (not sure whether it has been fully tested)
I am note sure about the STR91XF since I don't think that the interrupt from the PHY chip was working.
I known that it is not in the LPC23XX project because neither Olimex nor IAR boards have the IRQ line wired up.

I expect that you are using the LPC23XX project (?) since the event is really missing there. A solution would be to poll the PHY or else to modify the board and add the interrupt - I don't know why it is not connected on these EVBs but the best solution would of course be to add a HW patch (there are enough free interrupt pins) and then integrate the event generation in the PHY IRQ.

Regards

Mark

Offline Lukas

  • Newbie
  • *
  • Posts: 11
    • View Profile
Hallo Mark.
Yes, you are right, my board is an Olimex board.
I wondered why I can't find it. That's the reason, no interrupt line.
Ok, then I try to make my own line.  :)

Thanks
Lukas