前言

本文翻译自RFC7348

Virtual eXtensible Local Area Network (VXLAN)

1. 简介

网络虚拟化激增了物理网络基础设施的要求。一个服务器现如今可以被虚拟化为拥有独立MAC地址的虚拟机。由于大量的虚拟机间需要通信,这要求二层设备需要更大的Mac地址转发表。

数据中心基于VLAN划分,而目前VLAN仅仅可以划分4094个分区。

数据中心经常需要托管多个用户,每个用户都有自己的独立的网络。使用专用的网络设备是不经济的,管理员通常会在一个共享网络中实施隔离,此时,一个常见问题是,每个用户可能会独立分配 MAC地址和 VLAN ID,导致物理网络上可能出现重复。

为了高效分配计算、网络和存储资源,交换机虚拟化环境的一个重要要求是二层网络能够扩展到整个数据中心,甚至在数据中心之间进行扩展。在这种网络中,使用生成树协议(STP)等传统方法来实现无环路拓扑可能会导致大量的链路被禁用。

最后一种场景是网络运营商通常更喜欢使用IP来在物理设备之间实现互联(例如,通过等价多路径(ECMP)实现多路径可扩展性、从而避免禁用链路)。同时,仍需要保留用于虚拟机间通信的二层模型。

刚刚提到的最后一种场景导致需要一个overlay网络。这种overlay被用于传递那些来自独立虚拟机中的MAC流量,以形成一个逻辑上的隧道。

这篇文章详细描述了一种称为Virtual eXtensible Local Area Network (VXLAN)的框架。他为以上的需求提出了一种封装方案。本文记录了已部署的VXLAN协议,供互联网社区使用。

1.1 缩略语和定义

  • ACL: Access Control List
  • ECMP: Equal-Cost Multipath
  • IGMP: Internet Group Management Protocol
  • IHL: Internet Header Length
  • MTU: Maximum Transmission Unit
  • PIM: Protocol Independent Multicast
  • SPB: Shortest Path Bridging
  • STP: Spanning Tree Protocol
  • ToR: Top of Rack
  • TRILL: Transparent Interconnection of Lots of Links
  • VLAN: Virtual Local Area Network
  • VM: Virtual Machine
  • VNI: VXLAN Network Identifier (or VXLAN Segment ID)
  • VTEP: VXLAN Tunnel End Point. An entity that originates and/or terminates VXLAN tunnels
  • VXLAN: Virtual eXtensible Local Area Network
  • VXLAN Segment: VXLAN Layer 2 overlay network over which VMs communicate
  • VXLAN Gateway: an entity that forwards traffic between VXLANs

2 Conventions Used in This Document

The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in RFC 2119 [RFC2119].

3. VXLAN问题说明

本节将进一步详细介绍 VXLAN 所要解决的问题。重点是数据中心内的网络基础设施以及与之相关的问题。

3.1 生成树和 VLAN 带来的限制

当前2层网络通过STP协议来避免环路。STP中断了链路以避免避免复制和循环。由于STP的存在,使得一些端口其实并不可用,这在通常在一些数据中心中被认为是问题。此外,STP模型也不支持链路备份。最新的提案中已提出来帮助实现多路径,并克服 STP 的一些问题。然而,这与用于虚拟机间通信的二层模型不兼容。

在二层数据中心网络中,一个关键是特性就是使用VLAN来隔离广播域。12位VLAN ID用于以太网数据帧,将较大的二层网络划分为多个广播域。这种服务在少于4094VLAN环境中运行的很好,但是随着虚拟化技术的发展,这个上限有些捉襟见肘了。

3.2 多用户环境

云计算涉及为多用户环境按需弹性调配资源,最常见的例子就是公有云,云服务提供商通过相同的物理基础设施向多个客户/租户提供这些弹性服务。

用户可通过二层或三层网络隔离网络流量。针对二层网络,VLAN经常用来分流——每个用户有自己独有的VLAN ID。由于一个云可能为大量用户提供服务,4094上限的VLAN ID成为了限制。此外,更棘手的是,有些用户需要使用多VLAN。

