Active Members Fi8sVrs Posted March 9, 2014 Active Members Report Posted March 9, 2014 mrtparse is a module to read and analyze the MRT format data.The MRT format data can be used to export routing protocol messages, state changes, and routing information base contents, and is standardized in RFC6396.Programs like Quagga / Zebra, BIRD, OpenBGPD and PyRT can dump the MRT fotmat data.urrently supported typesTable_Dump(12), Table_Dump_V2(13), BGP4MP(16), BGP4MP_ET(17)RequirementsPython2?Python3Downloadgit command$ git clone https://github.com/YoshiyukiYamauchi/mrtparse.gitBrowserAccess https://github.com/YoshiyukiYamauchi/mrtparse.git, and click 'Download ZIP'.Install$ cd <Clone Directory>$ python setup.py installrunning installrunning buildrunning build_pyrunning install_libcopying build/lib/mrtparse.py -> /Library/Python/2.7/site-packagesbyte-compiling /Library/Python/2.7/site-packages/mrtparse.py to mrtparse.pycrunning install_egg_infoWriting /Library/Python/2.7/site-packages/mrtparse-0.8-py2.7.egg-infoUsagefrom mrtparse import *orimport mrtparseProgrammingFirst, import the module.from mrtparse import *And pass a MRT format data as a filepath string or file object to a class Reader().It is also supported gzip and bzip2 format.You can retrieve each entry from the returned object using a loop and then process it.d = Reader(f)for m in d: <statements>ExampleThese scripts are included in 'examples' directory.print_all.pyDescriptionIt displays the contents of a MRT format file.Usageprint_all.py <path to the file>Result---------------------------------------------------------------MRT Header Timestamp: 1392828028(2014-02-20 01:40:28) Type: 16(BGP4MP) Subtype: 5(BGP4MP_STATE_CHANGE_AS4) Length: 24BGP4MP_STATE_CHANGE_AS4 Peer AS Number: 100 Local AS Number: 64512 Interface Index: 0 Address Family: 1(AFI_IPv4) Peer IP Address: 192.168.1.21 Local IP Address: 192.168.1.100 Old State: 5(OpenConfirm) New State: 6(Established)---------------------------------------------------------------MRT Header Timestamp: 1392828028(2014-02-20 01:40:28) Type: 16(BGP4MP) Subtype: 4(BGP4MP_MESSAGE_AS4) ...exabgp_conf.pyDescriptionIt converts MRT format to 'exabgp' config format and displays it.Usageexabgp_conf.py <path to the file>Resultneighbor 192.168.1.100 { router-id 192.168.0.20; local-address 192.168.1.20; local-as 65000; peer-as 64512; graceful-restart; static { route 1.0.0.0/24 origin IGP as-path [29049 15169 ] next-hop 192.168.1.254; route 1.0.4.0/24 origin IGP as-path [29049 6939 7545 56203 ] next-hop 192.168.1.254; route 1.0.5.0/24 origin IGP as-path [29049 6939 7545 56203 ] next-hop 192.168.1.254; route 1.0.6.0/24 origin IGP as-path [29049 20485 4826 38803 56203 ] community [20485:31701] next-hop 192.168.1.254; route 1.0.7.0/24 origin IGP as-path [29049 20485 4826 38803 56203 ] community [20485:31701] next-hop 192.168.1.254; route 1.0.20.0/23 origin IGP as-path [29049 2914 2519 ] community [2914:410 2914:1403 2914:2401 2914:3400] next-hop 192.168.1.254; route 1.0.22.0/23 origin IGP as-path [29049 2914 2519 ] community [2914:410 2914:1403 2914:2401 2914:3400] next-hop 192.168.1.254; route 1.0.24.0/23 origin IGP as-path [29049 2914 2519 ] community [2914:410 2914:1403 2914:2401 2914:3400] next-hop 192.168.1.254; route 1.0.26.0/23 origin IGP as-path [29049 2914 2519 ] community [2914:410 2914:1403 2914:2401 2914:3400] next-hop 192.168.1.254; route 1.0.28.0/22 origin IGP as-path [29049 2914 2519 ] community [2914:410 2914:1403 2914:2401 2914:3400] next-hop 192.168.1.254; ... }}AuthorsTetsumune KISO t2mune@gmail.comYoshiyuki YAMAUCHI info@greenhippo.co.jpNobuhiro ITOU js333123@gmail.com Source Quote