Tuesday, May 16, 2017

Difference between CAPEX and OPEX

Comparison chart

Capex

Opex

DefinitionCapital expenditures are expenditures creating future benefits. A capital expenditure is incurred when a business spends money either to buy fixed assets or to add to the value of an existing asset with a useful life that extends beyond the tax year.OpEx (Operational expenditure) refers to expenses incurred in the course of ordinary business, such as sales, general and administrative expenses (and excluding cost of goods sold – or COGS, taxes, depreciation and interest).
Also known asCapital Expenditure, Capital ExpenseOperating Expense, Operating Expenditure, Revenue Expenditure
Accounting treatmentCannot be fully deducted in the period when they were incurred. Tangible assets are depreciated and intangible assets are amortized over time.Operating expenses are fully deducted in the accounting period during which they were incurred.
In throughput accountingMoney spent on inventory falls under capex.The money spent turning inventory into throughput is opex.
In real estateCosts incurred for buying the income producing property.Costs associated with the operation and maintenance of an income producing property.
ExamplesBuying machinery and other equipment, acquiring intellectual property assets like patents.Wages, maintenance and repair of machinery, utilities, rent, SG&A expenses

Download CCIE Routing & Switching Official Cert Guide Version 5 !!

Below gives a link to download latest CCIE Official Cert Guide download link


https://letsnetworking.wordpress.com/2017/04/17/ccie-routing-switching-official-cert-guide-version-5/

Friday, May 12, 2017

Python Script to Telnet Cisco Devices

As it is quite common to telnet into a router and run script to gather statistics or modify configurations. And python now is quite popular script. So today i wrote a script implementing logging in a cisco router and running command lines.

Below is the class, it is still simple as lots of exceptions i haven't taken into consideration. But it works well in most cases, i publish here and if have time i will try update it.

import telnetlib,time

TELNET_SLEEP_TIME = 1
class RouterDevice:
    host="localhost"    port=23    telnet = telnetlib.Telnet()
    #telnet.set_debuglevel(1000)    def __init__(self, host, port):
        self.host=host
        self.port=port

    def login(self, username, password):
        self.telnet.open(self.host, self.port, 1000)
        self.telnet.write("\n\n")
        time.sleep(TELNET_SLEEP_TIME)
        login_str = self.telnet.read_very_eager()
        print login_str,
        if login_str.endswith("Username: "):
            self.telnet.write(username+"\n")
            time.sleep(TELNET_SLEEP_TIME)
            login_str = self.telnet.read_very_eager()
            print login_str
        if login_str.endswith("Password: "):
            self.telnet.write(password+"\n")
            time.sleep(TELNET_SLEEP_TIME)
            login_str =  self.telnet.read_very_eager()
            print login_str
        if login_str.endswith("#"):
            return True        else:
            return False
    def command(self, cli):
        self.telnet.write(cli)
        time.sleep(TELNET_SLEEP_TIME)
        return self.telnet.read_very_eager()

    def close(self):
        print self.command("end\n"),
        print self.command("quit\n"),
        self.telnet.close()

Below is the demo on how to use the class
router1 = RouterDevice("localhost",30001)
if router1.login("cisco","cisco"):
    print router1.command("config terminal\n"),
    print router1.command("show running\n"),
router1.close()

I will keep publishing more and more useful knowledge on IP networking and also scripts. If you like please share this blog and follow me:)

Tuesday, May 9, 2017

OSPF sham link configuration example using Cisco IOS XR

To provide the backdoor link of CE routers wait as a backup link we can enable sham-link on PE routers.Here is the configuration on a IOS XR PE router:

PE1:

interface Loopback1
 vrf VRF_OSPF
 ipv4 address 172.0.1.4 255.255.255.255    ---->Sham link source IP

!

router ospf VRF_OSPF
 vrf VRF_OSPF
  redistribute bgp 65545
  area 0
   sham-link 172.0.1.4 172.0.1.5
   !
   interface GigabitEthernet0/0/0/6     ---> Link to CE1
   !
  !
 !

!

router bgp 65545
 vrf VRF_OSPF
  rd 65545:3
  address-family ipv4 unicast
   redistribute connected
  !
 !

!


PE2:

interface Loopback1
 vrf VRF_OSPF
 ipv4 address 172.0.1.5 255.255.255.255    ---->Sham link source IP

!


router ospf VRF_OSPF
 vrf VRF_OSPF
  redistribute bgp 65545
  area 0
   sham-link 172.0.1.5 172.0.1.4
   !
   interface GigabitEthernet0/0/0/6     ---> Link to CE1
   !
  !

 !

router bgp 65545
 vrf VRF_OSPF
  rd 65545:3
  address-family ipv4 unicast
   redistribute connected
  !
 !
!

CE1:

router ospf VRF_OSPF
 redistribute connected
 address-family ipv4 unicast
 area 0
  interface GigabitEthernet0/0/0/6    ---->link to PE1
  !
  interface GigabitEthernet0/0/0/8    --->backdoor link
  !
 !

!

CE2:

router ospf VRF_OSPF
 redistribute connected
 address-family ipv4 unicast
 area 0
  interface GigabitEthernet0/0/0/6  ---->link to PE2
  !
  interface GigabitEthernet0/0/0/8  --->backdoor link
  !
 !

!




Check the result:

RP/0/0/CPU0:Edge1#show ospf vrf VRF_OSPF sham-links 
Sat Apr 29 08:48:27.436 UTC

Sham Links for OSPF VRF_OSPF, VRF VRF_OSPF

Sham Link OSPF_SL0 to address 172.0.1.5 is up
Area 0, source address 172.0.1.4
IfIndex = 12
  Run as demand circuit
  DoNotAge LSA allowed., Cost of using 1
  Transmit Delay is 1 sec, State POINT_TO_POINT,
  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
    Hello due in 00:00:06:427
    Adjacency State FULL (Hello suppressed)
    Number of DBD retrans during last exchange 0
    Index 2/2, retransmission queue length 0, number of retransmission 0
    First 0(0)/0(0) Next 0(0)/0(0)
    Last retransmission scan length is 0, maximum is 0

    Last retransmission scan time is 0 msec, maximum is 0 msec




RP/0/0/CPU0:Edge1#show ospf vrf VRF_OSPF neighbor 
Sat Apr 29 08:49:35.922 UTC

* Indicates MADJ interface
# Indicates Neighbor awaiting BFD session up

Neighbors for OSPF VRF_OSPF, VRF VRF_OSPF

Neighbor ID     Pri   State           Dead Time   Address         Interface
10.127.224.2    1     FULL/  -           -        172.0.1.5       OSPF_SL0
    Neighbor is up for 00:44:16
30.0.0.0        1     FULL/BDR        00:00:35    172.0.0.3       GigabitEthernet0/0/0/6
    Neighbor is up for 03:12:02


Total neighbor count: 2



Before configuring sham link, the routes from CE2 on PE1 points to CE1 and go pass backdoor link


RP/0/0/CPU0:Edge1# show route vrf VRF_OSPF 30.0.1.186/32 
Sat Apr 29 09:03:12.326 UTC

Routing entry for 30.0.1.186/32
  Known via "ospf VRF_OSPF", distance 110, metric 20, type extern 2
  Installed Apr 29 09:03:08.046 for 00:00:04
  Routing Descriptor Blocks
    172.0.0.3, from 172.0.0.5, via GigabitEthernet0/0/0/6
      Route metric is 20
  No advertising protos. 

After configuring sham link, the routes points to PE2 via MPLS network

RP/0/0/CPU0:Edge1# show route vrf VRF_OSPF 30.0.1.186/32 
Sat Apr 29 09:06:30.362 UTC

Routing entry for 30.0.1.186/32
  Known via "ospf VRF_OSPF", distance 254, metric 20, type extern 2
  Installed Apr 29 09:06:26.493 for 00:00:03
  Routing Descriptor Blocks
    172.0.1.5, from 172.0.0.5
      Route metric is 20

  No advertising protos.

We see that, after we had configured shamlink between PE-1 and PE-2, previously coming inter-area routes became intra area routes as they were originated.This can prevent choosing backdoor link instead of Mpls VPN network.

Monday, May 8, 2017

How to convert IP address from Decimal to Binary using Python

class IPAddress:
    ip_address=""
    def __init__(self, string):
        #validate IP address
        valid_ip = True;
        invalid_reason = ""
        add_arr = string.split(".")
        add_int_arr = []
        if len(add_arr) != 4:
            valid_ip = False
            invalid_reason = "Invalid IP address: Length of IP is not correct"
        for add in add_arr:
            try:
                add_int_arr.append(int(add))
            except ValueError:
                valid_ip = False
                invalid_reason = "Invalid IP address: The input contains none number characters"

        if valid_ip == True:
            first_add, second_add, third_add, fourth_add = add_int_arr
            if (first_add < 1) or (first_add > 255):
                valid_ip = False
                invalid_reason = "Invalid IP address: The input IP address contains invalid number"
            for add in (second_add, third_add, fourth_add):
                if (add < 0) or (add > 255):
                    print add
                    valid_ip = False
                    invalid_reason = "Invalid IP address: The input IP address contains invalid number"

        if valid_ip == True:
            self.ip_address=string
        else:
            assert (valid_ip), invalid_reason
    def IPDec2Bin(self):
        ip_arr = self.ip_address.split(".")
        ip_bin_str = ""
        for ip in ip_arr:
            ip_bin_str = ip_bin_str + "{:08b}".format(int(ip)) + "."
        return ip_bin_str[0:len(ip_bin_str)-1]
#application script
IP = IPAddress("103.88.17.23")
final_ip_bin_str =IP.IPDec2Bin()
print "{:<15} {:<45}".format("IP address", "Binary")
print "{:<15} {:<45}".format(IP.ip_address, final_ip_bin_str)

Sunday, May 7, 2017

Elephant Flow VS Mice Flow

Elephant flow is an extremely large (in total bytes) continuous flow set up by a TCP (or other protocols) flow measured over a network link
Mice flow is an extremely short (in total bytes) continuous flow set up by a TCP (or other protocols) flow measured over a network link.
A mouse is a flow with fewer than C packets. An elephant flow is a flow with at least C packets. The constant C is left as a degree of freedom in the analysis. C is chosen depending on the target application

Saturday, May 6, 2017

DWDM vs CWDM

Core idea of xWDM technology: frequency duplex.  A multiplexer combines all different colors (with different wavelength/frequency)  and then data will be transmitted over one fiber using different wavelengths together. On the receive end, demultiplexer will separate them into different colors. This helps to improve the capacity using single fiber.

Coarse Wavelength Division Multiplexing (CWDM): 
  • Up to 16 CWDM wavelength over one pair of fiber
  • CWDM channel spacing 20 nm, 1720 nm to 1610 nm
  • Distances up to 120 km
  • Cost-effective WDM solution, mainly used in access, metro network.
DWDM (Dense Wavelength Division Multiplexing): 
  • Up to 96 DWDM wavelength over one pair of fiber
  • DWDM channel spacing 0.8 nm (100 GHz grid) or 0.4 nm (50 GHz grid)
  • Distances over 1,000 km can be achieved with the use of optical amplifier
  • Expensive, mainly used in core network

Understanding BIDI (Bi-Directional) transceivers

BiDi transceivers is short for Bi-Directional Optical Transceiver.
The key-point of BIDI transceivers is that a single fiber.used for both receiving and transmuting data.
In order to distinguish the receiving and transiting data, they must be transmitted using different wavelength. Then Wavelength Division Multiplexing (WDM) couplers is needed to combine and separate data transmitted over a single fiber based on  the wavelengths of the light. Based on this, BIDI transceivers are also referred to as WDM transceivers.
Example:
  • Transceiver A’s diplexer must have a receiving wavelength of 1490nm and a transmit wavelength of 1310nm
  • Transceiver B’s diplexer must have a receiving wavelength of 1310nm and a transmit wavelength of 1490n

Advantage of BIDI transceivers: require less fiber. 
While BiDi transceivers (a.k.a. WDM transceivers) cost more to initially purchase than traditional two-fiber transceivers, they utilize half the amount of fiber per unit of distance. For many networks, the cost savings of utilizing less fiber is enough to more than offset the higher purchase price of BiDi transceivers.

First Hop Redundancy protocol comparison (HSRP,VRRP,GLBP)

ProtocolFeaturesHSRP(Hot Standby Router protocol)VRRP(Virtual Redundancy Router Protocol)GLBP(Gateway Load Balancing Protocol)
Router role– 1 active router.
– 1 standby router.
– 1 or more listening routers.
– 1 master router.
– 1 or more backup routers.
– 1 AVG (Active Virtual Gateway).
– up to 4 AVF routers on the group (Active Virtual Forwarder) passing traffic.
– up to 1024 virtual routers (GLBP groups) per physical interface.
– Use virtual ip address.– Can use real router ip address, if not, the one with highest priority become master.– Use virtual ip address.
ScopeRFC 2281RFC 3768Cisco proprietary
ElectionActive Router:
1-Highest Priority
2-Highest IP (tiebreaker)
Master Router: (*)
1-Highest Priority
2-Highest IP (tiebreaker)
Active Virtual Gateway:
1-Highest Priority
2-Highest IP (tiebreaker)
Optimization featuresTrackingyesyesyes
Preemptyesyesyes
Timer adjustmentsyesyesyes
Traffic type224.0.0.2 – udp 1985 (version1)
224.0.0.102-udp 1985 (version2)
224.0.0.18 – IP 112224.0.0.102 udp 3222
TimersHello – 3 secondsAdvertisement – 1 secondHello – 3 seconds
(Hold) 10 seconds(Master Down Interval)3 * Advertisement + skew time(Hold) 10 seconds
(Skew time)(256-priority) / 256
Load-balancing functionality– Multiple HSRP group per interface/SVI/routed int.– Multiple VRRP group per interface/SVI/routed int.Load-balancing oriented- Weighted algorithm.- Host-dependent algorithm.– Round-Robin algorithm (default).
Requires appropriate distribution of Virtual GW IP per Clients for optimal load-balancing.(generally through DHCP)Requires appropriate distribution of Virtual GW IP per Clients for optimal load-balancing.(generally through DHCP)Clients are transparently updated with virtual MAC according to load-balancing algorithm through ARP requesting a unique virtual gateway.

Configuration Example on Cisco Router:
  • HSRP Configuration
interface FastEthernet0/0
ip address 10.0.1.2 255.255.255.0
standby version {1 | 2}
standby 1 ip 10.0.1.1
standby 1 timers <hello> <dead>
standby 1 priority <priority>
standby 1 preempt
standby 1 authentication md5 key-string <password>
standby 1 track <interface> <value>
standby 1 track <object> decrement <value>
  • VRRP Configuration
interface FastEthernet0/0
ip address 10.0.1.2 255.255.255.0
vrrp 1 ip 10.0.1.1
vrrp 1 timers {advertise <hello> | learn}
vrrp 1 priority <priority>
vrrp 1 preempt
vrrp 1 authentication md5 key-string <password>
vrrp 1 track <object> decrement <value>
  • GLBP Configuration
interface FastEthernet0/0
ip address 10.0.1.2 255.255.255.0
glbp 1 ip 10.0.1.1
glbp 1 timers <hello> <dead>
glbp 1 timers redirect <redirect> <time-out>
glbp 1 priority <priority>
glbp 1 preempt
glbp 1 forwarder preempt
glbp 1 authentication md5 key-string <password>
glbp 1 load-balancing <method>
glbp 1 weighting <weight> lower <lower> upper <upper>
glbp 1 weighting track <object> decrement <value>