以太网帧
网络中传输数据时需要定义并遵循一些标准,以太网是根据IEEE802.3标准来管理和控制数据帧的。
IEEE802就是一套用来管理物理数据流在局域网中传输的标准,包括在局域网中传输物理数据的802.3以太网标准。还有一些用来管理物理数据流在使用串行介质的广域网中传输的标准,如帧中继FR(Frame Relay),高级数据链路控制HDLC(High-Level Data Link Control),异步传输模式ATM(Asynchronous Transfer Mode)。
- 分层模型-OSI
以协议作为分层的标准
第七层:表示层
第六层:会话层
第五层:会话层
第四层:传输层 单位:segment(段)建立、维护、管理端到端的连接
第三层:网络层 单位:包() IP寻址和路由选择
第二层:数据链路层 单位:帧(Frame) 控制网络层与物理层之间通信
第一层:物理层 单位:比特(bit) 比特流传输
- 数据封装
-
以太二型
-
802.3的格式
这两种类型主要区别在于,Ethernet II型格式中包含一个Type字段,标识以太帧处理完成之后将被发送到哪个上层协议进行处理。IEEE 802.3格式中,同样的位置是长度字段。
image.png
图中的FCS被叫做帧校验和(无法观察到)
Type字段值小于十进制1500帧使用的则是 IEEE802.3格式。 Type字段值若大于等于1536,帧则使用的是Ethernet II型。 以太网中大多数的数据帧使用的是Ethernet II格式。
type类型包含有哪些:IP(0800)、ARP(0806)、PPPoE(8864)、MPLS、IPv6
例如:
IP 0800 则使用的是Ethernet II型
- IEEE802.3帧格式(多用于交换机与交换机之间的封装)
- Length字段定义了Data字段包含的字节数。
- 逻辑链路控制LLC(Logical Link Control)由目的服务访问点DSAP(Destination Service Access Point)、源服务访问点SSAP(Source Service Access Point)和Control字段组成。
- SNAP (Sub-network Access Protocol)由机构代码(Org Code)和类型(Type)字段组成。Org Code三个字节都为0.Type字段的含义与Ethernet II帧中的Type字段相同。
- 数据帧传输
以太网的帧传输是基于MAC地址进行传输的。还有其他协议(FR帧中继依靠的是DLCI进行传输、PPP和HDLC是基于点到点的网络设计不需要依赖即可发送)
- 以太网的MAC地址
MAC地址由两部分组成,分别是供应商代码和序列号。其中前24位代表该供应商代码,由IEEE管理和分配。剩下的24位序列号由厂商自己分配。
局域网中的帧可以通过三种方式发送。第一种是单播(组播、和广播),指从单一的源端发送到单一目的的端。每个主机接口由一个MAC地址唯一表示,MAC地址的OUI中,第一个字节第8个比特表示地址类型。对于主机MAC地址,这个比特固定为0,表示目的MAC地址为此MAC地址的帧都是发送到某个唯一的目的端。
单播实验:
在两个路由器配置好ip地址后ping对端,对数据包进行分析查看获取到以太网帧,对目的MAC地址进行观察。进行分析是否属于单播?

- 获取到的目的MAC地址:00:e0:fc:bf:09:40
- 取得第一个字节为:00
- 换算为二进制则为:0
- 取第最后一位则为:0
- 可以证明地址MAC地址为单播。

这里01转成二进制也是01,也就是组播。

