①数据链路的建立,维护与拆除
②帧包装,帧传输,帧同步
③帧的差错恢复
④流量控制
MAC地址为48位,前24位供应商标识,后24位是供应商对网卡的唯一编号。第8位为0是单播,1是组播,全为1是广播
前导码:同步时钟
帧起始定界符:告诉别人开始传输数据
目的mac地址:想去的mac地址
源mac地址:自己的mac地址
类型:标识上层协议,例如0800表示ip协议
帧校验序列(FCS):循环冗余校验
①初始状态
②MAC地址学习
③广播未知数据帧
④接收方回应
⑤交换机实现单播通信
单工:只能沿单一方向传输
半双工:可以双向数据传输,但不能同时进行
全双工:可以双向同时进行数据传输
查看mac地址表
[sw1]display mac-add
MAC address table of slot 0:
-------------------------------------------------------------------------------
MAC Address VLAN/ PEVLAN CEVLAN Port Type LSP/LSR-ID
VSI/SI MAC-Tunnel
-------------------------------------------------------------------------------
5489-988a-3ef8 1 - - Eth0/0/1 dynamic 0/-
5489-9816-35e2 1 - - Eth0/0/2 dynamic 0/-
-------------------------------------------------------------------------------
Total matching items on slot 0 displayed = 2
[sw1]
查看mac地址表老化时间及修改mac地址表的老化时间
[sw1]dis mac-add aging-time
Aging time: 300 seconds
[sw1]
[sw1]mac-address aging-time ?
<0,10-1000000> Aging-time seconds, 0 means that MAC aging function does not
work
[sw1]mac-address aging-time 10000
[sw1]dis mac-add aging-time
Aging time: 10000 seconds
[sw1]
0为永不过期
查看指定接口
[sw1]dis int e0/0/1
Ethernet0/0/1 current state : UP
Line protocol current state : UP
Description:
Switch Port, PVID : 1, TPID : 8100(Hex), The Maximum Frame Length is 9216
IP Sending Frames' Format is PKTFMT_ETHNT_2, Hardware address is 4c1f-cce2-0cfe
Last physical up time : 2021-03-30 16:05:22 UTC-08:00
Last physical down time : 2021-03-30 16:05:21 UTC-08:00
Current system time: 2021-03-30 16:34:23-08:00
Hardware address is 4c1f-cce2-0cfe
Last 300 seconds input rate 0 bytes/sec, 0 packets/sec
Last 300 seconds output rate 0 bytes/sec, 0 packets/sec
Input: 1960 bytes, 28 packets
Output: 340855 bytes, 2873 packets
Input:
Unicast: 20 packets, Multicast: 0 packets
Broadcast: 8 packets
Output:
Unicast: 22 packets, Multicast: 2851 packets
Broadcast: 0 packets
Input bandwidth utilization : 0%
Output bandwidth utilization : 0%
[sw1]
查看所有接口
dis int brief
PHY: Physical
*down: administratively down
(l): loopback
(s): spoofing
(b): BFD down
(e): ETHOAM down
(dl): DLDP down
(d): Dampening Suppressed
InUti/OutUti: input utility/output utility
Interface PHY Protocol InUti OutUti inErrors outErrors
Ethernet0/0/1 up up 0% 0% 0 0
Ethernet0/0/2 up up 0% 0% 0 0
Ethernet0/0/3 up up 0% 0% 0 0
Ethernet0/0/4 down down 0% 0% 0 0
Ethernet0/0/5 down down 0% 0% 0 0
Ethernet0/0/6 down down 0% 0% 0 0
Ethernet0/0/7 down down 0% 0% 0 0
Ethernet0/0/8 down down 0% 0% 0 0
Ethernet0/0/9 down down 0% 0% 0 0
Ethernet0/0/10 down down 0% 0% 0 0
Ethernet0/0/11 down down 0% 0% 0 0
Ethernet0/0/12 down down 0% 0% 0 0
Ethernet0/0/13 down down 0% 0% 0 0
Ethernet0/0/14 down down 0% 0% 0 0
Ethernet0/0/15 down down 0% 0% 0 0
Ethernet0/0/16 down down 0% 0% 0 0
Ethernet0/0/17 down down 0% 0% 0 0
Ethernet0/0/18 down down 0% 0% 0 0
Ethernet0/0/19 down down 0% 0% 0 0
Ethernet0/0/20 down down 0% 0% 0 0
Ethernet0/0/21 down down 0% 0% 0 0
Ethernet0/0/22 down down 0% 0% 0 0
GigabitEthernet0/0/1 down down 0% 0% 0 0
GigabitEthernet0/0/2 down down 0% 0% 0 0
MEth0/0/1 down down 0% 0% 0 0
NULL0 up up(s) 0% 0% 0 0
Vlanif1 up down -- -- 0 0
[sw1]
如何配置接口工作模式
[sw1]int e0/0/2
[sw1-Ethernet0/0/2]undo negotiation auto
[sw1-Ethernet0/0/2]duplex full
[sw1-Ethernet0/0/2]speed 100
此时e/0/0/2接口取消自动协商,改成全双工,速率为100m
首先主机想要跟另一台主机通信,需要广播,找谁是1.1.1.2,自己是1.1.1.1。所以源mac是自己的物理mac,目的mac是全为f,然后主机1.1.1.2回应自己是1.1.1.2,所以源mac是1.1.1.2的物理地址,目标mac是1.1.1.1的物理地址。
然后在二层交换机中建立了一个mac地址表。之后1.1.1.1想要找1.1.1.2就直接以单播的形式了。