Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Doc] kind of an update {R, A, W, S} / a bit off topic #24

Open
cherepanovic opened this issue Mar 24, 2020 · 5 comments
Open

[Doc] kind of an update {R, A, W, S} / a bit off topic #24

cherepanovic opened this issue Mar 24, 2020 · 5 comments

Comments

@cherepanovic
Copy link

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!

@digizeph
Copy link
Contributor

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

@cherepanovic
Copy link
Author

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.

@digizeph
Copy link
Contributor

@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)

@cherepanovic
Copy link
Author

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

@digizeph
Copy link
Contributor

Note that it should be record_types, not record_type.
record_types accept an array, while record_type accepts a single string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants