CAIDA / pybgpstream

Python bindings for BGPStream
https://bgpstream.caida.org
BSD 2-Clause "Simplified" License
28 stars 22 forks source link

Output in BGP-dump format #46

Open Tf-arch opened 2 years ago

Tf-arch commented 2 years ago

I am getting data from the below code. Could you please tell me how can I get data from pybgpstream in exactly bgpdump format

import pybgpstream stream = pybgpstream.BGPStream( from_time="2017-07-07 00:00:00", until_time="2017-07-07 00:10:00 UTC", collectors=[ "rrc12"], record_type="updates", filter="community *:3400" )

for dump in stream:

record fields can be accessed directly from elem

# e.g. elem.time
# or via elem.record
# e.g. elem.record.time
print( dump)

output update|A|1499386168.000000|ris|rrc12|None|None|2914|80.81.192.46|122.162.240.0/20|80.81.192.46|2914 9498 24560 24560|65500:7018 65500:3257 2914:410 65500:3356 65500:6762 2914:2406 2914:3400 65500:174 65500:3549 65500:7473 65500:3491 2914:1405 65500:1299|None|None

I wanna get output like BGP4MP|1635316051|A|80.33.33.99|14061|185.25.9.1/32|14061 31500 199624 49058|IGP|80.81.193.66|0|0|333:777 6666:888|NAG||

ACodingfreak commented 1 year ago

I have similar issue as the current output format is missing the key BGP details unlike BGP-dump format.

alistairking commented 1 year ago

Which key BGP details are you missing?

If you're using bgpreader you can use the -m option to get bgpdump-style output (https://bgpstream.caida.org/docs/tools/bgpreader) If you want this format from pybgpstream then a PR would be gladly welcomed.

ACodingfreak commented 1 year ago

Hi @alistairking

Yes I am looking for this option in pybgpstream.

ACodingfreak commented 1 year ago

@alistairking

I never tried creating python api for C library. Any reference pointers or examples which can be helpful in creating the PR where I can extend the elem to carry more information.