广播的mac地址则全为ff,如ARP协议。
经典组播MAC:01005E
IP的基础
- IP编址
- IP地址氛围网络部分和主机部分。
- IP地址由32个二进制组成,通常用点份十进制形式表示。
一个字段Protocol(占了8个比特),2的八次方
VRP的操作
-
FTP(File Transfer Protocol)文件传输协议。
FTP采用两个TCP连接,控制连接和数据连接。其中控制连接用于连接控制端口(21),传输控制命令。数据连接用于连接数据端口(20),传输数据。在控制连接建立后,数据连接通过控制端口的命令建立起连接,进行数据传输。FTP数据连接的建立有两种:主动模式和被动模式,两者的区别在于数据连接是由服务i发起还是由客户端发起。 -
TFTP(Trivial File Transfer Protocol)是一种简化的文件传输协议。
TFTP协议使用UDP协议进行文件的传输,由客户端发起TFTP传输请求,实现文件的上传和下载。
作业
- 使用两台三层交换,并配置vlan。
- 开启ftp服务。
- 配置新增用户密码。
- 开启三a认证。
- 保存配置。
- 从第二台交换上下载刚才保存的配置。
解答:
- 配置两台三层交换,并使用以太网进行连接,并设置vlanip。
交换机1:
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname wh-sw1
[wh-sw1]interface Vlanif 1
[wh-sw1-Vlanif1]ip address 10.0.0.199 24
[wh-sw1-Vlanif1]display th
Nov 8 2020 00:19:04-08:00 wh-sw1 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 5, the change loop count is 0, and the maximum number of records is 4095.
#
interface Vlanif1
ip address 10.0.0.199 255.255.255.0
#
return
交换机2:
<Huawei>system-view
[Huawei]sysname wh-sw2
[wh-sw2]interface Vlanif 1
[wh-sw2-Vlanif1] ip address 10.0.0.200 255.255.255.0
[wh-sw2-Vlanif1]display this
#
interface Vlanif1
ip address 10.0.0.200 255.255.255.0
#
return
- 测试连通性
[wh-sw1-Vlanif1]ping 10.0.0.200
PING 10.0.0.200: 56 data bytes, press CTRL_C to break
Reply from 10.0.0.200: bytes=56 Sequence=1 ttl=255 time=40 ms
Reply from 10.0.0.200: bytes=56 Sequence=2 ttl=255 time=50 ms
Reply from 10.0.0.200: bytes=56 Sequence=3 ttl=255 time=20 ms
Reply from 10.0.0.200: bytes=56 Sequence=4 ttl=255 time=40 ms
--- 10.0.0.200 ping statistics ---
4 packet(s) transmitted
4 packet(s) received
0.00% packet loss
round-trip min/avg/max = 20/37/50 ms
- 在交换机1上开启ftp服务。
[wh-sw1]ftp server enable
Info: Succeeded in starting the FTP server.
[wh-sw1]display this
#
sysname wh-sw1
#
FTP server enable
#
cluster enable
ntdp enable
ndp enable
#
drop illegal-mac alarm
#
return
- 在交换机1上开启三a认证。
[wh-sw1-aaa]local-user lqh password simple 123
Info: Add a new user.
[wh-sw1-aaa]local-user lqh privilege level 15
# 设置权限等级
[wh-sw1-aaa]local-user lqh ftp-directory flush:
# 设定ftp的目录限制
[wh-sw1-aaa]local-user lqh service-type ftp
# 设定服务的类型
[wh-sw1-aaa]display this
#
aaa
authentication-scheme default
# 认证
authorization-scheme default
# 授权
accounting-scheme default
# 统计
domain default
domain default_admin
local-user lqh password simple 123
# lqh用户认证简单密码123
local-user lqh privilege level 15
# lqh用户权限等级15
local-user lqh ftp-directory flush:
# lqh用户ftp目录
local-user lqh service-type ftp
# lqh用户服务类型
local-user admin password simple admin
local-user admin service-type http
#
return
<wh-sw1>save sw1-config.cfg
Are you sure to save the configuration to flash:/sw1-config.cfg?[Y/N]:y
Now saving the current configuration to the slot 0.
Save the configuration successfully.
<wh-sw1>
Nov 8 2020 00:42:36-08:00 wh-sw1 %%01CFM/4/SAVE_FILE(l)[0]:When deciding whether to save the configuration to the file flash:/sw1-config.cfg, the user chose Y.
<wh-sw1>dir
Directory of flash:/
Idx Attr Size(Byte) Date Time FileName
0 drw- - Aug 01 2012 10:31:23 compatible
1 drw- - Nov 08 2020 00:14:22 src
2 -rw- 1,395 Nov 08 2020 00:42:36 sw1-config.cfg
32,004 KB total (31,968 KB free)
- 在交换机2上进行下载。
<wh-sw2>ftp 10.0.0.199
Trying 10.0.0.199 ...
Press CTRL+K to abort
Connected to 10.0.0.199.
220 FTP service ready.
User(10.0.0.199:(none)):lqh
331 Password required for lqh.
Enter password:
530 Logged fail, authentication directory is incorrect.
# 提示我登陆错误,授权目录不正确
Error: Failed to run this command because the connection was closed by remote host.
- 提示我登陆错误,授权目录不正确,回到交换机1上查看用户lqh的目录授权。(原来是把flash写成了flush)
<wh-sw1>system-view
Enter system view, return user view with Ctrl+Z.
[wh-sw1]aaa
[wh-sw1-aaa]local
[wh-sw1-aaa]dis th
#
aaa
authentication-scheme default
authorization-scheme default
accounting-scheme default
domain default
domain default_admin
local-user lqh password simple 123
local-user lqh privilege level 15
local-user lqh ftp-directory flush:
# 可以看到我flash写成了flush,马上修改回来。
local-user lqh service-type ftp
local-user admin password simple admin
local-user admin service-type http
#
return
[wh-sw1-aaa]
[wh-sw1-aaa]local-user lqh ftp-directory flash:
[wh-sw1-aaa]save
^
Error: Unrecognized command found at '^' position.
[wh-sw1-aaa]
Nov 8 2020 00:47:54-08:00 wh-sw1 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 11, the change loop count is 0, and the maximum number of records is 4095.q
[wh-sw1]q
<wh-sw1>save config.cfg
Are you sure to save the configuration to flash:/config.cfg?[Y/N]:y
Now saving the current configuration to the slot 0.
Save the configuration successfully.
<wh-sw1>
Nov 8 2020 00:48:09-08:00 wh-sw1 %%01CFM/4/SAVE_FILE(l)[2]:When deciding whether to save the configuration to the file flash:/config.cfg, the user chose Y.
- 重新回到交换机2上进行登录尝试下载交换机1的配置文件。
<wh-sw2>ftp 10.0.0.199
Trying 10.0.0.199 ...
Press CTRL+K to abort
Connected to 10.0.0.199.
220 FTP service ready.
User(10.0.0.199:(none)):lqh
331 Password required for lqh.
Enter password:
230 User logged in.
[ftp]dir
200 Port command okay.
150 Opening ASCII mode data connection for *.
drwxrwxrwx 1 noone nogroup 0 Aug 01 2012 compatible
drwxrwxrwx 1 noone nogroup 0 Nov 08 00:14 src
-rwxrwxrwx 1 noone nogroup 1395 Nov 08 00:42 sw1-config.cfg
-rwxrwxrwx 1 noone nogroup 1395 Nov 08 00:48 config.cfg
226 Transfer complete.
[ftp]get sw
[ftp]get sw1-config.cfg
200 Port command okay.
150 Opening ASCII mode data connection for sw1-config.cfg.
226 Transfer complete.
FTP: 1395 byte(s) received in 0.170 second(s) 8.20Kbyte(s)/sec.
[ftp]q
221 Server closing.
<wh-sw2>dir
Directory of flash:/
Idx Attr Size(Byte) Date Time FileName
0 drw- - Aug 01 2012 10:31:23 compatible
1 drw- - Nov 08 2020 00:14:21 src
2 -rw- 1,395 Nov 08 2020 00:49:55 sw1-config.cfg
32,004 KB total (31,968 KB free)
-
下载成功,来看看我们整个ftp的过程。
image.png
image.png
传输控制命令使用21,传输数据采用20号端口。
网友评论