# OSPF的网络5种接口类型,适应不同拓扑结构
IOU4(config-if)#ip ospf network ?
  broadcast            Specify OSPF broadcast multi-access network
  non-broadcast        Specify OSPF NBMA network
  point-to-multipoint  Specify OSPF point-to-multipoint network
  point-to-point       Specify OSPF point-to-point network
IOU4(config-if)#ip ospf network point-to-multipoint ?
  non-broadcast  Specify non-broadcast point-to-mpoint network
  
网络接口类型    二层封装    Hello/Dead     DR/BDR    主动Hello    /32主机路由    
P2P        PPP/HDLC/FR-P2Psub  10/40          N           Y             N
Broadcast       ETH/FDDI       10/40          Y           N             N
NBMA         FR/ATM/X.25       30/120         Y           N             N
P2mp          hub/spoke        30/120         N           Y             Y
P2mp nb(思科)hub/spoke        30/120         N           N             Y 

#  NBMA网络类型
# 1、帧中继配置需要配置frame-relay map ip broadcast,可以选择是否接收broadcast;
# 2、NBMA网络中ospf为单播报文,配置neighbor命令,邻居状态为ATTEMPT
# 3、DR只能配置在hub,spoke配置priority为0;
#  4、问题:拓扑结构由Hub-spoke,转变为full-mesh结构,无法直接反映结构类型

# NBMA配置案例
IOU2#sh run int s2/0
interface Serial2/0
 ip address 10.1.234.2 255.255.255.0
 encapsulation frame-relay
 ip ospf network point-to-multipoint
 serial restart-delay 0
 frame-relay map ip 10.1.234.3 204 broadcast
 frame-relay map ip 10.1.234.4 204 broadcast
 no frame-relay inverse-arp

IOU3#sh run int s2/0
interface Serial2/0
 ip address 10.1.234.3 255.255.255.0
 encapsulation frame-relay
 ip ospf network point-to-multipoint
 serial restart-delay 0
 frame-relay map ip 10.1.234.2 304 broadcast
 frame-relay map ip 10.1.234.4 304 broadcast
 no frame-relay inverse-arp

IOU4#sh run int s2/0
interface Serial2/0
 ip address 10.1.234.4 255.255.255.0
 encapsulation frame-relay
 serial restart-delay 0
 frame-relay map ip 10.1.234.2 402 broadcast
 frame-relay map ip 10.1.234.3 403 broadcast
 no frame-relay inverse-arp
 
IOU4#sh run | b r o
router ospf 1
 router-id 4.4.4.4
 network 10.1.4.4 0.0.0.0 area 0
 network 10.1.45.0 0.0.0.255 area 1
 network 10.1.234.0 0.0.0.255 area 0
 neighbor 10.1.234.3
 neighbor 10.1.234.2

# 邻居状态会出现ATTEMPT
IOU4#sh ip ospf neighbor
Neighbor ID     Pri   State           Dead Time   Address         Interface
N/A               0   ATTEMPT/DROTHER 00:01:37    10.1.234.2      Serial2/0
N/A               0   ATTEMPT/DROTHER 00:01:43    10.1.234.3      Serial2/0
5.5.5.5           0   FULL/  -        00:00:36    10.1.45.5       Serial2/1

# 问题:NBMA网络为full-mesh连接,与拓扑结构hub-spoke不一致;
IOU2#sh ip ro 10.1.234.3
Routing entry for 10.1.234.0/24
  Known via "connected", distance 0, metric 0 (connected, via interface)
  Routing Descriptor Blocks:
  * directly connected, via Serial2/0
      Route metric is 0, traffic share count is 1

IOU3#sh ip ro 10.1.234.2
Routing entry for 10.1.234.0/24
  Known via "connected", distance 0, metric 0 (connected, via interface)
  Routing Descriptor Blocks:
  * directly connected, via Serial2/0
      Route metric is 0, traffic share count is 1
# P2MP网络类型
# 帧中继Hub-spoke网络中 配置frame-relay map ip和OSPF协议配置量为n*n;
# P2MP网络中,POINT_TO_MULTIPOINT 类型配置量为3n,不用配置其他spoke的frame-relay,大大降低配置量; 
# POINT_TO_MULTIPOINT ,不需要配置neighbor,spoke的frame-relay

# P2MP配置案例 (P2MP+P2MP)
IOU2#sh run int s2/0
interface Serial2/0
 ip address 10.1.234.2 255.255.255.0
 encapsulation frame-relay
 ip ospf network point-to-multipoint
 serial restart-delay 0
 frame-relay map ip 10.1.234.4 204 broadcast
 no frame-relay inverse-arp

IOU3#sh run int s2/0
interface Serial2/0
 ip address 10.1.234.3 255.255.255.0
 encapsulation frame-relay
 ip ospf network point-to-multipoint
 serial restart-delay 0
 frame-relay map ip 10.1.234.4 304 broadcast
 no frame-relay inverse-arp

IOU4#sh run int s2/0
interface Serial2/0
 ip address 10.1.234.4 255.255.255.0
 encapsulation frame-relay
 ip ospf network point-to-multipoint
 serial restart-delay 0
 frame-relay map ip 10.1.234.2 402 broadcast
 frame-relay map ip 10.1.234.3 403 broadcast
 no frame-relay inverse-arp

IOU4#sh run | b r o
router ospf 1
 router-id 4.4.4.4
 network 10.1.4.4 0.0.0.0 area 0
 network 10.1.45.0 0.0.0.255 area 1
 network 10.1.234.0 0.0.0.255 area 0