与此相关的一个用例是跨模块扩展。一个pod通常由一个或多个服务器以及相关的网络和存储连接组成。用户可能一开始使用一个pod,但由于扩展的需要,需要其他pod上的服务器/虚拟机,尤其是当其他pod上的租户没有充分利用其全部资源时。这种用例需要一个”延伸”的二层环境连接各个服务器/虚拟机。

三层网络不是多租户的全面解决方案。两个租户可能在其网络中使用同一组三层地址,这就要求云提供商以其他形式提供隔离。

3.3 ToR交换机的转发表大小受限

当今的虚拟化环境对连接到机架顶部(ToR)交换机的 MAC 地址表提出了更多要求。不是每个服务器链路只有一个 MAC 地址,如今,ToR交换机还得学习每个虚拟机的地址(每台服务器可能有几百个)。这是因为虚拟机到物理网络其他部分的流量将穿过服务器和交换机之间的链路。典型的 ToR 交换机可连接 24 或 48 台服务器,具体取决于其面向服务器的端口数量。数据中心可能由多个机架组成,因此每个ToR 交换机需要为不同物理服务器上的通信虚拟机维护一个地址表。与非虚拟化环境相比,这对转发表容量的需求要大得多。

如果表溢出,交换机可能会停止学习新地址直到空闲条目老化,从而导致大量未知目标帧泛洪。

4. VXLAN

VXLAN(虚拟可扩展局域网)可满足上述要求二层和三层数据中心网络基础设施的上述要求。它在现有网络基础设施上运行,提供了一种伸展二层网络的手段。简而言之,VXLAN 是一种二层在三层网络上的叠加方案。每一个overlay被视为一个VXLAN segment。只有具有相同VXLAN segment的虚拟机间才可以互相通信。每一个VXLAN segment通过24比特位来用作唯一标识——“VXLAN Network Identifier (VNI)。这允许16M个VXLAN网段在同一个管理区域内共存。

VNI 可识别由单个 VM 发起的内部 MAC 帧的范围。因此,您可以在不同网段之间使用重复的 MAC 地址,绝不会出现流量 “交叉 “的情况。因为流量是通过 VNI 隔离的。VNI 位于外层报头中,该报头封装了由虚拟机发起的内层 MAC 帧。在以下章节中””VXLAN segment”与”VXLAN overlay network”可以互换使用。

由于采用了这种封装方式,VXLAN 也可称为一种在第三层网络上覆盖第二层网络的隧道方案。隧道是无状态的,因此每个帧都是根据一组规则进行封装的。下文讨论的隧道端点(VXLAN Tunnel End Point或 VTEP)位于托管虚拟机的服务器上的管理程序中。因此,与VNI和与 VXLAN相关的隧道/外部报头封装只有VTEP知道,虚拟机永远不会看到。请注意,VTEP 也可能位于物理交换机或物理服务器上,并可能通过软件或硬件实现。第 6 节 “VXLAN 部署方案 “将讨论 VTEP 是物理交换机的一种使用情况。

以下各节将讨论 VXLAN 环境中使用基于学习的控制方案的典型流量场景。在这里,虚拟机 MAC 与 VTEP IP 地址的关联是通过源地址学习发现的。组播用于传输未知目标、广播和组播帧。
除了基于学习的控制平面外、还有其他分配 VTEP IP 到虚拟机 MAC 映射信息的方案。可选方案包括基于权限/目录的查询、由中央机构将此映射信息分发给 VTEP 等。这两种模式有时分别被称为push and pull模型。本文将重点讨论基于学习的控制方案。

4.1 单播虚拟机到虚拟机通信

在VXLAN子网中的虚拟机,是意识不到存在VXLAN的。要与不同主机上的虚拟机通信,它会像往常一样发送一个MAC帧。物理主机上的 VTEP 查找与该虚拟机关联的 VNI。然后确定目标 MAC 是否在同一网段上,以及是否有目的地 MAC 地址到远程 VTEP 的映射。如果有,一个外层的MAC,外层的IP和VXLAN header将会封装在原始MAC帧上。这个封装后的帧将被发送到远端的VTEP上。远端VTEP接受后,会确认是否是合法的VNI和是否存在使用与内部目标 MAC 地址匹配的 MAC 地址的虚拟机。如果是这样,数据包就会被去掉封装头,并传递给目标虚拟机。目的地虚拟机永远不会知道VNI,也不知道帧是用VXLAN封装。

