Looking Glass
- class prsw.stat.looking_glass.LookingGlass(RIPEstat, resource: ip_network)
This data call returns information commonly coming from a Looking Glass. The data is based on a data feed from the RIPE NCC’s network of BGP route collectors (RIS, see https://www.ripe.net/data-tools/stats/ris for more information). The data processing usually happens with a small delay and can be considered near real-time. The output is structured by collector node (RRC) accompanied by the location and the BGP peers which provide the routing information.
Reference: https://stat.ripe.net/docs/data_api#looking-glass
Property
Description
latest_timeProvides datetime on how recent this data is.
query_timeProvides datetime on when the query was performed.
peersList containing all peers from every collector node (RRC)
rrcsDict containing each collector node (RRC)
import prsw ripe = prsw.RIPEstat() result = ripe.looking_glass('140.78.0.0/16') for collector in result: # RRC(rrc='RRC00', location='Amsterdam, Netherlands', peers=[...]) print(collector.rrc) print(collector.location) for peer in collector.peers: # Peer( # asn_origin=1205, # as_path=(34854, 6939, 1853, 1853, 1205), # community=['34854:1009'], # last_updated=datetime.datetime(2021, 4, 13, 22, 48, 26), # prefix=IPv4Network('140.78.0.0/16'), # peer=IPv4Address('2.56.11.1'), origin='IGP', # next_hop=IPv4Address('2.56.11.1'), # latest_time=datetime.datetime(2021, 4, 14, 12, 54, 37) # ) print( peer.asn_origin, peer.as_path, peer.community, peer.last_update, peer.prefix, peer.peer, peer.origin, peer.next_hop, peer.latest_time )
- __getitem__(rrc)
Return the collector node specified.
import prsw ripe = prsw.RIPEstat() rrcs = ripe.looking_glass('140.78.0.0/16') rrc = rrcs['RRC00'] print(rrc.location) for peer in rrc.peers: print(peer.as_path)
- __init__(RIPEstat, resource: ip_network)
Initialize and request prefix from the Looking Glass.
- Parameters
resource – A prefix or an IP address. Prefixes need to match exactly a prefix found in the routing data. If given as IP address, the data call will try to find the encompassing prefix for the IP address.
- __iter__()
Provide a way to iterate over each collector node (RRC).
import prsw ripe = prsw.RIPEstat() rrcs = ripe.looking_glass('140.78.0.0/16') for collector in rrcs: print(collector.rrc, collector.location, collector.peers)
- __len__()
Get the number of collector nodes (RRC)
import prsw ripe = prsw.RIPEstat() rrcs = ripe.looking_glass('140.78.0.0/16') print(len(rrcs))
- property latest_time
Provides datetime on how recent the data is.
- property peers
Shortcut to a list containing all peers from every collector node (RRC).
Each peer entry is a Peer named tuple with the following properties:
Property
Description
asn_originThe originating ASN for the matched prefix (int)
as_pathThe path of ASNs seen for this route (tuple)
communityBGP community information for this route (list)
last_updatedThe timestamp when this route was last changed (datetime)
prefixThe matched prefix (IPv4Network or IPv6Network) based on the query input resource
peerIPv4Address or IPv6Address of the peer interface
nexthopThe next hop (IPv4Address or IPv6Address) from the perspective of this peer
latest_timeThe datetime when this route was last confirmed
import prsw ripe = prsw.RIPEstat() rrcs = ripe.looking_glass('140.78.0.0/16') for peer in rrcs.peers: print(peer.as_path)
- property query_time
Provides datetime on when the query was performed.
- property rrcs
Dict containing one entry for each collector node (RRC) that provides data for the given input resource. Each RRC entry holds the location and the ID of the RRC together with the list of BGP peer information.
Each value is an RRC named tuple with the following properties:
Property
Description
rrcID of the RRC (str), “RRC00”
locationLocation of the RRC (str), “Amsterdam, Netherlands”
peersList of BGP peer information, see peers