Thursday, August 28, 2014

EoMPLS

EoMPLS - Ethernet over MPLS


EoMPLS encapsulates ethernet frames in MPLS packets and forwards them across the MPLS network. Each frame is transported as a single packet, and the PE routers connected to the backbone add and remove labels as appropriate for packet encapsulation

EoMPLS Operation

 
The ingress PE router receives an Ethernet frame and encapsulates the packet by removing the preamble, the start of frame delimiter (SFD), and the frame check sequence (FCS). The rest of the packet header is not changed.

The ingress PE router adds a point-to-point virtual connection (VC) label and a label switched path (LSP) tunnel label for normal MPLS routing through the MPLS backbone.

The network core routers use the LSP tunnel label to move the packet through the MPLS backbone and do not distinguish Ethernet traffic from any other types of packets in the MPLS backbone.

At the other end of the MPLS backbone, the egress PE router receives the packet and de-encapsulates the packet by removing the LSP tunnel label if one is present. The PE router also removes the VC label from the packet.

  The PE router updates the header, if necessary, and sends the packet out the appropriate interface to the destination switch.


EoMPLS Type 1 - Port mode

Allows all traffic on a port to share a single VC across an MPLS network

Topology




Configurations


    CE1#show running-config

    vlan 455
     name PPPoE-H1-40fl

    interface GigabitEthernet4/0/0
     switchport
     switchport trunk allowed vlan 455
     switchport mode trunk
     no mls qos trust

    interface Vlan455
     ip address 192.168.14.1 255.255.255.0

    PE1#show running-config
    mpls ldp router-id Loopback0
    mpls ip

    vlan 455
     name PPPoE-H1-40fl

    interface Loopback0
     ip address 192.168.22.22 255.255.255.255

    interface GigabitEthernet3/0/0
     no ip address
     negotiation auto

    interface GigabitEthernet3/0/0.1
     encapsulation dot1Q 455
     xconnect 192.168.33.33 455 encapsulation mpls

    interface GigabitEthernet3/1/0
     ip address 192.168.23.2 255.255.255.0
     negotiation auto
     mpls ip

    router ospf 1
     router-id 2.2.2.2
     log-adjacency-changes detail
     network 192.168.0.0 0.0.255.255 area 0

    PE2#show running-config
    mpls ldp router-id Loopback0
    mpls ip

    vlan 455
     name PPPoE-H1-40fl
     
    interface Loopback0
     ip address 192.168.33.33 255.255.255.255

    interface GigabitEthernet4/0/0
     ip address 192.168.23.3 255.255.255.0

     mpls ip
     mls qos trust dscp

    interface GigabitEthernet6/2.1
     encapsulation dot1Q 455
     xconnect 192.168.22.22 455 encapsulation mpls

    router ospf 1
     router-id 3.3.3.3
     network 192.168.0.0 0.0.255.255 area 0

    CE2#show running-config
    
    vlan 455
     name PPPoE-H1-40fl

    interface GigabitEthernet3/3
     switchport
     switchport trunk encapsulation dot1q
     switchport trunk allowed vlan 455
     switchport mode trunk

    interface Vlan455
     ip address 192.168.14.4 255.255.255.0

Configurations Verification

Checking MPLS link on PE1 and PE2

PE1#show mpls ldp bindings 192.168.33.33 32
  lib entry: 192.168.33.33/32, rev 6
        local binding:  label: 17
        remote binding: lsr: 192.168.33.33:0, label: imp-null

PE2#show mpls ldp bindings 192.168.22.22 32
  lib entry: 192.168.22.22/32, rev 6
        local binding:  label: 17
        remote binding: lsr: 192.168.22.22:0, label: imp-null

Checking MPLS connectivity on PE1 and PE2

PE1#ping mpls ipv4 192.168.33.33 255.255.255.255      
Sending 5, 100-byte MPLS Echos to 192.168.33.33/32,
     timeout is 2 seconds, send interval is 0 msec:
Type escape sequence to abort.
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/4 ms

Checking MPLS forwarding table on PE1 and PE2 to see if the VC labels are present