VXLAN封装

除了将数据包转发到目的地虚拟机外,远端VTEP还会学习从内部的源MAC到外部源IP的映射。它将此映射存储在一个表中,这样当目的地虚拟机发送响应数据包时就不需要对响应数据包进行 “未知目的地 “泛洪。

在源虚拟机进行传输之前,确定目标虚拟机的 MAC 地址的方法与非 VXLAN 环境相同。使用广播帧,但将其封装在组播数据包中。

4.2 Broadcast Communication and Mapping to Multicast

以后弄明白了再来翻译吧。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
Consider the VM on the source host attempting to communicate with the
destination VM using IP. Assuming that they are both on the same
subnet, the VM sends out an Address Resolution Protocol (ARP)
broadcast frame. In the non-VXLAN environment, this frame would be
sent out using MAC broadcast across all switches carrying that VLAN.

With VXLAN, a header including the VXLAN VNI is inserted at the
beginning of the packet along with the IP header and UDP header.
However, this broadcast packet is sent out to the IP multicast group
on which that VXLAN overlay network is realized.

To effect this, we need to have a mapping between the VXLAN VNI and
the IP multicast group that it will use. This mapping is done at the
management layer and provided to the individual VTEPs through a
management channel. Using this mapping, the VTEP can provide IGMP
membership reports to the upstream switch/router to join/leave the
VXLAN-related IP multicast groups as needed. This will enable
pruning of the leaf nodes for specific multicast traffic addresses
based on whether a member is available on this host using the
specific multicast address (see [RFC4541]). In addition, use of
multicast routing protocols like Protocol Independent Multicast -
Sparse Mode (PIM-SM see [RFC4601]) will provide efficient multicast
trees within the Layer 3 network.

The VTEP will use (*,G) joins. This is needed as the set of VXLAN
tunnel sources is unknown and may change often, as the VMs come up /
go down across different hosts. A side note here is that since each
VTEP can act as both the source and destination for multicast
packets, a protocol like bidirectional PIM (BIDIR-PIM -- see
[RFC5015]) would be more efficient.

The destination VM sends a standard ARP response using IP unicast.
This frame will be encapsulated back to the VTEP connecting the
originating VM using IP unicast VXLAN encapsulation. This is
possible since the mapping of the ARP response's destination MAC to
the VXLAN tunnel end point IP was learned earlier through the ARP
request.

Note that multicast frames and "unknown MAC destination" frames are
also sent using the multicast tree, similar to the broadcast frames.

4.3 Physical Infrastructure Requirements

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
When IP multicast is used within the network infrastructure, a
multicast routing protocol like PIM-SM can be used by the individual
Layer 3 IP routers/switches within the network. This is used to
build efficient multicast forwarding trees so that multicast frames
are only sent to those hosts that have requested to receive them.

Similarly, there is no requirement that the actual network connecting
the source VM and destination VM should be a Layer 3 network: VXLAN
can also work over Layer 2 networks. In either case, efficient
multicast replication within the Layer 2 network can be achieved
using IGMP snooping.

VTEPs MUST NOT fragment VXLAN packets. Intermediate routers may
fragment encapsulated VXLAN packets due to the larger frame size.
The destination VTEP MAY silently discard such VXLAN fragments. To
ensure end-to-end traffic delivery without fragmentation, it is
RECOMMENDED that the MTUs (Maximum Transmission Units) across the
physical network infrastructure be set to a value that accommodates
the larger frame size due to the encapsulation. Other techniques
like Path MTU discovery (see [RFC1191] and [RFC1981]) MAY be used to
address this requirement as well.

5. VXLAN帧格式

