HCIP(网络类型)
网络类型概述
网络类型主要基于数据链路层使用的协议不同,导致数据包封装方式不同,工作方式也有所区别。根据这些特点,网络可以被分类为以下几种类型:
- MA网络(多点接入网络):允许同时接入多台设备进行通讯的网络。
- BMA(广播型多点接入网络):支持广播,常见的传输介质包括网线、光纤、同轴电缆和无线(如Wi-Fi)。
- NBMA(非广播型多点接入网络):不支持广播。
- P2P网络(点对点网络):只允许两个节点互相通讯,不允许接入多个节点设备。常见的例子包括console线路(PC在设备配置时使用)和串线。
网络类型详细信息
- BMA网络:如以太网,使用频分技术进行数据传输。
- P2P网络:由于只存在两台设备,不需要对设备进行区分和标识,因此没有MAC地址也可以进行通讯,也不需要配置IP地址。
<Huawei>display ip interface brief
*down: administratively down
^down: standby
(1): loopback
(s) : spoofing
The number of interface that is UP in Physical is 2
The number of interface that is DOWN in Physical is 4
The number of interface that is UP in Protocol is 2
The number of interface that is DOWN in Protocol is 4
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 unassigned down down
GigabitEthernet0/0/1 unassigned down down
GigabitEthernet0/0/2 unassigned down down
NULLO unassigned up up (s)
Serial4/0/0 unassigned up up
Serial4/0/1 unassigned down down
<Huawei>
- HDLC(高级数据链路控制协议):由ISO组织提出,兼容性较差,在国内很少使用。
查看接口使用的二层协议--必须一致
[Huawei]display interface Serial 4/0/0
Serial4/0/0 current state : UP
Line protocol current state : UP
Last line protocol up time : 2025-04-09 20:38:19 UTC-08:00
Description: HUAWEI, AR Series, Serial4/0/0 Interface
Route Port, The Maximum Transmit Unit is 1500, Hold timer is 10 (sec)
Internet protocol processing : disabled
Link layer protocol is PPP
修改接口二层协议
[Huawei-Serial4/0/0]link-protocol ?
fr Select FR as line protocol
hdlc Enable HDLC protocol
lapb LAPB (X.25 level 2 protocol)
ppp Point-to-Point protocol
sdlc SDLC (Synchronous Data Line Control) protocol
x25 X.25 protocol
[Huawei-Serial4/0/0]link-protocol h
[Huawei-Serial4/0/0]link-protocol hdlc
Warning: The encapsulation protocol of the link will be changed. Continue? [Y/N]
: y
PPP协议
PPP(点对点协议)具有以下特点:
- 兼容性强:只有一个版本的PPP协议,标准统一。
- 支持认证和授权。
- 可移植性强:如PPPOE,常用于广域网接入。
PPP协议传输数据需要先建立逻辑通道(类比TCP),包括以下步骤:
- LCP协商:检测设备和链路是否支持PPP协议传输,协商参数如MRU(最大传输单元)和是否认证。
- 认证(可选):支持单向和双向认证,如PAP(密码认证协议,明文认证,不安全)和CHAP(挑战握手认证)。
- NCP协商:网络层协议协商阶段,如IPCP(IP控制协议),用于协商设备自身的IP地址和报文的压缩格式。
-
Flag:
- Flag 是用于区分不同数据报文的一个特殊字符或比特序列。在许多通信协议中,Flag 用来标识报文的开始、结束或特定部分的边界。例如,在HDLC(高级数据链路控制)协议中,特殊的Flag序列(01111110)用于标识每个帧的开始和结束。
-
Information:
- Information 字段包含实际的传输数据,这些数据可以是用户数据或用于网络通信的协议控制信息。在数据帧中,Information 字段通常位于控制字段(如地址和协议信息)之后,FCS之前。它包含了上层协议的数据包,这些数据包可能被进一步封装和解析。
-
Protocol:
- Protocol 字段用于指示数据帧中封装的上层数据使用的协议类型。例如,在以太网帧中,Type 字段(或Length 字段,取决于帧的长度)用来指示上层是IPv4、IPv6还是其他类型的网络协议数据。这有助于接收设备正确地解封装数据,并向上层协议正确传递。
-
FCS (Frame Check Sequence):
- FCS 是一个错误检测机制,通常用于数据链路层。它是一个附加在数据帧末尾的校验值,用于接收方验证数据在传输过程中是否保持完整性。FCS通常通过循环冗余校验(CRC)算法计算得出。如果接收方计算出的FCS与接收到的FCS不匹配,则表明数据帧在传输过程中可能发生了错误。
IPCP协商:
作用:
-
IP地址管理:IPCP协商可以动态或静态地分配IP地址,确保双方设备在网络层能够正确寻址,可以利用IPCP协商过程来获取公网IP地址。
-
认证和授权:在IPCP协商中可以实施认证机制,确保只有授权的用户可以建立连接。
-
压缩选项:IPCP协商可以启用数据压缩,减少传输的数据量,提高链路效率。
-
网络层参数配置:除了IP地址,IPCP还可以协商其他网络层参数,如MTU(最大传输单元)等。
配置示例
-
一、PPP认证配置
-
认证方配置:
- 进入AAA(认证计费授权)空间创建账号和密码。
- 修改二层协议为PPP,并配置认证模式(PAP或CHAP)。
[isp-Serial4/0/0]link-protocol ppp ----修改二层协议
[isp]aaa
[isp-aaa]local-user huawei password cipher 123456
[isp-aaa]local-user huawei service-type ppp--定义账号服务的协议
[isp-Serial4/0/0]ppp authentication-mode pap
-
被认证方配置:
- 进行认证(拨号),配置PPP认证相关参数。
[bj]interface Serial 4/0/0
[bj-Serial4/0/0]ppp pap local-user huawei password cipher 123456
-
二、CHAP配置:
-
相同输入相同输出:如果两次输入相同的数据,哈希函数将产生相同的输出。
-
不可逆性:从哈希值无法推导出原始数据。
-
雪崩效应:原始数据发生微小变化时,哈希值将发生显著变化。
-
-
认证方配置:
[isp]aaa [isp-aaa]local-user a password cipher 123456 [isp-aaa]local-user a service-type ppp [isp-Serial4/0/0]ppp authentication-mode chap
-
被认证方配置:
[Huawei]interface Serial 4/0/0 [Huawei-Serial4/0/0]ppp chap user a [Huawei-Serial4/0/0]ppp chap password cipher 123456
-
三、ISP端配置:
[isp]interface Serial 4/0/0 [isp-Serial4/0/0]ip address 12.0.0.2 24 [isp-Serial4/0/0]remote address 12.0.0.1
-
四、边界设备配置:
[Huawei-Serial4/0/0]ip address ppp-negotiate
(1): loopback (s) : spoofing The number of interface that is UP in Physical is 2 The number of interface that is DOWN in Physical is 4 The number of interface that is UP in Protocol is 2 The number of interface that is DOWN in Protocol is 4 Interface IP Address/Mask Physical Protocol GigabitEthernet0/0/0 unassigned down down GigabitEthernet0/0/1 unassigned down down GigabitEthernet0/0/2 unassigned down down NULLO unassigned up up (s) Serial4/0/0 12.0.0.1/32 up up Serial4/0/1 unassigned down down
-
在IPCP协商过程中设备会自动生成一条主机路由(指向对端设备IP地址 的路由--掩码为32的路由仅代表一个IP地址),所以允许P2P网络一段链路配置不同网段的IP地址
Huawei]display ip routing-table Route Flags: R - relay, D - download to fib Routing Tables: Public Destinations : 7 Routes : 7 Destination/Mask Proto Pro Cost Flags NextHop Interface 0.0.0.0/0 Static 60 0 RD 12.0.0.2 Serial4/0/0 12.0.0.2/32 Direct 0 0 D 12.0.0.2 Serial4/0/0 23.0.0.1/32 Direct 0 0 D 127.0.0.1 Serial4/0/0 127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0 127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0 27.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0 255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0