mz-automation / libiec61850

Official repository for libIEC61850, the open-source library for the IEC 61850 protocols
http://libiec61850.com/libiec61850
GNU General Public License v3.0
880 stars 468 forks source link

[C#] Testing download and delete of COMTRADE files #75

Closed IgorMundstein closed 6 years ago

IgorMundstein commented 6 years ago

Hi Michael @mzillgith

I found a crazy problem and it's kind of hard to explain. I developed two different threads. One task is reading files and the other task is reading data objects.

I am testing download and delete of COMTRADE files. Download is ok. When I try to delete some file i get access denied [21 - IED_ERROR_ACCESS_DENIED] or timeout [20 - IED_ERROR_TIMEOUT] IedConnectionExceptions. So far, so good.

However, this task of deleting files seems to be causing the IED or libiec61850 to go crazy. I'm getting a lot of random IedConnectionExceptions like:

[99 - IED_ERROR_UNKNOWN] Reading file directory failed.

TEMPLATEMET/METMMXU1$MX$A$phsA$cVal$mag$f (This object exists!) [0 - IED_ERROR_OK] Variable not found on server.

image

Two MMS responses on same packet? image

I attached the Wireshark log file: Wireshark.zip

The error codes and messages are confusing. Can you please check this?

mzillgith commented 6 years ago

Hi @IgorMundstein , That's interesting. It seems the IED gets confused when you send multiple requests at the same time. In your wireshark file each time you see some consecutive request messages the IED sends two responses with the same invoke ID instead of using the correct invoke ID in each response. In the picture above the file delete request has ID 1645 but the related response has ID 1646! This way the client cannot know what to do with the response because it has an unexpected invoke ID. Looks like a bug in the IED. According to the initiate response it should be able to handle at least 3 requests at the same time. As a workaround you can try to do both tasks in the same thread. This way the client will not send a new request before receiving an answer.

IgorMundstein commented 6 years ago

Michael,

I undestand, but I wanna download the files and read the points asynchronously. One task can not block the other. This problem only occurs if I try to delete the files. If I just download the files, this does not happen.

The strange thing is that the library continues to send read requests and receive responses with values. This can be seen by Wireshark. However, responses with values are not always processed by the read task, as it throws timeout exceptions. Are you sure this is not a problem?

Maybe, I need to create a new instance of IedConnection and open another connection for each thread in that case. What do you think?

mzillgith commented 6 years ago

The problem is (as you can see in the wireshark file) that the IED send responses with the wrong invoke ID. So the client cannot relate the responses to the request. In case of the read sometimes the read will timeout because there will never be a read response with the invoke ID matching the request. In other cases it will receive a response with the correct invoke ID but with the delete response as content. This will also cause an error. You can send a problem report to the IED vendor. If the problem is only with the delete and the delete doesn't work anyway why not simply skip the delete?

IgorMundstein commented 6 years ago

Sorry for being pushy, but this is a Schweitzer IED. It hardly has a bug.

I'm just a software developer. As you know, my company is interested in buying your library. I'm inserting it into our SCADA system. The KEMA certification requires that the features be described in forms. For this, I need to test the features, but our testing lab is not complete. I am relying on your assertion, it must be a limitation or bad configuration on the equipment. I'll report it issue to the our electrical engineers.

Thank you for your support.