[HCIA] 08. Switch basics and VLAN

Switch Basics

ethernet protocol

  • Ethernet is a broadcast network based on the CSMA/CD (Carrier Sence Multiple Access/Collision Detection, Carrier Sense/Multiple Access/Collision Detection) mechanism. Listen first and then send, listen and send, and give in to conflicts.
  • Each port of a switch is an independent collision domain.

MAC address

  • The MAC address has a total of 48 bits and occupies 6 Bytes. The first 24 bits are purchased by the manufacturer from IEEE, and the last 24 bits are customized by the manufacturer. Usually expressed in hexadecimal.
  • The MAC address is unique in the world, the MAC address cannot be changed, and the MAC address is assigned based on the manufacturer.
  • A hexadecimal number is represented by 4 binary numbers, and the MAC address is generally divided into 6 segments, and each segment is represented by two hexadecimal numbers (that is, 8 binary numbers), connected by -- in the middle.

Unicast multicast broadcast

  • If the eighth bit of a MAC address is 1 (the second is an odd number in hexadecimal), it means that the address is a multicast address. If the eighth bit is 0 (the second is an even number), it means that the address is unicast.
  • The source address can only be unicast, not broadcast or multicast
  • Unicast needs to check the mac address table for data forwarding, multicast and broadcast need to flood data (except for the receiving end to send data to all other ports.)
  • The difference between unicast and broadcast lies in the way the receiving end handles it. If it is a broadcast, it will be processed unconditionally. If it is a multicast, it will check whether it is in this group. If it is in the group, it will be processed, and if it is not in the group, it will be discarded.

How the Switch Works

  • Whenever the switch receives a data frame, it must first learn or refresh. What is learned is the source port and MAC address, and the mac address entry is generated before considering forwarding. The aging time of the mac address table is 300s.
  • In the Layer 2 data frame, the destination address comes first, and the source address comes after.
  • Behavior of the switch:
    • Flooding: unknown unicast, multicast, broadcast.
    • Forwarding: Forwarding according to the interface in the MAC address table.
    • Discarding: The switch receives a data frame whose purpose is unicast. After checking the table, it finds that the port for this purpose is the port receiving the data frame, and chooses to discard it.
display mac-addressdisplay mac-address

VLAN

  • Virtual local area network, all interfaces are in VLAN1 by default.
  • Only devices in the same VLAN can communicate at Layer 2 without geographical restrictions.
  • VLAN division methods: interface-based, MAC address-based, IP subnet-based, protocol-based, and policy-based.

ACCESS interface

  • Why there is a tag, because you need to know which virtual switch he is looking for

  1. When the ACCESS interface receives data, it judges first to see if there is a Tag.
  2. If there is no Tag, add a tag and receive it.
  3. If there is a Tag, check to see if the tag is equal to pvid, if it is equal to receive it, and discard it if the tag is not equal to pvid.
  4. When sending, strip the Tag and send the original data directly.

TRUNK interface

The trunk interface will also have a pvid, and the default pvid is 1.

HYBRID interface

When sending a data frame, check whether it is in the allowed list. If it is not, it will be discarded. If it is in the allowed list, check whether it needs to be tagged. If it needs to be tagged, it will be tagged. Whether to strip is not determined by whether pvid and interface pvid are the same, but by tag or untag.

  1. When the hybrid interface of the switch is connected to the PC, the VLAN to which the PC belongs needs to be untagged, because the PC can only receive untagged data frames. In this way, the data frames sent by the switch will not be untagged.
  2. The port hybrid pvid determines which vlan the pc belongs to, and determines the uplink data frame of the computer.

VLAN data frame

  • The range of VLANid is from 0-4095, a total of 4096 numbers, 0 and 4095 cannot be used, and the range is 1-4094.

Guess you like

Origin blog.csdn.net/weixin_45988710/article/details/131711810