<?xml version="1.0" encoding="UTF-8"?>
<xs:schema elementFormDefault="qualified"
           targetNamespace="urn:ietf:params:xml:ns:traceroute-1.0"
           xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:tr="urn:ietf:params:xml:ns:traceroute-1.0">
  <xs:simpleType name="string255">
    <xs:annotation>
      <xs:documentation>String restricted to 255
      characters.</xs:documentation>
    </xs:annotation>

    <xs:restriction base="xs:string">
      <xs:maxLength value="255"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="u8nonzero">
    <xs:annotation>
      <xs:documentation>unsignedByte with non zero
      value.</xs:documentation>
    </xs:annotation>

    <xs:restriction base="xs:unsignedByte">
      <xs:minInclusive value="1"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:complexType name="_roundTripTime">
    <xs:choice>
      <xs:element name="roundTripTime">
        <xs:simpleType>
          <xs:restriction base="xs:unsignedInt"/>
        </xs:simpleType>
      </xs:element>

      <xs:element name="roundTripTimeNotAvailable">
        <xs:complexType/>
      </xs:element>
    </xs:choice>
  </xs:complexType>

  <xs:complexType name="_inetAddressUnknown"/>

  <xs:simpleType name="_inetAddressIpv4">
    <xs:restriction base="xs:string">
      <xs:pattern value="(([1-9]?[0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5
]).){3}([1-9]?[0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="_inetAddressIpv6">
    <xs:restriction base="xs:string">
      <xs:pattern value="(([\dA-Fa-f]{1,4}:){7}[\dA-Fa-f]{1,4})(:([\d
]{1,3}.){3}[\d]{1,3})?"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="_inetAddressDns">
    <xs:restriction base="xs:string">
      <xs:maxLength value="256"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:complexType name="_inetAddressASNumber">
    <xs:annotation>
      <xs:documentation>Specifies the AS number of a hop in the
      traceroute path as a 32-bit number and indicates how the
      mapping from IP address to AS number was
      performed.</xs:documentation>
    </xs:annotation>

    <xs:sequence>
      <xs:element name="asNumber" type="xs:unsignedInt"/>

      <xs:element name="ipASNumberMappingType">
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:enumeration value="bgptables"/>

            <xs:enumeration value="routingregistries"/>

            <xs:enumeration value="nslookup"/>

            <xs:enumeration value="others"/>

            <xs:enumeration value="unknown"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="inetAddress">
    <xs:choice>
      <xs:element name="inetAddressUnknown"
                  type="tr:_inetAddressUnknown"/>

      <xs:element name="inetAddressIpv4" type="tr:_inetAddressIpv4"/>

      <xs:element name="inetAddressIpv6" type="tr:_inetAddressIpv6"/>

      <xs:element name="inetAddressASNumber"
                  type="tr:_inetAddressASNumber"/>

      <xs:element minOccurs="0" name="inetAddressDns"
                  type="tr:_inetAddressDns"/>
    </xs:choice>
  </xs:complexType>

  <xs:complexType name="inetAddressWithoutDns">
    <xs:sequence>
      <xs:choice>
        <xs:element name="inetAddressUnknown"
                    type="tr:_inetAddressUnknown"/>

        <xs:element name="inetAddressIpv4"
                    type="tr:_inetAddressIpv4"/>

        <xs:element name="inetAddressIpv6"
                    type="tr:_inetAddressIpv6"/>

        <xs:element name="inetAddressASNumber"
                    type="tr:_inetAddressASNumber"/>
      </xs:choice>
    </xs:sequence>
  </xs:complexType>

  <xs:simpleType name="operationResponseStatus">
    <xs:restriction base="xs:string">
      <xs:enumeration value="responseReceived"/>

      <xs:enumeration value="unknown"/>

      <xs:enumeration value="internalError"/>

      <xs:enumeration value="requestTimedOut"/>

      <xs:enumeration value="unknownDestinationAddress"/>

      <xs:enumeration value="noRouteToTarget"/>

      <xs:enumeration value="interfaceInactiveToTarget"/>

      <xs:enumeration value="arpFailure"/>

      <xs:enumeration value="maxConcurrentLimitReached"/>

      <xs:enumeration value="unableToResolveDnsName"/>

      <xs:enumeration value="invalidHostAddress"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:complexType name="_CtlType">
    <xs:choice>
      <xs:element name="TCP">
        <xs:complexType/>
      </xs:element>

      <xs:element name="UDP">
        <xs:complexType/>
      </xs:element>

      <xs:element name="ICMP">
        <xs:complexType/>
      </xs:element>

      <xs:any namespace="##other"/>
    </xs:choice>
  </xs:complexType>

  <xs:complexType name="_ProbeResults">
    <xs:sequence>
      <xs:element maxOccurs="255" name="hop">
        <xs:complexType>
          <xs:sequence>
            <xs:element maxOccurs="10" name="probe">
              <xs:complexType>
                <xs:sequence>
                  <xs:element name="HopAddr"
                              type="tr:inetAddressWithoutDns">
                    <xs:annotation>
                      <xs:documentation>Specifies the address of a
                      hop in the traceroute measurement path.  This
                      object is not allowed to be a DNS name.  The
                      address type can be determined by examining the
                      "inetAddress" type name and the corresponding
                      element value.</xs:documentation>
                    </xs:annotation>
                  </xs:element>

                  <xs:element minOccurs="0" name="HopName"
                              type="tr:_inetAddressDns">
                    <xs:annotation>
                      <xs:documentation>Specifies the DNS name of
                      the "HopAddr" if it is available.  If it is
                      not available, the element is
                      omitted.</xs:documentation>
                    </xs:annotation>
                  </xs:element>

                  <xs:element maxOccurs="255" minOccurs="0"
                              name="MPLSLabelStackEntry">
                    <xs:annotation>
                      <xs:documentation>Specifies entries of the
                      MPLS label stack of a probe observed when the
                      probe arrived at the hop that replied to the
                      probe.  This object contains one MPLS label stack
                      entry as a 32-bit value as it is observed on the
                      MPLS label stack.  Contained in this single
                      number are the MPLS label, the Exp field, the S
                      flag, and the MPLS TTL value as specified in
                      [RFC3032].  If more than one MPLS label stack
                      entry is reported, then multiple instances of
                      elements of this type are used.  They must be
                      ordered in the same order as on the label stack
                      with the top label stack entry being reported
                      first.</xs:documentation>
                    </xs:annotation>

                    <xs:simpleType>
                      <xs:restriction base="xs:unsignedInt">
                        <xs:maxInclusive value="4294967295"/>
                      </xs:restriction>
                    </xs:simpleType>
                  </xs:element>

                  <xs:element name="ProbeRoundTripTime"
                              type="tr:_roundTripTime">
                    <xs:annotation>
                      <xs:documentation>If this element contains the
                      element "roundTripTime", this specifies the
                      amount of time measured in milliseconds from
                      when a probe was sent to when its response was
                      received or when it timed out.  The value of
                      this element is reported as the truncation of
                      the number reported by the traceroute tool (the
                      output "&lt; 1 ms" is therefore encoded as 0 ms).
                      If it contains the element
                      "roundTripTimeNotAvailable", it means either
                      the probe was lost because of a timeout or it
                      was not possible to transmit a probe.
                      </xs:documentation>
                    </xs:annotation>
                  </xs:element>

                  <xs:element name="ResponseStatus"
                              type="tr:operationResponseStatus">
                    <xs:annotation>
                      <xs:documentation>Specifies the result of a
                      traceroute measurement made by the host for a
                      particular probe.</xs:documentation>
                    </xs:annotation>
                  </xs:element>

                  <xs:element name="Time" type="xs:dateTime">
                    <xs:annotation>
                      <xs:documentation>Specifies the timestamp for
                      the time the response to the probe was
                      received at the interface.</xs:documentation>
                    </xs:annotation>
                  </xs:element>
                </xs:sequence>
              </xs:complexType>
            </xs:element>

            <xs:element minOccurs="0" name="HopRawOutputData"
                        type="tr:string255">
              <xs:annotation>
                <xs:documentation>Specifies the raw output data
                returned by the traceroute measurement for a
                certain hop in a traceroute measurement path.  It is
                an implementation-dependent, printable string,
                expected to be useful for a human interpreting the
                traceroute results.</xs:documentation>
              </xs:annotation>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="_Metadata">
    <xs:annotation>
      <xs:documentation>Specifies the metadata for a traceroute
      operation -- the parameters requested if used in
      "RequestMetadata" or the actual parameters used if used in
      "MeasurementMetadata".</xs:documentation>
    </xs:annotation>

    <xs:sequence>
      <xs:element name="TestName" type="tr:string255">
        <xs:annotation>
          <xs:documentation>Specifies the name of a traceroute
          measurement.  This is not necessarily unique within any
          well-defined scope (e.g., a specific host, initiator of
          the traceroute measurement).</xs:documentation>
        </xs:annotation>
      </xs:element>

      <xs:element default="" name="OSName" type="tr:string255">
        <xs:annotation>
          <xs:documentation>Specifies the name of the operating
          system on which the traceroute measurement was launched.
          This element is ignored if used in the
          "RequestMetadata".</xs:documentation>
        </xs:annotation>
      </xs:element>

      <xs:element default="" name="OSVersion" type="tr:string255">
        <xs:annotation>
          <xs:documentation>Specifies the OS version on which the
          traceroute measurement was launched.  This element is
          ignored if used in the
          "RequestMetadata".</xs:documentation>
        </xs:annotation>
      </xs:element>

      <xs:element default="" name="ToolVersion" type="tr:string255">
        <xs:annotation>
          <xs:documentation>Specifies the version of the traceroute
          tool (requested to be used if in the "RequestMetadata"
          element, actually used if in the "MeasurementMetadata"
          element).</xs:documentation>
        </xs:annotation>
      </xs:element>

      <xs:element default="" name="ToolName" type="tr:string255">
        <xs:annotation>
          <xs:documentation>Specifies the name of the traceroute
          tool (requested to be used if in the "RequestMetadata"
          element, actually used if in the "MeasurementMetadata"
          element).</xs:documentation>
        </xs:annotation>
      </xs:element>

      <xs:element name="CtlTargetAddress" type="tr:inetAddress">
        <xs:annotation>
          <xs:documentation>In the "RequestMetadata" element, it
          specifies the host address requested to be used in the
          traceroute measurement.  In the "MeasurementMetadata"
          element, it specifies the host address used in the
          traceroute measurement.  The host address type can be
          determined by examining the "inetAddress" type name and
          the corresponding element value.</xs:documentation>
        </xs:annotation>
      </xs:element>

      <xs:element default="false" name="CtlBypassRouteTable"
                  type="xs:boolean">
        <xs:annotation>
          <xs:documentation>In the "RequestMetadata" element
          specifies if the optional bypassing of the route
          table was enabled or not.  In the "MeasurementMetadata"
          element, specifies if the optional bypassing of the route
          table was enabled or not.  If enabled, the normal routing
          tables will be bypassed and the probes will be sent
          directly to a host on an attached network.  If the host is
          not on a directly attached network, an error is returned.
          This option can be used to perform the traceroute
          measurement to a local host through an interface that has
          no route defined.  This object can be used when the
          setsockopt SOL_SOCKET SO_DONTROUTE option is supported and
          set (see the POSIX standard IEEE.1003-1G.1997).
          </xs:documentation>
        </xs:annotation>
      </xs:element>

      <xs:element default="0" name="CtlProbeDataSize">
        <xs:annotation>
          <xs:documentation>Specifies the size of the probes of a
          traceroute measurement in octets (requested if in the
          "RequestMetadata" element, actually used if in the
          "MeasurementMetadata" element).  If UDP datagrams are used
          as probes, then the value contained in this object is
          exact.  If another protocol is used to transmit probes
          (i.e., TCP or ICMP) for which the specified size is not
          appropriate, then the implementation can use whatever
          size (appropriate to the method) is closest to the
          specified size.  The maximum value for this object is
          computed by subtracting the smallest possible IP header
          size of 20 octets (IPv4 header with no options) and the
          UDP header size of 8 octets from the maximum IP packet
          size.  An IP packet has a maximum size of 65535 octets
          (excluding IPv6 jumbograms).</xs:documentation>
        </xs:annotation>

        <xs:simpleType>
          <xs:restriction base="xs:unsignedShort">
            <xs:maxInclusive value="65507"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>

      <xs:element default="3" name="CtlTimeOut">
        <xs:annotation>
          <xs:documentation>Specifies the timeout value, in
          seconds, for each probe of a traceroute measurement
          (requested if in the "RequestMetadata" element, actually
          used if in the "MeasurementMetadata"
          element).</xs:documentation>
        </xs:annotation>

        <xs:simpleType>
          <xs:restriction base="xs:unsignedByte">
            <xs:minInclusive value="1"/>

            <xs:maxInclusive value="60"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>

      <xs:element default="3" name="CtlProbesPerHop">
        <xs:annotation>
          <xs:documentation>Specifies the number of probes with the
          same time-to-live (TTL) value that are sent for each host
          (requested if in the "RequestMetadata" element, actually
          used if in the "MeasurementMetadata"
          element).</xs:documentation>
        </xs:annotation>

        <xs:simpleType>
          <xs:restriction base="xs:unsignedByte">
            <xs:minInclusive value="1"/>

            <xs:maxInclusive value="10"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <xs:element default="33434" name="CtlPort">
        <xs:annotation>
          <xs:documentation>Specifies the base port used by the
          traceroute measurement (requested if in the
          "RequestMetadata" element, actually used if in the
          "MeasurementMetadata" element).</xs:documentation>
        </xs:annotation>

        <xs:simpleType>
          <xs:restriction base="xs:unsignedShort">
            <xs:minInclusive value="1"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>

      <xs:element default="30" name="CtlMaxTtl" type="tr:u8nonzero">
        <xs:annotation>
          <xs:documentation>Specifies the maximum TTL value for the
          traceroute measurement (requested if in the
          "RequestMetadata" element, actually used if in the
          "MeasurementMetadata" element).</xs:documentation>
        </xs:annotation>
      </xs:element>

      <xs:element default="0" name="CtlDSField"
                  type="xs:unsignedByte">
        <xs:annotation>
          <xs:documentation>Specifies the value that was requested
          to be stored in the Differentiated Services (DS) field in
          the traceroute probe (if in the "RequestMetadata"
          element).  Specifies the value that was stored in the
          Differentiated Services (DS) field in the traceroute
          probe (if in the "MeasurementMetadata" element).  The DS
          field is defined as the Type of Service (TOS) octet in an
          IPv4 header or as the Traffic Class octet in an IPv6
          header (see Section 7 of [RFC8200]).  The value of this
          object must be a decimal integer in the range from 0 to
          255.  This option can be used to determine what effect an
          explicit DS field setting has on a traceroute measurement
          and its probes.  Not all values are legal or meaningful.
          Useful TOS octet values are probably 16 (low delay) and
          8 (high throughput).  Further references can be found in
          [RFC2474] for the definition of the Differentiated
          Services (DS) field and in [RFC1812] Section 5.3.2 for
          Type of Service (TOS).</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="CtlSourceAddress"
                  type="tr:inetAddressWithoutDns">
        <xs:annotation>
          <xs:documentation>Specifies the IP address (which has to
          be given as an IP number, not a hostname) as the source
          address in traceroute probes (requested if in the
          "RequestMetadata" element, actually used if in the
          "MeasurementMetadata" element).  On hosts with more than
          one IP address, this option can be used in the
          "RequestMetadata" element to force the source address to
          be something other than the primary IP address of the
          interface the probe is sent on; the value "unknown" means
          the default address will be used.  The address type can be
          determined by examining the "inetAddress" type name and the
          corresponding element value.</xs:documentation>
        </xs:annotation>
      </xs:element>

      <xs:element default="0" name="CtlIfIndex"
                  type="xs:unsignedInt">
        <xs:annotation>
          <xs:documentation>Specifies the interface index as
          defined in [RFC2863] that is requested to be used in the
          traceroute measurement for sending the traceroute probes
          (if in the "RequestMetadata" element).  A value of 0
          indicates that no specific interface is requested.
          Specifies the interface index actually used (if in the
          "MeasurementMetadata" element).</xs:documentation>
        </xs:annotation>
      </xs:element>

      <xs:element minOccurs="0" name="CtlMiscOptions"
                  type="tr:string255">
        <xs:annotation>
          <xs:documentation>Specifies implementation-dependent
          options (requested if in the "RequestMetadata" element,
          actually used if in the "MeasurementMetadata"
          element).</xs:documentation>
        </xs:annotation>
      </xs:element>

      <xs:element default="5" name="CtlMaxFailures"
                  type="xs:unsignedByte">
        <xs:annotation>
          <xs:documentation>Specifies the maximum number of
          consecutive timeouts allowed before terminating a
          traceroute measurement (requested if in the
          "RequestMetadata" element, actually used if in the
          "MeasurementMetadata" element).  A value of either 255
          (maximum hop count/possible TTL value) or 0 indicates
          that the function of terminating a remote traceroute
          measurement when a specific number of consecutive
          timeouts are detected was disabled.  This element is
          included to give full compatibility with [RFC4560].  No
          known implementation of traceroute currently supports
          it.</xs:documentation>
        </xs:annotation>
      </xs:element>

      <xs:element default="false" name="CtlDontFragment"
                  type="xs:boolean">
        <xs:annotation>
          <xs:documentation>Specifies if the don't fragment (DF)
          flag in the IP header for a probe was enabled or not (if
          in the "MeasurementMetadata" element).  If in the
          "RequestMetadata", it specifies if the flag was requested
          to be enabled or not.  Setting the DF flag can be used for
          performing a manual PATH MTU test.</xs:documentation>
        </xs:annotation>
      </xs:element>

      <xs:element default="1" name="CtlInitialTtl"
                  type="tr:u8nonzero">
        <xs:annotation>
          <xs:documentation>Specifies the initial TTL value for a
          traceroute measurement (requested if in the
          "RequestMetadata" element, actually used if in the
          "MeasurementMetadata" element).  Such TTL setting is
          intended to bypass the initial (often well-known) portion
          of a path.</xs:documentation>
        </xs:annotation>
      </xs:element>

      <xs:element maxOccurs="1" minOccurs="0" name="CtlDescr"
                  type="tr:string255">
        <xs:annotation>
          <xs:documentation>Provides a description of the traceroute
          measurement.</xs:documentation>
        </xs:annotation>
      </xs:element>

      <xs:element name="CtlType" type="tr:_CtlType">
        <xs:annotation>
          <xs:documentation>Specifies the implementation method
          used for the traceroute measurement (requested if in the
          "RequestMetadata" element, actually used if in the
          "MeasurementMetadata" element).  It specifies if the
          traceroute is using TCP, UDP, ICMP, or other types of
          probes.  It is possible to specify other types of probes
          by using an element specified in another schema with a
          different namespace.</xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="_Measurement">
    <xs:annotation>
      <xs:documentation>Contains the actual traceroute measurement
      results.</xs:documentation>
    </xs:annotation>

    <xs:sequence>
      <xs:element name="TestName" type="tr:string255">
        <xs:annotation>
          <xs:documentation>Specifies the name of a traceroute
          measurement.  This is not necessarily unique within any
          well-defined scope (e.g., a specific host, initiator of
          the traceroute measurement).</xs:documentation>
        </xs:annotation>
      </xs:element>

      <xs:element name="ResultsStartDateAndTime" type="xs:dateTime">
        <xs:annotation>
          <xs:documentation>Specifies the date and start time of
          the traceroute measurement.  This is the time when the
          first probe was seen at the sending
          interface.</xs:documentation>
        </xs:annotation>
      </xs:element>

      <xs:element name="ResultsIpTgtAddr"
                  type="tr:inetAddressWithoutDns">
        <xs:annotation>
          <xs:documentation>Specifies the IP address associated
          with a "CtlTargetAddress" value when the destination
          address is specified as a DNS name.  The value of this
          object should be "unknown" if a DNS name is not specified
          or if a specified DNS name fails to resolve.  The
          address type can be determined by examining the "inetAddress"
          type name and the corresponding element
          value.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="ProbeResults" type="tr:_ProbeResults"/>

      <xs:element name="ResultsEndDateAndTime" type="xs:dateTime">
        <xs:annotation>
          <xs:documentation>Specifies the date and end time of the
          traceroute measurement.  It is either the time when the
          response to the last probe of the traceroute measurement
          was received or the time when the last probe of the
          traceroute measurement was sent plus the relative timeout
          (in case of a missing response).</xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
  </xs:complexType>

  <xs:element name="traceRoute">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" name="RequestMetadata"
                    type="tr:_Metadata"/>

        <xs:element maxOccurs="2147483647" minOccurs="0"
                    name="Measurement">
          <xs:complexType>
            <xs:sequence>
              <xs:element minOccurs="0" name="MeasurementMetadata"
                          type="tr:_Metadata"/>

              <xs:element maxOccurs="2147483647" minOccurs="0"
                          name="MeasurementResult"
                          type="tr:_Measurement"/>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>