Skip to end of metadata
Go to start of metadata

The Daffodil Releases come with an example directory containing DFDL schemas and files used to exercise the Daffodil parser. Following are commands that can be run from the root directory of the of the extracted release. Note that these commands assume a Linux terminal. If you are using Windows, replace ./bin/daffodil.sh with .\bin\daffodil.bat, and use the appropriate file delimiting character when specifying paths.

Visit the Daffodil Command Line Interface for more detailed usage on the CLI.

See Daffodil Performance for metrics on how these examples perform.

There is also a separate example integration of Daffodil into the Calabash XProc processor. See the Daffodil Calabash page.

Comma-separated Values (CSV)

A comma-separated value file is a file that contains a single row of headers followed by one or more rows of data. The header and data rows are separated into records by a comma. For information on the file format, visit Comma-separated Values.

command
$ ./bin/daffodil parse --schema examples/csv/csv.dfdl.xsd examples/csv/simpleCSV
csv.dfdl.xsd
<?xml version="1.0" encoding="UTF-8"?> 
<!-- 
Copyright (c) 2012-2015 Tresys Technology, LLC. All rights reserved.
Developed by: Tresys Technology, LLC
              http://www.tresys.com
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal with
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
 1. Redistributions of source code must retain the above copyright notice,
    this list of conditions and the following disclaimers.
 2. Redistributions in binary form must reproduce the above copyright
    notice, this list of conditions and the following disclaimers in the
    documentation and/or other materials provided with the distribution.
 3. Neither the names of Tresys Technology, nor the names of its contributors
    may be used to endorse or promote products derived from this Software
    without specific prior written permission.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
SOFTWARE.
 -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions"
  xmlns:dfdl="http://www.ogf.org/dfdl/dfdl-1.0/" xmlns:ex="http://example.com"
  targetNamespace="http://example.com" elementFormDefault="unqualified">
  <xs:include schemaLocation="xsd/built-in-formats.xsd" />
  <xs:annotation>
    <xs:appinfo source="http://www.ogf.org/dfdl/">
      <dfdl:format ref="ex:daffodilTest1" separator="" initiator=""
        terminator="" leadingSkip='0' textTrimKind="none" initiatedContent="no"
        alignment="implicit" alignmentUnits="bits" trailingSkip="0" ignoreCase="no"
        separatorPosition="infix" occursCountKind="parsed"
        emptyValueDelimiterPolicy="both" representation="text" textNumberRep="standard"
        lengthKind="delimited" encoding="ASCII" />
    </xs:appinfo>
  </xs:annotation>
  <xs:element name="file">
    <xs:complexType>
      <xs:sequence dfdl:separator="%NL;" dfdl:separatorPosition="postfix">
        <xs:element name="header" minOccurs="0" maxOccurs="1"
          dfdl:occursCountKind="implicit">
          <xs:complexType>
            <xs:sequence dfdl:separator=",">
              <xs:element name="title" type="xs:string" maxOccurs="unbounded" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="record" maxOccurs="unbounded">
          <xs:complexType>
            <xs:sequence dfdl:separator=",">
              <xs:element name="item" type="xs:string" maxOccurs="unbounded"
                dfdl:occursCount="{ fn:count(../../header/title) }"
                dfdl:occursCountKind="expression" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>
examples/csv/simpleCSV
last,first,middle,DOB
smith,robert,brandon,1988-03-24
johnson,john,henry,1986-01-23
jones,arya,cat,1986-02-19
output
<ex:file xmlns:ex="http://example.com">
  <header>
    <title>last</title>
    <title>first</title>
    <title>middle</title>
    <title>DOB</title>
  </header>
  <record>
    <item>smith</item>
    <item>robert</item>
    <item>brandon</item>
    <item>1988-03-24</item>
  </record>
  <record>
    <item>johnson</item>
    <item>john</item>
    <item>henry</item>
    <item>1986-01-23</item>
  </record>
  <record>
    <item>jones</item>
    <item>arya</item>
    <item>cat</item>
    <item>1986-02-19</item>
  </record>
</ex:file>

 

PCAP

