how many memory one BGP prefix holds

m4rtinm4rtin Member Posts: 170
How to find out how many memory one BGP prefix takes? I found out the total amount of memory for BGP with "sh ip bgp summary | i total" command and then added up all the "State/PfxRcd" columns in "sh ip bgp summary" output and divided memory usage with number of prefixes. So in my case one prefix takes 163 bytes of memory. Am I doing it right? Last but not least, is there memory consumption of one BGP prefix different on various router and L3 switch platforms and IOS versions?

Comments

  • networker050184networker050184 Mod Posts: 11,962 Mod
    Around 100 bytes sounds about right. Things can differ slightly depending on things like communities attached etc as far as I know. You will probably end up with memory calculated slightly different by platform/IOS version but I doubt it wuld be off by any significant number without hitting some sort of memory leak.
    An expert is a man who has made all the mistakes which can be made.
  • m4rtinm4rtin Member Posts: 170
    Around 100 bytes sounds about right. Things can differ slightly depending on things like communities attached etc as far as I know. You will probably end up with memory calculated slightly different by platform/IOS version but I doubt it wuld be off by any significant number without hitting some sort of memory leak.

    You are correct:

    Without community:
    r2#sh ip bg 192.168.1.0
    BGP routing table entry for 192.168.1.0/24, version 33
    Paths: (1 available, best #1, table default)
      Not advertised to any peer
      65000
        10.10.10.1 from 10.10.10.1 (192.168.1.1)
          Origin IGP, metric 0, localpref 100, valid, external, best
    r2#sh ip bgp summary | i bytes of memory
    1 network entries using 136 bytes of memory
    1 path entries using 56 bytes of memory
    1/1 BGP path/bestpath attribute entries using 128 bytes of memory
    1 BGP AS-PATH entries using 24 bytes of memory
    0 BGP route-map cache entries using 0 bytes of memory
    0 BGP filter-list cache entries using 0 bytes of memory
    BGP using 344 total bytes of memory
    r2#
    



    With communities:
    r2#sh ip bgp 192.168.1.0                
    BGP routing table entry for 192.168.1.0/24, version 34
    Paths: (1 available, best #1, table default)
      Not advertised to any peer
      65000
        10.10.10.1 from 10.10.10.1 (192.168.1.1)
          Origin IGP, metric 0, localpref 100, valid, external, best
          Community: 1111:222 2222:333 4444:555 6666:777 8888:999
    r2#sh ip bgp summary | i bytes of memory
    1 network entries using 136 bytes of memory
    1 path entries using 56 bytes of memory
    1/1 BGP path/bestpath attribute entries using 128 bytes of memory
    1 BGP AS-PATH entries using 24 bytes of memory
    1 BGP community entries using 40 bytes of memory
    0 BGP route-map cache entries using 0 bytes of memory
    0 BGP filter-list cache entries using 0 bytes of memory
    BGP using 384 total bytes of memory
    r2#
    

    One other observation- if I make some changes to advertised prefix(for example add attached communities) and clear the BGP session, then I see "2/1 BGP path/bestpath" in BGP neighbor router for about one minute:
    r2#sh ip bgp summary | i bytes of memory
    1 network entries using 136 bytes of memory
    1 path entries using 56 bytes of memory
    2/1 BGP path/bestpath attribute entries using 256 bytes of memory
    1 BGP AS-PATH entries using 24 bytes of memory
    2 BGP community entries using 48 bytes of memory
    0 BGP route-map cache entries using 0 bytes of memory
    0 BGP filter-list cache entries using 0 bytes of memory
    BGP using 520 total bytes of memory
    r2#
    

    How to explain this? In addition, it keeps the memory consumption high.
  • srgsrg Member Posts: 140
    m4rtin wrote: »
    How to explain this? In addition, it keeps the memory consumption high.
    It probably has to wait for the BGP Walker process to remove the old path, and it runs once ever 60 seconds by default.
  • m4rtinm4rtin Member Posts: 170
    srg wrote: »
    It probably has to wait for the BGP Walker process to remove the old path, and it runs once ever 60 seconds by default.

    Ok, thanks!

    In summary, I would say that one average BGP prefix will take around 200B of memory if one includes AS-path entries and there might be few communities attached to prefix. Does this mean that in order to store full BGP table, one would need at least about 80MiB(200B*400000) of memory? This of course does not include possible filter-lists, route-maps or routes which are not removed by BGP Walker process.
Sign In or Register to comment.