OSPF-1

  • Config OSPF
  • Introducing the  OSPF Protocol
    Link-State Protocols
    1、范围(IGP)
    2、设计原理(Link-State)
    3、有类和无类( 无类,CIDR)
    封装
    IP OSPF(IP报文封装,Port:89 )
    组播地址:224.0.0.5,224.0.0.6

LSA:链路状态通告。

  • LSDB:Link-State Datebase ------>SPF Algoriithm  SPF Tree ------> Routing Table、
  •  

Link -State Routing Protocols (特点:)

  • Link-state routers reconginze more information about the network than their distance vector counterparts.(比 DV识别更多的信息)
  • Each router has a full picture of the topology.
  • Consequently,link-state routers tend to make more accurate decisions

 

Link-State data Structure:

三张表

  • Neighbor table:
  • Topology table
  • Routing table:

分层化设计

Link-state routing requires a hierachical network structure that is eforced by OSPF.()

This two-level hierarchy consists of the following:

  • --Transit area (backbone or area 0)(三个区域)
  • -- Regular areas (nonbackbons areas)

OSPF area characteristics:

  • Minimizes routing table entries(减少路由条目)【域间汇总】
  • Localizes impact of a topology change within an area【本地拓扑变化,只会影响到本地区域】
  • Detailed LSA flooding stops at the area boundary
  • Requires a hierarchical network design

Routers A ang B are backbone router

Routers C,D,and E are known as area border routers(ABRS)

ABRS attach all other areas to area0.

OSPF Adjacencies

  • Routers disover neighbors by exchanging hello packets.
  • Router declare neghbors to be up after checking certain parameters or options in the helllo packet.

Forming OSPF Adjacencies

邻居邻接的区别

邻居(hello),邻接的区别(交互lsa)

  • Point-to-point WAN links:

               --Both neighbors become fully adjacent.

  • LAN links:

                    1, BMA(LAN),2 ,NBMA(帧中继)

               --Neighbors form a full adjacency with the DR(指定路由器Designated ) and BDR

                       减少LSA数量,

               --Routers maintain two-way state with the other routers (DROTHERs)

  • Routing updates and topology information are passed only between adjacent routers.
  • Once an adjacency is formed,LSDBs are synchronized by exchanging LSAs.
  • LSAs are flooded reliable throughout the area (or network)

OSPF Calculation

Routers find find the best paths to destinations by applying Dijkstra's SPF algorithmto the link-state database as  follows:

  • Every router in an area has the identical(一致) link-state database
  • Each router in the area places It self into the root of the tree that is built.
  • The best path is calculated with respect ot the lowest total cost of links to a specific destination.
  • Best routes are put into the forwarding database(routing table)

 

  • 触发更新
  • 周期性

OSPF:触发更新,每30分钟更新,60分钟删除。

LSA Sequence Numbering

  • Each LSA In the LSDB maintains a sequence number:
  • The sequence numbering scheme is a 4-byte number that begins with 0x80000001 and ends with 0xF7FFFFFF.
  • OSPF floods each LSA every 30 minutes to maintain proper database synchronization.Each time the LSA is flooded,the sequence number si incremented by one.
  • Ultimately,an LSA sequence number will wrap around to 0x80000001.When this occurs,the existing LSA is prematurely aged to the maximum age(one hour) and flushed.
  • When a router encounters two instances of an LSA,It must determine which is more recnet.The LSA having the newer(higher)LS a sequence number is more recent.

序列号算法

               线性 问题,有最大值

               圆形

               棒棒糖

 

OSPF Packet Types

  • Hello(没有确认)
  • Database Description(隐式确认)

           OSPF应用在中大型网络中,先传摘要信息,节省带宽

  • Link-State Request
  • Link-state Update
  • Link-State Acknowlegment LSACK(显式确认)

显式确认,隐式确认。

OSPF Packet Header Format

Version :V2,V3

Type:

Router ID(标识OSPF的一台路由器)

Router-ID选举方式:

  1. 手工指定(任意,唯一,)
  2. LoopBack口最大的IP地址。
  3. 物理接口最大IP地址.

认证类型

  • 明文
  • MD5

Data

      1,

      2,

      3,

      4,

      5,

Hello

10s 或 30s。dead 时间 乘以4 

邻居建立 4个必须相同

 

Establishing Bidirectional Communication

A进入Two-Way State

主/从关系 First DBD,隐式确认

Down State-->init State-->Two-Way State-->Exstart State-->Exchange State-->Loading state -->Full State

