def main(rib, target_prefs): # Create a new bgpstream instance and a reusable bgprecord instance stream = BGPStream() rec = BGPRecord() with open('./data/stream_{0}'.format(start), 'wb') as bw: for ptmp in target_prefs: stream.add_filter('prefix', ptmp) # Consider RIPE RRC 10 only stream.add_filter('record-type', 'updates') stream.add_filter('record-type', 'ribs') #stream.add_filter('collector', 'rrc04') stream.add_filter('project', 'ris') stream.add_filter('project', 'routeviews') stream.add_interval_filter(start-60*60*8, start) stream.add_rib_period_filter(10000000000000) # Start the stream stream.start() while stream.get_next_record(rec): # Print the record information only if it is not a valid record if rec.status != "valid": continue #if rec.time < start: elem = rec.get_next_elem() while elem: if elem.type == 'A' or elem.type == 'R': rib.add_to_rib(rec.collector, elem.peer_address, elem.fields['prefix'], elem.time, elem.fields['as-path']) elem = rec.get_next_elem() #else: rib.flush() print 'Successful termination; Start time: {0}'.format(start)
stream = BGPStream() rec = BGPRecord() # Consider multi hop collectors stream.add_filter('collector', 'rrc00') stream.add_filter('collector', 'rrc00') stream.add_filter('collector', 'route-views2') # all data with community attributes stream.add_filter('community', '*:*') # Consider RIBs dumps only stream.add_filter('record-type', 'ribs') # One rib per day stream.add_rib_period_filter(3600 * 24) # Consider this time interval: May 2016 stream.add_interval_filter(1462060800, 1464739200) # Start the stream stream.start() sys.stderr.write("Reading BGP Data\n") # Get next record while (stream.get_next_record(rec)): elem = rec.get_next_elem() while (elem): # only consider RIBs entries and Announcement messages if elem.type in ["R", "A"]:
bh_db = BlackHoleDb() # export LD_LIBRARY_PATH="/usr/local/lib" # Create a new bgpstream instance and a reusable bgprecord instance stream = BGPStream() rec = BGPRecord() # Consider RRC12 stream.add_filter('collector','rrc12') # Consider RIBs dumps only stream.add_filter('record-type','ribs') # One rib per day stream.add_rib_period_filter(3600*24) # Consider this time interval: May 2016 stream.add_interval_filter(1462060800,1464739200) # Start the stream stream.start() sys.stderr.write("Reading BGP Data\n") # Get next record while(stream.get_next_record(rec)): elem = rec.get_next_elem() while(elem): # only consider RIBs entries and Announcement messages if elem.type in ["R", "A"]:
from _pybgpstream import BGPStream, BGPRecord, BGPElem import radix import sys import calendar import time stream = BGPStream() rec = BGPRecord() start_interval= 1401623715 ##stream.add_filter('project', 'ris') stream.add_filter('collector', 'route-views2') #stream.add_filter('collector', 'rrc04') stream.add_filter('record-type', 'ribs') stream.add_filter('record-type', 'updates') stream.add_interval_filter(start_interval,1406894115 ) stream.add_rib_period_filter(172800) stream.set_data_interface('broker') #stream.set_data_interface_option('broker', 'db-host', 'loki-ge') #stream.set_data_interface_option('broker', 'db-port', '3306') #stream.set_data_interface_option('broker', 'db-user', 'bgpstream') print "start bgpstream" stream.start() # signature {collector}{ip}{asn} -> id info_id = {} # id peer ASN (for right analysis) id_ASN = {} # id signature (for charthouse) id_sig = {} # last id assigned
# Timestep between Frame nodes delta_time = 300 # Initialize BGPStream with relevant filters stream = BGPStream() rec = BGPRecord() mode = "" if len(sys.argv) == 1: collectors = ['rrc01'] for collector in collectors: stream.add_filter('collector', collector) stream.add_filter('record-type', 'ribs') stream.add_filter('record-type', 'updates') stream.add_interval_filter(1203850000,1203920000) stream.add_rib_period_filter(70000) stream.add_filter('prefix', '208.65.153.0/22') mode = 'ripe' elif len(sys.argv) == 2: dirname = sys.argv[1] filelist = os.listdir(dirname) filelist.sort() filelist = [dirname + os.sep + f for f in filelist] stream.set_data_interface('singlefile') stream.set_data_interface_option('singlefile','rib-file', filelist[0]) # stream.add_filter('prefix', '8.8.0.0/16') filelist = filelist[1:] collectors = ['singlefile_ds'] mode = 'file' stream.start()