Coder Social home page Coder Social logo

Python3 Error in mrtparse about mrtparse HOT 9 OPEN

t2mune avatar t2mune commented on June 3, 2024
Python3 Error in mrtparse

from mrtparse.

Comments (9)

t2mune avatar t2mune commented on June 3, 2024

Hi,

Thank you for using mrtparse.
It looks like an error when you send ctrl+c.

Using " -G" option, all entries of MRT data are temporarily stored in python dictionary to group prefixes with the same path attributes. After all MRT entries are parsed, output finally begins. Therefore, it takes a long time to output(not hang). If you want to accelerate, I recommend using pypy instead of python3.

In my environment, the result follows:

(mrtparse-python3) [root@host-12 ~]# python3 --version
Python 3.6.8
(mrtparse-python3) [root@host-12 ~]# time python3 mrt2exabgp.py -G -P latest-bview.gz > fullbgptable-python3.py                                                                                                     

real    231m14.710s
user    230m5.261s
sys     0m24.153s

(mrtparse-pypy) [root@host-12 ~]# pypy --version
Python 2.7.18 (a29ef73f9b32, Nov 09 2020, 18:42:06)
[PyPy 7.3.3 with GCC 7.3.1 20180303 (Red Hat 7.3.1-5)]

(mrtparse-pypy) [root@host-12 ~]# time pypy mrt2exabgp.py -G -P latest-bview.gz > fullbgptable-pypy.py

real    100m0.023s
user    94m19.296s
sys     4m59.085s

from mrtparse.

mahmutaydin1 avatar mahmutaydin1 commented on June 3, 2024

from mrtparse.

t2mune avatar t2mune commented on June 3, 2024

It's a typo, sorry.
I fixed it, so could you try again?
3dfd9a4

from mrtparse.

mahmutaydin1 avatar mahmutaydin1 commented on June 3, 2024

from mrtparse.

t2mune avatar t2mune commented on June 3, 2024

You need "-P" option.
Without "-P" option, It goes into an infinite loop and never exits.

(...snip)
if params['flags'] & FLAG_T['API_PROG']:
    print_api_prog_footer()
else:
    while True:
        time.sleep(1)
(...snip)

from mrtparse.

mahmutaydin1 avatar mahmutaydin1 commented on June 3, 2024

Dear,

I have added -P paramater and script is completed. BUt please this knowledge should be added to help or documentation.
Also, when I run again same command, there is no LOCAL AS, PEERAS and NEIGHBOUR in output. When I add -P parameter, it outputs in API format of announce subnets. As below:

Thank you,