PE1#show mpls forwarding-table
Local      Outgoing   Prefix           Bytes Label   Outgoing   Next Hop  
Label      Label      or Tunnel Id     Switched      interface            
17         Pop Label  192.168.33.33/32 160           Gi3/1/0    192.168.23.3
18         No Label   l2ckt(8193)      282808        Gi3/0/0.1  point2point

PE2#show mpls forwarding-table
Local      Outgoing   Prefix           Bytes Label   Outgoing   Next Hop  
Label      Label      or Tunnel Id     Switched      interface            
16         No Label   l2ckt(1)         132           Gi6/2.1    point2point
17         Pop Label  192.168.22.22/32 0             Gi4/0/0    192.168.23.2

Checking L2 VC on PE1 and PE2

PE1#show mpls l2transport vc

Local intf     Local circuit              Dest address    VC ID      Status  
-------------  -------------------------- --------------- ---------- ----------
Gi3/0/0.1      Eth VLAN 455               192.168.33.33   455        UP      

PE1#show mpls l2transport vc 455 detail
Local interface: Gi3/0/0.1 up, line protocol up, Eth VLAN 455 up
  Destination address: 192.168.33.33, VC ID: 455, VC status: up
    Output interface: Gi3/1/0, imposed label stack {16}
    Preferred path: not configured
    Default path: active
    Next hop: 192.168.23.3
  Create time: 02:54:21, last status change time: 02:22:16
  Signaling protocol: LDP, peer 192.168.33.33:0 up
    Targeted Hello: 192.168.22.22(LDP Id) -> 192.168.33.33, LDP is UP
    Status TLV support (local/remote)   : enabled/supported
      LDP route watch                   : enabled
      Label/status state machine        : established, LruRru
      Last local dataplane   status rcvd: No fault
      Last BFD dataplane     status rcvd: Not sent
      Last local SSS circuit status rcvd: No fault
      Last local SSS circuit status sent: No fault
      Last local  LDP TLV    status sent: No fault
      Last remote LDP TLV    status rcvd: No fault
      Last remote LDP ADJ    status rcvd: No fault
    MPLS VC labels: local 18, remote 16
    PWID: 8193
    Group ID: local 0, remote 0
    MTU: local 1500, remote 1500
    Remote interface description:
  Sequencing: receive disabled, send disabled
  Control Word: Off (configured: autosense)
  VC statistics:
    transit packet totals: receive 4264, send 2
    transit byte totals:   receive 289948, send 132
    transit packet drops:  receive 0, seq error 0, send 0

PE2#show mpls l2transport vc

Local intf     Local circuit              Dest address    VC ID      Status
-------------  -------------------------- --------------- ---------- ----------
Gi6/2.1        Eth VLAN 455               192.168.22.22   455        UP      


PE2#show mpls l2transport vc 455 detail
Local interface: Gi6/2.1 up, line protocol up, Eth VLAN 455 up
  Interworking type is Ethernet
  Destination address: 192.168.22.22, VC ID: 455, VC status: up
    Output interface: Gi4/0/0, imposed label stack {18}
    Preferred path: not configured
    Default path: active
    Next hop: 192.168.23.2
  Create time: 02:53:28, last status change time: 02:22:52
    Last label FSM state change time: 02:22:52
  Signaling protocol: LDP, peer 192.168.22.22:0 up
    Targeted Hello: 192.168.33.33(LDP Id) -> 192.168.22.22, LDP is UP
    Status TLV support (local/remote)   : enabled/supported
      LDP route watch                   : enabled
      Label/status state machine        : established, LruRru
      Last local dataplane   status rcvd: No fault
      Last BFD dataplane     status rcvd: Not sent
      Last BFD peer monitor  status rcvd: No fault
      Last local AC  circuit status rcvd: No fault
      Last local AC  circuit status sent: No fault
      Last local PW i/f circ status rcvd: No fault
      Last local LDP TLV     status sent: No fault
      Last remote LDP TLV    status rcvd: No fault
      Last remote LDP ADJ    status rcvd: No fault
    MPLS VC labels: local 16, remote 18
    Group ID: local 0, remote 0
    MTU: local 1500, remote 1500
    Remote interface description:
  Sequencing: receive disabled, send disabled
  Control Word: Off (configured: autosense)
  SSO Descriptor: 192.168.22.22/455, local label: 16
  Dataplane:
    SSM segment/switch IDs: 4097/4096 (used), PWID: 1
  VC statistics:
    transit packet totals: receive 2, send 4286
    transit byte totals:   receive 132, send 351434
    transit packet drops:  receive 0, seq error 0, send 0

