Using OpcCmd Utility as OPC UA PubSub Subscriber

From OPC Labs Knowledge Base
Jump to navigation Jump to search

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


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 PubSub security is not supported.


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

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]

  resourceDescriptor                                       PubSub connection resource descriptor
  brokerQueueName                                          Broker queue name

  -?|-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)

  !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:

The --SleepTimeMilliseconds (-stm) and --SleepTimeSpan (-sts) options determine how long the command runs.
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.
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.
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.


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://
  OpcCmd uaSubscriber subscribeDataSet opc.udp:// -dswi 62541
  OpcCmd uaSubscriber subscribeDataSet -cru opc.udp:// !wait 01:00
  OpcCmd uaSubscriber subscribeDataSet opc.udp:// -pi [UInt16]30
  OpcCmd uaSubscriber subscribeDataSet opc.eth://FF-FF-FF-FF-FF-FF -pi [UInt16]30
  OpcCmd uaSubscriber subscribeDataSet mqtt:// opcuademo/uadp/none
  OpcCmd uaSubscriber subscribeDataSet mqtt:// opcuademo/uadp/none -dswi 4 -!ve=:cls
  OpcCmd uaSubscriber subscribeDataSet mqtt:// opcuademo/json -ctpn MqttJson

Subscribe to an OPC UA PubSub dataset, specifying logical parameters (and resolving them first):
  OpcCmd uaSubscriber subscribeDataSet -rpeu opc.tcp:// -cn UDP1 -wgn WriterGroupStatic -dswn WriterSimple
  OpcCmd uaSubscriber subscribeDataSet -rpeu opc.tcp:// -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://

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:// -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) 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)...

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:// -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.

Tips and Tricks

Listen on UDP port for unicast messages
You can change the local port to listen on (e.g. to 9999) using the following command option: --ConnectionProperty {}LocalPort=[Int32]9999.

Related reading