#!/usr/bin/env python Code file for CS 6250 BGPM Project Edit this file according to docstrings. Do not...
Question:
#!/usr/bin/env python """Code file for CS 6250 BGPM Project Edit this file according to docstrings. Do not change the existing function name or arguments in any way. """ import pybgpstream from collections import defaultdict from statsmodels.distributions.empirical_distribution import ECDF import matplotlib.pyplot as plt # Task 1 Part A. def calculateUniqueIPAddresses(cache_files): """Retrieve the number of unique IP prefixes from input BGP data. Args: cache_files: A list of absolute file paths. File paths may not be in order but will end with a timestamp that can be used for sorting. For example: ["/rib_files_final/1357027200.120.cache", "/rib_files_final/1483257600.120.cache"] Returns: A list containing the number of unique IP prefixes for each input cache file. For example: [2, 5] """ cache_files = [] pybgpstream.BGPStream(data_interface="singlefile") stream = pybgpstream.BGPStream( collector="rrc06", record_type="ribs", from_time="1357027200", until_time="1609488000" ) stream.set_data_interface_option("singlefile", "rib-file", "Filepath") # prefix_origin = defaultdict(set) #for rec in stream.records(): # for elem in rec: # pfx = elem.fields["prefix"] # if len(pfx) > 0: # origin = pfx[-1] # prefix_origin[pfx].add(origin) ip_prefixes = set() for elem in stream: # Get the IP prefix pfx = elem.fields["prefix"] ip_prefixes.add(pfx) return [] # Task 1 Part B. def calculateUniqueAses(cache_files): """Retrieve the number of unique ASes from input BGP data. Args: cache_files: A list of absolute file paths. File paths may not be in order but will end with a timestamp that can be used for sorting. For example: ["/rib_files_final/1357027200.120.cache", "/rib_files_final/1483257600.120.cache"] Returns: A list containing the number of the number of unique AS for each input file. For example: [2, 5] """ return [] # Task 1 Part C. def examinePrefixes(cache_files): """ Args: cache_files: A list of absolute file paths. File paths may not be in order but will end with a timestamp that can be used for sorting. For example: ["/rib_files_final/1357027200.120.cache", "/rib_files_final/1483257600.120.cache"] Returns: A list of the top 10 origin ASes according to percentage increase of the advertised prefixes. See assignment description for details. """ return []
Task 1 - Part A
Using the data from the cache files you will plot a line graph that shows the number of total unique IP prefixes over time. Towards this goal, complete the function calculateUniqueIPAddresses in the bgpm.py file. Then modify bgpm.py to include matplotlib and write a function that uses output from calculateUniqueIPAddresses to create the line graph. This function can have a name of your choice. In your graph:
1. The X-axis should represent time (e.g., January 2013, January 2014 and so on)
2. The Y-axis should represent the number of unique prefixes within the specific time period (e.g. January 2013, January 2014 and so on)
Task 1 - Part B
Using the data from the cache files plot a line graph that shows the number of total unique ASes over time. Towards this goal, complete the function calculateUniqueAses in the bgpm.py file. Then write a function that uses output from calculateUniqueAses to create the line graph. This function can have a name of your choice. In your graph:
The X-axis should represent time (e.g., January 2013, January 2014 and so on).
The Y-axis should represent the number of unique ASes within the specific time period
(e.g. January 2013, January 2014 and so on).
Task 1 - Part C
For each origin AS, examine the growth of the total unique prefixes they advertise over time. To achieve this:
Identify the first and the last snapshot where the AS appeared in the dataset.
Calculate the percentage increase of the advertised prefixes, using the first and the last
snapshot
Report the top 10 origin ASes according to this metric. If you identify more than 10 ASes,
with the same growth randomly pick 10 from your set.
Towards this goal, complete the function examinePrefixes in the bgpm.py file so that it performs the processing and reporting of the ASes.
Cache file links: https://github.com/DannyChoo92/cachefiles