Closed SichangHe closed 2 months ago
ASes here include both the ones with aut-num in IRRs and the ones in CAIDA's AS relationship DB.
In [1]: from scripts.csv_files import * In [2]: import pandas as pd In [3]: df = pd.read_csv(as_neighbors_vs_rules.path) In [5]: df Out[5]: aut_num provider peer customer import export 0 42568 2 0 0 4 4 1 13418 1 0 0 -1 -1 2 263933 1 0 0 0 0 3 137210 -1 -1 -1 0 0 4 198931 1 0 0 2 2 ... ... ... ... ... ... ... 95843 268949 2 0 0 -1 -1 95844 263583 2 28 4 2 2 95845 399367 2 0 0 -1 -1 95846 43651 2 0 0 2 2 95847 48570 2 0 0 1 1 [95848 rows x 6 columns] In [6]: n_all = len(df) In [7]: an_dedup = set(df["aut_num"]) In [9]: len(an_dedup) Out[9]: 95848 In [11]: df["rules"] = df["import"] + df["export"] In [12]: df_w_rule = df[df["rules"] > 0] In [13]: df_w_rule Out[13]: aut_num provider peer customer import export rules 0 42568 2 0 0 4 4 8 4 198931 1 0 0 2 2 4 5 55700 -1 -1 -1 4 4 8 9 21785 2 0 0 2 2 4 10 39872 2 0 0 2 2 4 ... ... ... ... ... ... ... ... 95841 207145 2 0 0 2 2 4 95842 60841 1 0 0 6 6 12 95844 263583 2 28 4 2 2 4 95846 43651 2 0 0 2 2 4 95847 48570 2 0 0 1 1 2 [51002 rows x 7 columns] In [14]: n_w_rule = len(df_w_rule) In [15]: n_w_rule Out[15]: 51002 In [17]: percentage = f"{n_w_rule * 100.0 / n_all:.1f}" In [18]: percentage Out[18]: '53.2'
ASes here include both the ones with aut-num in IRRs and the ones in CAIDA's AS relationship DB.