Difference between revisions of "Using OpcCmd Utility as OPC UA PubSub Subscriber"

From OPC Labs Knowledge Base
Jump to navigation Jump to search
(19 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[Category:OPC UA PubSub]] [[Category:OpcCmd]] [[Category:Tools]]
+
[[Category:OPC UA PubSub]] [[Category:OpcCmd Utility]] [[Category:Tools and Online Services]]  
 +
For general information about the OpcCmd tool, see [[:Category:OpcCmd Utility]].
  
 
= Introduction =
 
= Introduction =
 
The '''OpcCmd''' utility is a program that allows performing various OPC operations from the command line. It can act as a generic OPC UA PubSub subscriber, and be used for evaluation, experiments, and testing.
 
 
OpcCmd is a console application, running on .NET. It is available for .NET Framework (Windows only), or .NET Core (Windows or Linux). It is available free of charge, but without an appropriate QuickOPC commercial or evaluation license made available to it, it provides valid data only for 30 minutes (it needs to be started over then).
 
  
 
This version supports following transport protocol mappings:
 
This version supports following transport protocol mappings:
 
* OPC UA UDP (UADP over UDP; IPv4 or IPv6)
 
* OPC UA UDP (UADP over UDP; IPv4 or IPv6)
 
* OPC UA Ethernet (UADP over Ethernet; with or without VLAN tagging)
 
* OPC UA Ethernet (UADP over Ethernet; with or without VLAN tagging)
Security is not supported.  
+
* OPC UA MQTT (UADP or JSON over MQTT)
 +
OPC UA PubSub security is not supported.  
  
{{Note|This page describes a preliminary version (5.55.0.5) of the program; the behavior is subject to change in future versions. We plan to add more features and mappings in the future.}}
+
{{Note|OpcCmd also supports other OPC-related functionality, for Client-Server or PubSub, and for OPC Classic. This page, however, is only for the UA PubSub subscriber aspect of the OpcCmd tool.}}
  
{{Note|OpcCmd may be enhanced in the future to support other OPC-related functionality, for Client-Server or PubSub. This page, however, is only for the PubSub subscriber aspect of the OpcCmd tool.}}
+
= Commands, Arguments and Options =
  
