OpenDaylight-Boron学习笔记: 6 VTN模块

SDN 专栏收录该内容
6 篇文章 0 订阅

环境及软件版本说明

===

SN-Controller:

CPU: 2 Cores

RAM: 4GB

Disk: 32GB

Operating System: CentOS7 x86_64 1611(Linux 3.10.0-514) Infrastructure Server

IP1: 10.0.3.100/24 (Public Network)

IP2: 172.16.3.100/24 (SDN Network)

===

OpenDaylight: Boron

下载地址

参考文献

Virtual Tenant Network(VTN)

《OpenDaylight应用指南》(唐宏 等编著)

功能体验

OpenDaylight的VTN是一个在SDN控制器上的应用,它可以提供多租户的虚拟网络。它主要包含两大组件:

  • VTN Manager
  • VTN Coordinator

VTN Manager

在ODL控制器的karaf控制台里安装vtn插件:

opendaylight-user@root>feature:install odl-vtn-manager odl-vtn-manager-rest odl-vtn-manager-neutron

发送下面Rest请求可以创建一个vtn:

[spinlock@Archer ~]$ curl -D - \
> --user "admin":"admin" \
> -H "Content-type: application/json" \
> -H "Accept: application/json" \
> -X POST \
> http://10.0.3.100:8181/restconf/operations/vtn:update-vtn \
> -d '{"input":{"tenant-name":"vtn1"}}'
HTTP/1.1 200 OK
Set-Cookie: JSESSIONID=1uvjeut3qyyncico5ha2btbrr;Path=/restconf
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Set-Cookie: rememberMe=deleteMe; Path=/restconf; Max-Age=0; Expires=Sun, 21-May-2017 13:12:21 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Server: Jetty(8.1.19.v20160209)

{"output": {"status": "CREATED"}}

发送请求后返回200 OK的状态码,发送下面的Rest请求可以查看vtn状态:

[spinlock@Archer ~]$ curl -D - \
> --user "admin":"admin" \
> -H "Accept: application/json" \
> -H "Content-type: application/json" \
> -X GET \
> http://10.0.3.100:8181/restconf/operational/vtn:vtns
HTTP/1.1 200 OK
Set-Cookie: JSESSIONID=u9c2ec8bfx4osiq1rio4l4wn;Path=/restconf
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Set-Cookie: rememberMe=deleteMe; Path=/restconf; Max-Age=0; Expires=Sun, 21-May-2017 13:15:39 GMT
Content-Type: application/json
Vary: Accept-Encoding, User-Agent
Transfer-Encoding: chunked
Server: Jetty(8.1.19.v20160209)

{"vtns":{"vtn":[{"name":"vtn1","vtenant-config":{"hard-timeout":0,"idle-timeout":300},"vbridge":[{"name":"vbr1","bridge-status":{"path-faults":0,"state":"UNKNOWN"},"vbridge-config":{"age-interval":600}}]}]}}

发送完成后会返回一个200 OK的状态码,并包含vtn1的数据。发送下面请求可以删除创建的vtn:

[spinlock@Archer ~]$ curl -D - \
> --user "admin":"admin" \
> -H "Content-type: application/json" \
> -X POST \
> http://10.0.3.100:8181/restconf/operations/vtn:remove-vtn \
> -d '{"input":{"tenant-name":"vtn1"}}'
HTTP/1.1 200 OK
Set-Cookie: JSESSIONID=1ea0ylyvlmz27m8io74da2b46;Path=/restconf
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Set-Cookie: rememberMe=deleteMe; Path=/restconf; Max-Age=0; Expires=Sun, 21-May-2017 13:40:02 GMT
Content-Type: application/yang.operation+json
Content-Length: 0
Server: Jetty(8.1.19.v20160209)

发送请求后返回一个200 OK的状态码。说明删除成功。在这里,官网没有删除vtn的Rest说明,一般这些Rest请求的说明,可以登录到ODL的控制页面,在Yang UI里找到。

VTN Coordinator

VTN Coordinator的Rest API说明文档:OpenDaylight Virtual Tenant Network (VTN):VTN Coordinator:RestApi

虚拟网络建设基元

在VTN里,虚拟网络由虚拟节点(如虚拟网桥、虚拟路由)、虚拟接口和虚拟链路构建而成。通过使用虚拟链路连接虚拟节点上的虚拟接口,可以组成包含L2或L3转发功能的虚拟网络。在VTN中,包含以下的虚拟节点:

虚拟节点名称虚拟节点功能
vBridge拥有2层交换功能的逻辑表示
vRouter拥有路由功能的逻辑表示
vTep隧道端点的逻辑表示
vTunnel隧道的逻辑表示
vBypass受控网络之间连接的逻辑表示
Virtual interface表示虚拟节点上的一个端点(接口)
Virtual Linkv(vLink)表示虚拟接口之间的L1层连接(物理连接)

实验

参考官网给出的例子进行相关的实验验证。

Mininet虚拟机参数:

  • HostName:mininet-vm1
  • CPU: 2核
  • RAM: 4GB
  • IP1:10.0.3.101(Public Network)
  • IP2: 172.16.3.101(SDN Network)

L2层虚拟网络

参考例子

使用Mininet创建拓扑

在mininet-vm1中,创建树型拓扑:

mininet@mininet-vm1:~$ sudo mn --topo=tree,2 --mac --controller=remote,ip=10.0.3.100,port=6633 --switch ovsk,protocols=OpenFlow13
mininet> pingall
*** Ping: testing ping reachability
h1 -> h2 h3 h4
h2 -> h1 h3 h4
h3 -> h1 h2 h4
h4 -> h1 h2 h3
*** Results: 0% dropped (12/12 received)
mininet> net
h1 h1-eth0:s2-eth1
h2 h2-eth0:s2-eth2
h3 h3-eth0:s3-eth1
h4 h4-eth0:s3-eth2
s1 lo:  s1-eth1:s2-eth3 s1-eth2:s3-eth3
s2 lo:  s2-eth1:h1-eth0 s2-eth2:h2-eth0 s2-eth3:s1-eth1
s3 lo:  s3-eth1:h3-eth0 s3-eth2:h4-eth0 s3-eth3:s1-eth2
c0

配置VTN

发送下面请求创建vtn:

[spinlock@Archer ~]$ curl -D - \
> --user "admin":"admin" \
> -H "Content-type: application/json" \
> -H "Accept: application/json" \
> -X POST \
> http://10.0.3.100:8181/restconf/operations/vtn:update-vtn \
> -d '{"input":{"tenant-name":"vtn1"}}'
HTTP/1.1 200 OK
Set-Cookie: JSESSIONID=1uvjeut3qyyncico5ha2btbrr;Path=/restconf
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Set-Cookie: rememberMe=deleteMe; Path=/restconf; Max-Age=0; Expires=Sun, 21-May-2017 13:12:21 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Server: Jetty(8.1.19.v20160209)

{"output": {"status": "CREATED"}}

请求后返回200 OK状态码,并包含创建成功的内容。发送下面请求创建一个虚拟网桥vbr1:

[spinlock@Archer ~]$ curl \
> --user "admin":"admin" \
> -H "Content-type: application/json" \
> -X POST \
> http://10.0.3.100:8181/restconf/operations/vtn-vbridge:update-vbridge \
> -d '{"input": {"tenant-name": "vtn1","bridge-name": "vbr1"}}'
{"output": {"status": "CREATED"}}

请求后返回200 OK状态码,并包含创建成功的内容。使用以下两次的Rest请求为虚拟网桥创建两个虚拟接口:

[spinlock@Archer ~]$ curl -D - \
> --user "admin":"admin" \
> -H "Content-type: application/json" \
> -X POST \
> http://10.0.3.100:8181/restconf/operations/vtn-vinterface:update-vinterface \
> -d '{"input":{"tenant-name":"vtn1", "bridge-name":"vbr1", "interface-name":"if1"}}'
HTTP/1.1 200 OK
Set-Cookie: JSESSIONID=1d84idpmj8u9ezkci184mdzmn;Path=/restconf
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Set-Cookie: rememberMe=deleteMe; Path=/restconf; Max-Age=0; Expires=Sun, 21-May-2017 13:21:30 GMT
Content-Type: application/yang.operation+json
Transfer-Encoding: chunked
Server: Jetty(8.1.19.v20160209)

{"output":{"status":"CREATED"}}
[spinlock@Archer ~]$ curl -D - \
> --user "admin":"admin" \
> -H "Content-type: application/json" \
> -X POST \
> http://10.0.3.100:8181/restconf/operations/vtn-vinterface:update-vinterface \
> -d '{"input":{"tenant-name":"vtn1", "bridge-name":"vbr1", "interface-name":"if2"}}'
HTTP/1.1 200 OK
Set-Cookie: JSESSIONID=evg2giwcf42990lfvulk91pq;Path=/restconf
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Set-Cookie: rememberMe=deleteMe; Path=/restconf; Max-Age=0; Expires=Sun, 21-May-2017 13:23:20 GMT
Content-Type: application/yang.operation+json
Transfer-Encoding: chunked
Server: Jetty(8.1.19.v20160209)

{"output":{"status":"CREATED"}}

两次请求使虚拟接口创建成功。下面发送两次Rest请求设置端口映射:

[spinlock@Archer ~]$ curl -D - \
> --user "admin":"admin" \
> -H "Content-type: application/json" \
> -X POST \
> http://10.0.3.100:8181/restconf/operations/vtn-port-map:set-port-map \
> -d '{"input":{"tenant-name":"vtn1", "bridge-name":"vbr1", "interface-name":"if1", "node":"openflow:2", "port-name":"s2-eth1"}}'
HTTP/1.1 200 OK
Set-Cookie: JSESSIONID=1ghi8v29vruwzw20by3q3hc84;Path=/restconf
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Set-Cookie: rememberMe=deleteMe; Path=/restconf; Max-Age=0; Expires=Sun, 21-May-2017 13:28:56 GMT
Content-Type: application/yang.operation+json
Transfer-Encoding: chunked
Server: Jetty(8.1.19.v20160209)

{"output":{"status":"CREATED"}}
[spinlock@Archer ~]$ curl -D - \
> --user "admin":"admin" \
> -H "Content-type: application/json" \
> -X POST \
> http://10.0.3.100:8181/restconf/operations/vtn-port-map:set-port-map \
> -d '{"input":{"tenant-name":"vtn1", "bridge-name":"vbr1", "interface-name":"if2", "node":"openflow:3", "port-name":"s3-eth1"}}'
HTTP/1.1 200 OK
Set-Cookie: JSESSIONID=1w6wntp502au11viqd7e6q1s8m;Path=/restconf
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Set-Cookie: rememberMe=deleteMe; Path=/restconf; Max-Age=0; Expires=Sun, 21-May-2017 13:29:56 GMT
Content-Type: application/yang.operation+json
Transfer-Encoding: chunked
Server: Jetty(8.1.19.v20160209)

{"output":{"status":"CREATED"}}

可以看到两次请求操作成功。下面在mininet-vm1的mn控制台中进行检验:

mininet> pingall
*** Ping: testing ping reachability
h1 -> h2 h3 h4
h2 -> h1 h3 h4
h3 -> h1 h2 h4
h4 -> h1 h2 h3
*** Results: 0% dropped (12/12 received)

h1和h3之间是通的。但是我个人觉得,官网给出的这样的实验好像并不能说明vtn真的生效了,毕竟在设置vtn之前h1和h3就是通的。但通过Rest请求可以看到当前的vtn配置:

[spinlock@Archer ~]$ curl -D - \
> --user "admin":"admin" \
> -H "Content-type: application/json" \
> -X GET \
> http://10.0.3.100:8181/restconf/operational/vtn:vtns/
HTTP/1.1 200 OK
Set-Cookie: JSESSIONID=1r3oda59gx3n2y52koy9jv7e6;Path=/restconf
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Set-Cookie: rememberMe=deleteMe; Path=/restconf; Max-Age=0; Expires=Sun, 21-May-2017 13:37:28 GMT
Content-Type: application/yang.data+json
Vary: Accept-Encoding, User-Agent
Transfer-Encoding: chunked
Server: Jetty(8.1.19.v20160209)

{"vtns":{"vtn":[{"name":"vtn1","vtenant-config":{"hard-timeout":0,"idle-timeout":300},"vbridge":[{"name":"vbr1","bridge-status":{"path-faults":0,"state":"UP"},"vbridge-config":{"age-interval":600},"vinterface":[{"name":"if2","vinterface-config":{"enabled":true},"port-map-config":{"vlan-id":0,"node":"openflow:3","port-name":"s3-eth1"},"vinterface-status":{"entity-state":"UP","state":"UP","mapped-port":"openflow:3:1"}},{"name":"if1","vinterface-config":{"enabled":true},"port-map-config":{"vlan-id":0,"node":"openflow:2","port-name":"s2-eth1"},"vinterface-status":{"entity-state":"UP","state":"UP","mapped-port":"openflow:2:1"}}]}]}]}}

使用以下的Rest请求,可以删除vtn:

[spinlock@Archer ~]$ curl -D - \
> --user "admin":"admin" \
> -H "Content-type: application/json" \
> -X POST \
> http://10.0.3.100:8181/restconf/operations/vtn:remove-vtn \
> -d '{"input":{"tenant-name":"vtn1"}}'
HTTP/1.1 200 OK
Set-Cookie: JSESSIONID=1ea0ylyvlmz27m8io74da2b46;Path=/restconf
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Set-Cookie: rememberMe=deleteMe; Path=/restconf; Max-Age=0; Expires=Sun, 21-May-2017 13:40:02 GMT
Content-Type: application/yang.operation+json
Content-Length: 0
Server: Jetty(8.1.19.v20160209)