Checking L2 xconnect on PE1 and PE2

PE2#show xconnect interface GigabitEthernet 6/2.1
Legend:    XC ST=Xconnect State  S1=Segment1 State  S2=Segment2 State
  UP=Up       DN=Down            AD=Admin Down      IA=Inactive
  SB=Standby  HS=Hot Standby     RV=Recovering      NH=No Hardware

XC ST  Segment 1                         S1 Segment 2                         S2
------+---------------------------------+--+---------------------------------+--
UP pri   ac Gi6/2.1:455(Eth VLAN)        UP mpls 192.168.22.22:455            UP

PE1#show xconnect interface GigabitEthernet 3/0/0.1
Legend:    XC ST=Xconnect State  S1=Segment1 State  S2=Segment2 State
  UP=Up       DN=Down            AD=Admin Down      IA=Inactive
  SB=Standby  HS=Hot Standby     RV=Recovering      NH=No Hardware

XC ST  Segment 1                         S1 Segment 2                         S2
------+---------------------------------+--+---------------------------------+--
UP     ac   Gi3/0/0.1:455(Eth VLAN)      UP mpls 192.168.33.33:455            UP

Segment 1 is the attach circuit (ie PE CE link)
Segment 2 is the core circuit (ie PE PE link)

Checking the L2 VC binding

PE1#show mpls l2transport binding 455
  Destination Address: 192.168.33.33,  VC ID: 455
    Local Label:  18
        Cbit: 0,    VC Type: Ethernet,    GroupID: 0
        MTU: 1500,   Interface Desc: n/a
        VCCV: CC Type: CW [1], RA [2], TTL [3]
              CV Type: LSPV [2], BFD/Raw [5]
    Remote Label: 16
        Cbit: 0,    VC Type: Ethernet,    GroupID: 0
        MTU: 1500,   Interface Desc: n/a
        VCCV: CC Type: RA [2], TTL [3]
              CV Type: LSPV [2], BFD/Raw [5]

PE2#show mpls l2transport binding 455
  Destination Address: 192.168.22.22,VC ID: 455
    Local Label:  16
        Cbit: 0,    VC Type: Ethernet,    GroupID: 0
        MTU: 1500,   Interface Desc: n/a
        VCCV: CC Type: RA [2], TTL [3]
              CV Type: LSPV [2], BFD/Raw [5]
    Remote Label: 18
        Cbit: 0,    VC Type: Ethernet,    GroupID: 0
        MTU: 1500,   Interface Desc: n/a
        VCCV: CC Type: RA [2], TTL [3]
              CV Type: LSPV [2], BFD/Raw [5]

Pinging from CE1 to CE2 to confirm the VC functionality

CE1#ping 192.168.14.4
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.14.4, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 1/1/1 ms
CE1#
   


EoMPLS Type 2 - VLAN mode

Transports Ethernet traffic from a source 802.1Q VLAN to a destination 802.1Q VLAN through a single VC over an MPLS network

Topology