== Installation ==
+
For the usage as OPC UA PubSub subscriber, you will need one command ('''uaSubscriber''') and most commonly one sub-command ('''subscribeDataSet'''), so they will practically always be present on the command line, and you will just give them additional options as needed. For this reason, most of your commands will start with:
If you have installed QuickOPC (version 2019.2 or later) using its Setup program, and have not excluded the Tools setup component, the OpcCmd utility is already installed on your computer, under the Bin subfolder of the QuickOPC installation folder. There are also shortcuts to it from the Start menu and the Launcher program. In other cases, for stand-alone installation, and for the latest version of the tool, see [[Tool Downloads#OpcCmd Utility|Tool Downloads]]. If you want to use OPC UA PubSub Ethernet transport protocol mapping, you will also need
 
  
* on Linux: [http://www.tcpdump.org/manpages/pcap.3pcap.html libpcap] (also see https://www.tcpdump.org/)
+
OpcCmd uaSubscriber subscribeDataSet
* on Windows: [https://nmap.org/npcap/ Npcap] (formerly [https://www.winpcap.org/ WinPcap])
 
See also: [[OPC UA PubSub Common Traps And Pitfalls]]
 
  
== Technical Support ==
+
{{Note|You can start the OpcCmd utility in ''interactive mode'' using <code>OpcCmd --interactive</code> or (shortened) <code>OpcCmd -i</code>. You can then experiment with various commands without having to restart the utility. OpcCmd commands can be executed directly at the {{Style=label|OpcCmd>}} prompt, or you can invoke the interactive mode for deeper levels by entering the command name without any arguments, such as <code>uaSubscriber</code>. In addition, the interactive mode gives you the ability to review and inspect the events generated by last command, and much more.}}
For technical support, use the corresponding category on our [http://www.opclabs.com/forum/opccmd-utility Online Forums].
+
== Command: uaSubscriber subscribeDataSet ==
  
= Usage =
+
After the command starts, it displays all dataset messages received (according to the criteria given by the command-line options) and their content (data fields). In case of an error, it displays an appropriate error message.
 
 
In order to run the OpcCmd utility, open a command prompt, and switch to the directory that contains the program. You start the program and give it a command and additional parameters (options). If you are using the .NET Framework version, type {{Style=keyboard|OpcCmd}}, followed by the commands and options, and press {{Style=shortcut|Enter}}. If you are using the .NET Core version, type {{Style=keyboard|dotnet OpcCmd.dll}}, followed by the commands and options, and press {{Style=shortcut|Enter}}. In the text that follows, when discussing the command line options, we will be listing the commands simply with the '''OpcCmd''' at the beginning; remember to use '''dotnet OpcCmd.dll''' in .NET Core instead.
 
 
 
After the program starts, it displays all dataset messages received (according to the criteria given by the command-line options) and their content (data fields). In case of an error, it displays an appropriate error message.
 
  
 
By default, OpcCmd stays subscribed for one minute, or until you interrupt it using the {{Style=shortcut|X}} key. The time period can be configured using the '''--SleepTimeMilliseconds''' ('''-stm''') or '''--SleepTimeSpan''' ('''-sts''') command-line option. You can also use {{Style=shortcut|Ctrl+Break}} key combination to terminate the OpcCmd utility at any time, but without giving it a chance to perform any finalization tasks or return to the interactive mode.
 
By default, OpcCmd stays subscribed for one minute, or until you interrupt it using the {{Style=shortcut|X}} key. The time period can be configured using the '''--SleepTimeMilliseconds''' ('''-stm''') or '''--SleepTimeSpan''' ('''-sts''') command-line option. You can also use {{Style=shortcut|Ctrl+Break}} key combination to terminate the OpcCmd utility at any time, but without giving it a chance to perform any finalization tasks or return to the interactive mode.
  
= Commands and Options =
+
Parameters of the '''subscribeDataSet''' command can be influenced by various arguments (positional) and options (named) given after it on the command line. The option names are case sensitive, and can be entered using the long form (starts with --) or the short form (starts with -). The options are (obtained through {{Style=keyboard|OpcCmd uaSubscriber subscribeDataSet --help}}):
 +
<nowiki>
 +
Usage: OpcCmd uaSubscriber|uas subscribeDataSet|sds [options] <resourceDescriptor> <brokerQueueName> [command]
  
OpcCmd has a concept of (possibly nested) ''commands'' and ''options''. For the usage as OPC UA PubSub subscriber, you will need one command ('''uaSubscriber''') and one sub-command ('''subscribeDataSet'''), so they will practically always be present on the command line, and you will just give them additional options as needed. For this reason, most of your commands will start with:
+
Arguments:
 +
  resourceDescriptor                                      PubSub connection resource descriptor
 +
  brokerQueueName                                          Broker queue name
  
  OpcCmd uaSubscriber subscribeDataSet
+
Options:
 +
  -?|-h|--help                                            Show help information
 +
  -!p|--!property <key-typedValue-pair>                    Execute with given property value (see documentation) (*)
 +
  -!x|--!extract <key>                                    Extract part of the result object
 +
  -!t2s|--!treeToSequence <treeTraversalType>              Define how to convert trees to sequences
 +
  -!ve|--!viewEvent[:<viewValueSpecifier>]                Specify how to view events
 +
  -!vv|--!viewValue[:<viewValueSpecifier>]                Specify to view the result as a value, and how
 +
  -!vs|--!viewSequence[:<viewSequenceSpecifier>]          Specify to view the result as a sequence, and how
 +
  -!vt|--!viewTree[:<viewTreeSpecifier>]                  Specify view the result as a tree, and how
 +
  -rpeu|--ResolverPublisherEndpointUri <uri>              Resolver publisher endpoint URI
 +
  -rpeun|--ResolverPublisherEndpointUserName <string>      Resolver publisher endpoint user name token - user name
 +
  -rpeup|--ResolverPublisherEndpointUserPassword <string> Resolver publisher endpoint user name token - password
 +
  -rpfru|--ResolverPublisherFileResourceUri <uri>          Resolver publisher file resource URI
 +
  -rk|--ResolverKind <uaResolverKind>                      Resolver kind
 +
  -cni|--ConnectionNetworkInterface <name>                PubSub connection network interface
 +
  -cn|--ConnectionName <name>                              PubSub connection name
 +
  -cru|--ConnectionResourceUri <uri>                      PubSub connection resource URI
 +
  -ctpn|--ConnectionTransportProfileName <uaPubsubTpn>    PubSub connection transport profile name
 +
  -ctpu|--ConnectionTransportProfileUri <uri>              PubSub connection transport profile URI
 +
  -cp|--ConnectionProperty <uaKey-uaValue-pair>            PubSub connection property (*)
 +
  -uecf|--UseEthernetCaptureFile <fileName>                Use Ethernet capture file (requires OpcLabs.Pcap)
 +
  -uucf|--UseUdpCaptureFile <fileName>                    Use UDP capture file (requires OpcLabs.Pcap)
 +
  -cbapu|--ConnectionBrokerAuthenticationProfileUri <uri>  PubSub connection broker authentication profile URI
 +
  -cbru|--ConnectionBrokerResourceUri <uri>                PubSub connection broker resource URI
 +
  -cddu|--ConnectionDatagramDiscoveryUri <uri>            PubSub connection datagram discovery URI
 +
  -mnms|--MaximumNetworkMessageSize <uint32>              Maximum network message size (ignored)
 +
  -mrt|--MessageReceiveTimeout <double>                    Message receive timeout (milliseconds)
 +
  -sgi|--SecurityGroupId <name>                            Security group Id
 +
  -sksu|--SecurityKeyServiceUri <uri>                      Security key service URI (*)
 +
  -sm|--SecurityMode <uaSecurityMode>                      Security mode
 +
  -stun|--SksTemplateUserName <string>                    SKS template user name token - user name
 +
  -stup|--SksTemplateUserPassword <string>                SKS template user name token - user password
 +
  -bapu|--BrokerAuthenticationProfileUri <uri>            Broker authentication profile URI
 +
  -bmdqn|--BrokerMetaDataQueueName <name>                  Broker metadata queue name
 +
  -bqn|--BrokerQueueName <name>                            Broker queue name
 +
  -brdg|--BrokerRequestedDeliveryGuarantee <uaGuarantee>  Broker requested delivery guarantee
 +
  -bru|--BrokerResourceUri <uri>                          Broker resource URI
 +
  -dso|--DataSetOffset <uint16>                            Dataset offset
 +
  -gv|--GroupVersion <uint32>                              Group version
 +
  -nmn|--NetworkMessageNumber <uint16>                    Network message number
 +
  -dsci|--DataSetClassId <guid>                            Dataset class Id
 +
  -adm|--AllowDataMessages <bool>                          Allow data messages (default=true)
 +
  -aem|--AllowEventMessages <bool>                        Allow event messages (default=true)
 +
  -dswi|--DataSetWriterId <uint16>                        Dataset writer Id
 +
  -dswn|--DataSetWriterName <name>                        Dataset writer name
 +
  -pi|--PublisherId <uaPublisherId>                        Publisher Id
 +
  -rfv|--RequiredFieldValue <key-typedValue-pair>          Required field value (uses promoted fields when available) (*)
 +
  -wgi|--WriterGroupId <uint16>                            Writer group Id
 +
  -wgn|--WriterGroupName <name>                            Writer group name
 +
  -mof|--MessageOriginFilter <string>                      Message origin filter (ipaddress:port for UDP)
 +
  -pdsn|--PublishedDataSetName <name>                      Published dataset name
 +
  -i|--interactive                                        Enter subcommands in an interactive loop ("exit" to leave)
  
== Command: uaSubscriber subscribeDataSet ==
+
Commands:
 +
  !getProperty|!gp                                        Get command property and display its value (see documentation)
 +
  !wait                                                    Specify how long will the parent command execute (default 00:01:00)
  
Parameters of the '''subscribeDataSet''' command can be influenced by various options given after it on the command line. The command are case insensitive. The options are case sensitive, and can be entered using the long form (starts with --) or the short form (starts with -). The options are (obtained through {{Style=keyboard|OpcCmd uaSubscriber subscribeDataSet --help}}):
+
Run 'subscribeDataSet|sds [command] --help' for more information about a command.
<nowiki>
+
(*) Indicates options that can be specified multiple times with multiple values.
Usage: OpcCmd uaSubscriber subscribeDataSet [options]
 
  
Options:
+
Parameter values:
   --SleepTimeMilliseconds|-stm <milliseconds>                         Sleep time (-1 for Infinite, default=1 minute)
+
   <typeCode>               Empty|Object|DBNull|Boolean|Char|SByte|Byte|Int16|UInt16|Int32|UInt32|Int64|UInt64|Single|Double|Decimal|DateTime|String
   --SleepTimeSpan|-sts <timespan>                                     Sleep timespan (e.g. hh:mm, or hh:mm:ss)
+
   <typedValue>            [<typeCode>]<value>
   --ResolverPublisherEndpointUri|-rpeu <uri>                           Resolver publisher endpoint URI
+
   <key-typedValue-pair>    <name>=<typedValue>
  --ResolverPublisherFileResourceUri|-rpfru <uri>                     Resolver publisher file resource URI
+
   <treeTraversalType>      None|DepthFirst|BreadthFirst
   --ResolverKind|-rk <None/Discovery/PublisherEndpoint/PublisherFile>  Resolver kind [DISCOVERY NOT IMPLEMENTED]
+
   <viewValueType>         Default|None|Simple|Write|Dump
   --ConnectionNetworkInterface|-cni <name>                             PubSub connection network interface
+
   <viewOption>             None|Cls
   --ConnectionName|-cn <name>                                         PubSub connection name
+
   <viewOptions>           <viewOption>[,<viewOption>]...
   --ConnectionResourceUri|-cru <uri>                                   PubSub connection resource URI
+
   <format>                <string>
  --ConnectionTransportProfile|-ctp <uri>                             PubSub connection transport profile
+
   <viewValueSpecifier>    [<viewValueType>][:<viewOptions>[:<format>]]
  --PcapReaderCaptureFile|-prcf <fileName>                             Pcap reader capture file (requires OpcLabs.Pcap)
+
   <viewSequenceType>       Default|None|Simple|Table|Browse
   --ConnectionBrokerAuthenticationProfileUri|-cbapu <uri>             PubSub connection broker authentication profile URI
+
   <viewSequenceSpecifier> [<viewSequenceType>][:<format>]
   --ConnectionBrokerResourceUri|-cbru <uri>                           PubSub connection broker resource URI
+
   <viewTreeType>           Default|None|Simple|Table
  --ConnectionDatagramDiscoveryUri|-cddu <uri>                         PubSub connection datagram discovery URI
+
   <viewTreeSpecifier>     [<viewTreeType>][:<format>]
   --MaximumNetworkMessageSize|-mnms <uint32>                           Maximum network message size (ignored)
+
   <uaGuarantee>           NotSpecified|BestEffort|AtLeastOnce|AtMostOnce|ExactlyOnce
   --MessageReceiveTimeout|-mrt <double>                               Message receive timeout (milliseconds)
+
   <clarkNotation>          [{<url>}]<name>
  --SecurityGroupId|-sgi <name>                                       Security group Id
+
   <uaBuiltInType>         Null|Boolean|SByte|Byte|Int16|UInt16|Int32|UInt32|Int64|UInt64|Float|Double|String|DateTime|Guid|ByteString|XmlElement|NodeId|ExpandedNodeId|StatusCode|QualifiedName|LocalizedText|ExtensionObject|DataValue|Variant|DiagnosticInfo|Number|Integer|UInteger|Enumeration
  --SecurityKeyServiceEndpointUris|-skseu <uris>                       Security key service endpoint URIs
+
   <uaValue>               [<uaBuiltInType>]<value>
   --SecurityMode|-sm <securityMode>                                   Security mode (None/SecurityNone/SecuritySign/SecuritySignAndEncrypt)
+
   <uaKey-uaValue-pair>    <clarkNotation>=<uaValue>
   --BrokerAuthenticationProfileUri|-bapu <uri>                         Broker authentication profile URI
+
   <uaPublisherId>         [<uaPublisherIdType>]<value>
  --BrokerMetaDataQueueName|-bmdqn <name>                             Broker metadata queue name
+
   <uaPublisherIdType>     |Byte|UInt16|UInt32|UInt64|String
  --BrokerQueueName|-bqn <name>                                       Broker queue name
+
   <uaResolverKind>         None|PubSubDiscovery|PublisherEndpoint|PublisherFile [DISCOVERY NOT IMPLEMENTED]
   --BrokerRequestedDeliveryGuarantee|-brdg <guarantee>                 Broker requested delivery guarantee (NotSpecified/BestEffort/AtLeastOnce/AtMostOnce/ExactlyOnce)
+
   <uaSecurityMode>         None|SecurityNone|SecuritySign|SecuritySignAndEncrypt|Secure|All
   --BrokerResourceUri|-bru <uri>                                       Broker resource URI
+
   <uaPubsubTpn>           AmqpJson|AmqpUadp|EthUadp|MqttJson|MqttUadp|UdpUadp</nowiki>
   --DataSetOffset|-dso <uint16>                                       Dataset offset
 
   --GroupVersion|-gv <uint32>                                         Group version
 
  --NetworkMessageNumber|-nmn <uint16>                                 Network message number
 
  --DataSetClassId|-dsci <guid>                                       Dataset class Id
 
   --AllowDataMessages|-adm <bool>                                     Allow data messages (default=true)
 
   --AllowEventMessages|-aem <bool>                                     Allow event messages (default=true)
 
  --DataSetWriterId|-dswi <uint16>                                     Dataset writer Id
 
  --DataSetWriterName|-dswn <name>                                     Dataset writer name
 
   --PublisherIdNumeric8|-pin8 <byte>                                   Publisher Id (Byte)
 
  --PublisherIdNumeric16|-pin16 <uint16>                              Publisher Id (UInt16)
 
  --PublisherIdNumeric32|-pin32 <uint32>                              Publisher Id (UInt32)
 
  --PublisherIdNumeric64|-pin64 <uint64>                              Publisher Id (UInt64)
 
  --PublisherIdString|-pis <string>                                    Publisher Id (String)
 
   --WriterGroupId|-wgi <uint16>                                       Writer group Id
 
   --WriterGroupName|-wgn <name>                                       Writer group name
 
   --MessageOriginFilter|-mof <string>                                 Message origin filter (ipaddress:port for UDP)
 
  --PublishedDataSetName|-pdsn <name>                                  Published dataset name
 
  -?|-h|--help                                                        Show help information</nowiki>
 
  
 
Help text for the '''OpcCmd''' utility itself can by displayed using {{Style=keyboard|OpcCmd --help}}. Help text for the '''OpcCmd uaSubscriber''' command can be displayed using {{Style=keyboard|OpcCmd uaSubscriber --help}} (there are some less-frequently options directly on this command, such as resolution timeouts, which are not discussed here).
 
Help text for the '''OpcCmd''' utility itself can by displayed using {{Style=keyboard|OpcCmd --help}}. Help text for the '''OpcCmd uaSubscriber''' command can be displayed using {{Style=keyboard|OpcCmd uaSubscriber --help}} (there are some less-frequently options directly on this command, such as resolution timeouts, which are not discussed here).
Line 150: Line 179:
 
Usage examples:
 
Usage examples:
  
Subscribe to a dataset, specifying physical parameters:
+
Subscribe to an OPC UA PubSub dataset, specifying physical parameters:
OpcCmd uaSubscriber subscribeDataSet -cru opc.udp://239.0.0.1:4840
+
  OpcCmd uaSubscriber subscribeDataSet opc.udp://239.0.0.1:4840
OpcCmd uaSubscriber subscribeDataSet -cru opc.udp://224.0.0.22 -dswi 62541
+
  OpcCmd uaSubscriber subscribeDataSet opc.udp://224.0.0.22 -dswi 62541
OpcCmd uaSubscriber subscribeDataSet -sts 01:00 -cru opc.udp://239.0.0.1:4840
+
  OpcCmd uaSubscriber subscribeDataSet -cru opc.udp://239.0.0.1:4840 !wait 01:00
OpcCmd uaSubscriber subscribeDataSet -cru opc.udp://239.0.0.1:4840 -pin16 30
+
  OpcCmd uaSubscriber subscribeDataSet opc.udp://239.0.0.1:4840 -pi [UInt16]30
OpcCmd uaSubscriber subscribeDataSet -cru opc.eth://FF-FF-FF-FF-FF-FF -pin16 30
+
  OpcCmd uaSubscriber subscribeDataSet opc.eth://FF-FF-FF-FF-FF-FF -pi [UInt16]30
 +
  OpcCmd uaSubscriber subscribeDataSet mqtt://opcua-pubsub.demo-this.com opcuademo/uadp/none
 +
  OpcCmd uaSubscriber subscribeDataSet mqtt://opcua-pubsub.demo-this.com opcuademo/uadp/none -dswi 4 -!ve=:cls
 +
  OpcCmd uaSubscriber subscribeDataSet mqtt://opcua-pubsub.demo-this.com opcuademo/json -ctpn MqttJson
  
Subscribe to a dataset, specifying logical parameters (and resolving them first):
+
Subscribe to an OPC UA PubSub dataset, specifying logical parameters (and resolving them first):
OpcCmd uaSubscriber subscribeDataSet -rpeu opc.tcp://192.168.0.85:4840 -cn UDP1 -wgn WriterGroupStatic -dswn WriterSimple
+
  OpcCmd uaSubscriber subscribeDataSet -rpeu opc.tcp://192.168.0.85:4840 -cn UDP1 -wgn WriterGroupStatic -dswn WriterSimple
OpcCmd uaSubscriber subscribeDataSet -rpeu opc.tcp://192.168.0.50:4842 -pdsn "PublishedDataSet #1"
+
  OpcCmd uaSubscriber subscribeDataSet -rpeu opc.tcp://192.168.0.50:4842 -pdsn "PublishedDataSet #1"
OpcCmd uaSubscriber subscribeDataSet -rpfru unified_automation_cpp.bin -cn UDP1 -wgn WriterGroupDynamic -dswn WriterAllTypes</nowiki>
+
  OpcCmd uaSubscriber subscribeDataSet -rpfru unified_automation_cpp.bin -cn UDP1 -wgn WriterGroupDynamic -dswn WriterAllTypes</nowiki>
  
 
More examples:
 
More examples:
Line 281: Line 313:
 
OpcCmd can read the network traffic from a file, instead of using live data. This is extremely handy for various kinds of troubleshooting, diagnostics, analysis and similar tasks. It allows you to capture the data generated by the publisher once, and then replay it as many times as you like.
 
OpcCmd can read the network traffic from a file, instead of using live data. This is extremely handy for various kinds of troubleshooting, diagnostics, analysis and similar tasks. It allows you to capture the data generated by the publisher once, and then replay it as many times as you like.
  
The network capture needs to be in the PCAP format. Various tools, including Wireshark, can read and write this format. The current versions of Wireshark, however, store network capture in a newer format (PCAPNG) by default. Using the "Save as type" drop-down in Wireshark's "Save file as" dialog, it is, however, easy to save your network captures in the PCAP format, or even convert existing PCAPNG captures to PCAP.
+
The network capture needs to be in the PCAP format. Various tools, including Wireshark, can read and write this format. The current versions of Wireshark, however, store network capture in a newer format (PCAPNG) by default. Using the "Save as type" drop-down in Wireshark's "Save file as" dialog, it is easy to save your network captures in the PCAP format, or even convert existing PCAPNG captures to PCAP.
  
 
For UDP message mapping, apply the '''--UseUdpCaptureFile''' ('''-uucf''') option, followed by the file name, to the '''subscribeDataSet''' or '''subscribeDataSetField''' command. For Ethernet message mapping, apply the '''--UseEthernetCaptureFile''' ('''-uecf''') option instead.
 
For UDP message mapping, apply the '''--UseUdpCaptureFile''' ('''-uucf''') option, followed by the file name, to the '''subscribeDataSet''' or '''subscribeDataSetField''' command. For Ethernet message mapping, apply the '''--UseEthernetCaptureFile''' ('''-uecf''') option instead.
Line 295: Line 327:
  
 
The packets in the capture file are used to provide "timed" replay of the network communication. This means that when the capture is replayed, the software not only mimics the actual data in the packets, but it also attempts to maintain the same timing of the packets as it appears in the capture. An initial delay of 1000 milliseconds is added before the replay starts, in order to allow for startup tasks on the receiver side to finalize.
 
The packets in the capture file are used to provide "timed" replay of the network communication. This means that when the capture is replayed, the software not only mimics the actual data in the packets, but it also attempts to maintain the same timing of the packets as it appears in the capture. An initial delay of 1000 milliseconds is added before the replay starts, in order to allow for startup tasks on the receiver side to finalize.
 +
 +
= See also =
 +
* [[OPC UA PubSub Common Traps And Pitfalls]]
 +
* [[MQTT communication packages]]
 +
* [[Certificate security plugin]]

Revision as of 17:52, 22 January 2021

For general information about the OpcCmd tool, see Category:OpcCmd Utility.

Introduction

This version supports following transport protocol mappings:

  • OPC UA UDP (UADP over UDP; IPv4 or IPv6)
  • OPC UA Ethernet (UADP over Ethernet; with or without VLAN tagging)
  • OPC UA MQTT (UADP or JSON over MQTT)

OPC UA PubSub security is not supported.

Note2-icon.png

Note: OpcCmd also supports other OPC-related functionality, for Client-Server or PubSub, and for OPC Classic. This page, however, is only for the UA PubSub subscriber aspect of the OpcCmd tool.

Commands, Arguments and Options

For the usage as OPC UA PubSub subscriber, you will need one command (uaSubscriber) and most commonly one sub-command (subscribeDataSet), so they will practically always be present on the command line, and you will just give them additional options as needed. For this reason, most of your commands will start with:

OpcCmd uaSubscriber subscribeDataSet
Note2-icon.png

Note: You can start the OpcCmd utility in interactive mode using OpcCmd --interactive or (shortened) OpcCmd -i. You can then experiment with various commands without having to restart the utility. OpcCmd commands can be executed directly at the OpcCmd> prompt, or you can invoke the interactive mode for deeper levels by entering the command name without any arguments, such as uaSubscriber. In addition, the interactive mode gives you the ability to review and inspect the events generated by last command, and much more.

Command: uaSubscriber subscribeDataSet

After the command starts, it displays all dataset messages received (according to the criteria given by the command-line options) and their content (data fields). In case of an error, it displays an appropriate error message.

By default, OpcCmd stays subscribed for one minute, or until you interrupt it using the X key. The time period can be configured using the --SleepTimeMilliseconds (-stm) or --SleepTimeSpan (-sts) command-line option. You can also use Ctrl+Break key combination to terminate the OpcCmd utility at any time, but without giving it a chance to perform any finalization tasks or return to the interactive mode.

Parameters of the subscribeDataSet command can be influenced by various arguments (positional) and options (named) given after it on the command line. The option names are case sensitive, and can be entered using the long form (starts with --) or the short form (starts with -). The options are (obtained through OpcCmd uaSubscriber subscribeDataSet --help):

Usage: OpcCmd uaSubscriber|uas subscribeDataSet|sds [options] <resourceDescriptor> <brokerQueueName> [command]

Arguments:
  resourceDescriptor                                       PubSub connection resource descriptor
  brokerQueueName                                          Broker queue name

Options:
  -?|-h|--help                                             Show help information
  -!p|--!property <key-typedValue-pair>                    Execute with given property value (see documentation) (*)
  -!x|--!extract <key>                                     Extract part of the result object
  -!t2s|--!treeToSequence <treeTraversalType>              Define how to convert trees to sequences
  -!ve|--!viewEvent[:<viewValueSpecifier>]                 Specify how to view events
  -!vv|--!viewValue[:<viewValueSpecifier>]                 Specify to view the result as a value, and how
  -!vs|--!viewSequence[:<viewSequenceSpecifier>]           Specify to view the result as a sequence, and how
  -!vt|--!viewTree[:<viewTreeSpecifier>]                   Specify view the result as a tree, and how
  -rpeu|--ResolverPublisherEndpointUri <uri>               Resolver publisher endpoint URI
  -rpeun|--ResolverPublisherEndpointUserName <string>      Resolver publisher endpoint user name token - user name
  -rpeup|--ResolverPublisherEndpointUserPassword <string>  Resolver publisher endpoint user name token - password
  -rpfru|--ResolverPublisherFileResourceUri <uri>          Resolver publisher file resource URI
  -rk|--ResolverKind <uaResolverKind>                      Resolver kind
  -cni|--ConnectionNetworkInterface <name>                 PubSub connection network interface
  -cn|--ConnectionName <name>                              PubSub connection name
  -cru|--ConnectionResourceUri <uri>                       PubSub connection resource URI
  -ctpn|--ConnectionTransportProfileName <uaPubsubTpn>     PubSub connection transport profile name
  -ctpu|--ConnectionTransportProfileUri <uri>              PubSub connection transport profile URI
  -cp|--ConnectionProperty <uaKey-uaValue-pair>            PubSub connection property (*)
  -uecf|--UseEthernetCaptureFile <fileName>                Use Ethernet capture file (requires OpcLabs.Pcap)
  -uucf|--UseUdpCaptureFile <fileName>                     Use UDP capture file (requires OpcLabs.Pcap)
  -cbapu|--ConnectionBrokerAuthenticationProfileUri <uri>  PubSub connection broker authentication profile URI
  -cbru|--ConnectionBrokerResourceUri <uri>                PubSub connection broker resource URI
  -cddu|--ConnectionDatagramDiscoveryUri <uri>             PubSub connection datagram discovery URI
  -mnms|--MaximumNetworkMessageSize <uint32>               Maximum network message size (ignored)
  -mrt|--MessageReceiveTimeout <double>                    Message receive timeout (milliseconds)
  -sgi|--SecurityGroupId <name>                            Security group Id
  -sksu|--SecurityKeyServiceUri <uri>                      Security key service URI (*)
  -sm|--SecurityMode <uaSecurityMode>                      Security mode
  -stun|--SksTemplateUserName <string>                     SKS template user name token - user name
  -stup|--SksTemplateUserPassword <string>                 SKS template user name token - user password
  -bapu|--BrokerAuthenticationProfileUri <uri>             Broker authentication profile URI
  -bmdqn|--BrokerMetaDataQueueName <name>                  Broker metadata queue name
  -bqn|--BrokerQueueName <name>                            Broker queue name
  -brdg|--BrokerRequestedDeliveryGuarantee <uaGuarantee>   Broker requested delivery guarantee
  -bru|--BrokerResourceUri <uri>                           Broker resource URI
  -dso|--DataSetOffset <uint16>                            Dataset offset
  -gv|--GroupVersion <uint32>                              Group version
  -nmn|--NetworkMessageNumber <uint16>                     Network message number
  -dsci|--DataSetClassId <guid>                            Dataset class Id
  -adm|--AllowDataMessages <bool>                          Allow data messages (default=true)
  -aem|--AllowEventMessages <bool>                         Allow event messages (default=true)
  -dswi|--DataSetWriterId <uint16>                         Dataset writer Id
  -dswn|--DataSetWriterName <name>                         Dataset writer name
  -pi|--PublisherId <uaPublisherId>                        Publisher Id
  -rfv|--RequiredFieldValue <key-typedValue-pair>          Required field value (uses promoted fields when available) (*)
  -wgi|--WriterGroupId <uint16>                            Writer group Id
  -wgn|--WriterGroupName <name>                            Writer group name
  -mof|--MessageOriginFilter <string>                      Message origin filter (ipaddress:port for UDP)
  -pdsn|--PublishedDataSetName <name>                      Published dataset name
  -i|--interactive                                         Enter subcommands in an interactive loop ("exit" to leave)

Commands:
  !getProperty|!gp                                         Get command property and display its value (see documentation)
  !wait                                                    Specify how long will the parent command execute (default 00:01:00)

Run 'subscribeDataSet|sds [command] --help' for more information about a command.
(*) Indicates options that can be specified multiple times with multiple values.

Parameter values:
  <typeCode>               Empty|Object|DBNull|Boolean|Char|SByte|Byte|Int16|UInt16|Int32|UInt32|Int64|UInt64|Single|Double|Decimal|DateTime|String
  <typedValue>             [<typeCode>]<value>
  <key-typedValue-pair>    <name>=<typedValue>
  <treeTraversalType>      None|DepthFirst|BreadthFirst
  <viewValueType>          Default|None|Simple|Write|Dump
  <viewOption>             None|Cls
  <viewOptions>            <viewOption>[,<viewOption>]...
  <format>                 <string>
  <viewValueSpecifier>     [<viewValueType>][:<viewOptions>[:<format>]]
  <viewSequenceType>       Default|None|Simple|Table|Browse
  <viewSequenceSpecifier>  [<viewSequenceType>][:<format>]
  <viewTreeType>           Default|None|Simple|Table
  <viewTreeSpecifier>      [<viewTreeType>][:<format>]
  <uaGuarantee>            NotSpecified|BestEffort|AtLeastOnce|AtMostOnce|ExactlyOnce
  <clarkNotation>          [{<url>}]<name>
  <uaBuiltInType>          Null|Boolean|SByte|Byte|Int16|UInt16|Int32|UInt32|Int64|UInt64|Float|Double|String|DateTime|Guid|ByteString|XmlElement|NodeId|ExpandedNodeId|StatusCode|QualifiedName|LocalizedText|ExtensionObject|DataValue|Variant|DiagnosticInfo|Number|Integer|UInteger|Enumeration
  <uaValue>                [<uaBuiltInType>]<value>
  <uaKey-uaValue-pair>     <clarkNotation>=<uaValue>
  <uaPublisherId>          [<uaPublisherIdType>]<value>
  <uaPublisherIdType>      |Byte|UInt16|UInt32|UInt64|String
  <uaResolverKind>         None|PubSubDiscovery|PublisherEndpoint|PublisherFile [DISCOVERY NOT IMPLEMENTED]
  <uaSecurityMode>         None|SecurityNone|SecuritySign|SecuritySignAndEncrypt|Secure|All
  <uaPubsubTpn>            AmqpJson|AmqpUadp|EthUadp|MqttJson|MqttUadp|UdpUadp

Help text for the OpcCmd utility itself can by displayed using OpcCmd --help. Help text for the OpcCmd uaSubscriber command can be displayed using OpcCmd uaSubscriber --help (there are some less-frequently options directly on this command, such as resolution timeouts, which are not discussed here).

Explanation of all the options is outside the scope of this article. Use the provided examples to work with the tool, and add options to the examples when the need arises. The options generally fall into several categories:

Execution
The --SleepTimeMilliseconds (-stm) and --SleepTimeSpan (-sts) options determine how long the command runs.
Resolver
Allow the physical parameters be determined from logical parameters by a resolution process, from a configuration file or an OPC UA server with PubSub configuration model. Options in this category start with the word Resolver.
Connection
Specify how the PubSub connection is made. The main options in this category start with the word Connection. The --ConnectionTransportProfile (-ctp) does not have to specified if it can be inferred from the --ConnectionResourceUri (-cru; for example, opc.udp and opc.eth schemes in the --ConnectionResourceUri imply the transport profile unambiguously, and therefore you do not have to specify --ConnectionTransportProfile with them). You can use one of the pre-defined symbolic names (such as ip6-allnodes) in place of the host name in --ConnectionResourceUri (-cru); see Enhanced Host Name Resolution for more information.
Communication parameters
E.g. --MessageReceiveTimeout (-mrt), or most of the options that start with the word Broker.
Filter
Allows filtering of the incoming messages. Main options in this category are the options that specify the publisher ID - they start with words PublisherId, such as --PublisherIdNumeric16 (-pin16). Other options in this category include --WriterGroupId (-wgi) and --DataSetWriterId (-dswi).

Command: uaSubscriber subscribeDataSetField

The subscribeDataSetField command is almost identical to the subscribeDataSet command. The only difference is that it does not display the whole dataset contents, but extracts a single given dataset field, and displays its data only.

The name of the field is given using an additional command-line option, --FieldName (-fn), followed by the field name. If there is a metadata available, this has to be the field name as it appears in the metadata. In absence of the metadata, you can use the field index instead - an integer (starting from 0), and preceded by'#', e.g. #2 for the 3rd field in the dataset.

If a dataset message is received but the specified field is not present in the dataset, the tool will display a corresponding error message.

Physical and Logical Parameters

The PubSub subscription can be specified using physical parameters, logical parameters, or a mix of them.

Physical parameters refer to data that is directly used to open the PubSub connection, and that appears "on the wire", in the PubSub messages. They include (only the most important parameters are listed; the list is not complete):

  • --ConnectionNetworkInterface (-cni)
  • --ConnectionResourceUri (-cru). This is the main parameter that always has to be specified. The scheme part is mandatory, always start the URI with "opc.udp://" in this version. Default port for OPC UA UDP is 4840 and does not have to be specified.
  • --ConnectionTransportProfile (-ctp). You do not need to specify it, if it can be derived from the scheme, such as in "opc.udp:".
  • --MessageReceiveTimeout (-mrt)
  • --DataSetOffset (-dso)
  • --GroupVersion (-gv)
  • --NetworkMessageNumber (-nmn)
  • --DataSetClassId (-dsci)
  • --DataSetWriterId (-dswi)
  • various PublisherIdXXXX (-piXX) options
  • --WriterGroupId (-wgi)

Logical parameters refer to named objects in the PubSub configuration. They are:

  • --ConnectionName (-cn)
  • --DataSetWriterName (-dswn)
  • --WriterGroupName (-wgn)
  • --PublishedDataSetName (-pdsn)

When using logical parameters, you typically specify the first three (connection, dataset writer and writer group names), or the last one (published data set name). When published data set name is specified, OpcCmd finds the instances in the PubSub configuration where the dataset is published; the outcome must be unambiguous, otherwise an error occurs. Other logical parameters, and some physical parameters (such as transport profile URI) can be used to narrow down the outcome of this selection process.

The PubSub configuration information must somehow be available to OpcCmd, and a so-called resolver is used to transform the logical parameters to physical ones. There are currently two kinds of resolvers: One takes the PubSub configuration from a file (in a format given by OPC UA specification), the other works with a live PubSub configuration in an information model of a live OPC server that supports it (and is typically part of, of connected with or related to, the actual OPC UA PubSub publisher).

Following parameters are used to specify the resolver and its parameters:

  • --ResolverPublisherEndpointUri (-rpeu). Use this option to resolve the logical parameters from an OPC UA server with PubSub configuration model.
  • --ResolverPublisherFileResourceUri (-rpfru). Use this option to resolve the logical parameters from a PubSub configuration file.
  • --ResolverKind (-rk). Not necessary unless you want to specify multiple resolvers, and then just switch between them.

The information you specify using the parameters must be valid for the subscription to work, but in some cases it does not have to be complete. For example, when using physical or logical parameters, you do not have to specify anything beyond the connection - the OpcCmd will then simply process all messages on that connection, without filtering. Or, you can filter just by publisher ID, but still receive different datasets provided by the given publisher.

Examples

Following examples show some typical OpcCmd use cases (obtained through OpcCmd uaSubscriber subscribeDataSet --help):

Usage examples:

Subscribe to an OPC UA PubSub dataset, specifying physical parameters:
  OpcCmd uaSubscriber subscribeDataSet opc.udp://239.0.0.1:4840
  OpcCmd uaSubscriber subscribeDataSet opc.udp://224.0.0.22 -dswi 62541
  OpcCmd uaSubscriber subscribeDataSet -cru opc.udp://239.0.0.1:4840 !wait 01:00
  OpcCmd uaSubscriber subscribeDataSet opc.udp://239.0.0.1:4840 -pi [UInt16]30
  OpcCmd uaSubscriber subscribeDataSet opc.eth://FF-FF-FF-FF-FF-FF -pi [UInt16]30
  OpcCmd uaSubscriber subscribeDataSet mqtt://opcua-pubsub.demo-this.com opcuademo/uadp/none
  OpcCmd uaSubscriber subscribeDataSet mqtt://opcua-pubsub.demo-this.com opcuademo/uadp/none -dswi 4 -!ve=:cls
  OpcCmd uaSubscriber subscribeDataSet mqtt://opcua-pubsub.demo-this.com opcuademo/json -ctpn MqttJson

Subscribe to an OPC UA PubSub dataset, specifying logical parameters (and resolving them first):
  OpcCmd uaSubscriber subscribeDataSet -rpeu opc.tcp://192.168.0.85:4840 -cn UDP1 -wgn WriterGroupStatic -dswn WriterSimple
  OpcCmd uaSubscriber subscribeDataSet -rpeu opc.tcp://192.168.0.50:4842 -pdsn "PublishedDataSet #1"
  OpcCmd uaSubscriber subscribeDataSet -rpfru unified_automation_cpp.bin -cn UDP1 -wgn WriterGroupDynamic -dswn WriterAllTypes

More examples:

Subscribe to all messages generated by a default configuration of the UADemoPublisher utility (see UADemoPublisher Basics for more information):

OpcCmd uaSubscriber subscribeDataSet -cru opc.udp://239.0.0.1

Subscribe to all messages on an IPv6 multicast address ff02::1 (all nodes on the local network segment):

OpcCmd uaSubscriber subscribeDataSet -cru opc.udp://[ff02::1]

Subscribe to all messages on an Ethernet broadcast address (FF-FF-FF-FF-FF-FF), tagged with VID (VLAN identifier) 2:

OpcCmd uaSubscriber subscribeDataSet -cru opc.eth://eth-broadcast:2

For messages from a default configuration of UADemoPublisher utility, with specific publisher ID (31, in 64 bits) and dataset writer ID (4):

OpcCmd uaSubscriber subscribeDataSet -cru opc.udp://239.0.0.1 -pin64 31 -dswi 4

Sample Output

The following listing shows a sample output of the OpcCmd tool, when subscribed to data coming from the UADemoPublisher (shortened):

OPC Labs OpcCmd Utility (.NET Core) 5.55.0.3: OPC Command-line Tool (OPC-UA PubSub Subscriber).
Copyright © 2019 CODE Consulting and Development, s.r.o., Plzen. All rights reserved.

Subscribing dataset...
Subscription handle: 12586001
Sleeping for 00:01:00 (press Ctrl+Break to abort)...

DataSetMessage: Success

DataSetMessage: Success; 0001-01-01T00:00:00.000,000,000,00; Good; Data; publisher="32", writer=1, class=eae79794-1af7-4f96-8401-4096cd1d8908, fields: 4
[#0, True {System.Boolean} @0001-01-01T00:00:00.000,000,000,00; Good]
[#1, 229 {System.Int32} @0001-01-01T00:00:00.000,000,000,00; Good]
[#2, 1109 {System.Int32} @0001-01-01T00:00:00.000,000,000,00; Good]
[#3, 7/17/2019 3:29:54 PM {System.DateTime} @0001-01-01T00:00:00.000,000,000,00; Good]

DataSetMessage: Success; 0001-01-01T00:00:00.000,000,000,00; Good; Data; publisher="32", writer=3, class=96976b7b-0db7-46c3-a715-0979884b55ae, fields: 100
[#0, 29 {System.Int64} @0001-01-01T00:00:00.000,000,000,00; Good]
[#1, 129 {System.Int64} @0001-01-01T00:00:00.000,000,000,00; Good]
[#2, 229 {System.Int64} @0001-01-01T00:00:00.000,000,000,00; Good]
[#3, 329 {System.Int64} @0001-01-01T00:00:00.000,000,000,00; Good]
[#4, 429 {System.Int64} @0001-01-01T00:00:00.000,000,000,00; Good]
[#5, 529 {System.Int64} @0001-01-01T00:00:00.000,000,000,00; Good]
[#6, 629 {System.Int64} @0001-01-01T00:00:00.000,000,000,00; Good]
[#7, 729 {System.Int64} @0001-01-01T00:00:00.000,000,000,00; Good]
[#8, 829 {System.Int64} @0001-01-01T00:00:00.000,000,000,00; Good]
[#9, 929 {System.Int64} @0001-01-01T00:00:00.000,000,000,00; Good]
[#10, 1029 {System.Int64} @0001-01-01T00:00:00.000,000,000,00; Good]
[#11, 1129 {System.Int64} @0001-01-01T00:00:00.000,000,000,00; Good]
[#12, 1229 {System.Int64} @0001-01-01T00:00:00.000,000,000,00; Good]
...

DataSetMessage: Success; 0001-01-01T00:00:00.000,000,000,00; Good; Data; publisher="32", writer=4, class=cc7cb5f4-4272-45c2-9a4d-f85a8b331f6a, fields: 16
[#0, True {System.Boolean} @0001-01-01T00:00:00.000,000,000,00; Good]
[#1, 230 {System.Byte} @0001-01-01T00:00:00.000,000,000,00; Good]
[#2, 230 {System.Int16} @0001-01-01T00:00:00.000,000,000,00; Good]
[#3, 230 {System.Int32} @0001-01-01T00:00:00.000,000,000,00; Good]
[#4, 230 {System.Int64} @0001-01-01T00:00:00.000,000,000,00; Good]
[#5, 102 {System.Int16} @0001-01-01T00:00:00.000,000,000,00; Good]
[#6, 230 {System.Int32} @0001-01-01T00:00:00.000,000,000,00; Good]
[#7, 230 {System.Int64} @0001-01-01T00:00:00.000,000,000,00; Good]
[#8, 230 {System.Decimal} @0001-01-01T00:00:00.000,000,000,00; Good]
[#9, 230 {System.Single} @0001-01-01T00:00:00.000,000,000,00; Good]
[#10, 230 {System.Double} @0001-01-01T00:00:00.000,000,000,00; Good]
[#11, Whiskey {System.String} @0001-01-01T00:00:00.000,000,000,00; Good]
[#12, [20] {169, 225, 194, 251, 149, ...} {System.Byte[]} @0001-01-01T00:00:00.000,000,000,00; Good]
[#13, d34c50d3-a8e0-4861-b1e7-1868ab97756d {System.Guid} @0001-01-01T00:00:00.000,000,000,00; Good]
[#14, 7/17/2019 3:29:55 PM {System.DateTime} @0001-01-01T00:00:00.000,000,000,00; Good]
[#15, [10] {230, 231, 232, 233, 234, ...} {System.Int64[]} @0001-01-01T00:00:00.000,000,000,00; Good]

...

DataSetMessage: *** Failure -1 (0xFFFFFFFF): The toolkit UADP NetworkMessage processor does not have DataSetMetaData available (publisher ID: 30, writer group ID: 101).

...

DataSetMessage: Success; 2019-07-17T15:29:55.329,733,500,00; Good; Event; publisher=(UInt64)31, writer=51, fields: 4
[#0, True {System.Boolean} @2019-07-17T15:29:55.329,733,500,00; Good]
[#1, 230 {System.Int32} @2019-07-17T15:29:55.329,733,500,00; Good]
[#2, 1219 {System.Int32} @2019-07-17T15:29:55.329,733,500,00; Good]
[#3, 7/17/2019 3:29:55 PM {System.DateTime} @2019-07-17T15:29:55.329,733,500,00; Good]

DataSetMessage: Success; 2019-07-17T15:29:57.333,255,400,00; Good; Event; publisher=(UInt64)31, writer=51, fields: 4
[#0, False {System.Boolean} @2019-07-17T15:29:57.333,255,400,00; Good]
[#1, 232 {System.Int32} @2019-07-17T15:29:57.333,255,400,00; Good]
[#2, 1571 {System.Int32} @2019-07-17T15:29:57.333,255,400,00; Good]
[#3, 7/17/2019 3:29:57 PM {System.DateTime} @2019-07-17T15:29:57.333,255,400,00; Good]

...

Unsubscribing dataset (subscription handle 12586001)...
Finished.

Explanation to some of the output follows.

DataSetMessage: Success

This line indicates that a PubSub connection has been successfully established (there is no direct connection to the publisher - but, depending on the protocol, an IP socket needs to be open, or similar "initiating" operation needs to be made, and the message indicates that the parameters used to specify the connections were OK in principle). If the connection could not have been established, there would be an error message instead.

DataSetMessage: Success; 0001-01-01T00:00:00.000,000,000,00; Good; Data; publisher="32", writer=1, class=eae79794-1af7-4f96-8401-4096cd1d8908, fields: 4

Similar lines precede each dataset message received. They contain the timestamp of the message, the status code, an indication whether the message contains Data or Event, and an identification of the dataset (depending on what is actually available).

[#0, True {System.Boolean} @0001-01-01T00:00:00.000,000,000,00; Good]

Similar lines contain the data fields of the message. '#' followed by a number indicates a field index. If metadata is available, there is a field name instead. Then, the actual data value is listed, followed by its type in '{ }' (this is .NET type; note that the values are converted to so-called CLS types, and therefore the .NET type may not be precisely the same as the type of the field). After that, a source timestamp preceded with '@' follows, and after a semicolon (';'), a status code. The lines with data fields are sorted alphabetically by the field name/index.

The timestamps are formatted down to 10-picosecond level.

DataSetMessage: *** Failure -1 (0xFFFFFFFF): The toolkit UADP NetworkMessage processor does not have DataSetMetaData available (publisher ID: 30, writer group ID: 101).

This message indicates that a dataset message has been received, but because the data uses raw encoding and no metadata is available, it cannot be fully parsed. Metadata can be provided from a configuration file or by an OPC UA server with PubSub configuration model. The related command-line options for that are (among others) --ResolverPublisherFileResourceUri (-rpfru) and --ResolverPublisherEndpointUri (-rpeu). The UADemoPublisher comes with (and/or can generate) a .uabinary file for itself.

Reading Capture Files

OpcCmd can read the network traffic from a file, instead of using live data. This is extremely handy for various kinds of troubleshooting, diagnostics, analysis and similar tasks. It allows you to capture the data generated by the publisher once, and then replay it as many times as you like.

The network capture needs to be in the PCAP format. Various tools, including Wireshark, can read and write this format. The current versions of Wireshark, however, store network capture in a newer format (PCAPNG) by default. Using the "Save as type" drop-down in Wireshark's "Save file as" dialog, it is easy to save your network captures in the PCAP format, or even convert existing PCAPNG captures to PCAP.

For UDP message mapping, apply the --UseUdpCaptureFile (-uucf) option, followed by the file name, to the subscribeDataSet or subscribeDataSetField command. For Ethernet message mapping, apply the --UseEthernetCaptureFile (-uecf) option instead.

You still need to specify the connection URI as usual. The command to subscribe to a dataset from a network capture file may then look like this (the file used is one of sample files that ship with the UADemoPublisher):

OpcCmd uaSubscriber subscribeDataSet opc.udp://239.0.0.1:4840 -uucf UADemoPublisher-UDP

The default file name extension is ".pcap".

When reading UDP message captures, there is a built-in IP fragment reassembler (for both IPv4 and IPv6), and thus you can work with messages whose requirements exceed the network's MTU.

The packets in the capture file are used to provide "timed" replay of the network communication. This means that when the capture is replayed, the software not only mimics the actual data in the packets, but it also attempts to maintain the same timing of the packets as it appears in the capture. An initial delay of 1000 milliseconds is added before the replay starts, in order to allow for startup tasks on the receiver side to finalize.

See also