Wednesday, June 23, 2010

OSPF notes

i. A link state protocol
ii. Maintains 3 tables
a. Neighbor table
b. Topology table
c. Routing table
iii. uses SPF algorithm
iv. Send triggered updates when n/w changes
v. Refresh updates are send in every 30 min

Area concept:

Need of areas: Since OSPF is a big process, which demands a good CPU time, as the n/w grows, the process will be slower and takes time to find the best route and convergence time increases. Hence we separate the OSPF domain into areas

i.                     all areas MUST be connected to area 0
ii.                   update messages will be distributed locally
iii.                  All routers in one area will have same topology table.

OSPF neighbors

i.                     determine router ID [highest interface IP < highest loop back IP < hardcoded router-id]
ii.                   add interface to the link state database [by network command]
iii.                  send hello
a.       In broadcast/p2p network:: hello interval = 10 sec, dead interval = 40 sec.
b.      In NBMA network:: hello interval = 30 sec, dead interval = 120 sec.
c.       Hello packet contains:

MUST match
  • Hello-dead interval
  • N/w mask
  • Area ID
  • Neighbor
  • Authentication/password
  • Router-id
  • Router priority
  • DR-BDR IP address

i.                     receives hello from neighbor

STATE: 2-way
i.                     Reply to hello messages
ii.                   DR-BDR election (if any)

STATE: Exstart
i.                     master-slave election
a.       decided by router priority < router ID
ii.                   Sends DBD
a.       Master sends DBD first and slave listens
b.      Slave sends DBD second  and master listens

STATE: Loading
i.                     DBDs are acknowledged and receiving updates
a.       Slave send LSR
b.      Master sends LSU for the LSR
c.       Master sends LSR
d.      Salve sends LSU for the LSR

i.                     neighbors are synchronized
ii.                   SPF algorithm has to run to find out best path to each network reachable.


Cost = 100/ BW in Mbps
56K = 1785
64K =1562
T1 = 65
E1 =48
Ethernet = 10
Fast ethernet 1


After Dr-BDR election, DR sends updates to all routers in the broadcast domain. All routers should send n/w change updates to only DR-BDR.
i.                     OSPF uses multicast for updates
a. for all routers in OSPF
b. to DR-BDR in domain.
ii.                   in point to point link there will not be any DR/BDR
iii.                  A DROTHER router will make FULL state with only DR and BDR, other routers in the domain will be in 2-WAY state.

OSPF packet types

  • Hello
  • DBD
  • LSR
  • LSA
  • LSU
  • Link state acknowledgement
i.                     LSU are send as reply to the LSR.
ii.                   One LSU may contain multiple LSA.
iii.                  LSAck will be send to each LSU received.

OSPF over NBMA [5 modes]

i.                     non-broadcast [NBMA] (RFC complained)
ii.                   point to multi point  – RFC complained)
iii.                  Point to point  – (CISCO)
iv.                 Broadcast   – (CISCO)
v.                   Point to multi point-non broadcast – (CISCO)

i.              NBMA

a.      neighbors statically configured
b.      must be in single subnet
c.       act like in LAN
d.      DR-BDR election happens

ii.         Point to multi-point

    1. must be in single subnet
    2. no DR-BDR
    3. neighbors auto detected

iii.    Point to multi point-non broadcast

a.      must be in single subnet
b.      no DR-BDR
c.       neighbors statically configured

iv.         Point to point
a.      separate subnet is possible
b.      no DR-BDR
c.       auto neighbor detection

Address summarization

i.                 Use the command: area range
ii.                   In order to hide a route from outside world use the keyword not-advertise at the end.

LSA types

i.                     router LSA
ii.                   network LSA [DR]
iii.                  summery LSA [ABR]
iv.                 ASBR summery [ ABR with ASBR IP]
v.                   External LSA [ ASBR]
vi.                 NSSA LSA - Type-7 [ASBR in not so stubby area]

Virtual link

