Skip to content

When binary data messages are read from TCP streams, an initial length field is typical. This provides an initial length field and a payload of that length as a reusable component DFDL schema.

License

Notifications You must be signed in to change notification settings

DFDLSchemas/tcpMessage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DFDL Schema: tcpMessage - simple length header for messages on byte streams

TCP streams have no notion of datagrams.

This schema provides the minimal notion of a TCP datagram, just a length field (32-bits, on a byte boundary, big-endian) followed by data of that length in bytes.

The length field's value is in addition to the 4 bytes of the length field itself. For example if a message has 100 bytes of data. The length field will contain the value 100, and the total number of bytes on the data stream, including the length field will be 104 bytes.

Usage

This is a component DFDL schema intended to be used by reference from an assembly schema that incorporates this header and the payload/content after it.

Herein when we refer to your schema we mean the assembly schema that is defining messages that use this TCP message component schema to get a TCP datagram.

To use this schema, the assembly schema must contain a file similar to the com/example/xsd/message.dfdl.xsd file (that you will find under src/test/resources/xsd/) which defines the root element of the TCP message. In your schema you would replace the com/example part of the path name with something more suitable.

TIP In your DFDL schema, the files described here will not be under src/test/resources/xsd, but rather src/main/resources/xsd. They are test files in this schema but main files in yours.

In addition the assembly schema must contain a file like the io/github/dfdlschemas/tcpMessage/xsd/tcpContentType.dfdl.xsd (that you will find under src/test/resources/xsd/) which must be located in this exact directory location.

The maximum message length defaults to 65535, but can be adjusted upward or downward by editing the default value of the DFDL variable tcpHdr:maxLength (in the tcpContentType.dfdl.xsd file) to the maximum length of your messages not including the 4 bytes of the stored length field.

Finally, the assembly schema must contain a file similar to the com/example/xsd/payloadGroup.dfdl.xsd which defines the fields of your messages. You would replace the com/example part of this directory path with more suitable names.

TIP: An available example assembly DFDL schema which uses this tcpMessage component DFDL schema is the envelope-payload DFDL schema.

About

When binary data messages are read from TCP streams, an initial length field is typical. This provides an initial length field and a payload of that length as a reusable component DFDL schema.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages