components:
  schemas:
    PeerRTT:
      description: PeerRTT
      properties:
        asn:
          description: ASN of the peer.
          example: 42000001
          type: integer
        ip:
          description: The IP address of the peer.
          example: fd42:1000::1
          type: string
        loss:
          description: Packet loss as `rx` / `tx` ratio.
          example: 0.0
          maximum: 1.0
          minimum: 0.0
          type: float
        neighbor:
          description: Name of the peer.
          example: Fast Packets LLC.
          type: string
        rtt_avg_ms:
          description: Average RTT in milliseconds.
          example: 0.523
          type: float
        rtt_max_ms:
          description: Maximum RTT in milliseconds.
          example: 0.61
          type: float
        rtt_mdev_ms:
          description: Standard deviation in milliseconds.
          example: 0.012
          type: float
        rtt_min_ms:
          description: Minimum RTT in milliseconds.
          example: 0.493
          type: float
        rx:
          description: The number of *packets received*.
          example: 10
          minimum: 0
          type: integer
        serial:
          description: 'The `serial` is an incrementing counter. You can use it

            to poll for changes.'
          example: 42834781723
          minimum: 0
          type: integer
        time_ms:
          description: The total duration of the measurement.
          example: 16000
          minimum: 0
          type: integer
        timestamp:
          description: The date and time when the RTT statistic was measured.
          format: date-time
          type: string
        tx:
          description: The number of *packets transmitted*.
          example: 10
          minimum: 0
          type: integer
      required:
      - serial
      - timestamp
      - neighbor
      - asn
      - ip
      - time_ms
      - tx
      - rx
      - loss
      - rtt_min_ms
      - rtt_max_ms
      - rtt_avg_ms
      - rtt_mdev_ms
      title: PeerRTT
      type: object
info:
  contact:
    url: https://ix-api.net
  description: 'This extension to the IX-API provides opeations to query

    and subscribe to `RTT` information about peers consuming a `NetworkService`.'
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0.html
  title: 'IX-API: RTT Statistics'
  version: 1.0.0
openapi: 3.0.0
paths:
  /network-services/{id}/rtts:
    get:
      description: 'Get **rtt statistics** from neighbors consuming this network

        service. You can filter by `asn`, peer `ip` or `neighbor`.


        If the `NetworkService` does not support RTT statistics,

        a `404` error response will be returned.


        ### Receiving Updates

        To poll for updates, you can provide a `serial` to the

        `after` parameter. All of the above filters can be applied

        here and allow for receiving updates for a specific peer.


        If no `serial` is provided the latest RTT statistics are returned.


        ### Event Streaming

        This endpoint supports streaming updates using

        [**Server Sent Events**](https://html.spec.whatwg.org/multipage/server-sent-events.html#server-sent-events).


        To subscribe to events, negotiate the response content

        using the HTTP header: `Accept: text/event-stream`.


        Filteres are applied as above.'
      operationId: network_services_statistics_rtt_read
      parameters:
      - description: Show only results from this `asn`.
        in: query
        name: asn
        required: false
        schema:
          type: string
      - description: Show only results from this `neighbor`.
        in: query
        name: neighbor
        required: false
        schema:
          type: string
      - description: Show only results from this neighbor `ip` address.
        in: query
        name: ip
        required: false
        schema:
          type: string
      - description: Show only results with a `serial` greater than `after`.
        in: query
        name: after
        required: false
        schema:
          type: string
      produces:
      - text/event-stream
      - application/json
      responses:
        '200':
          content:
            application/json:
              schema:
                items:
                  $ref: '#/components/schemas/PeerRTT'
                type: array
            text/event-stream:
              examples:
                streamExample:
                  value: '

                    data: {"serial": 421233, "asn": 42000001, "ip": "fd42:1000::1",
                    ...}

                    id: 421233


                    data: {"serial": 421234, "asn": 42000002, "ip": "fd42:1000::1",
                    ...}

                    id: 421234


                    '
              schema:
                description: '

                  A stream of Server Sent Events is returned.

                  The measurement result is encoded as JSON.


                  ### Example:


                  ```

                  data: {"serial": 42834781723, "timestamp": "2019-08-24T14:15:22Z",
                  "asn": 42000001, ...}

                  id: 42834781723


                  data: {"serial": 42834781724, "timestamp": "2019-08-24T14:16:22Z",
                  "asn": 42000002, ...}

                  id: 42834781724


                  ...

                  ```


                  For more information on how to use server sent events, see:

                  https://html.spec.whatwg.org/multipage/server-sent-events.html#server-sent-events


                  '
                type: string
          description: 'List of: PeerRTT'
        '404':
          content:
            application/json:
              schema:
                $ref: ix-api-schema-2.4.1.json#/components/schemas/ProblemResponse
          description: NotFound
      tags:
      - network-services
