Open cherepanovic opened 4 years ago
Hey @cherepanovic , thanks for using BGPStream!
Can you take a look at this documentation on data encoding in bgpstream and see if it clarifies things for you? https://bgpstream.caida.org/docs/encoding
Is there any possibility to request the rips and updates from a collector at the same time?
It seems that I have to make two requests for the same time in order to get these two types of updates.
@cherepanovic
try record_types=["updates","ribs"],
when initializing BGPStream
object. The following example should print out both ribs and updates.
import pybgpstream
# create and configure the stream
stream = pybgpstream.BGPStream(
from_time="2017-07-07 00:00:00", until_time="2017-07-07 00:10:00 UTC",
collectors=["route-views.sg", "route-views.eqix"],
record_types=["updates","ribs"],
filter="peer 11666 and prefix more 210.180.0.0/16"
)
# add any additional (or dynamic) filters
# e.g. from peer AS 11666 regarding the more-specifics of 210.180.0.0/16:
# stream.parse_filter_string("peer 11666 and prefix more 210.180.0.0/16")
# or using the old filter interface:
# stream.add_filter("peer-asn", "11666")
# stream.add_filter("prefix-more", "210.180.0.0/16")
# read elems
for elem in stream:
# record fields can be accessed directly from elem
# e.g. elem.time
# or via elem.record
# e.g. elem.record.time
print(elem)
# alternatively, records and elems can be read in nested loops:
for rec in stream.records():
# do something with rec (e.g., choose to continue based on timestamp)
print("Received %s record at time %d from collector %s" % (rec.type, rec.time, rec.collector))
for elem in rec:
# do something with rec and/or elem
print(" Elem Type: %s" % elem.type)
I have already tried it and got a failure
File "reader.py", line 71, in __init__
record_type= ["updates","ribs"],
File "/root/anaconda3/lib/python3.7/site-packages/pybgpstream/pybgpstream.py", line 62, in __init__
self._maybe_add_filter("record-type", record_type, record_types)
File "/root/anaconda3/lib/python3.7/site-packages/pybgpstream/pybgpstream.py", line 93, in _maybe_add_filter
self.stream.add_filter(fname, f)
TypeError: argument 2 must be str, not list
Note that it should be record_types
, not record_type
.
record_types
accept an array, while record_type
accepts a single string.
Hello bgpstream community,
my request is a bit off topic. Could you provide a description of the BGP updates (and format description of a message). The official documentation from ietf.org is too textuall (too much text, no overview).
Thank a lot!