Exstart State阶段主从关系,First DBD

DBD报文三个字段

                 I|M|M/S

          Initi               More                     Master/Slave

 

示例

R1(config-router)#network 12.1.1.0 0.0.0.255 area ?
  <0-4294967295>  OSPF area ID as a decimal value
  A.B.C.D         OSPF area ID in IP address format
  • 0.0.0.0=0
  • 0..0.0.1 =1
  • 0.0.0.255=255
  • 0.0.1.0=265

 

R1#debug ip ospf packet 
R1#debug ip ospf adj 
OSPF adjacency events debugging is on

R1调试信息

*Apr  8 06:51:21.959: %LINK-3-UPDOWN: Interface Serial2/0, changed state to up
*Apr  8 06:51:22.959: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial2/0, changed state to up
*Apr  8 06:51:22.959: OSPF: Serial2/0: Route adjust notification: UP/UP
*Apr  8 06:51:22.959: OSPF: Interface Serial2/0 going Up
*Apr  8 06:51:22.959: OSPF: Serial2/0: Interface state change to UP, new ospf state P2P
*Apr  8 06:51:22.971: OSPF: rcv. v:2 t:1 l:48 rid:2.2.2.2
      aid:0.0.0.0 chk:E694 aut:0 auk: from Serial2/0
*Apr  8 06:51:22.971: OSPF: 2 Way Communication to 2.2.2.2 on Serial2/0, state 2WAY
*Apr  8 06:51:22.971: OSPF: Serial2/0 Nbr 2.2.2.2: Prepare dbase exchange
*Apr  8 06:51:22.971: OSPF: Send DBD to 2.2.2.2 on Serial2/0 seq 0xDDB opt 0x52 flag 0x7 len 32
*Apr  8 06:51:22.979: OSPF: rcv. v:2 t:2 l:32 rid:2.2.2.2
      aid:0.0.0.0 chk:A053 aut:0 auk: from Serial2/0
*Apr  8 06:51:22.983: OSPF: Rcv DBD from 2.2.2.2 on Serial2/0 seq 0x1A3 opt 0x52 flag 0x7 len 32  mtu 1500 state EXSTART
*Apr  8 06:51:22.983: OSPF: NBR Negotiation Done. We are the SLAVE
*Apr  8 06:51:22.983: OSPF: Serial2/0 Nbr 2.2.2.2: Summary list built, size 2
*Apr  8 06:51:22.983: OSPF: Send DBD to 2.2.2.2 on Serial2/0 seq 0x1A3 opt 0x52 flag 0x2 len 72
*Apr  8 06:51:22.999: OSPF: rcv. v:2 t:2 l:72 rid:2.2.2.2
      aid:0.0.0.0 chk:1F78 aut:0 auk: from Serial2/0
*Apr  8 06:51:23.003: OSPF: Rcv DBD from 2.2.2.2 on Serial2/0 seq 0x1A4 opt 0x52 flag 0x1 len 72  mtu 1500 state EXCHANGE
*Apr  8 06:51:23.003: OSPF: Exchange Done with 2.2.2.2 on Serial2/0
*Apr  8 06:51:23.003: OSPF: Send LS REQ to 2.2.2.2 length 12 LSA count 1
*Apr  8 06:51:23.003: OSPF: Send DBD to 2.2.2.2 on Serial2/0 seq 0x1A4 opt 0x52 flag 0x0 len 32
*Apr  8 06:51:23.011: OSPF: rcv. v:2 t:4 l:64 rid:2.2.2.2
      aid:0.0.0.0 chk:9A0 aut:0 auk: from Serial2/0
*Apr  8 06:51:23.015: OSPF: Rcv LS UPD from 2.2.2.2 on Serial2/0 length 64 LSA count 1
*Apr  8 06:51:23.015: OSPF: Synchronized with 2.2.2.2 on Serial2/0, state FULL
*Apr  8 06:51:23.015: %OSPF-5-ADJCHG: Process 110, Nbr 2.2.2.2 on Serial2/0 from LOADING to FULL, Loading Done

 R2调试信息

*Apr  8 06:51:15.683: %LINK-3-UPDOWN: Interface Serial2/0, changed state to up
*Apr  8 06:51:16.687: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial2/0, changed state to up
*Apr  8 06:51:16.691: OSPF: Serial2/0: Route adjust notification: UP/UP
*Apr  8 06:51:16.691: OSPF: Interface Serial2/0 going Up
*Apr  8 06:51:16.691: OSPF: Serial2/0: Interface state change to UP, new ospf state P2P
R2(config-if)#
*Apr  8 06:51:17.195: OSPF: Build router LSA for area 0, router ID 2.2.2.2, seq 0x80000003, process 110
R2(config-if)#
*Apr  8 06:51:23.491: OSPF: rcv. v:2 t:1 l:44 rid:1.1.1.1
      aid:0.0.0.0 chk:EA9C aut:0 auk: from Serial2/0