Virtual link is used, where an area is not directly connected to area 0 and seeking a connection to area 0. This kind of situation comes when there is merger of networks demands a redesign of entire network, where virtual links are temporary fix.

area virtual-link

Transit area:
An area, which does not originate or terminate packets.  i.e a packet is moving from area 5 to area 4 through area 0 and 3, then both area 0 and 3 are transit areas.


The neighbor ABR of the transit area. i.e if router is ABR for area 0 and 1 and router is ABR for area 1 and 2. Area 2 is connecting to area 0 via area 1. Virtual link is created between and Hence the latter will be the neighbor id.

OSPF special area types

Stub area:

To make an area stub, give the following command in all routers. Because stub flag is also considered while an OSPF router add a new neighbor.

 area stub

Totally stub area:

Configure the ABR with following command:  area stub no-summery and other routers inside the area with: area stub command.

Totally stubby area is Cisco proprietary. So ABR MUST be a Cisco router, but member routers can be any make.

i.                     Stubby area blocks type 5 LSA from entering the area.
ii.                   Totally stubby area blocks type 3, 4 and 5 LSA from entering the area.

Not so stubby area [Not so totally stubby area]

Basically it is a totally stubby area to which an external protocol cloud is attached. Say, RIP network.  The router connected to RIP network becomes ASBR in OSPF domain. But as we know totally stubby area will block type-5 LSA, hence another LSA type, type-7 is introduced.  [aka NSSA LSA]
ASBR in the NSSA will generate type-7 LSA and once it reaches it ABR, it converts it into type-5 LSA and sends out to other routers (routers outside area).

Redistributed routers [E1 and E2]

E2 is the default for redistributed routes/external routes.
In E1 routes, cost will be increasing as it pass through areas; where as in E2 cost will remain same through out OSPF admin area.
E2 is used where we have a single exit point/single ASBR.
E1 is used where we have multiple ASBR. If we know the cost for different path leads to different ASBR, it will be easy for a router to select best path to the outside networks through each of the ASBR.

Monday, April 26, 2010

STP notes

  1. Root bridge selection: Lowest bridge id [unique bridge id + priority.
  2. Priority is considered first if tie happens then check MAC address]
  3. Select a least cost path from each bridge to root bridge.
  4. Any active port that is not a root port or a designated port is a blocked port.
  5. Tie breaker for root port: If a bridge has 2 candidate ports for root position, then the port connecting to the lowest bridge id (neighbor) will be selected as root port
  6. Tie breaker for designated port: If a bridge has 2 candidate ports for designated position, then the port connecting to the lowest bridge id (neighbor) will be selected as designated port; in case of tie, port connecting the bridge with lowest MAC address will be designated port.
  7. Tie breaker if two bridges are connected with more than one cable: In this case port with lowest port priority will be opted.
  8. STP uses multicast address 01:80:C2:00:00:00 for BPDU transmission.
  9. BPDU – 8 bytes length [2 bytes priority, 6 bytes MAC]
  10. BPDU exchange in every 2 seconds

    TCNs are injected into the network by a non-root switch and propagated to the root.
    Upon receipt of the TCN, the root switch will set a Topology Change flag in its normal BPDUs
  11. Three types of BPDU
  • Configuration BPDU [CBPDU]
  • Topology change notification [TCN]
  • Topology change notification acknowledgement [TCA]

Wednesday, April 7, 2010

Perl:: deleting log files older than 'N' days

#!/usr/bin/perl -w

use strict;

# Script to delete the files older than "N" days.

# The directory to be cleaned up.(e.g ' ' means current directory)

my $DIR='';

# The age of file to be deleted. (e.g if given 2, files older than two days will get deleted)

my $life=2;

# File format to be matched can be enhanced. formats are seperated by whitespace

foreach my $t (glob("$DIR*.pl_* $DIR*stc $DIR*tcl $DIR*topo"))


my $age =int(-M $t);

if($age > $life)


print "$t is " . $age . " days old. Hence deleting it...\n";

unlink $t;