Showing posts with label ldp. Show all posts
Showing posts with label ldp. Show all posts

Thursday, November 7, 2013

FEC 129 - VPLS with BGP auto-discovery using LDP

New version of JUNOS supports FEC 129 BGP auto-discovery.
You don't have to manually configure each pseudo wire. You will use BGP to auto discover the other PEs. no need for a site-ids (rsvp based) or vpls-ids (manual ldp psuedowires). 

Two commands to consider is the l2vpn-id which is similar to the vrf-target. And the auto-discovery-only command in BGP. 

Below will connect to various PEs 

user@router# show routing-instances 
VPLS {
    instance-type vpls;
    interface et-0/1/0.1;
    route-distinguisher 2.2.2.2:852;
    l2vpn-id l2vpn-id:100:1;
    vrf-target target:100:1;
    protocols {
        vpls {
            encapsulation-type ethernet-vlan;
            no-tunnel-services;
        }
    }
}

{master}[edit]
user@router# show protocols bgp 
path-selection external-router-id;
log-updown;
group RR {
    type internal;
    local-address 2.2.2.2;
    family l2vpn {
        auto-discovery-only;
    }
    neighbor 192.168.1.1;
    neighbor 192.168.1.2;
    neighbor 192.168.1.3;
    neighbor 192.168.1.4;
    neighbor 192.168.1.5;
    neighbor 192.168.1.6;               
    neighbor 192.168.1.7;
    neighbor 192.168.1.8;
    neighbor 192.168.1.10;
}

{master}[edit]
user@router# show interfaces et-0/1/0 
flexible-vlan-tagging;
encapsulation flexible-ethernet-services;
unit 1 {
    encapsulation vlan-vpls;
    vlan-id 1;
    family vpls;
}


user@router# run show ldp database session 192.168.1.1 
Input label database, 2.2.2.2:0--192.168.1.1:0
  Label     Prefix
     16      FEC129 NoCtrlWord VLAN 000a0064:00000001 c0a80101 02020202

Output label database, 2.2.2.2:0--192.168.1.1:0
  Label     Prefix
      0      2.2.2.2/32
 299920      192.168.1.1/32
 299936      192.168.1.2/32
 299952      192.168.1.3/32
 299968      192.168.1.4/32
 299984      192.168.1.5/32
 300000      192.168.1.6/32
 300016      192.168.1.7/32
 300032      192.168.1.8/32
 300048      192.168.1.9/32
 300064      192.168.1.10/32
 262145      FEC129 NoCtrlWord VLAN 000a0064:00000001 02020202 c0a80101

{master}[edit]
user@router# run show bgp summary 
Groups: 1 Peers: 9 Down peers: 0
Table          Tot Paths  Act Paths Suppressed    History Damp State    Pending
inet.0               
                       0          0          0          0          0          0
inet6.0              
                       0          0          0          0          0          0
bgp.l2vpn.0          
                       9          9          0          0          0          0
inet.2               
                       0          0          0          0          0          0
Peer                     AS      InPkt     OutPkt    OutQ   Flaps Last Up/Dwn State|#Active/Received/Accepted/Damped...
192.168.1.1             852         18         20       0       0        8:07 Establ
  inet.0: 0/0/0/0
  inet6.0: 0/0/0/0
  bgp.l2vpn.0: 1/1/1/0
  inet.2: 0/0/0/0
  VPLS.l2vpn.0: 1/1/1/0

                                        
{master}[edit]
user@router# run show vpls connections 
Layer-2 VPN connections:

Legend for connection status (St)   
EI -- encapsulation invalid      NC -- interface encapsulation not CCC/TCC/VPLS
EM -- encapsulation mismatch     WE -- interface and instance encaps not same
VC-Dn -- Virtual circuit down    NP -- interface hardware not present 
CM -- control-word mismatch      -> -- only outbound connection is up
CN -- circuit not provisioned    <- -- only inbound connection is up
OR -- out of range               Up -- operational
OL -- no outgoing label          Dn -- down                      
LD -- local site signaled down   CF -- call admission control failure      
RD -- remote site signaled down  SC -- local and remote site ID collision
LN -- local site not designated  LM -- local site ID not minimum designated
RN -- remote site not designated RM -- remote site ID not minimum designated
XX -- unknown connection status  IL -- no incoming label
MM -- MTU mismatch               MI -- Mesh-Group ID not available
BK -- Backup connection         ST -- Standby connection
PF -- Profile parse failure      PB -- Profile busy
RS -- remote site standby SN -- Static Neighbor
LB -- Local site not best-site   RB -- Remote site not best-site
VM -- VLAN ID mismatch