VXLAN 帧格式如下所示。内层MAC帧有自己的源目MAC地址。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 0                   1                   2                   3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
Inner Ethernet Header:
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Inner Destination MAC Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Inner Destination MAC Address | Inner Source MAC Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Inner Source MAC Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|OptnlEthtype = C-Tag 802.1Q | Inner.VLAN Tag Information |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Payload:
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Ethertype of Original Payload | |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| Original Ethernet Payload |
| |
|(Note that the original Ethernet Frame's FCS is not included) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

内层MAC帧被以下四个头进行封装:

  • VXLAN Header:
1
2
3
4
5
6
7
 0                   1                   2                   3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|R|R|R|R|I|R|R|R| Reserved |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| VXLAN Network Identifier (VNI) | Reserved |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Flags(8 bits):其中 I 标志必须设为 1,表示 VXLAN 网络 ID(VNI)有效。
VNI:这是一个 24 位值,用于指定通信虚拟机所在的单个VXLAN overlay网络。不用VNI之间无法通信

  • 外层UDP Header:

这是 UDP 的外层报头,源端口由 VTEP 提供,目的端口是众所周知的4789。

1
2
3
4
5
6
7
8
 0                   1                   2                   3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
Outer UDP Header:
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Source Port | Dest Port = VXLAN Port |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| UDP Length | UDP Checksum |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Dest Port:IANA将4789指定为VXLAN服务,端口可配置
Source Port:建议使用内部IP的hash值,建议在49152-65535取值
UDP Checksum:应将其传输为零。接收到 UDP 校验和为零的数据包时,必须接受它进行解封装。可选项,如果封装端点包含一个非零 UDP 校验和,则必须在整个数据包(包括 IP 头,UDP头,VXLAN头,和封装的MAC帧)中正确计算 UDP 校验和。当解包端点收到带有非零校验和的数据包时可以选择验证校验和值。如果它选择执行此类验证,而验证失败,则必须丢弃数据包。如果解封装目的地选择不执行验证,或校验成功,则必须接受数据包进行解封装。

  • 外层IP header:

外层源IP表示通信虚拟机(由内部源 MAC 地址表示)正在运行的 VTEP 的 IP 地址。目标 IP 地址可以是单播或组播IP地址,当它是单播 IP 地址时,它代表连接通信虚拟机的 VTEP 的 IP 地址。如果是组播IP地址时,请参考4.2小节。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
 0                   1                   2                   3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
Outer IPv4 Header:
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Version| IHL |Type of Service| Total Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Identification |Flags| Fragment Offset |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Time to Live |Protocl=17(UDP)| Header Checksum |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Outer Source IPv4 Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Outer Destination IPv4 Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  • 外层Ethernet Header:

该帧中的目的 MAC 地址可能是目标 VTEP 的地址,也可以是中间三层路由器的地址。外部 VLAN 标记是可选的。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
 0                   1                   2                   3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1

Outer Ethernet Header:
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Outer Destination MAC Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Outer Destination MAC Address | Outer Source MAC Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Outer Source MAC Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|OptnlEthtype = C-Tag 802.1Q | Outer.VLAN Tag Information |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Ethertype = 0x0800 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

上面的帧格式显示使用IPv4传输的以太网帧隧道。下文将详细介绍使用IPv6传输的VXLAN。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
 0                   1                   2                   3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1

Outer Ethernet Header:
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Outer Destination MAC Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Outer Destination MAC Address | Outer Source MAC Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Outer Source MAC Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|OptnlEthtype = C-Tag 802.1Q | Outer.VLAN Tag Information |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Ethertype = 0x86DD |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Outer IPv6 Header:
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Version| Traffic Class | Flow Label |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Payload Length | NxtHdr=17(UDP)| Hop Limit |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
+ +
| |
+ Outer Source IPv6 Address +
| |
+ +
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
+ +
| |
+ Outer Destination IPv6 Address +
| |
+ +
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Outer UDP Header:
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Source Port | Dest Port = VXLAN Port |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| UDP Length | UDP Checksum |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

VXLAN Header:
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|R|R|R|R|I|R|R|R| Reserved |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| VXLAN Network Identifier (VNI) | Reserved |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Inner Ethernet Header:
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Inner Destination MAC Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Inner Destination MAC Address | Inner Source MAC Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Inner Source MAC Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|OptnlEthtype = C-Tag 802.1Q | Inner.VLAN Tag Information |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Payload:
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Ethertype of Original Payload | |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| Original Ethernet Payload |
| |
|(Note that the original Ethernet Frame's FCS is not included) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Frame Check Sequence:
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| New FCS (Frame Check Sequence) for Outer Ethernet Frame |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

6. VXLAN部署场景

VXLAN通常部署在数据中心的虚拟主机上、这些主机可能分布在多个服务器上。单个服务器可以是不同的三网络的一部分,也可以是单个二层网络的一部分。VXLAN segments就在这些二三层网络上运行。

考虑下图

这里有4个VXLAN overlay网络,分别为22/34/74/98。两个服务器通过三次网络连接。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
+------------+-------------+
| Server 1 |
| +----+----+ +----+----+ |
| |VM1-1 | |VM1-2 | |
| |VNI 22 | |VNI 34 | |
| | | | | |
| +---------+ +---------+ |
| |
| +----+----+ +----+----+ |
| |VM1-3 | |VM1-4 | |
| |VNI 74 | |VNI 98 | |
| | | | | |
| +---------+ +---------+ |
| Hypervisor VTEP (IP1) |
+--------------------------+
|
|
|
| +-------------+
| | Layer 3 |
|---| Network |
| |
+-------------+
|
|
+-----------+
|
|
+------------+-------------+
| Server 2 |
| +----+----+ +----+----+ |
| |VM2-1 | |VM2-2 | |
| |VNI 34 | |VNI 74 | |
| | | | | |
| +---------+ +---------+ |
| |
| +----+----+ +----+----+ |
| |VM2-3 | |VM2-4 | |
| |VNI 98 | |VNI 22 | |
| | | | | |
| +---------+ +---------+ |
| Hypervisor VTEP (IP2) |
+--------------------------+

Figure 3: VXLAN Deployment - VTEPs across a Layer 3 Network

关注在server1中的VM1-1和server2中的VM2-4。他们拥有相同的VNI:22。虚拟机并不知道自己处于VXLAN overlay网络中,因为封装与解封装都仅仅发生在VTEP上。

一种部署方案是,隧道终止点是一台能理解 VXLAN 的物理服务器。

另一种情况是VXLAN overlay网络上的节点需要与基于VLAN的传统网络上的节点通信。这个节点可能是物理设备或者虚拟设备。为了实现这种通信,网络需要包括 VXLAN 网关(见下图 4,交换机充当 VXLAN 网关)在 VXLAN 和非 VXLAN 环境之间转发流量。

如下图:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

+---+-----+---+ +---+-----+---+
| Server 1 | | Non-VXLAN |
(VXLAN enabled)<-----+ +---->| server |
+-------------+ | | +-------------+
| |
+---+-----+---+ | | +---+-----+---+
|Server 2 | | | | Non-VXLAN |
(VXLAN enabled)<-----+ +---+-----+---+ +---->| server |
+-------------+ | |Switch acting| | +-------------+
|---| as VXLAN |-----|
+---+-----+---+ | | Gateway |
| Server 3 | | +-------------+
(VXLAN enabled)<-----+
+-------------+ |
|
+---+-----+---+ |
| Server 4 | |
(VXLAN enabled)<-----+
+-------------+

Figure 4: VXLAN Deployment - VXLAN Gateway

对于 VXLAN 连接接口上的传入帧,网关会去除 VXLAN头,并根据内部以太网帧的目标 MAC 地址将其转发到物理端口。除非显式配置为传递到非 VXLAN 接口,否则带有内 VLAN ID 的解封装帧应被丢弃。反之亦然,非 VXLAN 接口的传入帧会根据帧中的 VLAN ID 映射到特定的 VXLAN 覆盖网络。除非明确配置为在封装的 VXLAN 帧中传递,VLAN ID 会在为 VXLAN 封装帧之前被移除。

1
2
3
4
5
6
7
These gateways that provide VXLAN tunnel termination functions could
be ToR/access switches or switches higher up in the data center
network topology -- e.g., core or even WAN edge devices. The last
case (WAN edge) could involve a Provider Edge (PE) router that
terminates VXLAN tunnels in a hybrid cloud environment. In all these
instances, note that the gateway functionality could be implemented
in software or hardware.