#!/usr/bin/env python
import sys
import time
msgs = [
'announce attributes origin IGP as-path [139589 49752 137490 39533 267397 ] community [0:39533 39533:49666 64700:26162] large-community [57463:0:8966 57463:0:44901 57463:0:52863 57463:0:201133 57463:0:263009 57463:0:263080 57463:0:267242 57463:0:267613 139589:0:0] next-hop 45.14.68.30 nlri 45.233.206.0/23 45.233.205.0/24 45.233.207.0/24 45.233.204.0/24',
'announce attributes origin IGP as-path [34549 5511 1299 9498 714 ] community [5511:521 5511:666 5511:710 5511:5511 34549:100 34549:5511] next-hop 80.77.16.114 nlri 17.76.120.0/24',
'announce attributes origin IGP as-path [34800 58057 6939 3356 3549 27951 ] community [34800:65010 58057:65010] next-hop 2001:7f8:e7:c232::63fe nlri 2801:172:2::/48',
'announce attributes origin IGP as-path [139589 6939 201808 ] med 0 community [0:714 0:2906 0:6939 0:12876 0:12989 0:13335 0:15133 0:15169 0:16265 0:16276 0:16509 0:20940 0:22822 0:32590 0:48641 0:49029] large-community [139589:0:139589] next-hop 2a07:59c6:ee00:9589::1 nlri 2a01:a5e0::/32 2a0c:8c80::/32',
'announce attributes origin IGP as-path [139589 49752 34549 3356 13904 13904 13904 13904 13904 13904 13904 13904 13904 ] community [3356:3 3356:22 3356:100 3356:123 3356:575 3356:2026 34549:100 34549:3356] large-community [139589:0:0] next-hop 45.14.68.30 nlri 216.238.254.0/23',
'announce attributes origin IGP as-path [34549 3257 2914 61317 ] community [3257:8115 3257:30342 3257:50001 3257:53300 3257:53301 34549:100 34549:3257] next-hop 80.77.16.114 nlri
...

from mrtparse.

t2mune avatar t2mune commented on June 3, 2024

Thank you for your comment.
I will update a documentation for using ExaBGP with mrtparse.

When using ExaBGP API, you have to wirte ExaBGP config by yourself, and need to specify a generated script using mrt2exabgp in a process section. ExaBGP documentation might be helpful.

group TEST {
    neighbor 10.90.90.2 {
        router-id 10.90.90.1;
        local-address 10.90.90.1;
        local-as 100;
        peer-as 200;
        graceful-restart;

        process TEST {
            run GENERATED_SCRIPT.py;
        }
    }
}

from mrtparse.

mahmutaydin1 avatar mahmutaydin1 commented on June 3, 2024

Dear,
Thank you. I have taken progress with your help. But, now another problem exists.

this is my exabgp config file:

 process test  {
            run    fullroutebgp2.py;
            encoder json;
        }

    neighbor 10.90.90.2 {
        router-id 10.90.90.1;
        local-address 10.90.90.1;
        local-as 100;
        peer-as 200;

       api {
        processes  [test];
    }
    }

When I run command:[root@centos exabgp-git]# ./sbin/exabgp etc/exabgp/fullroutebgp.conf

my error is below:

[root@centos exabgp-git]# ./sbin/exabgp etc/exabgp/fullroutebgp.conf
welcome       Thank you for using ExaBGP
advice        environment file missing
advice        generate it using "exabgp env --fi > /root/exabgp-git/etc/exabgp/exabgp.env"
cli           could not find the named pipes (exabgp.in and exabgp.out) required for the cli
cli           we scanned the following folders (the number is your PID):
cli control    - /run/exabgp/
cli control    - /run/0/
cli control    - /run/
cli control    - /var/run/exabgp/
cli control    - /var/run/0/
cli control    - /var/run/
cli control    - /root/exabgp-git/run/exabgp/
cli control    - /root/exabgp-git/run/0/
cli control    - /root/exabgp-git/run/
cli control    - /root/exabgp-git/var/run/exabgp/
cli control    - /root/exabgp-git/var/run/0/
cli control    - /root/exabgp-git/var/run/
cli control   please make them in one of the folder with the following commands:
cli control   > mkfifo /root/exabgp-git/run/exabgp.{in,out}
cli control   > chmod 600 /root/exabgp-git/run/exabgp.{in,out}
configuration performing reload of exabgp master-d2c7c074134ca6015bf112076604110439bfcf4c
reactor       loaded new configuration successfully
/usr/bin/env: ‘python\r’: No such file or directory
/usr/bin/env: ‘python\r’: No such file or directory
/usr/bin/env: ‘python\r’: No such file or directory
/usr/bin/env: ‘python\r’: No such file or directory
/usr/bin/env: ‘python\r’: No such file or directory
outgoing-1    --------------------------------------------------------------------
outgoing-1    the connection can not carry the following family/families
outgoing-1     - peer is not configured for ipv4/multicast
outgoing-1     - peer is not configured for bgp-ls/bgp-ls
outgoing-1     - peer is not configured for ipv6/flow-vpn
outgoing-1     - peer is not configured for bgp-ls/bgp-ls-vpn
outgoing-1     - peer is not configured for ipv6/multicast
outgoing-1     - peer is not configured for l2vpn/evpn
outgoing-1     - peer is not configured for ipv4/rtc
outgoing-1     - peer is not configured for ipv4/nlri-mpls
outgoing-1     - peer is not configured for ipv6/unicast
outgoing-1     - peer is not configured for ipv4/flow
outgoing-1     - peer is not configured for ipv6/mpls-vpn
outgoing-1     - peer is not configured for ipv4/flow-vpn
outgoing-1     - peer is not configured for l2vpn/vpls
outgoing-1     - peer is not configured for ipv6/nlri-mpls
outgoing-1     - peer is not configured for ipv4/mpls-vpn
outgoing-1     - peer is not configured for ipv6/flow
outgoing-1    therefore no routes of this kind can be announced on the connection
outgoing-1    --------------------------------------------------------------------
process       Too many death for test (5) terminating program
reactor       Problem when sending message(s) to helper program, stopping
reactor       performing shutdown
: No such file or directory
outgoing-1    outgoing-1 10.90.90.1-10.90.90.2, closing connection

fullroutebgp2.py is afile that was converted via script of latest-update.gz (not latest-bview.gz)

from mrtparse.

t2mune avatar t2mune commented on June 3, 2024

Hi,

Sorry for my late reply.

The problem is shown as below:

/usr/bin/env: ‘python\r’: No such file or directory
/usr/bin/env: ‘python\r’: No such file or directory
/usr/bin/env: ‘python\r’: No such file or directory
/usr/bin/env: ‘python\r’: No such file or directory
/usr/bin/env: ‘python\r’: No such file or directory

So, you need to edit the first line of "fullroutebgp2.py" as follows:

#!/usr/bin/python3

In my envirtonment, the result is as follows:

welcome         Thank you for using ExaBGP                                                                                                                                                                          advice          environment file missing                                                                                                                                                                            advice          generate it using "exabgp env --fi > /home/t2mune/exabgp/etc/exabgp/exabgp.env"
cli             could not find the named pipes (exabgp.in and exabgp.out) required for the cli                                                                                                                      cli             we scanned the following folders (the number is your PID):                                                                                                                                          
cli control      - /run/exabgp/                                                                                                                                                                                     cli control      - /run/10001/                                                                                                                                                                                      
cli control      - /run/                                                                                                                                                                                            cli control      - /var/run/exabgp/                                                                                                                                                                                 
cli control      - /var/run/10001/                                                                                                                                                                                  cli control      - /var/run/ 
cli control      - /home/t2mune/exabgp/run/exabgp/                                                                                                                                                                  cli control      - /home/t2mune/exabgp/run/10001/
cli control      - /home/t2mune/exabgp/run/                                                               
cli control      - /home/t2mune/exabgp/var/run/exabgp/                                         
cli control      - /home/t2mune/exabgp/var/run/10001/                                                                                                                                                               cli control      - /home/t2mune/exabgp/var/run/                                                           
cli control     please make them in one of the folder with the following commands:                                                                                                                                  cli control     > mkfifo /home/t2mune/exabgp/run/exabgp.{in,out} 
cli control     > chmod 600 /home/t2mune/exabgp/run/exabgp.{in,out}                                                                                                                                                 cli control     > chown 10001:10001 /home/t2mune/exabgp/run/exabgp.{in,out}
configuration   performing reload of exabgp master-a07a3a833c57549812465ade446ee2decf31b109                                                                                                                         reactor         loaded new configuration successfully    
api             route added to neighbor 10.90.90.2 local-ip 10.90.90.1 local-as 100 peer-as 200 router-id 10.90.90.1 family-allowed in-open : 103.140.227.0/24 next-hop 5.178.95.254 origin igp as-path [ 59919 6939 9299 23930 ] med 0 aggregator ( 23930:121.127.1.235 ) community 59919:65002
api             route added to neighbor 10.90.90.2 local-ip 10.90.90.1 local-as 100 peer-as 200 router-id 10.90.90.1 family-allowed in-open : 95.175.64.0/22 next-hop 5.178.95.254 origin igp as-path [ 59919 41327 2914 1299 3225 ] aggregator ( 3225:10.20.100.28 ) community [ 2914:420 2914:1004 2914:2000 2914:3000 17152:1 41327:2914 41327:4500 41327:10001 41327:13000 41327:13001 ]
api             route added to neighbor 10.90.90.2 local-ip 10.90.90.1 local-as 100 peer-as 200 router-id 10.90.90.1 family-allowed in-open : 95.175.84.0/22 next-hop 5.178.95.254 origin igp as-path [ 59919 41327 2914 1299 3225 ] aggregator ( 3225:10.20.100.28 ) community [ 2914:420 2914:1004 2914:2000 2914:3000 17152:1 41327:2914 41327:4500 41327:10001 41327:13000 41327:13001 ]
api             route added to neighbor 10.90.90.2 local-ip 10.90.90.1 local-as 100 peer-as 200 router-id 10.90.90.1 family-allowed in-open : 95.175.68.0/22 next-hop 5.178.95.254 origin igp as-path [ 59919 41327 2914 1299 3225 ] aggregator ( 3225:10.20.100.28 ) community [ 2914:420 2914:1004 2914:2000 2914:3000 17152:1 41327:2914 41327:4500 41327:10001 41327:13000 41327:13001 ]
api             route added to neighbor 10.90.90.2 local-ip 10.90.90.1 local-as 100 peer-as 200 router-id 10.90.90.1 family-allowed in-open : 95.175.80.0/22 next-hop 5.178.95.254 origin igp as-path [ 59919 41327 2914 1299 3225 ] aggregator ( 3225:10.20.100.28 ) community [ 2914:420 2914:1004 2914:2000 2914:3000 17152:1 41327:2914 41327:4500 41327:10001 41327:13000 41327:13001 ]
api             route added to neighbor 10.90.90.2 local-ip 10.90.90.1 local-as 100 peer-as 200 router-id 10.90.90.1 family-allowed in-open : 95.175.92.0/22 next-hop 5.178.95.254 origin igp as-path [ 59919 41327 2914 1299 3225 ] aggregator ( 3225:10.20.100.28 ) community [ 2914:420 2914:1004 2914:2000 2914:3000 17152:1 41327:2914 41327:4500 41327:10001 41327:13000 41327:13001 ]
api             route added to neighbor 10.90.90.2 local-ip 10.90.90.1 local-as 100 peer-as 200 router-id 10.90.90.1 family-allowed in-open : 95.175.88.0/22 next-hop 5.178.95.254 origin igp as-path [ 59919 41327 2914 1299 3225 ] aggregator ( 3225:10.20.100.28 ) community [ 2914:420 2914:1004 2914:2000 2914:3000 17152:1 41327:2914 41327:4500 41327:10001 41327:13000 41327:13001 ]
api             route added to neighbor 10.90.90.2 local-ip 10.90.90.1 local-as 100 peer-as 200 router-id 10.90.90.1 family-allowed in-open : 162.217.44.0/22 next-hop 23.139.160.31 origin igp as-path [ 26073 6939 3356 13614 ] community [ 6939:7025 6939:8840 6939:9001 ]
(...snip)

from mrtparse.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.