<?xml version="1.0" encoding="UTF-8"?> 
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:annotation>
    <xs:documentation xml:lang="en">
License Agreement

NOTICE
This software (or technical data) was produced for the U. S.
Government under contract W15P7T-05-C-F600, and is
subject to the Rights in Data-General Clause 52.227-14 (JUNE 1987)

Copyright (C) 2006. The MITRE Corporation (http://www.mitre.org/).
All Rights Reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

* The US Government will not be charged any license fee and/or
royalties related to this software.

* Neither name of The MITRE Corporation; nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT
HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    </xs:documentation>
</xs:annotation>

<!-- TYPES -->

    <!-- Simple types -->

    <xs:simpleType name="dtnStatusType">
        <xs:restriction base="xs:string">
            <xs:enumeration value="justBooted"/>
            <xs:enumeration value="shuttingDown"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="bundlePriorityType">
        <xs:annotation>
            <xs:documentation xml:lang="en">
0 = bulk priority,
1 = normal priority,
2 = expedited priority,
3 = reserved
            </xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:unsignedByte">
            <xs:enumeration value="0"/>
            <xs:enumeration value="1"/>
            <xs:enumeration value="2"/>
            <xs:enumeration value="3"/>
        </xs:restriction>
    </xs:simpleType>
    
    <xs:simpleType name="eventSourceType">
        <xs:annotation>
            <xs:documentation xml:lang="en">
1 = peer bundle forwarder,
2 = local application,
3 = data store,
4 = admin logic,
5 = fragmentation engine
            </xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:unsignedByte">
            <xs:enumeration value="1"/>
            <xs:enumeration value="2"/>
            <xs:enumeration value="3"/>
            <xs:enumeration value="4"/>
            <xs:enumeration value="5"/>
        </xs:restriction>
    </xs:simpleType>
    
    <xs:simpleType name="forwardingStateType">
        <xs:annotation>
            <xs:documentation xml:lang="en">
0 = no forwarding state,
1 = currently being sent,
2 = successfully transmitted,
3 = transmission failed,
4 = transmission cancelled,
5 = custody transfer timeout
            </xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:unsignedByte">
            <xs:enumeration value="0"/>
            <xs:enumeration value="1"/>
            <xs:enumeration value="2"/>
            <xs:enumeration value="3"/>
            <xs:enumeration value="4"/>
            <xs:enumeration value="5"/>
        </xs:restriction>
    </xs:simpleType>
    
    <xs:simpleType name="bundleForwardActionType">
        <xs:annotation>
            <xs:documentation xml:lang="en">
0 = invalid action,
1 = forward bundle only to one next hop,
2 = forward a copy of the bundle,
            </xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:unsignedByte">
            <xs:enumeration value="0"/>
            <xs:enumeration value="1"/>
            <xs:enumeration value="2"/>
        </xs:restriction>
    </xs:simpleType>
    
    <xs:simpleType name="contactReasonType">
        <xs:annotation>
            <xs:documentation xml:lang="en">
0 = should not be used,
1 = no additional info,
2 = user action,
3 = unexpected session interruption,
4 = clean connection shutdown,
5 = re-establish link after failure,
6 = idle connection shut down by the CL,
7 = scheduled link ended duration
8 = no longer busy
            </xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:unsignedByte">
            <xs:enumeration value="0"/>
            <xs:enumeration value="1"/>
            <xs:enumeration value="2"/>
            <xs:enumeration value="3"/>
            <xs:enumeration value="4"/>
            <xs:enumeration value="5"/>
            <xs:enumeration value="6"/>
            <xs:enumeration value="7"/>
            <xs:enumeration value="8"/>
        </xs:restriction>
    </xs:simpleType>
    
    <xs:simpleType name="userContactReasonType">
        <xs:restriction base="contactReasonType">
            <xs:enumeration value="2"/>
        </xs:restriction>
    </xs:simpleType>
    
    <xs:simpleType name="linkTypeType">
        <xs:restriction base="xs:string">
            <xs:enumeration value="ALWAYSON"/>
            <xs:enumeration value="ONDEMAND"/>
            <xs:enumeration value="SCHEDULED"/>
            <xs:enumeration value="OPPORTUNISTIC"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="linkStateType">
        <xs:annotation>
            <xs:documentation xml:lang="en">
1 =  The link is closed and not able to be
     opened currently.
2 =  The link is closed but is able to be
     opened, either because it is an on demand
     link, or because an opportunistic peer
     node is in close proximity but no
     convergence layer session has yet been
     opened.
4 =  A convergence layer session is in the
     process of being established.
8 =  A convergence layer session has been
     established, and the link has capacity
     for a bundle to be sent on it. This may
     be because no bundle is currently being
     sent, or because the convergence layer
     can handle multiple simultaneous bundle
     transmissions.
16 = The link is busy, i.e. a bundle is
     currently being sent on it by the
     convergence layer and no more bundles may
     be delivered to the link.
32 = The link is in the process of being closed.
            </xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:unsignedByte">
            <xs:enumeration value="1"/>
            <xs:enumeration value="2"/>
            <xs:enumeration value="4"/>
            <xs:enumeration value="8"/>
            <xs:enumeration value="16"/>
            <xs:enumeration value="32"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="eidTypeType">
        <xs:union>
            <xs:simpleType>
                <xs:restriction base="xs:string">
                   <xs:enumeration value="*:*"/>
                   <xs:enumeration value="dtn:none"/>
                </xs:restriction>
            </xs:simpleType>
            <xs:simpleType>
                <xs:restriction base="xs:string">
                    <xs:pattern value="\S+://(\S|/)+/\*"/>
                </xs:restriction>
            </xs:simpleType>
            <xs:simpleType>
                <xs:restriction base="xs:anyURI"/>
            </xs:simpleType>
        </xs:union>
    </xs:simpleType>

    <xs:simpleType name="failureActionType">
        <xs:annotation>
            <xs:documentation xml:lang="en">
0 = Drop bundles
1 = Spool bundles until requested
2 = Execute the specified callback procedure
            </xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:unsignedByte">
            <xs:enumeration value="0"/>
            <xs:enumeration value="1"/>
            <xs:enumeration value="2"/>
        </xs:restriction>
    </xs:simpleType>
    
    <!-- Bundle Type -->
    
    <xs:attributeGroup name="bundleAttributes">
        <xs:attribute name="bundleid" type="xs:unsignedInt" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Local bundle identifier.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="is_fragment" type="xs:boolean" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Whether the bundle is a fragment.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="is_admin" type="xs:boolean" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Whether the bundle is an administrative record.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="do_not_fragment" type="xs:boolean" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Whether the bundle may be fragmented.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="priority" type="bundlePriorityType" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Bundle priority or class of service.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="custody_requested" type="xs:boolean" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Whether bundle custody is requested.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="local_custody" type="xs:boolean" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Whether the local node has custody of the bundle.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="singleton_dest" type="xs:boolean" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Whether the destination is exactly one endpoint.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="custody_rcpt" type="xs:boolean" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Whether custody receipts are requested.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="receive_rcpt" type="xs:boolean" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Whether hop-by-hop reception receipts are requested.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="forward_rcpt" type="xs:boolean" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Whether hop-by-hop forwarding reports are requested.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="delivery_rcpt" type="xs:boolean" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Whether end-to-end delivery receipts are requested.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="deletion_rcpt" type="xs:boolean" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Whether bundle deletion reports are requested.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="app_acked_rcpt" type="xs:boolean" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Whether application acknowlegements are requested.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="creation_ts_seconds" type="xs:unsignedInt" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Seconds since 1/1/2000.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="creation_ts_seqno" type="xs:unsignedInt" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Subsecond sequence number.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="expiration" type="xs:unsignedInt" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Bundle expiration time.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="orig_length" type="xs:unsignedInt" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Length of original bundle.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="frag_offset" type="xs:unsignedInt" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Offset of fragment in the original bundle.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="owner" type="xs:string" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Declared DTN node that "owns" the bundle (could be empty).
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:attributeGroup>

    <xs:complexType name="eidType">
        <xs:attribute name="uri" type="eidTypeType" use="required"/>
    </xs:complexType>

    <xs:attributeGroup name="payloadAttributes">
        <xs:attribute name="filename" type="xs:string" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Payload file name on local dtn node.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="length" type="xs:unsignedInt" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Payload length.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="rcvd_length" type="xs:unsignedInt" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Actual length of payload available.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="base_offset" type="xs:unsignedInt" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
For bundle fragments, offset into the file (todo)
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:attributeGroup>

    <xs:complexType name="payloadType">
        <xs:attributeGroup ref="payloadAttributes"/>
    </xs:complexType>

    <xs:attributeGroup name="blockInfoAttributes">
        <xs:attribute name="owner_type" type="xs:unsignedByte" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Extracted from owner
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="length" type="xs:unsignedInt" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Length of block contents
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="contents" type="xs:base64Binary" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Block contents
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="data_length" type="xs:unsignedInt" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Length of the block data (w/o preamble)
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="data_offset" type="xs:unsignedInt" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Offset of first byte of the block data
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="complete" type="xs:boolean" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Whether or not this block is complete
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:attributeGroup>

    <xs:complexType name="recvBlocksType">
        <xs:sequence>
            <xs:element name="element" minOccurs="0" maxOccurs="unbounded">
                <xs:complexType>
                    <xs:attributeGroup ref="blockInfoAttributes"/>
                </xs:complexType>
            </xs:element>
        </xs:sequence>
        <xs:attribute name="size" type="xs:unsignedInt"/>
    </xs:complexType>

    <xs:complexType name="bundleType">
        <xs:sequence>
            <xs:element name="source" type="eidType"/>
            <xs:element name="dest" type="eidType"/>
            <xs:element name="custodian" type="eidType"/>
            <xs:element name="replyto" type="eidType"/>
            <xs:element name="prevhop" type="eidType"/>
            <xs:element name="payload" type="payloadType"/>
            <xs:element name="recv_blocks" type="recvBlocksType"/>
        </xs:sequence>
        <xs:attributeGroup ref="bundleAttributes"/>
    </xs:complexType>

    <!-- ForwardingInfo Type -->
    
    <xs:attributeGroup name="forwardingInfoAttributes">
        <xs:attribute name="state" type="forwardingStateType" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
State of the transmission.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="action" type="bundleForwardActionType" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
How the bundle should be forwarded.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="clayer" type="xs:string" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Convergence layer for the contact.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="nexthop" type="xs:string" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Convergence layer specific next hop string.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="timestamp_sec" type="xs:unsignedInt" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Timestamp of last state update (seconds).
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="timestamp_usec" type="xs:unsignedInt" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Timestamp of last state update (milliseconds).
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:attributeGroup>
    
    <xs:complexType name="forwardingInfoType">
        <xs:sequence>
            <xs:element name="element" minOccurs="0" maxOccurs="unbounded">
                <xs:complexType>
                    <xs:attributeGroup ref="forwardingInfoAttributes"/>
                </xs:complexType>
            </xs:element>
        </xs:sequence>
    </xs:complexType>
    
    <!-- Contact Type -->
    
    <xs:attributeGroup name="contactAttributes">
        <xs:attribute name="start_time_sec" type="xs:unsignedInt" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Time when the contact began (seconds).
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="start_time_usec" type="xs:unsignedInt" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Time when the contact began (milliseconds).
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="duration" type="xs:unsignedInt" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Contact duration (0 if unknown).
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="bps" type="xs:unsignedInt" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Approximate bandwidth available.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="latency" type="xs:unsignedInt" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Approximate latency.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:attributeGroup>
    
    <xs:complexType name="contactType">
        <xs:sequence>
            <xs:element name="link" type="linkType"/>
        </xs:sequence>
        <xs:attributeGroup ref="contactAttributes"/>
    </xs:complexType>
        
    <!-- Convergence Layer Info Type -->
    
    <xs:attributeGroup name="clInfoAttributes">
        <xs:attribute name="local_addr" type="xs:string">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Local address.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="remote_addr" type="xs:string">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Remote address.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="local_port" type="xs:unsignedShort">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Local port.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="remote_port" type="xs:unsignedShort">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Remote port.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="segment_ack_enabled" type="xs:boolean">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Use per segment acks.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="negative_ack_enabled" type="xs:boolean">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Use negative acks.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="keepalive_interval" type="xs:unsignedInt">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Seconds between keepalive packets.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="segment_length" type="xs:unsignedInt">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Maximum size of transmitted segments.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="busy_queue_depth" type="xs:unsignedInt">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Maximum number of bundles allowed in connection queue.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="reactive_frag_enabled" type="xs:boolean">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Whether reactive fragmentation is enabled.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="sendbuf_length" type="xs:unsignedInt">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Buffer size for sending data (bytes).
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="recvbuf_length" type="xs:unsignedInt">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Buffer size for receiving data (bytes).
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="data_timeout" type="xs:unsignedInt">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Milliseconds to wait for data arrival.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="rate" type="xs:unsignedByte">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Rate (in bps)
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="bucket_depth" type="xs:unsignedInt">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Token bucket depth (in bits)
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="channel" type="xs:unsignedInt">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Default channel.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:attributeGroup>
    
    <xs:complexType name="clInfoType">
        <xs:attributeGroup ref="clInfoAttributes"/>
    </xs:complexType>
    
    <!-- Link Type -->
    
    <xs:attributeGroup name="linkAttributes">
        <xs:attribute name="type" type="linkTypeType" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Type of the link.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="nexthop" type="xs:string" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Next hop address.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="name" type="xs:string" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Internal name of the link.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="state" type="linkStateType" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
State of the link.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="reliable" type="xs:boolean" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Whether the link is reliable.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="clayer" type="xs:string" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Name of the convergence layer.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="min_retry_interval" type="xs:unsignedInt" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Minimum amount to wait between attempts to re-open the link (seconds).
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="max_retry_interval" type="xs:unsignedInt" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Maximum amount to wait between attempts to re-open the link (seconds).
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="idle_close_time" type="xs:unsignedInt" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Seconds of idle time before the link is closed. Zero for always on links (i.e. they are never closed).
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:attributeGroup>
    
    <xs:complexType name="linkType">
        <xs:sequence>
            <xs:element name="clinfo" type="clInfoType" minOccurs="0"/>
            <xs:element name="remote_eid" type="eidType"/>
        </xs:sequence>
        <xs:attributeGroup ref="linkAttributes"/>
    </xs:complexType>
    
    <!-- Route Entry Type -->
    
    <xs:attributeGroup name="routeEntryAttributes">
        <xs:attribute name="route_priority" type="xs:integer" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Route priority.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="action" type="bundleForwardActionType" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Forwarding behavior.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="link" type="xs:string" use="required">
            <xs:annotation>
                <xs:documentation xml:lang="en">
Next hop link.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:attributeGroup>
    
    <xs:complexType name="routeEntryType">
        <xs:sequence>
            <xs:element name="dest_pattern" type="eidType"/>
            <xs:element name="source_pattern" type="eidType"/>
        </xs:sequence>
        <xs:attributeGroup ref="routeEntryAttributes"/>
    </xs:complexType>
    
    <!-- Custody Signal Type -->
    
    <xs:attributeGroup name="custodySignalAttributes">
        <xs:attribute name="admin_type" type="xs:unsignedByte" use="required"/>
        <xs:attribute name="admin_flags" type="xs:unsignedByte" use="required"/>
        <xs:attribute name="succeeded" type="xs:boolean" use="required"/>
        <xs:attribute name="reason" type="xs:unsignedByte" use="required"/>
        <xs:attribute name="orig_frag_offset" type="xs:unsignedLong" use="required"/>
        <xs:attribute name="orig_frag_length" type="xs:unsignedLong" use="required"/>
        <xs:attribute name="custody_signal_seconds" type="xs:unsignedInt" use="required"/>
        <xs:attribute name="custody_signal_seqno" type="xs:unsignedInt" use="required"/>
        <xs:attribute name="orig_creation_seconds" type="xs:unsignedInt" use="required"/>
        <xs:attribute name="orig_creation_seqno" type="xs:unsignedInt" use="required"/>
    </xs:attributeGroup>

    <!-- Registration Type -->

    <xs:attributeGroup name="registrationAttributes">
        <xs:attribute name="regid" type="xs:unsignedInt" use="required"/>
        <xs:attribute name="action" type="failureActionType" use="required"/>
        <xs:attribute name="script" type="xs:string" use="required"/>
        <xs:attribute name="creation_time" type="xs:unsignedInt" use="required"/>
        <xs:attribute name="expiration" type="xs:unsignedInt" use="required"/>
    </xs:attributeGroup>

    <xs:complexType name="registrationType">
        <xs:sequence>
            <xs:element name="endpoint" type="eidType"/>
        </xs:sequence>
        <xs:attributeGroup ref="registrationAttributes"/>
    </xs:complexType>

<!-- EVENTS -->

    <!-- Bundle Received Event -->

    <xs:element name="bundle_received_event">
        <xs:annotation>
            <xs:documentation xml:lang="en">
Signals a new bundle arrival.
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element name="bundle" type="bundleType"/>
            </xs:sequence>
            <xs:attribute name="source" type="eventSourceType" use="required"/>
            <xs:attribute name="bytes_received" type="xs:unsignedInt" use="required"/>
        </xs:complexType>
    </xs:element>

    <!-- Bundle Transmitted Event -->
    
    <xs:element name="bundle_transmitted_event">
        <xs:annotation>
            <xs:documentation xml:lang="en">
Signals a bundle or bundle fragment transmission.
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element name="bundle" type="bundleType"/>
                <xs:element name="contact" type="contactType"/>
            </xs:sequence>
            <xs:attribute name="bytes_sent" type="xs:unsignedInt" use="required"/>
            <xs:attribute name="reliably_sent" type="xs:unsignedInt" use="required"/>
        </xs:complexType>
    </xs:element>
    
    <!-- Bundle Transmit Failed Event -->

    <xs:element name="bundle_transmit_failed_event">
        <xs:annotation>
            <xs:documentation xml:lang="en">
Signals a failed transmission, which can occur if a link closes after a router has issued a transmission request but before the bundle is successfully sent.
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element name="bundle" type="bundleType"/>
                <xs:element name="contact" type="contactType"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>

    <!-- Bundle Delivery Event -->

    <xs:element name="bundle_delivery_event">
        <xs:annotation>
            <xs:documentation xml:lang="en">
Signals a new bundle arrival that is destined for an external router.  External routers access the bundle using the payload filename attribute.
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element name="bundle" type="bundleType"/>
            </xs:sequence>
            <xs:attribute name="source" type="eventSourceType" use="required"/>
        </xs:complexType>
    </xs:element>

    <!-- Bundle Expired Event -->
    
    <xs:element name="bundle_expired_event">
        <xs:annotation>
            <xs:documentation xml:lang="en">
Signals bundle expiration.
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element name="bundle" type="bundleType"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>

    <!-- Contact Up Event -->
    
    <xs:element name="contact_up_event">
        <xs:annotation>
            <xs:documentation xml:lang="en">
Signals a contact is up.
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element name="contact" type="contactType"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    
    <!-- Contact Down Event -->

    <xs:element name="contact_down_event">
        <xs:annotation>
            <xs:documentation xml:lang="en">
Signals a contact is down.
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element name="contact" type="contactType"/>
            </xs:sequence>
            <xs:attribute name="reason" type="contactReasonType" use="required"/>
        </xs:complexType>
    </xs:element>

    <!-- Link Created Event -->
    
    <xs:element name="link_created_event">
        <xs:annotation>
            <xs:documentation xml:lang="en">
Signals the creation of a new link.
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element name="link" type="linkType"/>
            </xs:sequence>
            <xs:attribute name="reason" type="userContactReasonType" use="required"/>
        </xs:complexType>
    </xs:element>
    
    <!-- Link Deleted Event -->

    <xs:element name="link_deleted_event">
        <xs:annotation>
            <xs:documentation xml:lang="en">
Signals a link deletion.
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element name="link" type="linkType"/>
            </xs:sequence>
            <xs:attribute name="reason" type="userContactReasonType" use="required"/>
        </xs:complexType>
    </xs:element>
    
    <!-- Link Available Event -->

    <xs:element name="link_available_event">
        <xs:annotation>
            <xs:documentation xml:lang="en">
Signals availability of a link.  ONDEMAND links still need to be opened (open_link_request) before they can be used.
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element name="link" type="linkType"/>
            </xs:sequence>
            <xs:attribute name="reason" type="contactReasonType" use="required"/>
        </xs:complexType>
    </xs:element>

    <!-- Link Unavailable Event -->
    
    <xs:element name="link_unavailable_event">
        <xs:annotation>
            <xs:documentation xml:lang="en">
Signals a link as unavailable.
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element name="link" type="linkType"/>
            </xs:sequence>
            <xs:attribute name="reason" type="contactReasonType" use="required"/>
        </xs:complexType>
    </xs:element>
    
    <!-- Route Add Event -->
    
    <xs:element name="route_add_event">
        <xs:annotation>
            <xs:documentation xml:lang="en">
Signals a new static route added from the DTN console.
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element name="route_entry" type="routeEntryType"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    
    <!-- Route Delete Event -->

    <xs:element name="route_delete_event">
        <xs:annotation>
            <xs:documentation xml:lang="en">
Signals a static route was deleted from the DTN console.
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element name="dest" type="eidType"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>

    <!-- Custody Signal Event -->
    
    <xs:element name="custody_signal_event">
        <xs:annotation>
            <xs:documentation xml:lang="en">
Signals a bundle custody transfer.
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element name="orig_source_eid" type="eidType"/>
            </xs:sequence>
            <xs:attributeGroup ref="custodySignalAttributes"/>
        </xs:complexType>
    </xs:element>
    
    <!-- Custody Timeout Event -->

    <xs:element name="custody_timeout_event">
        <xs:annotation>
            <xs:documentation xml:lang="en">
Signals a bundle custody transfer timeout.
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element name="bundle" type="bundleType"/>
                <xs:element name="link" type="linkType"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>

    <!-- Registration Added Event -->

    <xs:element name="registration_added_event">
        <xs:annotation>
            <xs:documentation xml:lang="en">
Signals a new application registration
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element name="registration" type="registrationType"/>
            </xs:sequence>
            <xs:attribute name="source" type="eventSourceType" use="required"/>
        </xs:complexType>
    </xs:element>

    <!-- Registration Removed Event -->

    <xs:element name="registration_removed_event">
        <xs:annotation>
            <xs:documentation xml:lang="en">
Signals a registration removal
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element name="registration" type="registrationType"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>

    <!-- Registration Expired Event -->

    <xs:element name="registration_expired_event">
        <xs:annotation>
            <xs:documentation xml:lang="en">
Signals a registration expiration
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:attribute name="regid" type="xs:unsignedInt" use="required"/>
        </xs:complexType>
    </xs:element>

<!-- REQUESTS --> 

    <!-- Open Link Request -->

    <xs:element name="open_link_request">
        <xs:annotation>
            <xs:documentation xml:lang="en">
Request that a link be opened.
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:attribute name="link" type="xs:string" use="required"/>
        </xs:complexType>
    </xs:element>
    
    <!-- Send Bundle Request -->

    <xs:element name="send_bundle_request">
        <xs:annotation>
            <xs:documentation xml:lang="en">
Request that a bundle with "bundleid" be sent on "link" with a particular "fwd_action". See bundleForwardActionType.
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:attribute name="bundleid" type="xs:unsignedInt" use="required"/>
            <xs:attribute name="link" type="xs:string" use="required"/>
            <xs:attribute name="fwd_action" type="bundleForwardActionType" use="required"/>
        </xs:complexType>
    </xs:element>

    <!-- Cancel Bundle Request -->
    
    <xs:element name="cancel_bundle_request">
        <xs:annotation>
            <xs:documentation xml:lang="en">
Request that a bundle transmission be cancelled.
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:attribute name="bundleid" type="xs:unsignedInt" use="required"/>
            <xs:attribute name="link" type="xs:string" use="required"/>
        </xs:complexType>
    </xs:element>

    <!-- Inject Bundle Request -->

    <xs:element name="inject_bundle_request">
        <xs:annotation>
            <xs:documentation xml:lang="en">
Request that a router generated bundle be sent.  Pay special attention to required and optional attributes.  This message type requires that the bundle payload be base64 encoded.
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:attribute name="source" type="xs:string" use="required"/>
            <xs:attribute name="dest" type="xs:string" use="required"/>
            <xs:attribute name="replyto" type="xs:string" use="optional"/>
            <xs:attribute name="custodian" type="xs:string" use="optional"/>
            <xs:attribute name="link" type="xs:string" use="required"/>
            <xs:attribute name="fwd_action" type="bundleForwardActionType" use="optional"/>
            <xs:attribute name="priority" type="bundlePriorityType" use="optional"/>
            <xs:attribute name="expiration" type="xs:unsignedInt" use="optional"/>
            <xs:attribute name="payload" type="xs:base64Binary" use="required"/>
        </xs:complexType>
    </xs:element>

<!-- QUERIES / REPORTS -->

    <!-- Links -->

    <xs:element name="link_query">
        <xs:annotation>
            <xs:documentation xml:lang="en">
Query for information on links.
            </xs:documentation>
        </xs:annotation>
    </xs:element>

    <xs:element name="link_report">
        <xs:annotation>
            <xs:documentation xml:lang="en">
Meta-information on links.
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element name="link" type="linkType" minOccurs="0" maxOccurs="unbounded"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>

    <!-- Contacts -->

    <xs:element name="contact_query">
        <xs:annotation>
            <xs:documentation xml:lang="en">
Query for information on contacts.
            </xs:documentation>
        </xs:annotation>
    </xs:element>

    <xs:element name="contact_report">
        <xs:annotation>
            <xs:documentation xml:lang="en">
Meta-information on contacts.
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element name="contact" type="contactType" minOccurs="0" maxOccurs="unbounded"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    
    <!-- Static Routes -->

    <xs:element name="route_query">
        <xs:annotation>
            <xs:documentation xml:lang="en">
Query for information on static routes.
            </xs:documentation>
        </xs:annotation>
    </xs:element>

    <xs:element name="route_report">
        <xs:annotation>
            <xs:documentation xml:lang="en">
Meta-information on static routes.
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element name="route_entry" type="routeEntryType" minOccurs="0" maxOccurs="unbounded"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    
    <!-- Bundles -->
    
    <xs:element name="bundle_query">
        <xs:annotation>
            <xs:documentation xml:lang="en">
Query for information on bundles (incl. custody bundles).
            </xs:documentation>
        </xs:annotation>
    </xs:element>

    <xs:element name="bundle_report">
        <xs:annotation>
            <xs:documentation xml:lang="en">
Meta-information on bundles.
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element name="bundle" type="bundleType"  minOccurs="0" maxOccurs="unbounded"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>


    <xs:element name="dtn">
    <xs:annotation>
        <xs:documentation xml:lang="en">
Carry two or more router message on a single packet.
        </xs:documentation>
    </xs:annotation>
    <xs:complexType>
        <xs:all>
            <xs:element ref="bundle_received_event" minOccurs="0"/>
            <xs:element ref="bundle_transmitted_event" minOccurs="0"/>
            <xs:element ref="bundle_transmit_failed_event" minOccurs="0"/>
            <xs:element ref="bundle_delivery_event" minOccurs="0"/>
            <xs:element ref="bundle_expired_event" minOccurs="0"/>
            <xs:element ref="contact_up_event" minOccurs="0"/>
            <xs:element ref="contact_down_event" minOccurs="0"/>
            <xs:element ref="link_created_event" minOccurs="0"/>
            <xs:element ref="link_deleted_event" minOccurs="0"/>
            <xs:element ref="link_available_event" minOccurs="0"/>
            <xs:element ref="link_unavailable_event" minOccurs="0"/>
            <xs:element ref="route_add_event" minOccurs="0"/>
            <xs:element ref="route_delete_event" minOccurs="0"/>
            <xs:element ref="custody_signal_event" minOccurs="0"/>
            <xs:element ref="custody_timeout_event" minOccurs="0"/>
            <xs:element ref="registration_added_event" minOccurs="0"/>
            <xs:element ref="registration_removed_event" minOccurs="0"/>
            <xs:element ref="registration_expired_event" minOccurs="0"/>
            <xs:element ref="open_link_request" minOccurs="0"/>
            <xs:element ref="send_bundle_request" minOccurs="0"/>
            <xs:element ref="cancel_bundle_request" minOccurs="0"/>
            <xs:element ref="inject_bundle_request" minOccurs="0"/>
            <xs:element ref="link_query" minOccurs="0"/>
            <xs:element ref="link_report" minOccurs="0"/>
            <xs:element ref="contact_query" minOccurs="0"/>
            <xs:element ref="contact_report" minOccurs="0"/>
            <xs:element ref="route_query" minOccurs="0"/>
            <xs:element ref="route_report" minOccurs="0"/>
            <xs:element ref="bundle_query" minOccurs="0"/>
            <xs:element ref="bundle_report" minOccurs="0"/>
        </xs:all>
        <xs:attribute name="eid" type="xs:string" use="optional"/>
        <xs:attribute name="hello_interval" type="xs:unsignedShort" use="optional"/>
        <xs:attribute name="alert" type="dtnStatusType" use="optional"/>
    </xs:complexType>
</xs:element>

</xs:schema>

