Exemple #1
0
    def _get_list_of_data(self, probe_id):
        list_of_data = []

        with open(self.filename) as results:
            for this_result in results:
                parsed_result = PingResult.get(this_result)
                this_probe_id = parsed_result.probe_id

                # if a probe_id was specified, we only care about that probe's measurements
                if probe_id != None and this_probe_id != probe_id:
                    continue
                
                packets_sent = parsed_result.packets_sent
                packets_received = parsed_result.packets_received
                packets_lost = packets_sent - packets_received
                try:
                    loss_rate = packets_lost/packets_sent
                except ZeroDivisionError:
                    loss_rate = None

                data_row = []
                for this_attr in self.list_of_headings_and_attr[0]:
                    data_row.append(self._get_attr(this_attr, parsed_result))

                list_of_data.append(data_row)

        return list_of_data
Exemple #2
0
    def _get_list_of_data(self, probe_id):
        list_of_data = []

        with open(self.filename) as results:
            for this_result in results:
                parsed_result = PingResult.get(this_result)
                this_probe_id = parsed_result.probe_id

                # if a probe_id was specified, we only care about that probe's measurements
                if probe_id != None and this_probe_id != probe_id:
                    continue
                
                packets_sent = parsed_result.packets_sent
                packets_received = parsed_result.packets_received
                packets_lost = packets_sent - packets_received
                try:
                    loss_rate = packets_lost/packets_sent
                except ZeroDivisionError:
                    loss_rate = None

                data_row = []
                for this_attr in self.list_of_headings_and_attr[0]:
                    data_row.append(self._get_attr(this_attr, parsed_result))

                list_of_data.append(data_row)

        return list_of_data
Exemple #3
0
 def print_nicely(self, limit):
     with open(self.filename) as results:
         i = 0
         for result in results.readlines():
             if limit is not None:
                 if i >= limit:
                     return
             parsed_result = PingResult.get(result)
             print("PROBE ID:        "+str(parsed_result.probe_id))
             print("firmware:        "+str(parsed_result.firmware))
             print("origin:            "+parsed_result.origin)
             print("measurement type:    "+self.measurement_type)
             self._print_ping_nicely(parsed_result)
             print("\n")
             i +=1
Exemple #4
0
 def print_nicely(self, limit):
     with open(self.filename) as results:
         i = 0
         for result in results.readlines():
             if limit is not None:
                 if i >= limit:
                     return
             parsed_result = PingResult.get(result)
             print("PROBE ID:        "+str(parsed_result.probe_id))
             print("firmware:        "+str(parsed_result.firmware))
             print("origin:            "+parsed_result.origin)
             print("measurement type:    "+self.measurement_type)
             self._print_ping_nicely(parsed_result)
             print("\n")
             i +=1
Exemple #5
0
def get_packet_loss(probe, start_time, end_time):

    kwargs = {
        "msm_id": "1001",  ## K Root Servers
        "start": start_time - 300,
        "stop": end_time + 300,
        "probe_ids": [probe]
    }

    is_success, results = AtlasResultsRequest(**kwargs).create()

    count = 0
    if is_success:
        for result in results:
            ping_data = PingResult(result)
            if ping_data.packets_sent != ping_data.packets_received:
                count += 1
    packet_loss = False
    if count > 0:
        packet_loss = True

    return packet_loss
Exemple #6
0
#Read measurement from a URL
#https://github.com/RIPE-NCC/ripe.atlas.sagan
#Documentation can be found on https://ripe-atlas-sagan.readthedocs.io/en/latest/

import requests
from ripe.atlas.sagan import PingResult

source = "https://atlas.ripe.net//api/v2/measurements/20335797/results/?format=json"
response = requests.get(source).json()

for result in response:
    parsed_result = PingResult.get(result)
    print(parsed_result.rtt_min)
Exemple #7
0
    "msm_id": measurement,   # my south africa measurement 
    #"start": datetime(2015, 05, 19), # just testing date filtering
    #"stop": datetime(2015, 05, 20),  # just testing date filtering
    #"probe_ids": [1000070]  # the first probe in the measurement

    }
    is_success, results = AtlasLatestRequest(**kwargs).create()
    if is_success:                                          # if measuremnt was a success
        measurements_dict[measurement] = {}                 # initialis this measurements dictionary
        probes = {}                                         # initialise all the probes dictionaries within this measurement
        i = 0
        for result in results:                              # get all the results of the pings from landmarks to target
            print("Reading measurement data, ",measurement, "from probes ", i," one moment")
            # print("this is result ",i, "of measuremnt ", measurement)

            result = PingResult(result) 
                             
            p = result.probe_id
            probe = Probe(id=p)                                                     # Get all the properties of the individual probe used in this individual measurement 
            a = probe.geometry['coordinates']                                       # Create a list of Coordinates
            probe_x = a[0]                                                          # Probes X coordinate
            probe_y = a[1]                                                          # Probes Y coordinate
            probe_id = result.probe_id                                              # get the probe_id for this individual measurement
            measurements_dict[measurement][probe_id] = {}                           # initialise this probes dictioonary
            measurements_dict[measurement][probe_id]['rtt'] = result.rtt_min        # get the minimum RTT measurement of the 3 pings from this probe
            measurements_dict[measurement][probe_id]['ip_addr'] = result.origin     # get the Ip address of this probe
            measurements_dict[measurement][probe_id]['x_coord'] = probe_x           # get the x coordinate of this probe
            measurements_dict[measurement][probe_id]['y_coord'] = probe_y           # get the y coordinate of this probe
            measurements_dict[measurement][probe_id]['asn'] = probe.asn_v4