HomeDatabaseMysql Tutorial交换机中tag、untag的理解

交换机 中tag、untag的 理解 情况列举 Switch收发 Switch对标记的处理 remark Access (接收) Tagged = PVID 不接收 注:部分高端产品可能接收。 Access (接收) Tagged =/ PVID 不接收 注:部分高端产品可能接收。 Access (接收) Untagged 接收 增加tag=PVID

交换机中tag、untag的理解

情况列举 Switch收发 Switch对标记的处理 remark
Access (接收) Tagged = PVID 不接收 注:部分高端产品可能接收。
Access (接收) Tagged =/ PVID 不接收 注:部分高端产品可能接收。
Access (接收) Untagged 接收 增加tag=PVID 从PC

Access (发送) Tagged = PVID 转发 删除tag
Access (发送) Tagged =/ PVID 不转发 不处理
Access (发送) Untagged 无此情况 无此情况 无此情况

Trunk (接收) Tagged = PVID 接收 不修改tag
Trunk (接收) Tagged =/ PVID 接收 不修改tag
Trunk (接收) Untagged 接收 增加tag=PVID
Trunk (发送) Tagged = PVID If Passing then 转发 删除tag
Trunk (发送) Tagged =/ PVID If Passing then 转发 不修改tag
Trunk (发送) Untagged 无此情况 无此情况 无此情况(注)

Hybrid (接收) Tagged = PVID 接收 不修改tag 对端是trunk
Hybrid (接收) Tagged =/ PVID 接收 不修改tag 对端是trunk
Hybrid (接收) Untagged 接收 增加tag=PVID 类Trunk
Hybrid (发送) Tagged = PVID Tag 和 untag 中列出的vlan可以passing 看Tag项和untag项
Hybrid (发送) Tagged =/ PVID Tag 和 untag 中列出的vlan可以passing 看Tag项和untag项
Hybrid (发送) Untagged 无此情况 无此情况 无此情况(注)


我来解释一下
收报文:
Acess端口1、收到一个报文,判断是否有VLAN信息:如果没有则打上端口的PVID,并进行交换转发,如果有则直接丢弃(缺省)
发报文:
Acess端口: 1、将报文的VLAN信息剥离,直接发送出去      
收报文:
trunk端口: 1、收到一个报文,判断是否有VLAN信息:如果没有则打上端口的PVID,并进行交换转发,如果有判断该trunk端口是否允许该 VLAN的数据进入:如果可以则转发,否则丢弃
发报文:
trunk端口: 1、比较端口的PVID和将要发送报文的VLAN信息,如果两者相等则剥离VLAN信息,再发送,如果不相等则直接发送
收报文:
hybrid端口: 1、收到一个报文
      2、判断是否有VLAN信息:如果没有则打上端口的PVID,并进行交换转发,如果有则判断该hybrid端口是否允许该VLAN的数据进入:如果可以则转发,否则丢弃
发报文:
hybrid端口:1、判断该VLAN在本端口的属性(disp interface 即可看到该端口对哪些VLAN是untag, 哪些VLAN是tag)
      2、如果是untag则剥离VLAN信息,再发送,如果是tag则直接发送

================================
以下是神码大学郑老师的讲解,更清楚直观

先呈请一下上面的几个帖子的术语:

Tag为IEEE802.1Q协议定义的VLAN的标记在数据帧中的标示;
ACCESS端口,TRUNK端口是厂家对某一种端口的叫法,并非IEEE802.1Q协议的标准定义;

这个数据交换的过程比较复杂,如果想解释的话,首先要了解一下几个IEEE802.1Q协议的定理;
1、下面是定义的各种端口类型对各种数据帧的处理方法;

————————Tagged数据帧 Tagged数据帧 Untagged数据帧   Untagged数据帧
————————in             out               in                     out
Tagged端口___原样接收     原样发送     按端口PVID打TAG标记 按照PVID打TAG标记
Untagged端口_丢弃       去掉TAG标记   按端口PVID打TAG标记 原样发送

2、所谓的Untagged Port和tagged Port不是讲述物理端口的状态,而是将是物理端口所拥有的某一个VID的状态,所以一个物理端口可以在某一个VID上是Untagged Port,在另一个VID上是tagged Port;

3、一个物理端口只能拥有一个PVID,当一个物理端口拥有了一个PVID的时候,必定会拥有和PVID的TAG等同的VID,而且在这个VID上,这个物理端口必定是Untagged Port;

4、PVID的作用只是在交换机从外部接受到可以接受Untagged 数据帧的时候给数据帧添加TAG标记用的,在交换机内部转发数据的时候PVID不起任何作用;

5、拥有和TAG标记一致的VID的物理端口,不论是否在这个VID上是Untagged Port或者tagged Port,都可以接受来自交换机内部的标记了这个TAG标记的tagged 数据帧;

6、拥有和TAG标记一致的VID的物理端口,只有在这个VID上是tagged Port,才可以接受来自交换机外部的标记了这个TAG标记的tagged 数据帧;

以下是神州数码对命令的定义(各个厂家对命令的定义可能不一定一致,但是都必须遵循上面的定理):

1、Trunk端口就是在一个物理端口上增加这个交换机所有VLAN的VID标示,并且除了和这个物理端口PVID标示一致的VID标示为Untagged Port外,在其他的VID上都是Tagged Port;

2、Access端口就是指拥有一个和PVID标记相同的VID的物理端口,在这个VID上,遵循定理一定为untagged Port;

在了解了以上的基础理论之后,我们在来看一下楼主的问题:

一个数据包从PC机发出经过ACCESS端口->TRUNK端口->TRunk->ACCESS->PC数据包发生了怎么样的变化?

我们先把上述的描述变换为IEEE802.1Q的标准描述:

一个数据包从PC机发出经过(Untagged 数据帧)

ACCESS端口(PVID定义为100,VID=100=Untagged Port)->

TRUNK端口(PVID定义为1〈出厂配置,没有更改〉,VID=1=Untagged Port,VID=100=tagged Port)->

另一个交换机的TRunk端口(PVID定义为1〈出厂配置,没有更改〉,VID=1=Untagged Port,VID=100=tagged Port)->

另一个交换机的ACCESS端口(PVID定义为100,VID=100=Untagged Port)->

PC数据包发生了怎么样的变化?(Untagged 数据帧)

首先假设两台交换机刚刚开机(MAC地址表为空)从PC机发出的数据帧进入交换机的ACCESS端口以后,会按照这个端口的PVID打100的Tag标记,根据交换机的转发原理,交换机会把这个数据帧转发给VID=100的所有端口(除了进口以外),这个过程叫做VLAN Flood;参照上面的定理1;

由于Trunk端口拥有VID=100,所以才可接受这个标记Tag为100的tagged数据帧;参照上面的定理5;

由于Trunk端口在VID=100上为tagged Port,所以在发送数据帧出交换机的时候,不改变Tagged数据帧的结构;参照上面的定理1;

到了另一个交换机的Trunk端口的时候,由于Trunk端口拥有VID=100,所以才可接受这个标记Tag为100的tagged数据帧;参照上面的定理6;

另一个交换机的Trunk端口,接收到标记tag为100的tagged数据帧,并不作任何的更改;参照上面的定理1;

另一个交换机收到到标记tag为100的tagged数据帧,根据交换机的转发原理,交换机会把这个数据帧转发给VID=100的所有端口(除了进口以外);参照交换机交换原理(受到一个未知目的MAC数据帧);

这样另一个交换机的ACCESS端口就可以收到标记tag为100的tagged数据帧;参照上面的定理5;

另一个交换机的ACCESS端口在发出标记tag为100的tagged数据帧的时候,会去掉TAG标记,转发untagged数据帧给PC;参照上面的定理1;

这样PC机就收到了这个数据;

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
MySQL: BLOB and other no-sql storage, what are the differences?MySQL: BLOB and other no-sql storage, what are the differences?May 13, 2025 am 12:14 AM

