100% de satisfacción garantizada Inmediatamente disponible después del pago Tanto en línea como en PDF No estas atado a nada
logo-home
bgpm.py Georgia Institute Of Technology CS 6250 7,59 €   Añadir al carrito

Otro

bgpm.py Georgia Institute Of Technology CS 6250

 131 vistas  4 veces vendidas
  • Grado
  • Institución

#!/usr/bin/env python from collections import defaultdict import datetime, glob from matplotlib import pyplot as plt from ical_distribution import ECDF import pybgpstream """Code file for CS 6250 BGPM Project Edit this file according to docstrings. Do not change the existing function name o...

[Mostrar más]

Vista previa 2 fuera de 7  páginas

  • 29 de marzo de 2023
  • 7
  • 2022/2023
  • Otro
  • Desconocido
avatar-seller
#!/usr/bin/env python

from collections import defaultdict
import datetime, glob
from matplotlib import pyplot as plt
from statsmodels.distributions.empirical_distribution import ECDF

import pybgpstream

"""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.

"""

# 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]
"""
files = sorted(cache_files)
unique_prefixes = []
for file in files:
stream = pybgpstream.BGPStream(data_interface="singlefile")
stream.set_data_interface_option("singlefile","rib-file",file)
prefixes = []
for elem in stream:
prefixes.append(elem.fields['prefix'])
prefixes = list(set(prefixes))
unique_prefixes.append(len(prefixes))
return unique_prefixes


# 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.


This study source was downloaded by 100000850872992 from CourseHero.com on 03-29-2023 08:29:41 GMT -05:00


https://www.coursehero.com/file/142684040/bgpmpy/

, For example: [2, 5]
"""
files = sorted(cache_files)
unique_ases = []
for file in files:
stream = pybgpstream.BGPStream(data_interface="singlefile")
stream.set_data_interface_option("singlefile","rib-file",file)
ases = []
for elem in stream:
for _as in elem.fields['as-path'].split(' '):
ases.append(_as)
ases = list(set(ases))
unique_ases.append(len(ases))
return unique_ases


# 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.
"""
files = sorted(cache_files)
ds = {}
final_list = []
ases = []
for file in files:
stream = pybgpstream.BGPStream(data_interface="singlefile")
stream.set_data_interface_option("singlefile","rib-file",file)
time = datetime.datetime.fromtimestamp(int(file.split('.')[-3]))
for elem in stream:
origin = elem.fields['as-path'].split(' ')[-1]
if origin in ds.keys():
if time in ds[origin].keys():
ds[origin][time].append(elem.fields['prefix'])
else:
ds[origin][time] = [elem.fields['prefix']]
else:
ds[origin] = {}
ds[origin][time] = [elem.fields['prefix']]
for _as in ds.keys():
dates = sorted(list(ds[_as].keys()))
if len(dates) < 2:
final_list.append((_as,0.0))
continue
else:
unique_prefixes_start = list(set(ds[_as][dates[0]]))
unique_prefixes_end = list(set(ds[_as][dates[-1]]))
calc = ((len(unique_prefixes_end) -
len(unique_prefixes_start))/len(unique_prefixes_start)) * 100


This study source was downloaded by 100000850872992 from CourseHero.com on 03-29-2023 08:29:41 GMT -05:00


https://www.coursehero.com/file/142684040/bgpmpy/

Los beneficios de comprar resúmenes en Stuvia estan en línea:

Garantiza la calidad de los comentarios

Garantiza la calidad de los comentarios

Compradores de Stuvia evaluaron más de 700.000 resúmenes. Así estas seguro que compras los mejores documentos!

Compra fácil y rápido

Compra fácil y rápido

Puedes pagar rápidamente y en una vez con iDeal, tarjeta de crédito o con tu crédito de Stuvia. Sin tener que hacerte miembro.

Enfócate en lo más importante

Enfócate en lo más importante

Tus compañeros escriben los resúmenes. Por eso tienes la seguridad que tienes un resumen actual y confiable. Así llegas a la conclusión rapidamente!

Preguntas frecuentes

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

100% de satisfacción garantizada: ¿Cómo funciona?

Nuestra garantía de satisfacción le asegura que siempre encontrará un documento de estudio a tu medida. Tu rellenas un formulario y nuestro equipo de atención al cliente se encarga del resto.

Who am I buying this summary from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller ExamsConnoisseur. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy this summary for 7,59 €. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

45,681 summaries were sold in the last 30 days

Founded in 2010, the go-to place to buy summaries for 14 years now

Empieza a vender
7,59 €  4x  vendido
  • (0)
  Añadir