*Apr  8 06:51:23.503: OSPF: rcv. v:2 t:2 l:32 rid:1.1.1.1
      aid:0.0.0.0 chk:961D aut:0 auk: from Serial2/0
*Apr  8 06:51:23.503: OSPF: Rcv DBD from 1.1.1.1 on Serial2/0 seq 0xDDB opt 0x52 flag 0x7 len 32  mtu 1500 state INIT
*Apr  8 06:51:23.503: OSPF: 2 Way Communication to 1.1.1.1 on Serial2/0, state 2WAY
*Apr  8 06:51:23.503: OSPF: Serial2/0 Nbr 1.1.1.1: Prepare dbase exchange
*Apr  8 06:51:23.503: OSPF: Send DBD to 1.1.1.1 on Serial2/0 seq 0x1A3 opt 0x52 flag 0x7 len 32
*Apr  8 06:51:23.503: OSPF: First DBD and we are not SLAVE
*Apr  8 06:51:23.503: OSPF: rcv. v:2 t:1 l:48 rid:1.1.1.1
      aid:0.0.0.0 chk:E694 aut:0 auk: from Serial2/0
*Apr  8 06:51:23.515: OSPF: rcv. v:2 t:2 l:72 rid:1.1.1.1
      aid:0.0.0.0 chk:67B9 aut:0 auk: from Serial2/0
*Apr  8 06:51:23.519: OSPF: Rcv DBD from 1.1.1.1 on Serial2/0 seq 0x1A3 opt 0x52 flag 0x2 len 72  mtu 1500 state EXSTART
*Apr  8 06:51:23.519: OSPF: NBR Negotiation Done. We are the MASTER
*Apr  8 06:51:23.519: OSPF: Serial2/0 Nbr 1.1.1.1: Summary list built, size 2
*Apr  8 06:51:23.519: OSPF: Send DBD to 1.1.1.1 on Serial2/0 seq 0x1A4 opt 0x52 flag 0x1 len 72
*Apr  8 06:51:23.535: OSPF: rcv. v:2 t:3 l:36 rid:1.1.1.1
      aid:0.0.0.0 chk:F3CD aut:0 auk: from Serial2/0
*Apr  8 06:51:23.535: OSPF: Rcv LS REQ from 1.1.1.1 on Serial2/0 length 36 LSA count 1
*Apr  8 06:51:23.535: OSPF: Send UPD to 12.1.1.1 on Serial2/0 length 40 LSA count 1
*Apr  8 06:51:23.535: OSPF: rcv. v:2 t:2 l:32 rid:1.1.1.1
      aid:0.0.0.0 chk:A25B aut:0 auk: from Serial2/0
*Apr  8 06:51:23.539: OSPF: Rcv DBD from 1.1.1.1 on Serial2/0 seq 0x1A4 opt 0x52 flag 0x0 len 32  mtu 1500 state EXCHANGE
*Apr  8 06:51:23.539: OSPF: Exchange Done with 1.1.1.1 on Serial2/0
*Apr  8 06:51:23.539: OSPF: Send LS REQ to 1.1.1.1 length 12 LSA count 1
*Apr  8 06:51:23.555: OSPF: rcv. v:2 t:4 l:52 rid:1.1.1.1
      aid:0.0.0.0 chk:78D aut:0 auk: from Serial2/0
*Apr  8 06:51:23.559: OSPF: Rcv LS UPD from 1.1.1.1 on Serial2/0 length 52 LSA count 1
*Apr  8 06:51:23.559: OSPF: Synchronized with 1.1.1.1 on Serial2/0, state FULL
*Apr  8 06:51:23.559: %OSPF-5-ADJCHG: Process 110, Nbr 1.1.1.1 on Serial2/0 from LOADING to FULL, Loading Done
R2(config-if)#
*Apr  8 06:51:23.559: OSPF: Serial2/0 Nbr 1.1.1.1: Clean-up dbase exchange
*Apr  8 06:51:23.991: OSPF: rcv. v:2 t:4 l:76 rid:1.1.1.1
      aid:0.0.0.0 chk:4265 aut:0 auk: from Serial2/0