The PCAP file format is a binary file format used to capture network packets. For information on this file format, visit the Wireshark Libpcap File Format page.

command
$ ./bin/daffodil parse --schema examples/pcap/pcap.dfdl.xsd examples/pcap/icmp.cap
pcap.dfdl.xsd
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012-2014 Tresys Technology, LLC. All rights reserved.
Developed by: Tresys Technology, LLC
              http://www.tresys.com
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal with
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
 1. Redistributions of source code must retain the above copyright notice,
    this list of conditions and the following disclaimers.
 2. Redistributions in binary form must reproduce the above copyright
    notice, this list of conditions and the following disclaimers in the
    documentation and/or other materials provided with the distribution.
 3. Neither the names of Tresys Technology, nor the names of its contributors
    may be used to endorse or promote products derived from this Software
    without specific prior written permission.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
SOFTWARE.
-->

<!--
Version 1.1  pcap.dfdl.xsd
Change History
1.1: Support parsing link layer (ethernet), network layer (ipv4, ipv6, icmpv4)
     and transport layer (tcp, udp)
This DFDL schema provides a DFDL model for PCAP v2.4 binary data, which
contains network packet capture data.
The message root is 'PCAP'.
-->

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:dfdl="http://www.ogf.org/dfdl/dfdl-1.0/"
           xmlns:fn="http://www.w3.org/2005/xpath-functions"
           xmlns:pcap="urn:pcap:2.4"
           targetNamespace="urn:pcap:2.4">
  <xs:annotation>
    <xs:appinfo source="http://www.ogf.org/dfdl/">
      <dfdl:defineVariable name="ByteOrder" type="xs:string" />
      <dfdl:defineFormat name="defaults">
        <dfdl:format alignment="1" alignmentUnits="bits"
        binaryBooleanFalseRep="0" binaryBooleanTrueRep="1"
        binaryCalendarEpoch="1970-01-01T00:00:00+00:00" binaryCalendarRep="bcd"
        binaryDecimalVirtualPoint="0" binaryFloatRep="ieee"
        binaryNumberCheckPolicy="lax" binaryNumberRep="binary"
        binaryPackedSignCodes="C D F C" calendarCenturyStart="53"
        calendarCheckPolicy="lax" calendarDaysInFirstWeek="4"
        calendarFirstDayOfWeek="Monday" calendarLanguage="en-US"
        calendarObserveDST="yes" calendarPatternKind="implicit"
        calendarPattern="yyyy-MM-dd'T'HH:mm:ss" calendarTimeZone="UTC"
        choiceLengthKind="implicit" decimalSigned="yes"
        documentFinalTerminatorCanBeMissing="no" emptyValueDelimiterPolicy="none"
        encoding="UTF-8" encodingErrorPolicy="replace" escapeSchemeRef=""
        fillByte="0" floating="no" ignoreCase="no" initiatedContent="no"
        initiator="" leadingSkip="0" lengthKind="implicit" lengthUnits="bits"
        nilKind="literalValue" nilValueDelimiterPolicy="none" nilValue="NIL"
        occursCountKind="implicit" outputNewLine="%CR;%LF;"
        prefixIncludesPrefixLength="no" representation="binary" separator=""
        separatorPosition="infix" sequenceKind="ordered" terminator=""
        textBidi="no" textBooleanFalseRep="false" textBooleanJustification="left"
        textBooleanPadCharacter="%SP;" textBooleanTrueRep="true"
        textCalendarJustification="left" textCalendarPadCharacter="%SP;"
        textNumberCheckPolicy="lax" textNumberJustification="right"
        textNumberPadCharacter="0" textNumberPattern="#0" textNumberRep="standard"
        textNumberRoundingIncrement="0.0" textNumberRoundingMode="roundUp"
        textNumberRounding="pattern" textOutputMinLength="0" textPadKind="none"
        textStandardBase="10" textStandardDecimalSeparator="."
        textStandardGroupingSeparator="," textStandardInfinityRep="Inf"
        textStandardNaNRep="NaN" textStandardZeroRep=""
        textStringJustification="left" textStringPadCharacter="%SP;"
        textTrimKind="none" textZonedSignStyle="asciiStandard" trailingSkip="0"
        truncateSpecifiedLengthString="no" useNilForDefault="no" utf16Width="fixed"
        bitOrder="mostSignificantBitFirst"/>
      </dfdl:defineFormat>
      <dfdl:format ref="pcap:defaults" byteOrder="{ $pcap:ByteOrder }" />
    </xs:appinfo>
  </xs:annotation>
  <xs:simpleType name="uint16" dfdl:lengthKind="explicit" dfdl:length="16">
    <xs:restriction base="xs:unsignedInt"/>
  </xs:simpleType>
  <xs:simpleType name="uint32" dfdl:lengthKind="explicit" dfdl:length="32">
    <xs:restriction base="xs:unsignedInt"/>
  </xs:simpleType>
  <xs:simpleType name="int32" dfdl:lengthKind="explicit" dfdl:length="4" dfdl:lengthUnits="bytes">
    <xs:restriction base="xs:int"/>
  </xs:simpleType>
  <xs:simpleType name="bit" dfdl:lengthKind="explicit" dfdl:byteOrder="bigEndian" dfdl:lengthUnits="bits">
    <xs:restriction base="xs:unsignedInt" />
  </xs:simpleType>
  <xs:simpleType name="hexByte" dfdl:lengthKind="explicit" dfdl:byteOrder="bigEndian" dfdl:lengthUnits="bytes">
    <xs:restriction base="xs:hexBinary" />
  </xs:simpleType>
  <xs:element name="PCAP">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="PCAPHeader">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="MagicNumber" type="xs:hexBinary" dfdl:lengthKind="explicit" dfdl:length="4" dfdl:lengthUnits="bytes" dfdl:byteOrder="bigEndian">
                <xs:annotation>
                  <xs:appinfo source="http://www.ogf.org/dfdl/">
                    <dfdl:assert message="Magic number was not 0xA1B2C3D4 (for bigEndian) or 0xD4C3B2A1 (for littleEndian)."
                                 test="{ (xs:string(.) eq 'A1B2C3D4') or (xs:string(.) eq 'D4C3B2A1') }" />
                    <dfdl:setVariable ref="pcap:ByteOrder" value="{ if (xs:string(.) eq 'A1B2C3D4') then 'bigEndian' else 'littleEndian' }" />
                  </xs:appinfo>
                </xs:annotation>
              </xs:element>
              <xs:element name="Version">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="Major" type="pcap:uint16" />
                    <xs:element name="Minor" type="pcap:uint16" />
                    <xs:sequence>
                      <xs:annotation>
                        <xs:appinfo source="http://www.ogf.org/dfdl/">
                          <dfdl:assert message="PCAP version must be 2.4" test="{ (xs:unsignedInt(./Major) eq 2) and (xs:unsignedInt(./Minor) eq 4) }" />
                        </xs:appinfo>
                      </xs:annotation>
                    </xs:sequence>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
              <xs:element name="Zone" type="pcap:int32" />
              <xs:element name="SigFigs" type="pcap:uint32" />
              <xs:element name="SnapLen" type="pcap:uint32" />
              <xs:element name="Network" type="pcap:uint32" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="Packet" maxOccurs="unbounded">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="PacketHeader">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="Seconds" type="pcap:uint32"/> <!-- TODO: ts_sec should be a dateTime -->
                    <xs:element name="USeconds" type="pcap:uint32"/>
                    <xs:element name="InclLen" type="pcap:uint32"/>
                    <xs:element name="OrigLen" type="pcap:uint32"/>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
              <xs:element ref="pcap:LinkLayer" dfdl:lengthUnits="bytes" dfdl:lengthKind="explicit" dfdl:length="{ ../PacketHeader/InclLen }"/>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <!-- LINK LAYER -->
  <xs:element name="LinkLayer">
    <xs:complexType>
      <xs:choice>
        <xs:element ref="pcap:Ethernet" />
      </xs:choice>
    </xs:complexType>
  </xs:element>
  <xs:element name="Ethernet">
    <xs:complexType>
      <xs:sequence>
        <xs:annotation>
          <xs:appinfo source="http://www.ogf.org/dfdl/">
            <dfdl:discriminator message="Link layer type is not Ethernet" test="{ xs:unsignedInt(../../../PCAPHeader/Network) eq 1 }" />
          </xs:appinfo>
        </xs:annotation>
        <xs:element name="MACDest" type="pcap:hexByte" dfdl:length="6" />
        <xs:element name="MACSrc" type="pcap:hexByte" dfdl:length="6" />
        <xs:element name="Ethertype" type="pcap:bit" dfdl:length="16" />
        <xs:element ref="pcap:NetworkLayer" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <!-- NETWORK LAYER -->
  <xs:element name="NetworkLayer">
    <xs:complexType>
      <xs:choice>
        <xs:element ref="pcap:IPv4" />
        <xs:element ref="pcap:IPv6" />
      </xs:choice>
    </xs:complexType>
  </xs:element>
  <xs:simpleType name="IPSeg" dfdl:lengthKind="explicit" dfdl:lengthUnits="bytes" dfdl:length="1">
    <xs:restriction base="xs:unsignedInt"/>
  </xs:simpleType>
  <xs:group name="IPSrcGrp">
    <xs:sequence>
      <xs:element name="IPSrcByte" type="pcap:IPSeg" minOccurs="4" maxOccurs="4"/>
    </xs:sequence>
  </xs:group>
  <xs:group name="IPDestGrp">
    <xs:sequence>
      <xs:element name="IPDestByte" type="pcap:IPSeg" minOccurs="4" maxOccurs="4"/>
    </xs:sequence>
  </xs:group>
  <xs:element name="IPv4">
    <xs:complexType>
      <xs:sequence>
        <xs:annotation>
          <xs:appinfo source="http://www.ogf.org/dfdl/">
            <dfdl:discriminator message="Ethertype is not IPv4" test="{ xs:unsignedInt(../../Ethertype) eq 2048 }" />
          </xs:appinfo>
        </xs:annotation>
        <xs:element name='IPv4Header'>
          <xs:complexType>
            <xs:sequence>
              <xs:element name="Version" type="pcap:bit" dfdl:length="4" />
              <xs:element name="IHL" type="pcap:bit" dfdl:length="4" />
              <xs:element name="DSCP" type="pcap:bit" dfdl:length="6" />
              <xs:element name="ECN" type="pcap:bit" dfdl:length="2" />
              <xs:element name="Length" type="pcap:bit" dfdl:length="16" />
              <xs:element name="Identification" type="pcap:bit" dfdl:length="16" />
              <xs:element name="Flags" type="pcap:bit" dfdl:length="3" />
              <xs:element name="FragmentOffset" type="pcap:bit" dfdl:length="13" />
              <xs:element name="TTL" type="pcap:bit" dfdl:length="8" />
              <xs:element name="Protocol" type="pcap:bit" dfdl:length="8" />
              <xs:element name="Checksum" type="pcap:bit" dfdl:length="16" />
                      <xs:sequence dfdl:hiddenGroupRef="pcap:IPSrcGrp"/>
              <xs:element name="IPSrc" type="xs:string" dfdl:inputValueCalc="{ fn:concat(../IPSrcByte[1], '.', ../IPSrcByte[2], '.', ../IPSrcByte[3], '.', ../IPSrcByte[4]) }"/>
              <xs:sequence dfdl:hiddenGroupRef="pcap:IPDestGrp"/>
              <xs:element name="IPDest" type="xs:string" dfdl:inputValueCalc="{ fn:concat(../IPDestByte[1], '.', ../IPDestByte[2], '.', ../IPDestByte[3], '.', ../IPDestByte[4]) }"/>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="PayloadLength" type="xs:unsignedInt" dfdl:inputValueCalc="{ xs:unsignedInt(../IPv4Header/Length) - 20 }" />
        <xs:element name="Protocol" type="xs:unsignedInt" dfdl:inputValueCalc="{ xs:unsignedInt(../IPv4Header/Protocol) }" />
        <xs:choice>
            <xs:element ref="pcap:TransportLayer" dfdl:lengthKind="explicit" dfdl:lengthUnits="bytes" dfdl:length="{ ../PayloadLength }" />
            <xs:element ref="pcap:ICMPv4" dfdl:lengthKind="explicit" dfdl:lengthUnits="bytes" dfdl:length="{ ../PayloadLength }"/>
        </xs:choice>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="ICMPv4">
    <xs:complexType>
      <xs:sequence>
        <xs:annotation>
          <xs:appinfo source="http://www.ogf.org/dfdl/">
            <dfdl:discriminator message="Protocol type is not ICMPv4" test="{ xs:unsignedInt(../Protocol) eq 1 }" />
          </xs:appinfo>
        </xs:annotation>
        <xs:element name="Type" type="pcap:bit" dfdl:length="8" />
        <xs:element name="Code" type="pcap:bit" dfdl:length="8" />
        <xs:element name="Checksum" type="pcap:bit" dfdl:length="16" />
        <xs:element name="Data" type="pcap:hexByte" dfdl:length="4" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  
  <xs:element name="IPv6">
    <xs:complexType>
      <xs:sequence>
        <xs:annotation>
          <xs:appinfo source="http://www.ogf.org/dfdl/">
            <dfdl:discriminator message="Ethertype is not IPv6" test="{ xs:unsignedInt(../../Ethertype) eq 34525 }" />
          </xs:appinfo>
        </xs:annotation>
        <xs:element name='IPv6Header'>
          <xs:complexType>
            <xs:sequence>
              <xs:element name="Version" type="pcap:bit" dfdl:length="4" />
              <xs:element name="TrafficClass" type="pcap:bit" dfdl:length="8" />
              <xs:element name="FlowLabel" type="pcap:bit" dfdl:length="20" />
              <xs:element name="PayloadLength" type="pcap:bit" dfdl:length="16" />
              <xs:element name="NextHeader" type="pcap:bit" dfdl:length="8" /> <!-- TODO: Add support for extension headers -->
              <xs:element name="HopLimit" type="pcap:bit" dfdl:length="8" />
              <xs:element name="IPSrc" type="pcap:hexByte" dfdl:length="16" />
              <xs:element name="IPDest" type="pcap:hexByte" dfdl:length="16" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="PayloadLength" type="xs:unsignedInt" dfdl:inputValueCalc="{ xs:unsignedInt(../IPv6Header/PayloadLength) }" />
        <xs:element name="Protocol" type="xs:unsignedInt" dfdl:inputValueCalc="{ xs:unsignedInt(../IPv6Header/NextHeader) }" />
        <xs:element ref="pcap:TransportLayer" dfdl:lengthKind="explicit" dfdl:lengthUnits="bytes" dfdl:length="{ ../PayloadLength }" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <!-- TRANSPORT LAYER -->
  <xs:element name="TransportLayer">
    <xs:complexType>
      <xs:choice>
        <xs:element ref="pcap:TCP" />
        <xs:element ref="pcap:UDP" />
      </xs:choice>
    </xs:complexType>
  </xs:element>
  <xs:element name="TCP">
    <xs:complexType>
      <xs:sequence>
        <xs:annotation>
          <xs:appinfo source="http://www.ogf.org/dfdl/">
            <dfdl:discriminator message="Protocol type is not TCP" test="{ xs:unsignedInt(../../Protocol) eq 6 }" />
          </xs:appinfo>
        </xs:annotation>
        <xs:element name='TCPHeader'>
          <xs:complexType>
            <xs:sequence>
              <xs:element name="PortSRC" type="pcap:bit" dfdl:length="16" />
              <xs:element name="PortDest" type="pcap:bit" dfdl:length="16" />
              <xs:element name="Seq" type="pcap:bit" dfdl:length="32" />
              <xs:element name="Ack" type="pcap:bit" dfdl:length="32" />
              <xs:element name="DataOffset" type="pcap:bit" dfdl:length="4" />
              <xs:element name="Reserved" type="pcap:bit" dfdl:length="3" />
              <xs:element name="Flags" type="pcap:bit" dfdl:length="9" />
              <xs:element name="WindowSize" type="pcap:bit" dfdl:length="16" />
              <xs:element name="Checksum" type="pcap:bit" dfdl:length="16" />
              <xs:element name="Urgent" type="pcap:bit" dfdl:length="16" />
              <xs:element name="Options" type="pcap:hexByte" dfdl:length="{ (xs:unsignedInt(../DataOffset) - 5) * 4 }" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="Data" type="pcap:hexByte" dfdl:length="{ xs:unsignedInt(../../../PayloadLength) - (xs:unsignedInt(../TCPHeader/DataOffset) * 4) }"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="UDP">
    <xs:complexType>
      <xs:sequence>
        <xs:annotation>
          <xs:appinfo source="http://www.ogf.org/dfdl/">
            <dfdl:discriminator message="Protocol type is not UDP" test="{ xs:unsignedInt(../../Protocol) eq 17 }" />
          </xs:appinfo>
        </xs:annotation>
        <xs:element name='UDPHeader'>
          <xs:complexType>
            <xs:sequence>
              <xs:element name="PortSrc" type="pcap:bit" dfdl:length="16" />
              <xs:element name="PortDest" type="pcap:bit" dfdl:length="16" />
              <xs:element name="Length" type="pcap:bit" dfdl:length="16" />
              <xs:element name="Checksum" type="pcap:bit" dfdl:length="16" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="Data" type="pcap:hexByte" dfdl:length="{ xs:unsignedInt(../UDPHeader/Length) - 8 }"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>