MySQL'sBLOBissuitableforstoringbinarydatawithinarelationaldatabase,whileNoSQLoptionslikeMongoDB,Redis,andCassandraofferflexible,scalablesolutionsforunstructureddata.BLOBissimplerbutcanslowdownperformancewithlargedata;NoSQLprovidesbetterscalabilityand

MySQL Add User: Syntax, Options, and Security Best PracticesMySQL Add User: Syntax, Options, and Security Best PracticesMay 13, 2025 am 12:12 AM

ToaddauserinMySQL,use:CREATEUSER'username'@'host'IDENTIFIEDBY'password';Here'showtodoitsecurely:1)Choosethehostcarefullytocontrolaccess.2)SetresourcelimitswithoptionslikeMAX_QUERIES_PER_HOUR.3)Usestrong,uniquepasswords.4)EnforceSSL/TLSconnectionswith

MySQL: How to avoid String Data Types common mistakes?MySQL: How to avoid String Data Types common mistakes?May 13, 2025 am 12:09 AM

ToavoidcommonmistakeswithstringdatatypesinMySQL,understandstringtypenuances,choosetherighttype,andmanageencodingandcollationsettingseffectively.1)UseCHARforfixed-lengthstrings,VARCHARforvariable-length,andTEXT/BLOBforlargerdata.2)Setcorrectcharacters

MySQL: String Data Types and ENUMs?MySQL: String Data Types and ENUMs?May 13, 2025 am 12:05 AM

MySQloffersechar, Varchar, text, Anddenumforstringdata.usecharforfixed-Lengthstrings, VarcharerForvariable-Length, text forlarger text, AndenumforenforcingdataAntegritywithaetofvalues.

MySQL BLOB: how to optimize BLOBs requestsMySQL BLOB: how to optimize BLOBs requestsMay 13, 2025 am 12:03 AM

Optimizing MySQLBLOB requests can be done through the following strategies: 1. Reduce the frequency of BLOB query, use independent requests or delay loading; 2. Select the appropriate BLOB type (such as TINYBLOB); 3. Separate the BLOB data into separate tables; 4. Compress the BLOB data at the application layer; 5. Index the BLOB metadata. These methods can effectively improve performance by combining monitoring, caching and data sharding in actual applications.

Adding Users to MySQL: The Complete TutorialAdding Users to MySQL: The Complete TutorialMay 12, 2025 am 12:14 AM

Mastering the method of adding MySQL users is crucial for database administrators and developers because it ensures the security and access control of the database. 1) Create a new user using the CREATEUSER command, 2) Assign permissions through the GRANT command, 3) Use FLUSHPRIVILEGES to ensure permissions take effect, 4) Regularly audit and clean user accounts to maintain performance and security.

Mastering MySQL String Data Types: VARCHAR vs. TEXT vs. CHARMastering MySQL String Data Types: VARCHAR vs. TEXT vs. CHARMay 12, 2025 am 12:12 AM

ChooseCHARforfixed-lengthdata,VARCHARforvariable-lengthdata,andTEXTforlargetextfields.1)CHARisefficientforconsistent-lengthdatalikecodes.2)VARCHARsuitsvariable-lengthdatalikenames,balancingflexibilityandperformance.3)TEXTisidealforlargetextslikeartic

MySQL: String Data Types and Indexing: Best PracticesMySQL: String Data Types and Indexing: Best PracticesMay 12, 2025 am 12:11 AM

Best practices for handling string data types and indexes in MySQL include: 1) Selecting the appropriate string type, such as CHAR for fixed length, VARCHAR for variable length, and TEXT for large text; 2) Be cautious in indexing, avoid over-indexing, and create indexes for common queries; 3) Use prefix indexes and full-text indexes to optimize long string searches; 4) Regularly monitor and optimize indexes to keep indexes small and efficient. Through these methods, we can balance read and write performance and improve database efficiency.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.