VLAN映射实验

参考例子

创建拓扑环境

vlan_vtn_test.py
下载到mininet-vm1中。并执行以下命令创建拓扑:

mininet@mininet-vm1:~$ sudo mn --controller=remote,ip=10.0.3.100,port=6633 --custom=./vlan_vtn_test.py --topo=mytopo --mac --switch=ovsk,protocols=OpenFlow13
mininet> net
h1 h1-eth0.200:s1-eth1
h2 h2-eth0.300:s2-eth2
h3 h3-eth0.200:s2-eth3
h4 h4-eth0.300:s2-eth4
h5 h5-eth0.200:s3-eth2
h6 h6-eth0.300:s3-eth3
s1 lo:  s1-eth1:h1-eth0.200 s1-eth2:s2-eth1 s1-eth3:s3-eth1
s2 lo:  s2-eth1:s1-eth2 s2-eth2:h2-eth0.300 s2-eth3:h3-eth0.200 s2-eth4:h4-eth0.300
s3 lo:  s3-eth1:s1-eth3 s3-eth2:h5-eth0.200 s3-eth3:h6-eth0.300
c0
mininet> pingall
*** Ping: testing ping reachability
h1 -> X h3 X h5 X
h2 -> X X h4 X h6
h3 -> h1 X X h5 X
h4 -> X h2 X X h6
h5 -> h1 X h3 X X
h6 -> X h2 X h4 X
*** Results: 60% dropped (12/30 received)

配置VTN

发送下面Rest请求,创建VTN:

[spinlock@Archer ~]$ curl -D - \
> --user "admin":"admin" \
> -H "Content-type: application/json" \
> -X POST \
> http://10.0.3.100:8181/restconf/operations/vtn:update-vtn \
> -d '{"input":{"tenant-name":"vtn1"}}'
HTTP/1.1 200 OK
Set-Cookie: JSESSIONID=10y3wftiocua018h9ksdi6uq1h;Path=/restconf
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Set-Cookie: rememberMe=deleteMe; Path=/restconf; Max-Age=0; Expires=Mon, 22-May-2017 03:27:36 GMT
Content-Type: application/yang.operation+json
Transfer-Encoding: chunked
Server: Jetty(8.1.19.v20160209)

{"output":{"status":"CREATED"}}

接下来创建虚拟网桥vbr1:

[spinlock@Archer ~]$ curl -D - \
> --user "admin":"admin" \
> -H "Content-type: application/json" \
> -X POST \
> http://10.0.3.100:8181/restconf/operations/vtn-vbridge:update-vbridge \
> -d '{"input":{"tenant-name":"vtn1","bridge-name":"vbr1"}}'
HTTP/1.1 200 OK
Set-Cookie: JSESSIONID=n0qy5m5gx7lyeii2irrccwc7;Path=/restconf
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Set-Cookie: rememberMe=deleteMe; Path=/restconf; Max-Age=0; Expires=Mon, 22-May-2017 03:36:58 GMT
Content-Type: application/yang.operation+json
Transfer-Encoding: chunked
Server: Jetty(8.1.19.v20160209)

{"output":{"status":"CREATED"}}

为vbr1做vlan映射,映射到vlan-id为200的网络上。

[spinlock@Archer ~]$ curl -D - \
> --user "admin":"admin" \
> -H "Content-type: application/json" \
> -X POST \
> http://10.0.3.100:8181/restconf/operations/vtn-vlan-map:add-vlan-map \
> -d '{"input":{"vlan-id":200,"tenant-name":"vtn1","bridge-name":"vbr1"}}'
HTTP/1.1 200 OK
Set-Cookie: JSESSIONID=wibnti530eim1i8wtn9pmotgm;Path=/restconf
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Set-Cookie: rememberMe=deleteMe; Path=/restconf; Max-Age=0; Expires=Mon, 22-May-2017 06:57:13 GMT
Content-Type: application/yang.operation+json
Transfer-Encoding: chunked
Server: Jetty(8.1.19.v20160209)

{"output":{"map-id":"ANY.200","active":true}}

同样地,继续创建第二个虚拟网桥vbr2:

[spinlock@Archer ~]$ curl -D - \
> --user "admin":"admin" \
> -H "Content-type: application/json" \
> -X POST \
> http://10.0.3.100:8181/restconf/operations/vtn-vbridge:update-vbridge \
> -d '{"input":{"tenant-name":"vtn1","bridge-name":"vbr2"}}'
HTTP/1.1 200 OK
Set-Cookie: JSESSIONID=4sa6xi08ws8v1obxkv3v1zcj7;Path=/restconf
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Set-Cookie: rememberMe=deleteMe; Path=/restconf; Max-Age=0; Expires=Mon, 22-May-2017 06:59:24 GMT
Content-Type: application/yang.operation+json
Transfer-Encoding: chunked
Server: Jetty(8.1.19.v20160209)

{"output":{"status":"CREATED"}}

然后为vbr2遇到到vlan-id为300的vlan网络上:

[spinlock@Archer ~]$ curl -D - \
> --user "admin":"admin" \
> -H "Content-type: application/json" \
> -X POST \
> http://10.0.3.100:8181/restconf/operations/vtn-vlan-map:add-vlan-map \
> -d '{"input":{"vlan-id":300,"tenant-name":"vtn1","bridge-name":"vbr2"}}'
HTTP/1.1 200 OK
Set-Cookie: JSESSIONID=g2mkt9nyadh815rbg2smrcvlj;Path=/restconf
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Set-Cookie: rememberMe=deleteMe; Path=/restconf; Max-Age=0; Expires=Mon, 22-May-2017 07:01:06 GMT
Content-Type: application/yang.operation+json
Transfer-Encoding: chunked
Server: Jetty(8.1.19.v20160209)

{"output":{"map-id":"ANY.300","active":true}}

设置完成后可以在mininet-vm1的mn控制台上进行验证:

mininet> pingall
*** Ping: testing ping reachability
h1 -> X h3 X h5 X
h2 -> X X h4 X h6
h3 -> h1 X X h5 X
h4 -> X h2 X X h6
h5 -> h1 X h3 X X
h6 -> X h2 X h4 X
*** Results: 60% dropped (12/30 received)

可以发现互通性是和预期效果一样的。同样也可以通过Rest请求查看当前的vtn配置:

[spinlock@Archer ~]$ curl -D - \
> --user "admin":"admin" \
> -H "Content-type: application/json" \
> -X GET \
> http://10.0.3.100:8181/restconf/operational/vtn:vtns
HTTP/1.1 200 OK
Set-Cookie: JSESSIONID=zapg0btgip5684wh4w4aex53;Path=/restconf
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Set-Cookie: rememberMe=deleteMe; Path=/restconf; Max-Age=0; Expires=Mon, 22-May-2017 07:10:56 GMT
Content-Type: application/yang.data+json
Vary: Accept-Encoding, User-Agent
Transfer-Encoding: chunked
Server: Jetty(8.1.19.v20160209)

{"vtns":{"vtn":[{"name":"vtn1","vbridge":[{"name":"vbr2","bridge-status":{"path-faults":0,"state":"UP"},"vbridge-config":{"age-interval":600},"vlan-map":[{"map-id":"ANY.300","vlan-map-config":{"vlan-id":300},"vlan-map-status":{"active":true}}]},{"name":"vbr1","bridge-status":{"path-faults":0,"state":"UP"},"vbridge-config":{"age-interval":600},"vlan-map":[{"map-id":"ANY.200","vlan-map-config":{"vlan-id":200},"vlan-map-status":{"active":true}}]}],"vtenant-config":{"hard-timeout":0,"idle-timeout":300}}]}}

最后,使用下面请求清除vtn1配置。完成实验。

[spinlock@Archer ~]$ curl -D - \
> --user "admin":"admin" \
> -H "Content-type: application/json" \
> -X POST \
> http://10.0.3.100:8181/restconf/operations/vtn:remove-vtn \
> -d '{"input":{"tenant-name":"vtn1"}}'
HTTP/1.1 200 OK
Set-Cookie: JSESSIONID=rjyzfx4pgokz13e5t5pjbexnr;Path=/restconf
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Set-Cookie: rememberMe=deleteMe; Path=/restconf; Max-Age=0; Expires=Mon, 22-May-2017 07:16:02 GMT
Content-Type: application/yang.operation+json
Content-Length: 0
Server: Jetty(8.1.19.v20160209)

官网给出的这一个实验和上一个实验一样,在配置之前与配置之后,vlan的互通性都是一样的,也看不出配置究竟有没有效。这里表示疑问。

  • 0
    点赞
  • 2
    评论
  • 0
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

©️2021 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值