Configurations


    CE1#show running-config
    vlan 455
     name PPPoE-H1-40fl

    interface TenGigabitEthernet2/1
     switchport
     switchport trunk encapsulation dot1q
     switchport trunk allowed vlan 455
     switchport mode trunk

    interface Vlan455
     ip address 192.168.14.1 255.255.255.0

    PE1#show running-config
    mpls ldp router-id Loopback0
    mpls ip

    vlan 455
     name PPPoE-H1-40fl

    interface Loopback0
     ip address 192.168.22.22 255.255.255.255

    interface TenGigabitEthernet2/0/0
     switchport
     switchport trunk allowed vlan 455
     switchport mode trunk
     no mls qos trust

    interface GigabitEthernet3/1/0
     ip address 192.168.23.2 255.255.255.0
     negotiation auto
     mpls ip

    interface Vlan455
     no ip address
     xconnect 192.168.33.33 455 encapsulation mpls

    router ospf 1
     router-id 2.2.2.2
     log-adjacency-changes detail
     network 192.168.0.0 0.0.255.255 area 0

    PE2#show running-config

    mpls ldp router-id Loopback0
    mpls ip

    vlan 455
     name PPPoE-H1-40fl

    interface Loopback0
     ip address 192.168.33.33 255.255.255.255

    interface GigabitEthernet4/0/0
     ip address 192.168.23.3 255.255.255.0
     mpls ip
     mls qos trust dscp

    interface GigabitEthernet6/2
     switchport
     switchport trunk encapsulation dot1q
     switchport trunk allowed vlan 455
     switchport mode trunk

    interface Vlan455
     no ip address
     xconnect 192.168.22.22 455 encapsulation mpls

    router ospf 1
     router-id 3.3.3.3
     network 192.168.0.0 0.0.255.255 area 0

    CE2#show running-config
    vlan 455
     name PPPoE-H1-40fl

    interface GigabitEthernet3/3
     switchport
     switchport trunk encapsulation dot1q
     switchport trunk allowed vlan 455
     switchport mode trunk
     
    interface Vlan455
     ip address 192.168.14.4 255.255.255.0


Configurations Verification

Checking MPLS link on PE1 and PE2

PE1#show mpls ldp bindings 192.168.33.33 32
  lib entry: 192.168.33.33/32, rev 6
        local binding:  label: 17
        remote binding: lsr: 192.168.33.33:0, label: imp-null

PE2#show mpls ldp bindings 192.168.22.22 32
  lib entry: 192.168.22.22/32, rev 6
        local binding:  label: 17
        remote binding: lsr: 192.168.22.22:0, label: imp-null

Checking MPLS connectivity on PE1 and PE2

PE1#ping mpls ipv4 192.168.33.33 255.255.255.255      
Sending 5, 100-byte MPLS Echos to 192.168.33.33/32,
     timeout is 2 seconds, send interval is 0 msec:
Type escape sequence to abort.
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/4 ms

Checking MPLS forwading table on PE1 and PE2 to see if the VC labels are present

PE1#show mpls forwarding-table
Local      Outgoing   Prefix           Bytes Label   Outgoing   Next Hop  
Label      Label      or Tunnel Id     Switched      interface            
16         No Label   l2ckt(4096)      556           Vl455      point2point
17         Pop Label  192.168.33.33/32 0             Gi3/1/0    192.168.23.3

PE2#show mpls forwarding-table
Local      Outgoing   Prefix           Bytes Label   Outgoing   Next Hop  
Label      Label      or Tunnel Id     Switched      interface            
16         No Label   l2ckt(1)         624           Vl455      point2point
17         Pop Label  192.168.22.22/32 0             Gi4/0/0    192.168.23.2
     
Checking L2 VC on PE1 and PE2

PE1#show mpls l2transport vc

Local intf     Local circuit              Dest address    VC ID      Status  
-------------  -------------------------- --------------- ---------- ----------
Vl455          Eth VLAN 455               192.168.33.33   455        UP      

