ASN Neighbours

class prsw.stat.asn_neighbours.ASNNeighbours(RIPEstat, resource, lod: Optional[int] = 0, query_time: Optional[datetime] = None)

This data call shows information on the network neighbours for a given ASN. This includes statistical information, the list of observed ASN neighbours and, depending on the level of detail, the ASN paths that this data is based on.

Reference: https://stat.ripe.net/docs/data_api#asn-neighbours

Property

Description

query_time

Reflects the time the data is valid for.

neighbours

Contains all neighbours that were seen at the defined point in time (see neighbours())

neighbor_counts

Shows total counts for the neighbours (see neighbour_counts())

resource

Defines the resource used for the query.

lod

Level of detail.

latest_time

Latest time in dataset.

earliest_time

Earliest time in dataset.

import prsw

ripe = prsw.RIPEstat()
neighbours = ripe.asn_neighbours(3333, lod=1)

neighbours.query_time
# datetime.datetime(2021, 3, 31, 8, 0)

for neighbour in neighbours:
    neighbour
    # ASNNeighbour(
    #   asn: 1853,
    #   position: "left",
    #   details: {
    #       "peer_count": { "v4": 288, "v6": 0 },
    #       "path_count": 81,
    #       "paths": [
    #           ASNNeighbourPath(
    #               path: (1103, 20965, 1853, 1205)
    #               locations: {
    #                   "v4": [
    #                       {
    #                           "location": "rrc03",
    #                           "peer_count": 3
    #                       },
    #                   ],
    #                   "v6": [
    #                       {
    #                           "location": "rrc03",
    #                           "peer_count": 3
    #                       },
    #                   ]
    #               }
    #           )
    #       ]
    #   }
    # )

neighbours.neighbour_counts
# ASNNeighbourCount(left=1, right=0, uncertain=1, unique=2)

neighbours.resource
# 3333

neighbours.lod
# 1

neighbours.latest_time
# datetime.datetime(2021, 3, 31, 8, 0)

neighbours.earliest_time
# datetime.datetime(2021, 3, 31, 8, 0)
__init__(RIPEstat, resource, lod: Optional[int] = 0, query_time: Optional[datetime] = None)

Initialize and request ASN Neighbors.

Parameters
  • resource – The ASN for this query.

  • lod – 0 or 1, defines how main details are returned in the result

  • query_time – Query time for the query. Default is the latest available data point.

import prsw
from datetime import datetime

timestamp = datetime.now()

neighbours = ripe.asn_neighbours(3333, lod=1, query_time=timestamp)
__iter__()

Provide a way to iterate over neighbours.

import prsw

ripe = prsw.RIPEstat()
neighbours = ripe.asn_neighbours(3333)

for neighbour in neighbours:
    print(neighbour.asn, neighbour.position)
__len__()

Get the number of neighbours in the response.

import prsw

ripe = prsw.RIPEstat()
neighbours = ripe.asn_neighbours(3333)

print(len(neighbours))
property earliest_time

Earliest datetime data is available for.

property latest_time

Latest datetime data is available for.

property lod

Level of detail. See neighbors()

property neighbour_counts

Shows total counts for the neighbours.

The total number of “left”, “right” and “unique” neighbours found. Neighbours that have been seen as left neighbours, but only as direct peers of one of our route collectors (RIS collectors), are flagged “uncertain” because our own peering with this ASN could artifically include it as neigbour. ASNs that have been seen as a left neighbour and not as a direct peer with RIS are not flagged as “uncertain”.

import prsw

ripe = prsw.RIPEstat()
neighbours = ripe.asn_neighbours(3333)

neighbours.neighbour_counts
# ASNNeighbourCount(left=1, right=0,uncertain=1,unique=2)
property neighbours

Contains all neighbours that were seen at the defined point in time.

Details are only returned if the level of detail (“lod”) is 1:

Attribute

Description

peer_count

Summarizes the number of peers seeing this neighbour/position combination.

path_count

States in how many paths this neighbour/position combination has been seen.

paths

Contains details about the paths, including the RRC location where it has been seen and by how many (full-table) peers.

property query_time

The datetime of the query.

property resource

The resource, autonomous system number, used for the query.