examples/pcap/icmp.cap (binary hexdump)
0000000     c3d4 a1b2 0002 0004 0000 0000 0000 0000
0000020     ffff 0000 0001 0000 6fc4 51c1 ccf8 000c
0000040     004a 0000 004a 0000 5000 e056 4914 0c00
...
0001300     0000 5c2f 0002 0024 6261 6463 6665 6867
0001320     6a69 6c6b 6e6d 706f 7271 7473 7675 6177
0001340     6362 6564 6766 6968
output
<pcap:PCAP xmlns:pcap="urn:pcap:2.4">
  <PCAPHeader>
    <MagicNumber>D4C3B2A1</MagicNumber>
    <Version>
      <Major>2</Major>
      <Minor>4</Minor>
    </Version>
    <Zone>0</Zone>
    <SigFigs>0</SigFigs>
    <SnapLen>65535</SnapLen>
    <Network>1</Network>
  </PCAPHeader>
  <Packet>
    <PacketHeader>
      <Seconds>1371631556</Seconds>
      <USeconds>838904</USeconds>
      <InclLen>74</InclLen>
      <OrigLen>74</OrigLen>
    </PacketHeader>
    <pcap:LinkLayer>
      <pcap:Ethernet>
        <MACDest>005056E01449</MACDest>
        <MACSrc>000C29340BDE</MACSrc>
        <Ethertype>2048</Ethertype>
        <pcap:NetworkLayer>
          <pcap:IPv4>
            <IPv4Header>
              <Version>4</Version>
              <IHL>5</IHL>
              <DSCP>0</DSCP>
              <ECN>0</ECN>
              <Length>60</Length>
              <Identification>55107</Identification>
              <Flags>0</Flags>
              <FragmentOffset>0</FragmentOffset>
              <TTL>128</TTL>
              <Protocol>1</Protocol>
              <Checksum>11123</Checksum>
              <IPSrc>192.168.158.139</IPSrc>
              <IPDest>174.137.42.77</IPDest>
            </IPv4Header>
            <PayloadLength>40</PayloadLength>
            <Protocol>1</Protocol>
            <pcap:ICMPv4>
              <Type>8</Type>
              <Code>0</Code>
              <Checksum>10844</Checksum>
              <Data>02002100</Data>
            </pcap:ICMPv4>
          </pcap:IPv4>
        </pcap:NetworkLayer>
      </pcap:Ethernet>
    </pcap:LinkLayer>
  </Packet>
  ...
</pcap:PCAP>
  • No labels