PE1#show mpls l2transport vc 455 detail
Local interface: Vl455 up, line protocol up, Eth VLAN 455 up
  Destination address: 192.168.33.33, VC ID: 455, VC status: up
    Output interface: Gi3/1/0, imposed label stack {16}
    Preferred path: not configured
    Default path: active
    Next hop: 192.168.23.3
  Create time: 00:22:09, last status change time: 00:17:41
  Signaling protocol: LDP, peer 192.168.33.33:0 up
    Targeted Hello: 192.168.22.22(LDP Id) -> 192.168.33.33, LDP is UP
    Status TLV support (local/remote)   : enabled/supported
      LDP route watch                   : enabled
      Label/status state machine        : established, LruRru
      Last local dataplane   status rcvd: No fault
      Last BFD dataplane     status rcvd: Not sent
      Last local SSS circuit status rcvd: No fault
      Last local SSS circuit status sent: No fault
      Last local  LDP TLV    status sent: No fault
      Last remote LDP TLV    status rcvd: No fault
      Last remote LDP ADJ    status rcvd: No fault
    MPLS VC labels: local 16, remote 16
    PWID: 4096
    Group ID: local 0, remote 0
    MTU: local 1500, remote 1500
    Remote interface description:
    MAC Withdraw: sent:1, received:0
  Sequencing: receive disabled, send disabled
  Control Word: On (configured: autosense)
  VC statistics:
    transit packet totals: receive 5, send 6
    transit byte totals:   receive 556, send 624
    transit packet drops:  receive 0, seq error 0, send 0


Checking L2 xconnect on PE1 and PE2

PE2#show xconnect interface Vlan 455
Legend:    XC ST=Xconnect State  S1=Segment1 State  S2=Segment2 State
  UP=Up       DN=Down            AD=Admin Down      IA=Inactive
  SB=Standby  HS=Hot Standby     RV=Recovering      NH=No Hardware

XC ST  Segment 1                         S1 Segment 2                         S2
------+---------------------------------+--+---------------------------------+--
UP pri   ac Vl455:455(Eth VLAN)          UP mpls 192.168.22.22:455            UP


PE1#show xconnect interface Vlan 455
Legend:    XC ST=Xconnect State  S1=Segment1 State  S2=Segment2 State
  UP=Up       DN=Down            AD=Admin Down      IA=Inactive
  SB=Standby  HS=Hot Standby     RV=Recovering      NH=No Hardware

XC ST  Segment 1                         S1 Segment 2                         S2
------+---------------------------------+--+---------------------------------+--
UP     ac   Vl455:455(Eth VLAN)          UP mpls 192.168.33.33:455            UP

Segment 1 is the attach circuit (ie PE CE link)
Segment 2 is the core circuit (ie PE PE link)

Checking the L2 VC binding

PE1#show mpls l2transport binding 455
  Destination Address: 192.168.33.33,  VC ID: 455
    Local Label:  16
        Cbit: 1,    VC Type: Ethernet,    GroupID: 0
        MTU: 1500,   Interface Desc: n/a
        VCCV: CC Type: CW [1], RA [2], TTL [3]
              CV Type: LSPV [2], BFD/Raw [5]
    Remote Label: 16
        Cbit: 1,    VC Type: Ethernet,    GroupID: 0
        MTU: 1500,   Interface Desc: n/a
        VCCV: CC Type: CW [1], RA [2], TTL [3]
              CV Type: LSPV [2], BFD/Raw [5]

PE2#show mpls l2transport binding 455
  Destination Address: 192.168.22.22,VC ID: 455
    Local Label:  16
        Cbit: 1,    VC Type: Ethernet,    GroupID: 0
        MTU: 1500,   Interface Desc: n/a
        VCCV: CC Type: CW [1], RA [2], TTL [3]
              CV Type: LSPV [2], BFD/Raw [5]
    Remote Label: 16
        Cbit: 1,    VC Type: Ethernet,    GroupID: 0
        MTU: 1500,   Interface Desc: n/a
        VCCV: CC Type: CW [1], RA [2], TTL [3]
              CV Type: LSPV [2], BFD/Raw [5]

Pinging from CE1 to CE2 to confirm the VC functionality

CE1#ping 192.168.14.4
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.14.4, timeout is 2 seconds:
!!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 1/1/1 ms
CE1#



prajsree[at]gmail.com

Wednesday, August 27, 2014

Shared Objects