# P2MP网络不选举DR,链路类型为P2P
IOU4#sh ip ospf neighbor 
Neighbor ID     Pri   State           Dead Time   Address         Interface
2.2.2.2           0   FULL/  -        00:01:37    10.1.234.2      Serial2/0
3.3.3.3           0   FULL/  -        00:01:37    10.1.234.3      Serial2/0
5.5.5.5           0   FULL/  -        00:00:32    10.1.45.5       Serial2/1

# P2MP网络结构类型为hub-spoke类型,与拓扑结构一致
IOU2#sh ip ro 10.1.234.3
Routing entry for 10.1.234.3/32
  Known via "ospf 1", distance 110, metric 128, type intra area
  Last update from 10.1.234.4 on Serial2/0, 00:05:17 ago
  Routing Descriptor Blocks:
  * 10.1.234.4, from 3.3.3.3, 00:05:17 ago, via Serial2/0
      Route metric is 128, traffic share count is 1

IOU3#sh ip ro 10.1.234.2
Routing entry for 10.1.234.2/32
  Known via "ospf 1", distance 110, metric 128, type intra area
  Last update from 10.1.234.4 on Serial2/0, 00:05:38 ago
  Routing Descriptor Blocks:
  * 10.1.234.4, from 2.2.2.2, 00:05:38 ago, via Serial2/0
      Route metric is 128, traffic share count is 1
      
# POINT_TO_MULTIPOINT原理:改变路由下一跳地址,通过递归计算到目的地址;
IOU2#sh ip ro
      10.0.0.0/8 is variably subnetted, 11 subnets, 2 masks
O        10.1.1.1/32 [110/11] via 10.1.123.1, 01:25:55, Ethernet0/0
C        10.1.2.0/24 is directly connected, Loopback0
L        10.1.2.2/32 is directly connected, Loopback0
O        10.1.3.3/32 [110/65] via 10.1.234.3, 00:15:56, Serial2/0   # 下一跳地址为目的spoke地址:10.1.234.3
O        10.1.4.4/32 [110/65] via 10.1.234.4, 00:16:01, Serial2/0
O IA     10.1.5.5/32 [110/129] via 10.1.234.4, 00:16:01, Serial2/0
O IA     10.1.45.0/24 [110/128] via 10.1.234.4, 00:16:01, Serial2/0
C        10.1.123.0/24 is directly connected, Ethernet0/0
L        10.1.123.2/32 is directly connected, Ethernet0/0
C        10.1.234.0/24 is directly connected, Serial2/0
L        10.1.234.2/32 is directly connected, Serial2/0

IOU2#sh ip route
      10.0.0.0/8 is variably subnetted, 13 subnets, 2 masks
O        10.1.1.1/32 [110/11] via 10.1.123.1, 01:46:14, Ethernet0/0
C        10.1.2.0/24 is directly connected, Loopback0
L        10.1.2.2/32 is directly connected, Loopback0
O        10.1.3.3/32 [110/129] via 10.1.234.4, 00:07:36, Serial2/0  # 下一跳地址为hub地址:10.1.234.4
O        10.1.4.4/32 [110/65] via 10.1.234.4, 00:07:36, Serial2/0
O IA     10.1.5.5/32 [110/129] via 10.1.234.4, 00:07:36, Serial2/0
O IA     10.1.45.0/24 [110/128] via 10.1.234.4, 00:07:36, Serial2/0
C        10.1.123.0/24 is directly connected, Ethernet0/0
L        10.1.123.2/32 is directly connected, Ethernet0/0
C        10.1.234.0/24 is directly connected, Serial2/0
L        10.1.234.2/32 is directly connected, Serial2/0
O        10.1.234.3/32 [110/128] via 10.1.234.4, 00:07:36, Serial2/0
O        10.1.234.4/32 [110/64] via 10.1.234.4, 00:07:36, Serial2/0
#  P2MP配置案例(P2P +  P2MP),有问题待验证
#  将spoke节点R2和R3的网络类型由P2MP改为P2P
IOU2#sh run int s2/0
interface Serial2/0
 ip address 10.1.234.2 255.255.255.0
 encapsulation frame-relay
 ip ospf network point-to-point      # 网络类型 point-to-point
 serial restart-delay 0
 frame-relay map ip 10.1.234.4 204 broadcast
 no frame-relay inverse-arp

IOU3#sh run int s2/0
interface Serial2/0
 ip address 10.1.234.3 255.255.255.0
 encapsulation frame-relay
 ip ospf network point-to-point      # 网络类型 point-to-point
 serial restart-delay 0
 frame-relay map ip 10.1.234.4 304 broadcast
 no frame-relay inverse-arp
 
IOU4#sh run int s2/0
interface Serial2/0
 ip address 10.1.234.4 255.255.255.0
 encapsulation frame-relay
 ip ospf network point-to-multipoint  # 网络类型 point-to-multipoint
 serial restart-delay 0
 frame-relay map ip 10.1.234.2 402 broadcast
 frame-relay map ip 10.1.234.3 403 broadcast
 no frame-relay inverse-arp

# P2MP网络实现多节点之间P2P互联,P2P网络仅适用于双节点之间互联
IOU2#sh ip ro 10.1.234.3
Routing entry for 10.1.234.0/24
  Known via "connected", distance 0, metric 0 (connected, via interface)
  Routing Descriptor Blocks:
  * directly connected, via Serial2/0
      Route metric is 0, traffic share count is 1
 
IOU3#sh ip ro 10.1.234.2
Routing entry for 10.1.234.0/24
  Known via "connected", distance 0, metric 0 (connected, via interface)
  Routing Descriptor Blocks:
  * directly connected, via Serial2/0
      Route metric is 0, traffic share count is 1