Exploring the quirks of Network Engineering
Scenario
The BGP policy accounting enables you to account for traffic based on BGP attributes. So instead of relying on interface counters you can aggregate prefix counters based on something like communities or the AS_PATH attribute. The concept of an index, as shown below, is used to achieve this.
The router in the below comparison is in AS 200 and is configured to count all traffic sourced from AS100 on two interfaces.
IOS Config
ip as-path access-list 100 permit _100$
!
route-map BGP-POLICY-ACCOUNTING permit 10
match as-path 100
set traffic index 50
route-map BGP-POLICY-ACCOUNTING permit 20
!
router bgp 200
address-family ipv4
table-map BGP-POLICY-ACCOUNTING
!
!
interface GigabitEthernet1
bgp accounting input
!
interface GigabitEthernet2
bgp accounting input
!
!
! Verification commands:
! show ip cef <ip_address/mask> detail - look for `BGP: traffic_index 50` in output
! show cef interface policy-statistics | inc Giga|BGP|50 - to view specific counters
!
XR Config
as-path-set AS-PATH-SET
originates from '100'
end-set
!
route-policy BGP-POLICY-ACCOUNTING
if as-path in AS-PATH-SET then
set traffic-index 50
else
pass
end-if
end-policy
!
router bgp 200
address-family ipv4 unicast
table-policy BGP-POLICY-ACCOUNTING
!
!
interface Gi0/0/0/0
ipv4 bgp policy accounting input source-accounting
!
interface Gi0/0/0/1
ipv4 bgp policy accounting input source-accounting
!
!
! Verification commands:
! show cef ipv4 <ip_address/mask> - look for `traffic index 50` in output
! show cef ipv4 interface <interface> bgp-policy-statistics
!