Shared objects are must have for any major project with large chunk of data and multiple components. In many cases we may end up in situation where in more than one component may require to include the functionality of one particular component. Consider the case of a network router development. In a typical router code you may see a common Hardware Abstraction Layer and different Protocols will interact with this HAL layer to program the hardware. By using shared libraries it became convenient  for the HAL to generate one single shared library with all the HAL apis and then each of the protocol processes can include this shared library. This greatly improves the code maintainability and more over it highly reduces the final binary size and the ram usage.


Building the Binary with the shared Object


Create the Shared Object file
shared_crasher.c
    #include 

    void crasher_stack_2 (void)
    {
        int a = 0;
        int b;
        b = 100 / a;
    }

    void crasher_stack_1 (void)
    {
        crasher_stack_2();
    }

    void crasher_stack_0 (void)
    {
        crasher_stack_1();
    }
 shared_crasher.h
    void crasher_stack_0 (void);    


Build the shared .so file
The Position Independent Code Flag needs to be set and the shared attribute need to be set for the GCC command.

    gcc -fPIC -shared -o libshared_crasher.so shared_crasher.c

Create the Binary file which uses the shared library
gdb_test.c
    #include "shared_crasher.h"


    void stack_2 (void)
    {
        crasher_stack_0();
    }

    void stack_1 (void)
    {
        stack_2();
    }

    int main ()
    {
        stack_1();
        return (0);
    }

Build the Binary file with the shared library
The shared library needs to specified with the -l argument. The path to the shared library needs to be specified with the -L argument.

    gcc -L /users/pnaduvat/myCode -l shared_crasher -o gdb_test.bin gdb_test.c

Lets try running the Binary now. 
Before running the binary we need to export the path to the library to the LD_LIBRARY_PATH

    export LD_LIBRARY_PATH=/users/pnaduvat/myCode:$LD_LIBRARY_PATH

    ./gdb_test.bin



Debugging the program crash.

Load the program on GDB and add a breakpoint on main. Capture the shared library details and run the program until it crashes. The program will crash and generate a core file.


    Thor myCode]./gdb-7.2.1-64 gdb_test.bin

    (gdb) break main
    Breakpoint 1 at 0x400602

    (gdb) run
    Starting program: /users/pnaduvat/myCode/gdb_test.bin

    Breakpoint 1, 0x0000000000400602 in main ()

    (gdb) info shared
    From                To                  Syms Read   Shared Object Library
    0x0000003398400a70  0x000000339841682e  Yes (*)     /lib64/ld-linux-x86-64.so.2
    0x00002aaaaaab04b0  0x00002aaaaaab05e8  Yes (*)     /users/pnaduvat/myCode/libshared_crasher.so
    0x000000339881d780  0x0000003398909618  Yes (*)     /lib64/libc.so.6
    (*): Shared library is missing debugging information.

    (gdb) detach
    Detaching from program: /users/pnaduvat/myCode/gdb_test.bin, process 6082

    (gdb) quit

Now lets play with the core file. Load the core file to GDB


    Thor myCode]./gdb-7.2.1-64
    (gdb) core-file core.6082

Add the main binary symbol files to the GDB


    (gdb) symbol-file gdb_test.bin
    Reading symbols from /users/pnaduvat/myCode/gdb_test.bin...(no debugging symbols found)...done.

Add the shared library symbol to the GDB at address we got from the info shared output


    (gdb) add-symbol-file libshared_crasher.so 0x00002aaaaaab04b0
    add symbol table from file "libshared_crasher.so" at
        .text_addr = 0x2aaaaaab04b0
    (y or n) y
    Reading symbols from /users/pnaduvat/myCode/libshared_crasher.so...(no debugging symbols found)...done.

Now you are all set happy debugging


    (gdb) bt
    #0  0x00002aaaaaab0591 in crasher_stack_2 ()
    #1  0x00002aaaaaab05a2 in crasher_stack_1 ()
    #2  0x00002aaaaaab05ad in crasher_stack_0 ()
    #3  0x00000000004005f1 in stack_2 ()
    #4  0x00000000004005fc in stack_1 ()
    #5  0x0000000000400611 in main ()



References

[1] http://www.cprogramming.com/tutorial/shared-libraries-linux-gcc.html