Legend for interface status 
Up -- operational           
Dn -- down

Instance: VPLS
  L2vpn-id: 100:1
  Local-id: 2.2.2.2
    Remote-id                 Type  St     Time last up          # Up trans
    192.168.1.1               rmt   Up     Nov  7 20:58:18 2013           1
      Remote PE: 192.168.1.1, Negotiated control-word: No
      Incoming label: 262145, Outgoing label: 16
      Local interface: lsi.1048841, Status: Up, Encapsulation: VLAN
        Description: Intf - vpls VPLS local-id 2.2.2.2 remote-id 192.168.1.1 neighbor 192.168.1.1

Saturday, October 19, 2013

Create your own command with op script. Show ldp statics from an mpls label.


My customer asked me whether JUNOS supports a function about ldp traffic statistics per mpls label. You can do show ldp statistics, but you have to know the prefix. I didn't find any command about the function and our firewall filter only supports label exp flag. Can we write some op script tho support it?
I created an op script that will do a reverse lookup of the prefix from the label. It combines the following commands:

show route x.x.x.x table inet.3
show ldp traffic-statistics

Basically it looks for the label that is in the inet.3 table and finds the associated route. It then looks for the ldp-traffic stats from the route.


See below on how it works:

user@router# show system                                         
host-name router;
scripts {
    op {
        file label-stats.slax;
    }
}

[edit]
user@router# run op label-stats label 300048                     
label 300048 prefix 202.0.0.0/24
202.0.0.0/24 Transit 114533658740 5726682937000 No.
202.0.0.0/24 Ingress 0 0 No.

[edit]
user@router# run show route 202.0.0.0/24 table inet.3            

inet.3: 9 destinations, 9 routes (9 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

202.0.0.0/24       *[LDP/9] 22:28:18, metric 1
                    > to 10.2.3.3 via xe-3/0/0.0, Push 300048

[edit]
user@router# run show ldp traffic-statistics | find 202.0.0.0    
 202.0.0.0/24        Transit        114543762951      5727188147550    No   
                     Ingress                   0                  0    No   
 202.0.1.0/24        Transit           110333454         5516672700    No   
                     Ingress                   0                  0    No   
 202.0.2.0/24        Transit           110333454         5516672700    No   
                     Ingress                   0                  0    No   
 202.0.3.0/24        Transit           110333453         5516672650    No   
                     Ingress                   0                  0    No   

SOURCE CODE:
------------------------------------------------------------------------------------------
version 1.0;

ns junos = "http://xml.juniper.net/junos/*/junos";
ns xnm = "http://xml.juniper.net/xnm/1.1/xnm";
ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0";

import "../import/junos.xsl";
var $arguments = <argument> {
    <name> "label";
    <description> "mpls label";
}
param $label;
param $indent = "  TEXT";
param $newline = "\n";

match / {
    <op-script-results> {
        var $result = jcs:invoke("get-route-information");
        var $test = ($result);
        <output method = "text"> {
            
            for-each ($result/route-table) {
                if (table-name == "inet.3") {
                    var $content = .;
                    
                    for-each ($content/rt/rt-entry/nh) {
                        var $check = mpls-label;
                        
                        if (contains($check, $label)) {
                            var $route = normalize-space(../../rt-destination);
                            
                            expr "label " _ $label _ " prefix " _ $route _ "\n";
                            var $stats = jcs:invoke("get-ldp-traffic-statistics-information");
                            
                            for-each ($stats/ldp-traffic-statistics) {
                                var $compare = normalize-space(./ldp-prefix);
                                
                                if ($compare == $route) {
                                    expr normalize-space(.);
                                    expr ".\n";
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}