连网技术2023-04-08

Ethernet Frame以太网帧结构

默认最多1518字节,destination mac+source mac+type+payload+fcs=6+6+2+1500+4=1518。不包含前导码

 

A switch is a networking device that connects devices together on a local area network (LAN). Its primary function is to forward data packets between devices connected to its ports, based on the Media Access Control (MAC) addresses of the devices. When a switch receives a data packet on one of its ports, it looks at the MAC address of the source device, and then forwards the packet to the port associated with the MAC address of the destination device. This helps to ensure that the data packet only goes to the intended recipient, rather than being broadcast to all devices on the network. Switches can also be used to segment a network into smaller parts, which can improve network performance and security.

 

Yes, the source machine must know the MAC address of the destination device in order to send data to it.

When a device wants to communicate with another device on a network, it first checks its own ARP cache to see if it has the MAC address of the destination device. If it doesn't have the MAC address, it sends an ARP request to the network asking for the MAC address of the destination device. The ARP request is broadcast to all devices on the network, and the device with the requested IP address responds with its MAC address. Once the source device has the MAC address of the destination device, it can use this information to construct and send the Ethernet frame with the appropriate source and destination MAC addresses.

When the switch receives this Ethernet frame, it looks at the destination MAC address to determine which port to forward the frame to. If the switch doesn't know the location of the destination MAC address in its MAC address table, it will flood the frame to all ports except the port on which it was received, in order to reach the destination device. Once the destination device responds, the switch will learn the location of the MAC address in its MAC address table, and subsequent frames to that destination will be forwarded directly to the appropriate port.

 

ARP表记录的是ip和mac的映射关系,而switch的mac address table,记录的是port和mac的映射关系。因为每个设备,都是接在交换机的某一个接口上面的。

 

交换机学习

The MAC table, also known as the CAM (Content Addressable Memory) table, is a table in a switch that stores the MAC addresses of devices connected to each of its ports. When a switch receives a packet, it checks the destination MAC address of the packet and searches its MAC table to determine which port the MAC address is associated with. If the MAC address is not found in the table, the switch floods the packet out to all of its ports, except for the port the packet was received on. When the destination device responds, the switch learns its MAC address and updates its MAC table accordingly. This process is known as MAC address learning. The MAC table is important for efficient switching, as it allows the switch to forward packets only to the port that the destination device is connected to, rather than flooding the packet out to all ports.

 

The switch's CAM table is stored in volatile不稳定的,易变的 memory, which means that it is erased when the switch is restarted. Therefore, the switch needs to re-learn the MAC addresses of devices connected to its ports when it starts up again. However, some switches support the option to save the CAM table to non-volatile memory, which allows the switch to retain the MAC address information even after a restart.

 

LAN交换机有三种工作模式:直通模式、存储转发模式和免分片模式。

  1. 直通模式:数据包到达交换机后,直接转发给目标MAC地址,不做任何处理。直通模式是最快的交换机模式,但它并不能检查数据包的错误,因此在不可靠的网络环境中不建议使用。

  2. 存储转发模式:数据包到达交换机后,首先会在交换机内部的缓存中进行校验和修正,然后才会转发给目标MAC地址。这种模式可以避免因数据包错误导致的网络拥塞,同时也可以降低网络延迟,是目前最常用的交换机模式。

  3. 免分片模式:交换机会在接收到数据包时检查其大小,如果数据包大小超过了交换机的缓存或MTU(最大传输单元)值,则会将数据包丢弃。这种模式适用于网络环境稳定的场合,可以有效减少数据包重组的时间,提高网络传输效率。

 

LAN交换机是一种网络设备,可以在局域网中实现数据交换和传输。以下是LAN交换机的主要功能:

  1. 实现局域网内设备之间的通信:交换机可以连接多个设备,将它们连成一个局域网,使得这些设备可以相互通信和交换数据。

  2. 提高数据传输效率:交换机可以对传输过来的数据进行过滤和分类,只把目标设备需要的数据发送给它,避免了广播和冲突等问题,提高了数据传输效率。

  3. 广播处理:当有多个设备需要接收同一份数据时,交换机会把数据广播给所有的端口,使得所有设备都可以接收到该数据。

  4. 网络隔离:交换机可以实现不同网段之间的隔离,避免了不同网段之间的干扰和冲突。

  5. VLAN隔离:交换机可以实现不同VLAN之间的隔离,使得不同的用户组之间可以独立设置,提高了网络安全性。

  6. QoS支持:交换机可以对不同类型的数据进行优先级的设置和处理,提高了网络传输质量。

  7. 端口管理:交换机可以实现端口的开关、速率和双工模式的设置,对端口进行管理和监控。

总的来说,交换机可以提高局域网的通信速率、稳定性和安全性,是企业和家庭组网中不可缺少的网络设备。

 

交换机可以看作是网桥的升级版,它们都是用于局域网内部的数据交换设备。与网桥相比,交换机的功能更加强大,主要体现在以下几个方面:

  1. 更高的转发速度:交换机使用专用的硬件芯片进行数据转发,速度更快,能够处理更大的数据流量。

  2. 更多的端口数量:交换机一般有多个端口,可以连接更多的设备。

  3. 更智能的转发:交换机可以通过学习目的MAC地址,将数据直接发送到目标设备,避免了广播风暴和冲突,提高了网络性能和可靠性。

  4. 支持VLAN:交换机可以将局域网划分为多个虚拟局域网,实现更灵活的网络管理。

综上所述,交换机在性能和功能上都比网桥更加出色,因此逐渐取代了网桥成为局域网内部数据交换的主要设备。

 

 交换帧是指交换机在收到帧后对其进行处理和转发的过程。具体而言,交换机会根据帧中的目的MAC地址来判断应该将该帧转发到哪个接口,如果目的MAC地址在交换机的MAC地址表中已经存在对应的端口,那么交换机就会直接将该帧转发到对应的端口;如果目的MAC地址不在交换机的MAC地址表中,那么交换机就会通过广播的方式发送一个帧,以寻找该目的MAC地址所在的端口,然后将该帧转发到对应的端口。交换帧可以提高网络的传输效率和安全性,避免了广播帧对整个网络的影响。

 

VLAN和广播域

 

 

switch

enable进入管理员模式

 

 

In Cisco devices, the configuration of the device is stored in two places: the running-config and the startup-config.

The running-config is the configuration that is currently active on the device. It is the configuration that the device is currently using to operate. Any changes made to the configuration while the device is running are stored in the running-config.

The startup-config, on the other hand, is the configuration that is stored on the device's non-volatile memory (NVRAM). It is the configuration that the device will use when it is first powered on or restarted. The startup-config is loaded into the device's running-config during the boot process.

The "show running-config" command displays the current configuration that the device is using to operate. It displays the running-config in the device's RAM.

The "show startup-config" command displays the configuration that is stored on the device's NVRAM. It displays the startup-config, which is the configuration that the device will use when it is first powered on or restarted.

 

 

 

 

 

 

 

 

 

 

posted @ 2023-04-08 12:36  ChuckLu  阅读(12)  评论(0编辑  收藏  举报