*Apr  8 06:51:24.059: OSPF: Build router LSA for area 0, router ID 2.2.2.2, seq 0x80000004, process 110
R2(config-if)#
*Apr  8 06:51:26.047: OSPF: rcv. v:2 t:5 l:64 rid:1.1.1.1
      aid:0.0.0.0 chk:DEC8 aut:0 auk: from Serial2/0
R2(config-if)#
*Apr  8 06:51:33.027: OSPF: rcv. v:2 t:1 l:48 rid:1.1.1.1
      aid:0.0.0.0 chk:E694 aut:0 auk: from Serial2/0
R2(config-if)#
*Apr  8 06:51:43.023: OSPF: rcv. v:2 t:1 l:48 rid:1.1.1.1
      aid:0.0.0.0 chk:E694 aut:0 auk: from Serial2/0

查看哪些接口运行OSPF

R1#show ip ospf interface
Serial2/0 is up, line protocol is up 
  Internet Address 12.1.1.1/24, Area 0 
  Process ID 110, Router ID 1.1.1.1, Network Type POINT_TO_POINT, Cost: 64
  Topology-MTID    Cost    Disabled    Shutdown      Topology Name
        0           64        no          no            Base
  Transmit Delay is 1 sec, State POINT_TO_POINT
  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
    oob-resync timeout 40
    Hello due in 00:00:04
  Supports Link-local Signaling (LLS)
  Cisco NSF helper support enabled
  IETF NSF helper support enabled
  Index 1/1, flood queue length 0
  Next 0x0(0)/0x0(0)
  Last flood scan length is 1, maximum is 1
  Last flood scan time is 0 msec, maximum is 0 msec
  Neighbor Count is 1, Adjacent neighbor count is 1 
    Adjacent with neighbor 2.2.2.2
  Suppress hello for 0 neighbor(s)
R1#show ip ospf interface brief
Interface    PID   Area            IP Address/Mask    Cost  State Nbrs F/C
Lo1          110   0               1.1.1.1/24         1     LOOP  0/0
Se2/0        110   0               12.1.1.1/24        64    P2P   1/1

Cost计算

Cost=10^8/BW(bps)

10Mbps =10*10^6bps=10000000bps

10^8/(10*10^6 )=10

1.544M = 1.544*10^6    ------>10^8/(1.544*10^6 )----->100/1.544------>64.7668394

 

R1#show ip route 
      1.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        1.1.1.0/24 is directly connected, Loopback1
L        1.1.1.1/32 is directly connected, Loopback1
      2.0.0.0/32 is subnetted, 1 subnets
O        2.2.2.2 [110/65] via 12.1.1.2, 00:05:25, Serial2/0
      12.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        12.1.1.0/24 is directly connected, Serial2/0
L        12.1.1.1/32 is directly connected, Serial2/0

环回口被宣进OSPF 不管掩码是多少位,收到的路由都是32位。

 

R2(config-if)#ip ospf network point-to-point //还原lookback掩码真实信息。

R1#sho ip route 
      1.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        1.1.1.0/24 is directly connected, Loopback1
L        1.1.1.1/32 is directly connected, Loopback1
      2.0.0.0/24 is subnetted, 1 subnets
O        2.2.2.0 [110/65] via 12.1.1.2, 05:12:09, Serial2/0
      12.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        12.1.1.0/24 is directly connected, Serial2/0
L        12.1.1.1/32 is directly connected, Serial2/0

 更改接口hello时间

R1(config)#int s2/0
R1(config-if)#ip osp
R1(config-if)#ip ospf hello-interval ?
  <1-65535>  Seconds

R1(config-if)#ip ospf hello-interval 6

 

R1#show ip ospf neighbor 

Neighbor ID     Pri   State           Dead Time   Address         Interface
2.2.2.2           0   FULL/  -        00:00:09    12.1.1.2        Serial2/0
R1#show ip ospf neighbor 

Neighbor ID     Pri   State           Dead Time   Address         Interface
2.2.2.2           0   FULL/  -        00:00:05    12.1.1.2        Serial2/0
R1#show ip ospf neighbor 

Neighbor ID     Pri   State           Dead Time   Address         Interface
2.2.2.2           0   FULL/  -        00:00:04    12.1.1.2        Serial2/0
R1#show ip ospf neighbor 

Neighbor ID     Pri   State           Dead Time   Address         Interface
2.2.2.2           0   FULL/  -        00:00:03    12.1.1.2        Serial2/0
R1#show ip ospf neighbor 

