《计算机网络概论》学习笔记整理之Virtual Bridged LANs
/ / 点击 / 阅读耗时 8 分钟这篇笔记主要记录:
- VLAN解决的问题
- VLAN涉及的概念
- VLAN的结构
- VLAN的工作过程
下面三部分教程中有讲到,但没有记录在此:
- 交换机(bridge)之间传递信息的过程
- 设定的细节
- 交换机维护的member set和untag set是独立使用还是在交换机之间共用
另外这部分不需要图解,Yay~
VLAN存在的意义
- Without VLAN, the layer 2 switches/bridges will forward received broadcast and multicast frames to all ports(也就是无限制的广播)
这会带来两个问题:- 浪费带宽
- 带来安全问题
- Easy administration of logical group of stations(VLAN). Also moves, adds and changes in members of these groups.
- Traffic between VLANs is firewalled. The propagation of multicast and broadcast traffic between VLANs is limited.
- 不同VLAN之间的station如果要沟通,不能直接发信息,要通过router转送
- 在VLAN的架构下,任何一个成员丢出一个封包,它只会送给该VLAN下的成员,而不会送到整个网络上去
VLAN的特点
- shared和point-to-point media都支持VLAN
- 每一个VLAN都有唯一的ID(VID)
- 支持VLAN的switch/bridge和不支持的互相兼容
- In the absence of VLAN configuration, switch/bridges work in plug-and play(随插即用,大部分的layer2的设备都有这个特点,一开机就可以运作)
VLAN的架构
VLAN可以分为三个层级:
配置
先设定比如哪个station属于哪个VLAN,这些配置直接设定在交换机上
有四种划分VLAN的方式:- port-based VLAN,将port作为识别VLAN的对象,而不是station,这也是IEEE802.1Q的实现方式
- MAC-based VLAN,将station作为识别VLAN的对象,而不是port,这种方式更有弹性,支持设备的移动
- IP-subnet based VLAN
- layer-3 protocol(IP/IPX) based VLAN
Distribution/Resolution
将上面的设定告知其他交换机
Distribute VLAN membership information for Bridges to determine on which VLAN a given packet shoud be forwarded
实现方式:- Declaration Protocols(通常使用这种)
GARP(Generic Attributes Registration Protocol) is used to distribute membership information among Bridges - Request/Response protocols
- Declaration Protocols(通常使用这种)
交换机对封包的具体处理,可以分为三步:
- 判断这个封包来自哪个VLAN(Ingress rules,根据VID,决定是forwarding还是filtering)
- 这个VLAN下的成员都在哪些port上(Forwarding rules)
- 从某个port出去的时候是否要贴上该VLAN的tag(Egress rules)
交换机收到一个封包,如果:
- 没有带标签(implicitly tagged),标明它来自哪个port,则使用PVID(port VID)标记它归属的VLAN
- 带标签的VID(eplicitly tagged),带标签的VID能明确知道它属于哪个VLAN
Port-Based VLAN Definitions
- VLAN aware devices understand VLAN membership and VLAN frame format
- VlAN unaware devices
- AN Access Link is a LAN segement used to multiplex one or more VLAN unaware devices into a port of a VLAN Bridge(该link上连接的初交换机外的设备都不认识VLAN)
- All frams on an access link are implicitly tagged
- No VLAN tagged frames on a access link
- Viewed as being on the edge of the network
- Can be attached to other 802.1D-conforment BLAN(可以和旧有系统相容)
- A Trunk Link is a LAN segment used to multiplex VLANs between VLAN Bridges
- All devices connect to a Trunk Link must be VLAN aware
- All frames(including end station frames) on a Trunk Link are explicitly tagged with a VID
A Hybrid Link is a LAN segment that has both VLAN aware and unaware devices. There can be a mix of Tagged Frames and Untagged Frames but they must be from different VLANs.
Rules for Tagging Frames on a Hybrid Link:
- For each VLAN, an frames traversing a particular hybrid link must be tagged the same way:
- All implicitly tagged or
- All carrying the same explicit tag
- There can be a mix of implicity and explicit tagged frames but they must be for different VLANs
- For each VLAN, an frames traversing a particular hybrid link must be tagged the same way:
spanning tree and VLAN
- 所有的VLAN都是沿着spanning tree 构建的
- 每一个VLAN只是spanning tree的subset
- 不同VLAN的路径可能重叠,可能完全分开
- VLAN的拓扑结构是同态的,但不管怎么动态变化一定是spanning tree的subset
Bridge Operation for VLAN
这对每一个VLAN,bridge都要维护2个结构:
- Member set(Port ids)
- Untagged set(Port ids)
设定bridge => 交换机之间交换信息 => 每个bridge生成上述两个数据结构
封包进到一个bridge中,先看该封包属于哪个VLAN,然后查Member set,看目的地port是否在Member set中存在,如果不再就将这个封包过滤掉,所以在VLAN中广播,只有属于该VLAN的成员才能收到
VLA tag structure
由2部分组成:
- Tag Protocol Identifier(TPID):标记(81-00)这个封包是不是VLAN类型
- Tag Control Information(TCI 2bytes)
- User-Priority(0~7),优先权越高,可以越早被送出,使用3个bit表示
- Canonical Format Indicator(1 bit)
- VID(VLAN Identifier),12个bit(2^12 = 4096),所以最多可以有4096个VLAN
TPID有两种实现方式:Ethernet-encoded TPID(2 bytes)和SNAP-encoded TPID(8 bytes)