GIBSOCG IEC 61850 MMS CLIENT LIBRARY - Grid Software - UG.pdf · 61850 MMS communication protocol...
Transcript of GIBSOCG IEC 61850 MMS CLIENT LIBRARY - Grid Software - UG.pdf · 61850 MMS communication protocol...
Grid Software Inc. Calgary, Canada Ph: 1.403.246.1600 Belgrade, Serbia Ph: 381.11.405.77.14
GIBSOCG
IEC 61850 MMS CLIENT LIBRARY
User Guide
GIBSOCG User Guide 13-GS-002-GIBS-UG-en
2
Contents
Contents .................................................................................................................................................... 2
List of Figures ............................................................................................................................................ 3
1. Introduction .......................................................................................................................................... 7
1.1 List of Compilers ............................................................................................................................ 7
1.2 Purpose of this manual ................................................................................................................. 7
1.3 Purpose of the IEC 61850-8-1 part of the Standards .................................................................... 7
1.4 Purpose of the GIBSOCG IEC 61850 Client MMS Library .............................................................. 8
1.5 Requirements and Expectations ................................................................................................... 8
2. GIBSOCG Architecture ........................................................................................................................... 9
3. GIBSOC ................................................................................................................................................ 10
3.1 Creating new connection state handle ....................................................................................... 12
3.2 Blocking Issues ............................................................................................................................ 12
3.3 Multiple Request / Response ...................................................................................................... 13
3.4 Connecting .................................................................................................................................. 13
3.5 Disconnecting .............................................................................................................................. 15
3.6 Identifying ................................................................................................................................... 16
4. GIBSOC – MMS - ODATA ..................................................................................................................... 22
4.1 Discovery ..................................................................................................................................... 23
4.2 MMS Types and Values ............................................................................................................... 25
4.3 Reading ....................................................................................................................................... 25
4.4 Writing ........................................................................................................................................ 27
4.5 Unconfirmed Messages .............................................................................................................. 29
4.6 Additional GIBSOC Functions ...................................................................................................... 31
4.6.1 GIBSOC Slot Functions ......................................................................................................... 31
4.6.2 Socket and Protocol Related Functions .............................................................................. 33
5. GOOSE ................................................................................................................................................. 34
6. GSSE .................................................................................................................................................... 39
GIBSOCG User Guide 13-GS-002-GIBS-UG-en
3
List of Figures
Figure 1 - GIBSOC Architecture ..................................................................................................................... 9
Figure 2 - GIBSOC Life Cycle ........................................................................................................................ 10
Figure 3 - GIBSOC Functions........................................................................................................................ 11
Figure 4 – GIBSOC MMS Connect................................................................................................................ 14
Figure 5 - GIBSOCG Disconnect ................................................................................................................... 15
Figure 6 - GIBSOC and Supporting Libraries ................................................................................................ 22
Figure 7 - GIBSOC, MMS and ODATA Data Types ....................................................................................... 23
Figure 8 - MMS Tree of Types and Values .................................................................................................. 25
Figure 9 - GIBSOC Slots ............................................................................................................................... 31
Figure 10 - GIBSOC Slot Functions .............................................................................................................. 32
Figure 11 - GOOSE Life cycle ....................................................................................................................... 34
Figure 12 - goose_t structure ...................................................................................................................... 38
Figure 13 - GSSE Life cycle ........................................................................................................................... 39
Figure 14 - gsse_t structure ........................................................................................................................ 44
GIBSOCG User Guide 13-GS-002-GIBS-UG-en
5
Copyright 2013 Grid Software Inc.
All rights reserved. Copyright in this document is owned by Grid Software Inc.
Grid Software Inc. hereby grants to you at no charge a non-exclusive, non-transferable, worldwide, limited license (without the
right to sublicense) under the Grid Software inc intellectual property rights to evaluate and practice this document in order to
develop applications intended to run on the GIBSOC library exclusively, provided that such applications do not themselves
implement in any portion of this document.
Other than this limited license you shall have no right to use the document for productive or commercial use.
This publication is provided "AS IS" without warranty of any kind, either expressed or implied, including, but not limited to, the
implied warranties of merchantability, fitness for a particular purpose, or non-infringement.
This publication could include technical inaccuracies or typographical errors. Changes are periodically added to the information
herein. These changes will be incorporated in new editions of the publication. Grid Smart Step Inc may make improvements
and/or changes to the document(s) and/or the program(s) described in this publication at any time.
GIBSOCG User Guide 13-GS-002-GIBS-UG-en
6
ABBREVATIONS
ACSI Abstract Communication Service Interface
GIBSOC GSS 61850 MMS Client Library
GIBSOS GSS 61850 MMS Client Library
GIBSOCG GSS 61850 MMS Client Library with GSE (GOOSE/GSSE) implementation
GOOSE Generic object oriented substation event
GSE Lib GOOSE/GSSE Publisher Subscriber Library
GSSE Generic substation state event
IED Intelligent Electronic Devices
IP Internet Protocol
ISO International Organization for Standardization
MMS Manufacturing Message Specification (ISO 9506)
MMS Lib MMS Protocol Supporting Library
ODATA Library Supporting ASN.1 Data Type, encoding and decoding
PORTABLE Abstract Library enabling multiple OS to use same foundation interfaces
SCSM Specific Communication Service Mapping
TCP Transmission Control Protocol
XML Lib XML conversion Library
ABOUT THIS MANUAL This is the User Guide for the GIBSOC IEC 61850 Client MMS Library, version 1.0 through 2.0.69. This manual should not be use with any older version of the GIBSOC Library due to functional and implementation differences comparing to previous versions. It is not intention of the User Guide to provide full list and description of Functions and Data Types that compose GIBSOC library, instead please refer to ‘GIBSOC Reference Manual’ (13-GS-002-GIBS-RM-en).
AUDIENCE This document is intended for Software Engineers, Software Developers and Test personnel implementing the IEC 61850 based applications for intelligent electronic devices (IED). ASSUMED KNOWLEDGE C language programming
DESIREABLE KNOWLEDGE C language experience with knowledge of Poll/select, TCP sockets etc.
GIBSOCG User Guide 13-GS-002-GIBS-UG-en
7
1. Introduction GIBSOCG is the IEC 61850 MMS protocol stack Client Library that enables the IEC 61850 Clients to engage in the two-way (Client/Server) application association model communication with the IEC 61850 compatible Server IEDs. GIBSOCG Client Library has an option to include implementations of the GSE Publisher/Subscriber
multicast association model. Refer to GIBSOCG for GIBSOC Client with GSE (GSSE/GOOSE) support.
GOOSE and GSSE functionalities are provided by their corresponding libraries: GOOSE Lib and GSSE Lib.
Throughout this document GIBSOC will refer only to GIBSOC as a Client Library with no GSE Support.
GIBSOCG is set of C libraries designed to provide comfort access to the IEC 61850 MMS, GOOSE and
GSSE protocols. GIBSOCG is written in ANSI C, and as such is expected to be compiled on most currently
available development platforms.
1.1 List of Compilers
GIBSOCG has been successfully tested on:
Linux GNU C Compiler (GCC) MinGW C compiler (GCC for Windows) Microsoft C Compiler (Windows)
1.2 Purpose of this manual
Main purpose of this manual is to explain handling of the GIBSOCG API in order to: connect, identify and discover hierarchical object models of the IEC 61850 based IEDs, to perform reading & writing of data values, reports and logs, and to explain how to manage retrieved data. In addition, this manual describes internal architecture and techniques used to enable these functionalities.
1.3 Purpose of the IEC 61850-8-1 part of the Standards
The IEC 61850-8-1 defines Specific Communication Service Mapping - Mapping to MMS (ISO 9506-1, ISO 9506-2) using TCP/IP and ISO T and A-profiles. The IEC 61850-8-1 specifies methods of exchanging data between IEDs on local network, by mapping ACSI to MMS and ISO 8802-3 frames. The IEC 61850-8-1 maps ACSI concepts: objects and services to the MMS equivalent objects.
GIBSOCG User Guide 13-GS-002-GIBS-UG-en
8
1.4 Purpose of the GIBSOCG IEC 61850 Client MMS Library
Purpose of our library is to provide a simple, small footprint, fast and a non-blocking interface for the IEC 61850 MMS communication protocol significantly reducing development time to those planning to develop products based on the IEC 61850 communication models: Publisher/Subscriber multicast association and the Client/Server two party association.
1.5 Requirements and Expectations
Both GIBSOC and GIBSOCG versions require following to be part of the targeted platform:
TCP/IP BSD API socket interface for GIBSOC (IEC 61850 MMS client)
Libcap/Winpcap or similar ability to deal with the raw Ethernet packets
It is expected that a GIBSOCG user has solid understanding of the IED 61850 standards, working
knowledge of the listed compilers and basic understandings of the library concepts in general.
The examples provided herein are based on Linux as a targeted platform.
Windows users might need to slightly modify these examples to rely on pcap, due to the differences in
Interface naming between Linux and Windows. However, this document will guide you in making these
changes.
GIBSOCG User Guide 13-GS-002-GIBS-UG-en
9
2. GIBSOCG Architecture
GIBSOCG as a composition of GIBSOC, GOOSE and GSSE Libraries also includes set of the supporting libraries:
MMS a library that enables MMS Protocol layer communication. Supports: GIBSOC library directly.
ODATA a library that provides primitive data types and ASN.1 encoding/decoding. Supports: GIBSOC, GOOSE, GSSE, MMS and ISOPROFILES libraries.
XML a library that converts ODATA/MMS data types & structures to/from the XML. Support: MMS, GOOSE, GSSE, ODATA
ISOPROFILES a library that enables ISO Protocol layer communication. Support: MMS.
PORTABLE an abstract library enabling multiple OS to use same foundation interface. Support: All libraries.
Figure 1 - GIBSOC Architecture
All of the above components (Header files and Libraries) are required to compile examples described in
this document.
GIBSOCG User Guide 13-GS-002-GIBS-UG-en
10
3. GIBSOC
GIBSOC library provides ways to connect, disconnect, identify, read, write, enable and retrieve reports and logs. In addition, there is a set of features that provide advanced usage of GIBSOC, however not all are covered within the scope of this document. GIBSOC relies on the TCP/IP BSD socket API, and is written in a way to support asynchronous non-blocking operations. GIBSOC library also introduces a buffered layer for all incoming requests and responses. GIBSOC over the MMS library provides fundamental primitives for the IEC 61850 implementation -mapping of the IEC 61850 SCSM to MMS. As a connection oriented protocol, MMS life cycle has following pattern:
1) Create a new connection state handle 2) Establish connection to a remote device 3) Perform data manipulation 4) Terminate connection 5) Destroy state handle Based on the MMS life cycle, the GIBSOC life cycle simple follows the same pattern.
Figure 2 - GIBSOC Life Cycle
GIBSOCG User Guide 13-GS-002-GIBS-UG-en
11
GIBSOC functions are divided in the following groups:
GIBSOC state handling functions GIBSOC MMS connection handling functions GIBSOC MMS request handling functions GIBSOC additional functions
Figure 3 - GIBSOC Functions
The pattern of execution shown on Figure 3 will follow every GIBSOC example. GIBSOC gibsoc_state_t (see reference manual for details) is first allocated and then created, as shown in the gray region of the Figure 3. Immediately after, a connection is established (red region), after which the use of the data manipulation functions are enabled. Functions like: identify, read, write, discovery, or unconfirmed – all shown within the green section. At the end, the application disconnect is followed by the gibsoc_state_t state destruction.
GIBSOCG User Guide 13-GS-002-GIBS-UG-en
12
3.1 Creating new connection state handle
GIBSOC connection state handle is defined by the gibsoc_state_t. After the GIBSOC connection is allocated (either dynamically or statically), it has to be created by user calling the gibsoc_state_create function. This function returns gibsoc_result_t as a result. gibsoc_result_t, as described by the Reference Manual results with GIBSOC_OK for a successful return of the operation. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - gibsoc_result_t result; gibsoc_state_t state; /* create gibsoc state on allocated state structure */ result= gibsoc_state_create(&state); if( GIBSOC_RESULT_IS_ERROR(result) ) return 0; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - The gibsoc_result_t result may return value that is either greater or less than GIBSOC_OK.
Please see the reference manual for definitions of the following macros:
GIBSOC_RESULT_IS_AGAIN(result) GIBSOC_RESULT_IS_OK(result) GIBSOC_RESULT_IS_ERROR(result)
3.2 Blocking Issues
Within the GIBSOC library, every operation that may block is implemented with two function calls. First call is a request function call. The request call processes arguments for requested operation and initiates the operation. The second call is a response. Response call provides a way to execute the operation in a non-blocking way allowing multiple retries until GIBSOC/MMS multiple ISO layers execute transfer or retrieve what have been requested. That way, the user is given much more control over multiple tasks that can be dispatched on the event. Functions request and response return GIBSOC_OK on successful operation. In case the response function call blocks, returned result would be greater than GIBSOC_OK. For an error, a result less than GIBSOC_OK is returned.
GIBSOCG User Guide 13-GS-002-GIBS-UG-en
13
Use of GIBSOC_RESULT_IS_AGAIN, GIBSOC_RESULT_IS_OK, and GIBSOC_RESULT_IS_ERROR macro definitions is recommended. Every time requested operation blocks the GIBSOC_RESULT_IS_AGAIN (result) is set to True. On a successful completion of the operation the GIBSOC_RESULT_IS_OK (result) is set to True. For any error on requested operation the GIBSOC_RESULT_IS_ERROR (result) is then set to True. With multiple IEDs connected (one gibsoc_state_t for each connection) the user should rely on select or poll to optimize the I/O multiplexing.
3.3 Multiple Request / Response
For all operations with ability to write or read to the IEC 61850 capable IED, and for the operations that expect some value argument, there is always an accompanying request reference. If there are multiple read or write requests that are pending, the user can call a response function and refer to the exact request index that is provided by the related request.
3.4 Connecting
Connecting to an IED may end up with a block; therefore process of ‘connecting to’ is implemented with two calls: gibsoc_connect_request and gibosc_connect_response. Both return gibsoc_result_t as a result. Second argument of the gibsoc_connect_request is the IP address of the remote IED, while the third argument is the IED’s Port number. Both these arguments are represented as char * (i.e. strings).
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - gibsoc_result_t result; /* gibsoc connect procedure start */ /* gibsoc connect request */ result= gibsoc_connect_request(&state,”192.168.1.200”,”102”); if( GIBSOC_RESULT_IS_ERROR(result) ) { printf(“error on gibsoc_connect_request\n”); return 0; }
GIBSOCG User Guide 13-GS-002-GIBS-UG-en
14
/* gibsoc connect response */ do { result= gibsoc_connect_response(&state); } while( GIBSOC_RESULT_IS_AGAIN(result) ); if( GIBSOC_RESULT_IS_ERROR(result) ) { printf(“error on gibsoc_connect_response\n”); return 0; } /* gibsoc connect procedure end */ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Figure 4 – GIBSOC MMS Connect
GIBSOCG User Guide 13-GS-002-GIBS-UG-en
15
3.5 Disconnecting
Disconnecting is also implemented with two calls: gibsoc_disconnect_request and gibosc_disconnect_response. Both return gibsoc_result_t as a result.
Figure 5 - GIBSOCG Disconnect
NOTE: Once the application terminates, the operating system closes all TCP sockets it has previously opened. However, this is not a preferred way of closing an established connection to an IED. Exiting from the program without proper disconnect from the IED would not harm the Client application, but may interfere with the usually fragile protocol implementation on the IED side.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /* gibsoc disconnect procedure start */ /* gibsoc disconnect request */
GIBSOCG User Guide 13-GS-002-GIBS-UG-en
16
result= gibsoc_disconnect_request(&state); if( GIBSOC_RESULT_IS_ERROR(result) ) { printf(“error on gibsoc_disconnect_request\n”); return 0; } /* gibsoc disconnect response */ do { result= gibsoc_disconnect_response(&state); } while( GIBSOC_RESULT_IS_AGAIN(result) ); if( GIBSOC_RESULT_IS_ERROR(result) ) { printf(“error on gibsoc_disconnect_response\n”); return 0; } /* gibsoc disconnect procedure stop */ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3.6 Identifying
Identifying a remote IED is not is a requirement for accessing MMS as lower level protocol
implementation. Identifying operation confirms and recognizes a remote IED, keeps connection live and
keeps checking the connection state.
Similar to Connect & Disconnecting, Identifying operation is also implemented using two calls for
request and response. Two identify calls are: gibsoc_identify_request and gibosc_identify_response.
Both return gibsoc_result_t as a result.
In additional to the gibsoc_state_t argument necessary in every GIBSOCG function call, the Identify
Request calls require an additional argument. This second argument is of the gibsoc_index_t type, and
is used as a reference index for the corresponding request.
Advanced users may initiate multiple requests, and wait for multiple answers. GIBSOCG provides
multiple requests/response slots per single connection within the GIBSOCG layer implementation. The
Index argument provides the user with a reference for that particular request. That way, the user is
giving opportunity to collect the referenced response when the response actually arrives.
GIBSOCG User Guide 13-GS-002-GIBS-UG-en
17
Identify response also has one additional parameter: the mms_values_t values parameter. The mms_values_t parameter is a complex data type that is used to describe a hierarchical model of
data objects being retrieved or requested.
The GIBSOCG protocol layer provides an interface for the IEC 61850 objects and services that are
mapped to the equivalent MMS protocol objects and services. The mapping of the IEC 61850 models
and services to the MMS equivalents are done using the ASN.1 BER encoding.
It is important to understand that it is the MMS protocol that is used over the network. Therefore, the
results are stored in the MMS data types.
The following is a part of the GIBSOCG Identify code: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - gibsoc_index_t index; mms_values_t values; /* gibsoc identify procedure start */ /* gibsoc identify request */ result= gibsoc_identify_request(&state,&index); if( GIBSOC_RESULT_IS_ERROR(result) ) { printf(“error on gibsoc_identify_request\n”); return 0; } /* gibsoc identify response */ do { result= gibsoc_identify_response(&state,index,&values); } while( GIBSOC_RESULT_IS_AGAIN(result) ); if( GIBSOC_RESULT_IS_ERROR(result) ) { printf(“error on gibsoc_identify_response\n”); return 0; } /* gibsoc identify procedure end */ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - On completion of this part of the code, the result is stored in the values variable. Note: The GIBSOCG function mms_values_to_xml_file allows you to convert the mms_values_t data (first argument in mms_values_to_xml_file function call) to the XML format. (See GIBSOCG Reference Manual for further details of this function)
GIBSOCG User Guide 13-GS-002-GIBS-UG-en
18
The following example encapsulates Connect, Identify and Disconnect operations specific to the Windows platform. Note: Some calls described in the example to follow are not mandatory on the Linux platforms. In Windows users must initialize winsock library with gibsoc_init_winsock call. If the winsock library has already been initialized, there is no need to initialize it for the second time. ------------------------------------------------------------------------------------- #include <stdio.h> #define __GIBSOCG_GCC #include “gibsoc.h” int main() { gibsoc_state_t state; gibsoc_result_t result; gibsoc_index_t index; mms_values_t values; /* gibsoc create */ result= gibsoc_state_create(&state); if( GIBSOC_RESULT_IS_ERROR(result) ) return 1; #if defined(__GIBSOCG_MSVC) || defined(__GIBSOCG_WINMINGW) if( GIBSOC_NO == gibsoc_init_winsock() ) return 2; #endif
/* gibsoc connect procedure start */ result= gibsoc_connect_request(&state,”192.168.1.200”,”102”); if( GIBSOC_RESULT_IS_ERROR(result) ) { printf(“error on gibsoc_connect_request\n”); return 4; } do { result= gibsoc_connect_response(&state); } while( GIBSOC_RESULT_IS_AGAIN(result) ); if( GIBSOC_RESULT_IS_ERROR(result) ) { printf(“error on gibsoc_connect_response\n”);
GIBSOCG User Guide 13-GS-002-GIBS-UG-en
19
return 5; } /* gibsoc connect procedure end */ /* gibsoc identify procedure start */ result= gibsoc_identify_request(&state,&index); if( GIBSOC_RESULT_IS_ERROR(result) ) { printf(“error on gibsoc_identify_request\n”); return 6; } do { result= gibsoc_identify_response(&state,index,&values); } while( GIBSOC_RESULT_IS_AGAIN(result) ); if( GIBSOC_RESULT_IS_ERROR(result) ) { printf(“error on gibsoc_identify_response\n”); return 7; } /* gibsoc identify procedure stop */ /* gibsoc convert retrieved mms values to xml on standard output */ mms_values_to_xml_file(&values, MMS_VALUES_ROOT, stdout, 0, 2); /* gibsoc disconnect procedure start */ /* gibsoc disconnect request */ result= gibsoc_disconnect_request(&state); if( GIBSOC_RESULT_IS_ERROR(result) ) { printf(“error on gibsoc_disconnect_request\n”); return 8; } /* gibsoc disconnect response */ do { result= gibsoc_disconnect_response(&state); } while( GIBSOC_RESULT_IS_AGAIN(result) ); if( GIBSOC_RESULT_IS_ERROR(result) ) { printf(“error on gibsoc_disconnect_response\n”);
GIBSOCG User Guide 13-GS-002-GIBS-UG-en
20
return 9; } /* gibsoc disconnect procedure end */ return 0; } ------------------------------------------------------------------------------------- Example results Giving the existence of the IEC 61850 compatible IED on the specified IP address and Port number, the program would return the following results: ------------------------------------------------------------------------------------- <value type="Structure"> <value type="String" value="IED NAME"/> <value type="String" value="IED MODEL"/> <value type="String" value="IED VERSION"/> </value> -------------------------------------------------------------------------------------
Compiling on Linux Previous example can be compiled on Linux with the Gnu C Compiler (gcc) ------------------------------------------------------------------------------------- # gcc -I gibsocg_linux_gcc/include -c example05.c # gcc example05.o -o example05 -L gibsocg_linux_gcc/library -lgibsoc -lmms -lxml -lisoprofiles -lportable -lodata -lm ------------------------------------------------------------------------------------- In the above code example, specifically for Linux there is a line: ‘#define __GIBSOCG_GCC’ just before ‘#include “gibsoc.h” ’
This line instructs the portable library header files to adapt definitions and declarations to the Linux/GCC environment. Compiling on Windows In order to compile the same code with the Microsft Visual C, users should define __GIBSOCG_MSVC rather than __GIBSOCG_GCC. To compile the same code with MinGW compiler (gcc compiler for Windows) another two ‘define’
GIBSOCG User Guide 13-GS-002-GIBS-UG-en
21
directives are needed before #include “gibsoc.h” ------------------------------------------------------------------------------------- #define __GIBSOCG_GCC #define __GIBSOCG_WINMINGW ------------------------------------------------------------------------------------- NOTE: Some operating system environments (namely Windows) may have trouble with the calls if the mms_values_t is not allocated dynamically. As a result they might throw some execution time fault errors. The variable type mms_values_t on some environments might be too large to be allocated in a non-dynamical way.
GIBSOCG User Guide 13-GS-002-GIBS-UG-en
22
4. GIBSOC – MMS - ODATA
Handling of various data types within the GIBSOCG library is done by the supporting libraries. In the
previous example connection and state handling was done by the GIBSOC data types (gibsoc_state_t,
gibsoc_result_t, and gibsoc_index_t) and functions.
However, once the result was retrieved it was stored in the mms_values_t. This is because the effective
protocol is the MMS, and result data types and data handling functions are naturally placed within the
MMS library.
The values within the MMS data types are encoded with the ASN.1 presentation. In order to manipulate
retrieved data types within the mms_values_t, users further rely on the ODATA Library – the one that
handles all ASN.1 BER encoding and decoding tasks.
The following Figure highlights the interaction and dependencies between the user applications,
GIBSOC, MMS and the Supporting Libraries
Figure 6 - GIBSOC and Supporting Libraries
GIBSOCG User Guide 13-GS-002-GIBS-UG-en
23
The following Figure 7 provides a brief overview of data types within the GIBSOC, MMS, and ODATA libraries used within a connection or an application.
Figure 7 - GIBSOC, MMS and ODATA Data Types
Note: all data types listed in the Figure 6 are explained in the Reference Manual.
4.1 Discovery
The IEC 61850 Standard in its nature defines models and modeling methods for all known substation functions. The compatible IEDs providing some of the substation functionalities are internally organized by using the methods and the modeling blocks defined by the 7-2, 7-3 and 7-4 parts of the standards. When a Client engages in a Client/Server two way communications with a compatible IED, it can perform reading of the complete IED modeling structure, defined by the Standard. This modeling structure is a hierarchical structure of the IEC 61850 defined objects and their data types.
GIBSOCG User Guide 13-GS-002-GIBS-UG-en
24
For some of the operations that the Client might perform on the IED, it would be beneficiary that such self-descriptive IED modeling structure is retrieved up front. Discovery is the operation that Client uses to retrieve hierarchical modeling tree of the IEC 61850 compatible IEDs. During the Discovery operation multiple read requests are performed, and a large amount of data representing the IED models is retrieved. It is therefore expected that this operation might take a few seconds or more to complete.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - mms_types_t types; /* gibsoc discovery procedure start */ /* gibsoc discovery request */ result= gibsoc_discovery_request(&state); if( GIBSOC_RESULT_IS_ERROR(result) ) { printf(“error on gibsoc_discovery_request\n”); return 0; } /* gibsoc discovery response */ do { result= gibsoc_discovery_response(&state,&types); } while( GIBSOC_RESULT_IS_AGAIN(result) ); if( GIBSOC_RESULT_IS_ERROR(result) ) { printf(“error on gibsoc_discovery_response\n”); return 0; } /* gibsoc convert mms types to xml on standard output */ mms_types_to_xml_file(&types, MMS_TYPES_ROOT, stdout, 0, 2); - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
At the very end of the code example, there is a call to the mms_types_to_xml_file. This function displays discovered type structures in the XML format to the standard output. Please see the Reference Manual and the appropriate IEC 61850 documentation for more details. NOTE: Some operating system environments may have trouble with the calls if the mms_values_t is not allocated dynamically. As a result they might throw some execution time fault errors. The variable type mms_values_t on some environments might be too large to be allocated in a non-dynamical way.
GIBSOCG User Guide 13-GS-002-GIBS-UG-en
25
4.2 MMS Types and Values
Both mms_values_t and mms_types_t are representation of the hierarchical data model of the IEC 61850/MMS data values and data types found on a compatible IED. The Type structure describes what type of an object we can expect on which branch or leaf of the tree. The tree itself is provided by the gibsoc_discovery_request / gibsoc_discovery_response function calls. The Value tree provides us with the exact values retrieved with the read request or report that arrive. The Values found in the tree are of the ODATA data types, and are therefore handled by the ODATA library. Please see the Reference Manual for more information.
Figure 8 - MMS Tree of Types and Values
4.3 Reading
To perform reading operation on some variable referred by a name, user should use the gibsoc_read_request and gibsoc_read_response function calls. The Read request has an argument that is the IEC 61850 variable name. In addition, the function call also takes the index holding the reference to the same request.
GIBSOCG User Guide 13-GS-002-GIBS-UG-en
26
The Read response introduces a new argument: the mms_failrure_t. This argument type holds a failure code that could be later used within the mms_failure_to_xml to provide additional information about the potential error. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - mms_index_t index; mms_failure_t failure; mms_values_t values;
/* gibsoc read procedure start */ /* gibsoc read request */ result=gibsoc_read_request(&state, ”SOMELD0/VMMXU1$MX$PhV$phsA$cVal$mag$f”,&index); if( GIBSOC_RESULT_IS_ERROR(result) ) { printf(“error on gibsoc_read_request\n”); return 0; } /* gibsoc read response */ do { result= gibsoc_read_response(&state,index,&values,&failure); } while( GIBSOC_RESULT_IS_AGAIN(result) ); /* gibsoc process failure result */ mms_failure_to_xml_file(&failure, stdout, 0, 2); if( GIBSOC_RESULT_IS_ERROR(result) ) { printf(“error on gibsoc_read_response\n”); return 0; } /* gibsoc read procedure stop */ /* gibsoc covert values to xml on standard output */ mms_values_to_xml_file(&values, MMS_TYPES_ROOT, stdout, 0, 2); - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - NOTE: Reading some of the IEC 61850 variable names specified in the above example would most probably fail on your test environment. The names used in this example are provisional to the LAB environment used within our R&D team. To reuse this example, please adjust the IEC 61850 names and object references according to your test environment.
GIBSOCG User Guide 13-GS-002-GIBS-UG-en
27
You can perform Reading on complex data types. Not only you can read data of an individual leaf within the tree, but also can perform reading of the whole branch. The mms_values_t can store multiple object values sorted by the tree model hierarchy of the IEC 61850/MMS compatible IED.
4.4 Writing
The writing operation relies on the gibsoc_write_request and gibsoc_write_response functions. The mms_values_t argument is now at the gisbsoc_write_request side, since opposite to the reading operation, setting of the data values is now being performed. In the following example the frequency deadband represented by an uinteger value from the IEC 61850 compatible IED is retrieved, then incremented it, and finally written back to the same IED. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - mms_index_t index; mms_failure_t failure; mms_values_t values;
/* gibsoc read procedure start */ /* gibsoc read request */ result=gibsoc_read_request(&state,”SOME_LD/MMXU1$CF$Hz$db”,&index); if( GIBSOC_RESULT_IS_ERROR(result) ) { printf(“error on gibsoc_read_request\n”); return 0; } /* gibsoc read response */ do { result= gibsoc_read_response(&state,index,&values,&failure); } while( GIBSOC_RESULT_IS_AGAIN(result) ); /* gibsoc process failure result */ mms_failure_to_xml_file(&failure, stdout, 0, 2); if( GIBSOC_RESULT_IS_ERROR(result) ) {
GIBSOCG User Guide 13-GS-002-GIBS-UG-en
28
printf(“error on gibsoc_read_response\n”); return 0; } /* gibsoc read procedure stop */ /* gibsoc convert retreived values to xml on standard output */ mms_values_to_xml_file(&values, MMS_TYPES_ROOT, stdout, 0, 2); /* increment retrieved ODATA uinteger value */ values.nodes[MMS_VALUES_ROOT].value.value_uinteger++; /* gibsoc write procedure start */ /* gibsoc write request */ result=gibsoc_write_request(&state, ”SOME_LD/MMXU1$CF$Hz$db”,&values,&index); if( GIBSOC_RESULT_IS_ERROR(result) ) { printf(“error on gibsoc_write_request\n”); return 0; } /* gibsoc write response */ do { result= gibsoc_write_response(&state,index,&failure); } while( GIBSOC_RESULT_IS_AGAIN(result) ); /* gibsoc process failure result */ mms_failure_to_xml_file(&failure, stdout, 0, 2); if( GIBSOC_RESULT_IS_ERROR(result) ) { printf(“error on gibsoc_write_response\n”); return 0; } /* gibsoc write procedure stop */ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
GIBSOCG User Guide 13-GS-002-GIBS-UG-en
29
4.5 Unconfirmed Messages
In all of the above Reading and Writing examples, once the data is requested the mms_index_t index argument would hold a reference to that very request. Te function calls rely on the that argument in order to correctly reference a response that is expected to arrive. The MMS Reports are messages that do not have a reference number or an index. Once the Reports are initiated, they might arrive unexpectedly. Since there is no request, obviously there would be no response either. The gibsoc_unconfirmed_data is a function that is used to fetch the MMS Report data. This function has two arguments: the state (gibsoc_state_t) and the value (mms_values_t) arguments. If there is a response that has already arrived, the function would return GIBSOC_OK result. If no reports has arrived GIBSOC_RESULT_IS_AGAIN (result) is returned. In order to initiate buffered or unbuffered reports, the Client needs to enable them via their corresponding Report Control Blocks. For more information on the Report Control Blocks please refere to the appropriate part of the IEC 61850 standards. Once the control block’s report enable parameter is set to ON (reports started), over an MMS/GIBSOC connection, the Reports would continue to arrive as long as the MMS/GIBSOC connection is alive, or until the report control bloc’s enable parameter is set back to OFF (Boolean). Behaviour of the reports, the frequency and the amount of data received are further controlled by other Report Control Block parameters: the triggers, Integrity periods etc. (see standard for details) In the following example, the reports are initiated by writing Boolean ON value to the Report Control Block, and then waits indefinitely for Reports to arrive. (Or until terminating conditions described above are met) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - mms_index_t index; mms_failure_t failure; mms_values_t values;
result=gibsoc_read_request(&state, ”SOME_LD/MMXU1$BR$brcbMX$RptEna”,&index); if( GIBSOC_RESULT_IS_ERROR(result) ) { printf(“error on gibsoc_read_request\n”); return 0; } do { result= gibsoc_read_response(&state,index,&values,&failure); } while( GIBSOC_RESULT_IS_AGAIN(result) );
GIBSOCG User Guide 13-GS-002-GIBS-UG-en
30
if( GIBSOC_RESULT_IS_ERROR(result) ) { printf(“error on gibsoc_read_response\n”); return 0; } mms_failure_to_xml_file(&failure, stdout, 0, 2); mms_values_to_xml_file(&values, MMS_TYPES_ROOT, stdout, 0, 2); values.nodes[MMS_VALUES_ROOT].value.value_boolean = ODATA_TRUE; result=gibsoc_write_request(&state, ”SOME_LD/MMXU1$BR$brcbMX$RptEna”,&values,&index); if( GIBSOC_RESULT_IS_ERROR(result) ) { printf(“error on gibsoc_write_request\n”); return 0; } do { result= gibsoc_write_response(&state,index,&failure); } while( GIBSOC_RESULT_IS_AGAIN(result) ); if( GIBSOC_RESULT_IS_ERROR(result) ) { printf(“error on gibsoc_write_response\n”); return 0; } mms_failure_to_xml_file(&failure, stdout, 0, 2); for(;;) { result = gibsoc_unconfirmed_data(&state, &values); if( GIBSOC_RESULT_IS_ERROR(result) ) { printf(“error on gibsoc_unconfirmed_data\n”); return 0; } if( GIBSOC_RESULT_IS_OK(result) ) { mms_values_to_xml_file(values, MMS_VALUES_ROOT, stdout, 0, 2); } } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
GIBSOCG User Guide 13-GS-002-GIBS-UG-en
31
4.6 Additional GIBSOC Functions
GIBSOC has additional functions that users can consider for advance use of the GIBSOC Library.
4.6.1 GIBSOC Slot Functions
Every GIBSOC request function is stored in one pre-allocated slot. The requested function receives index of the slot being dedicated for that particular function. This very same index is then passed to the response function. The GIBSOC library provides a set of functions related to status and behaviour of the “Slots”.
Figure 9 - GIBSOC Slots
In general, a single slot can have one of the following statuses:
free – slot available for use (can be generated from a received or an unconfirmed slots)
send - slot taken, request sent to GIBSOC and further to the network (generated from a free slot)
received – response on corresponding request arrived (generated from the sent slot)
unconfirmed - slot filled with unconfirmed data (generated from a free slot)
GIBSOCG User Guide 13-GS-002-GIBS-UG-en
32
Allocation and de-allocation of slots can be done by functional requests and responses directly; however information about the status of a particular slot (identified by an index), or other information on available slots like number and types of available Slots can be obtained only through the gibsoc_ slot related functions. The following is a list of the gibsoc_ slot ‘count’ related functions: gibsoc_count_all_slots, gibsoc_count_free_slots, gibsoc_count_received_slots, gibsoc_count_unconfirmed_slots, gibsoc_count_received_or_unconfirmed_slots. To test the state of a specific slot referenced by the slot number use the gibsoc_slot_is_received, or the gibsoc_slot_is_unconfirmed functions. For each occupied slot (send, received, or unconfirmed) you can retrieve the exact time of the last state change by using the gibsoc_get_received_timeval or the gibsoc_get_send_timeval functions. See the Reference Manual for full details on all Slot related functions.
Figure 10 - GIBSOC Slot Functions
GIBSOCG User Guide 13-GS-002-GIBS-UG-en
33
4.6.2 Socket and Protocol Related Functions
In order to perform more flexible I/O multiplexing with select or poll, users may want to obtain the real socket descriptor of the TCP socket used by the GIBSOC library. This can be achieved by utilizing the gibsoc_get_socket_descriptor function. Furthermore; during the I/O multiplexing the users might need to know whether the fetched socket descriptor is blocked during receiving or sending operations. This information can be obtained with the gibsoc_is_block_direction_out function. Finally, to examine the content of the multiplex ISO protocol layer buffers, the users call the gibsoc_iso_is_empty function.
GIBSOCG User Guide 13-GS-002-GIBS-UG-en
34
5. GOOSE
GIBSOCG GOOSE Library API provides users with ability assemble or disassemble GOOSE publishing or subscribing packets, or to convert GOOSE packets to or from the XML format. The basic type of the GOOSE library is goose_t. This type contains all data necessary to represent a GOOSE packet. The GOOSE library functions operate on the goose_t type. Once allocated the goose_t should be initialized after which the user has ability to set or get some specific parameters of the GOOSE structure:
Extract from an Ethernet packet or Embed to an Ethernet packet data unit (PDU) Convert to or from the XML format
Figure 11 - GOOSE Life cycle
The Figure 11 describes all operations, related functions and structures that could be performed on the goose_t structure. The structure is fully explained in the GOOSE/GSSE Reference Manual.
GIBSOCG User Guide 13-GS-002-GIBS-UG-en
35
Significant part of the GOOSE data content is encoded with the ASN.1 BER. For that purpose the ODATA supporting library is used. Most terminal objects within the goose_t structure are described with the ODATA data types. The following example describes process of creating and publishing of a GOOSE packet to the network.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #include <stdio.h> #include <pcap.h> #include <unistd.h> #include "goose.h" #include "portable.h" #include "odata.h" #define INTERFACE "eth0" #define MAX_LENGTH 2000 int main(void) { pcap_t* pcap_descriptor; char error[PCAP_ERRBUF_SIZE]; const unsigned char *packet; struct pcap_pkthdr header; odata_float_t ofloat=3.14; uint16_t appid=0x4242; odata_integer_t sqnum=0; odata_integer_t stnum=0; odata_mac_t src,dst; uint8_t vlan_priority=3; odata_boolean_t cfi; uint16_t vlan_id=4; goose_t goose;
/* initialize goose structure */ goose_init(&goose); /* convert string represented mac to odata mac type */ odata_conversion_to_mac("07:08:09:10:1a:1b",&dst); goose_set_destination_mac(&goose,&dst); /* convert string represented mac to odata mac type */ odata_conversion_to_mac("01:02:03:04:05:06",&src); /* store odata_mac_type variable as goose source mac */ goose_set_source_mac(&goose,&src);
/* prepare boolean odata type */ odata_conversion_to_boolean("T",&cfi);
GIBSOCG User Guide 13-GS-002-GIBS-UG-en
36
/* set vlan priority, form indicator (cfi) and vlan id */ goose_set_vlan(&goose,vlan_priority,cfi,vlan_id);
/* set application Id in goose header */ goose_set_appid(&goose,appid); /* set goose control block Reference */ goose_set_gocbRef(&goose,"gocbref"); /* set goose ID */ goose_set_goID(&goose,"GOID"); /* set DATSET as dataset */ goose_set_datSet(&goose,"DATSET"); /* set sequence Number */ goose_set_sqNum(&goose,sqnum); /* set state number */ goose_set_stNum(&goose,stnum); /* add one float data type with it’s value to goose data*/ goose_add_data_float(&goose,&ofloat);
/* open pcap interface */ pcap_descriptor = pcap_open_live(INTERFACE, MAX_LENGTH, 1, 0, error); if(pcap_descriptor == NULL) { printf("unable to pcap_open_live on %s: %s\n",INTERFACE,error); return 1; } for(;;) { char goose_packet[MAX_LENGTH]; int taken=0;
/* set sequence number to new value */ goose_set_sqNum(&goose,++sqnum); /* convert goose_t structure to GOOSE packet data unit */ if( GOOSE_OK == goose_to_eth(goose_packet,MAX_LENGTH,&taken,&goose) ) /* send PDU - an array of bytes, to pcap opened network device */ pcap_inject(pcap_descriptor,goose_packet,taken); else printf("illegal goose %lld\n",(uint64_t)sqnum); usleep(100000); } pcap_close(pcap_descriptor); return 0; } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
GIBSOCG User Guide 13-GS-002-GIBS-UG-en
37
The next example describes Subscribing process. A GOOSE packet is received and forwarded as an XML to the standard output using the goose_to_xml function.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #include <stdio.h> #include <pcap.h> #include "goose.h" #define PCAP_INTERFACE "eth0" #define PCAP_PACKET_MAX_LEN 1500 int main() { pcap_t *pcap; char errbuf[PCAP_ERRBUF_SIZE]; unsigned char *packet; struct pcap_pkthdr *phead; pcap=pcap_open_live(PCAP_INTERFACE,PCAP_PACKET_MAX_LEN,1,1,errbuf); if(pcap == NULL) { printf("pcap_open_live error %s\n",errbuf); return 1; } for(;;) { goose_result_t goose_result; int pcap_next_ex_result; odata_size_t taken; goose_t goose; pcap_next_ex_result= pcap_next_ex(pcap,&phead,(const u_char **)&packet); if(pcap_next_ex_result == 1) { goose_result= goose_from_eth(packet,phead->caplen,&taken,&goose); if(goose_result == GOOSE_OK) goose_to_xml_file(&goose,stdout,0,2); } } return 0; } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
GIBSOCG User Guide 13-GS-002-GIBS-UG-en
38
Compiling of the above examples is done by: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # gcc -I gibsocg_linux_gcc/include -c -o goose_receive.o goose_receive.c # gcc goose_receive.o -o goose_receive -L gibsocg_linux_gcc/library -lgoose -lportable -lodata -lpcap -lm -lxml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *NOTE: Linux users should have enough privileges (root access) to be able to execute this program. The GOOSE/GSSE Reference Manual lists all GOOSE handling functions. The following Figure 12 provides a brief summary of the Get/Set operations performed on the goose_t. It also highlights the structure of the GOOSE PDU.
Figure 12 - goose_t structure
GIBSOCG User Guide 13-GS-002-GIBS-UG-en
39
6. GSSE
GIBSOCG GSSE Library API provides users with ability to capture and disassemble the GSSE publishing
packets, and to decompress data carried within the GSSE messages.
The basic type of the GSSE library is gsse_t. This type contains all the data necessary to represent a GSSE
packet. The GSSE library functions operate on the gsse_t type.
Once allocated the gsse_t should be initialized after which the user has ability to set or get some specific parameters of the GSSE structure:
Extract from an Ethernet packet or Embed to an Ethernet packet data unit (PDU) Convert to or from the XML format
Figure 13 - GSSE Life cycle
The Figure 13 describes all operations, related functions and structures that could be performed on the gsse_t structure. The structure is fully explained in the GOOSE/GSSE Reference Manual.
GIBSOCG User Guide 13-GS-002-GIBS-UG-en
40
The following example is very similar to the previous one (goose receive). Simple replace goose_from_eth with gsse_from_eth, and goose_to_xml_file with gsse_to_xml_file. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #include <stdio.h> #include <pcap.h> #include "gsse.h" #define PCAP_INTERFACE "eth0" #define PCAP_PACKET_MAX_LEN 1500 int main() { pcap_t *pcap; char errbuf[PCAP_ERRBUF_SIZE]; unsigned char *packet; struct pcap_pkthdr *phead; pcap=pcap_open_live(PCAP_INTERFACE,PCAP_PACKET_MAX_LEN,1,1,errbuf); if(pcap == NULL) { printf("pcap_open_live error %s\n",errbuf); return 1; } for(;;) { gsse_result_t gsse_result; int pcap_next_ex_result; odata_size_t taken; gsse_t gsse; pcap_next_ex_result= pcap_next_ex(pcap,&phead, (const u_char **)&packet); if(pcap_next_ex_result == 1) { gsse_result= gsse_from_eth(packet,phead->caplen,&taken,&gsse); if(gsse_result == GSSE_OK) gsse_to_xml_file(&gsse,stdout,0,2); } } return 0; } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
GIBSOCG User Guide 13-GS-002-GIBS-UG-en
41
Compiling above example is done by: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # gcc -I gibsocg_linux_gcc/include -c -o gsse_receive.o gsse_receive.c # gcc gsse_receive.o -o gsse_receive -L gibsocg_linux_gcc/library -lgsse -lportable -lodata -lpcap -lm -lxml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *NOTE: Linux users should have enough privileges (root access) to be able to execute this program. The GSSE library allows you to compose and publish a GSSE message from the XML by using the gsse_from_xml function. In the following example a new function xml_from_string is introduced. This function converts string representation of XML using the xml_t data type representation, part of the XML Library. The string passed to the xml_from_string should not be a constant and would eventually be destroyed during this function.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #include <stdio.h> #include <pcap.h> #include <unistd.h> #include <string.h> #include "gsse.h" #include "portable.h" #include "odata.h" #define INTERFACE "eth0" #define MAX_LENGTH 2000 #define XML_STRING_SIZE 8192 char gsse_xml[]= "<gsse>\n" " <data_link_layer>\n" " <destination_mac>01:a0:f4:01:9c:39</destination_mac>\n" " <source_mac>01:a0:f4:01:9c:39</source_mac>\n" " <DSAP>254</DSAP>\n" " <SSAP>254</SSAP>\n" " <control>3</control>\n" " </data_link_layer>\n" " <network_layer>\n" " <pdu_lifetime>50</pdu_lifetime>\n" " <flags>28</flags>\n" " <destination_address>49.00.01</destination_address>\n" " <source_address>49.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00.00</source_address>\n" " </network_layer>\n" " <transport_layer>\n"
GIBSOCG User Guide 13-GS-002-GIBS-UG-en
42
" <source_address_TSAP>00.01</source_address_TSAP>\n" " <destination_address_TSAP>00.01</destination_address_TSAP>\n" " </transport_layer>\n" " <session_layer>\n" " <calling_session_selector>00.01</calling_session_selector>\n" " <called_session_selector>00.01</called_session_selector>\n" " </session_layer>\n" " <presentation_layer>\n" " <calling_presentation_selector>00.00.00.01</calling_presentation_selector>\n" " <called_presentation_selector>00.00.00.01</called_presentation_selector>\n" " <presentation_contex_definition_list number=\"2\">\n" " <presentation_contex_definition_parameter number=\"0\" transfer_syntax_list_number=\"1\">\n" " <presentation_context_identifier>1</presentation_context_identifier>\n" " <abstract_syntax_name>1.0.9506.2.1</abstract_syntax_name>\n" " <transfer_syntax_name_list nubmer=\"0\">2.1.1</transfer_syntax_name_list>\n" " </presentation_contex_definition_parameter>\n" " <presentation_contex_definition_parameter number=\"1\" transfer_syntax_list_number=\"1\">\n" " <presentation_context_identifier>3</presentation_context_identifier>\n" " <abstract_syntax_name>2.2.1.0.1</abstract_syntax_name>\n" " <transfer_syntax_name_list nubmer=\"0\">2.1.1</transfer_syntax_name_list>\n" " </presentation_contex_definition_parameter>\n" " </presentation_contex_definition_list>\n" " <user_data_transfer_syntax_name>2.1.1</user_data_transfer_syntax_name>\n" " <user_data_presentation_context_identifier>3</user_data_presentation_context_identifier>\n" " </presentation_layer>\n" " <aplication_layer>\n" " <protocol_version>T</protocol_version>\n" " <application_context_name>0.6.5.40.9506.2.3</application_context_name>\n" " <calling_AP_title>0.6.4.43.9999.106</calling_AP_title>\n" " <calling_AE_qualifier>0.2.1.33</calling_AE_qualifier>\n" " <called_AP_title>0.6.4.43.9999.106</called_AP_title>\n" " <called_AE_qualifier>0.2.1.33</called_AE_qualifier>\n" " <user_information_externl_direct_reference>2.1.1</user_information_externl_direct_reference>\n" " <user_information_externl_indirect_reference>1</user_information_externl_indirect_reference>\n" " </aplication_layer>\n" " <gsse_message>\n" " <ObjectName>GOOSE</ObjectName>\n" " <LSentData>\n" " <GsID>GSSEOut</GsID>\n" " <t>36171474 09202</t>\n" " <SqNum>3</SqNum>\n" " <StNum>0</StNum>\n" " <TAL>45000</TAL>\n" " <usec>474487</usec>\n"
GIBSOCG User Guide 13-GS-002-GIBS-UG-en
43
" <PhsID>0</PhsID>\n" " <DNA>F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T</DNA>\n" " <UserSt>T.F.F.T.T.F.T.F.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T.F.T</UserSt>\n" " </LSentData>\n" " </gsse_message>\n" "</gsse>\n"; int main(void) { pcap_t* pcap_descriptor; char error[PCAP_ERRBUF_SIZE]; const unsigned char *packet; struct pcap_pkthdr header; gsse_t gsse; gsse_result_t gsse_result; xml_result_t xml_result; xml_t xml; char gsse_packet[MAX_LENGTH]; int taken; char xml_string[XML_STRING_SIZE]; snprintf(xml_string,XML_STRING_SIZE,"%s",gsse_xml); xml_result= xml_from_string(&xml,xml_string,strlen(xml_string)); if( xml_result != XML_OK ) { printf("xml_from_string conversion failed\n"); return 1; } gsse_result= gsse_from_xml(&xml,XML_ELEMENT_ROOT,&gsse); if( gsse_result != GSSE_OK ) { printf("gsse from xml conversion failed\n"); return 2; } /* open pcap interface */ pcap_descriptor = pcap_open_live(INTERFACE, MAX_LENGTH, 1, 0, error); if(pcap_descriptor == NULL) { printf("unable to pcap_open_live on %s\n",INTERFACE);
GIBSOCG User Guide 13-GS-002-GIBS-UG-en
44
return 3; } /* convert gsse_t structure to GSSE packet data unit */ if( GSSE_OK == gsse_to_eth(gsse_packet,MAX_LENGTH,&taken,&gsse) ) /* send PDU - an array of bytes , to pcap opened network device */ pcap_inject(pcap_descriptor,gsse_packet,taken); pcap_close(pcap_descriptor); return 0; } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - The GOOSE/GSSE Reference Manual lists all GSSE handling functions. The following Figure 14 provides a brief summary of the Get/Set operations performed on the goose_t. It also highlights the structure of the GSSE PDU.
Figure 14 - gsse_t structure