Neighbor ID     Pri   State           Dead Time   Address         Interface
2.2.2.2           0   FULL/  -        00:00:01    12.1.1.2        Serial2/0
R1#show ip ospf neighbor 

R1#
*Apr  8 12:55:39.818: %OSPF-5-ADJCHG: Process 110, Nbr 2.2.2.2 on Serial2/0 from FULL to DOWN, Neighbor Down: Dead timer expired

邻居消失

 

Maintaining Routing Information

DR的选举方法:

       1、较大的priority(default=1)

       2、较大的Router-ID

 

1.1.1.255 哪个大 1.1.2.1  1.1.2.1大

示例

R1#show ip ospf neighbor 

Neighbor ID     Pri   State           Dead Time   Address         Interface
2.2.2.2           1   FULL/DR         00:00:32    100.1.1.2       Ethernet0/0

 

R2#show ip ospf neighbor 

Neighbor ID     Pri   State           Dead Time   Address         Interface
1.1.1.1           1   FULL/BDR        00:00:33    100.1.1.1       Ethernet0/0
R1#sho ip ospf neighbor 

Neighbor ID     Pri   State           Dead Time   Address         Interface
2.2.2.2           1   FULL/DR         00:00:37    100.1.1.2       Ethernet0/0
R1(config)#int e0/0
R1(config-if)#ip os
R1(config-if)#ip ospf prio
R1(config-if)#ip ospf priority ?
  <0-255>  Priority

 将e/0优先级设置为3

R1(config-if)#ip ospf priority 3

 DRi没有变

R1#sho ip ospf neighbor 

Neighbor ID     Pri   State           Dead Time   Address         Interface
2.2.2.2           1   FULL/DR         00:00:37    100.1.1.2       Ethernet0/0

 R1 的Pri已经改为3

R2#show ip ospf neighbor 

Neighbor ID     Pri   State           Dead Time   Address         Interface
1.1.1.1           3   FULL/BDR        00:00:32    100.1.1.1       Ethernet0/0

 

新增加一台路由器,DR,BDR不改变

R3#show ip ospf neighbor 

Neighbor ID     Pri   State           Dead Time   Address         Interface
1.1.1.1           3   FULL/BDR        00:00:39    100.1.1.1       Ethernet0/0
2.2.2.2           1   FULL/DR         00:00:32    100.1.1.2       Ethernet0/0
R3(config-if)#ip ospf priority 7

模拟R2路由器down

确认配置生效,R3的Pri已改为7

R2#show ip ospf neighbor 

Neighbor ID     Pri   State           Dead Time   Address         Interface
1.1.1.1           3   FULL/BDR        00:00:34    100.1.1.1       Ethernet0/0
3.3.3.3           7   FULL/DROTHER    00:00:33    100.1.1.3       Ethernet0/0

 关闭R2的e0/0接口

R2(config)#int e0/0
R2(config-if)#shutdown

 R1为DR

R3#show ip ospf neighbor 

Neighbor ID     Pri   State           Dead Time   Address         Interface
1.1.1.1           3   FULL/DR         00:00:34    100.1.1.1       Ethernet0/0

 查看R2的状态,为BDR

R3#show ip ospf interface Ethernet 0/0
Ethernet0/0 is up, line protocol is up 
  Internet Address 100.1.1.3/24, Area 0 
  Process ID 110, Router ID 3.3.3.3, Network Type BROADCAST, Cost: 10
  Topology-MTID    Cost    Disabled    Shutdown      Topology Name
        0           10        no          no            Base
  Transmit Delay is 1 sec, State BDR, Priority 7
  Designated Router (ID) 1.1.1.1, Interface address 100.1.1.1
  Backup Designated router (ID) 3.3.3.3, Interface address 100.1.1.3
  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
    oob-resync timeout 40
    Hello due in 00:00:04
  Supports Link-local Signaling (LLS)
  Cisco NSF helper support enabled
  IETF NSF helper support enabled
  Index 1/1, flood queue length 0
  Next 0x0(0)/0x0(0)
  Last flood scan length is 1, maximum is 1
  Last flood scan time is 0 msec, maximum is 0 msec
  Neighbor Count is 1, Adjacent neighbor count is 1 
    Adjacent with neighbor 1.1.1.1  (Designated Router)
  Suppress hello for 0 neighbor(s)

 选择特点

1、不抢占

2、当DR Down BDR->DR,重新选举BDR.

3、DR,BDR DROTHER 是一个接口概念。

4、不同网段,分别选DR.

clear ip ospf process//清进程。

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值