准备工作:
postman
mininet (2.3.0d1), ovs(v2.5.0),
创建网络拓扑:
sudo mn –topo single,2 –cOntroller=remote,ip=192.168.1.157
h1—s1—h2
Opendaylight (Boron-SR3),安装后启动,并安装ovsdb组件;
feature:install odl-ovsdb-southbound-impl-ui
ODL所在主机的IP是192.168.1.157,Miminet的IP是192.168.1.181。
实验步骤
Mininet OVSDB连接到ODL
可以用OVSDB主动模式或是被动模式,本文使用主动模式,Mininet上打开6640端口监听
# ovs-vsctl set-manager ptcp:6640
ODL上添加node信息
URL=http://127.0.0.1:8181/restconf/config/network-topology:network-topology/topology/ovsdb:1/
Action=POST
COntent=
{
“network-topology:node”:[
{
“node-id”: “ovsdb:
“connection-info”: {
“ovsdb:remote-port”: 6640,
“ovsdb:remote-ip”: “192.168.1.181”
}
}
]
}
查看连接状态
ODL主机上:
Mininet上
查看获取的bridge的信息
URL=http://127.0.0.1:8181/restconf/operational/network-topology:network-topology/topology/ovsdb:1/node/ovsdb:%2F%2F192.168.1.181:6640%2Fbridge%2Fs1
Action=GET
注意URL中node后面的”/“用”%2F”代替
获取的内容很多,包括bridge:s1还有s1-eth1/s1-eth2的信息,就不贴了
向queue-entries中添加QUEUE-1
URL=http://127.0.0.1:8181/restconf/config/network-topology:network-topology/topology/ovsdb:1/node/ovsdb:%2F%2F192.168.1.181:6640/ovsdb:queues/QUEUE-1/
Action=PUT
{
"ovsdb:queues": [
{
"queue-id": "QUEUE-1",
"queues-other-config": [
{
"queue-other-config-key": "max-rate",
"queue-other-config-value": "1000000"
}
]
}
]
}
URL=http://127.0.0.1:8181/restconf/config/network-topology:network-topology/topology/ovsdb:1/node/ovsdb:%2F%2F192.168.1.181:6640/ovsdb:queues/QUEUE-2/
Action=PUT
COntent=
{
"ovsdb:queues": [
{
"queue-id": "QUEUE-2",
"queues-other-config": [
{
"queue-other-config-key": "max-rate",
"queue-other-config-value": "10000000"
}
]
}
]
}
接着添加QUEUE-3
URL=http://127.0.0.1:8181/restconf/config/network-topology:network-topology/topology/ovsdb:1/node/ovsdb:%2F%2F192.168.1.181:6640/ovsdb:queues/QUEUE-3/
Action=PUT
COntent=
{
"ovsdb:queues": [
{
"queue-id": "QUEUE-3",
"queues-other-config": [
{
"queue-other-config-key": "max-rate",
"queue-other-config-value": "100000000"
}
]
}
]
}
获取分配给两个queue的uuid
URL=http://127.0.0.1:8181/restconf/operational/network-topology:network-topology/topology/ovsdb:1/node/ovsdb:%2F%2F192.168.1.181:6640/ovsdb:queues/QUEUE-1/
Action=GET
return
所以QUEUE-1的uuid=”fdcf79a6-fd1d-4602-a119-1308aba594cb”
类似地,获取QUEUE-2的uuid=”bb895c20-f38d-4d49-babf-75faf1eba490”
获取QUEUE-3的uuid=”de9c017e-c092-4606-9fbf-4e2fbb8bc82f”
将三条queue的配置加到QoS entry
URL=http://127.0.0.1:8181/restconf/config/network-topology:network-topology/topology/ovsdb:1/node/ovsdb:%2F%2F192.168.1.181:6640/ovsdb:qos-entries/QOS-1/
Action=PUT
Content
{
"ovsdb:qos-entries": [
{
"qos-id": "QOS-1",
"qos-type":"ovsdb:qos-type-linux-htb",
"qos-other-config":[
{
"other-config-key":"max-rate",
"other-config-value":"100000000"
}
],
"queue-list": [
{
"queue-number": "1",
"queue-uuid": "fdcf79a6-fd1d-4602-a119-1308aba594cb"
},
{
"queue-number": "2",
"queue-uuid": "bb895c20-f38d-4d49-babf-75faf1eba490"
},
{
"queue-number": "3",
"queue-uuid": "de9c017e-c092-4606-9fbf-4e2fbb8bc82f"
}
]
}
]
}
即queue_1使用QUEUE-1策略,queue_2使用QUEUE-2策略
获取QOS的uuid
URL=http://127.0.0.1:8181/restconf/operational/network-topology:network-topology/topology/ovsdb:1/node/ovsdb:%2F%2F192.168.1.157:6640/ovsdb:qos-entries/QOS-1/
Action=GET
return
所以QOS-1的uuid=”2d44e4f2-ce14-4d99-8608-53388481a6d4”
将QOS-1应用到termination-point s1-eth1上
URL=http://127.0.0.1:8181/restconf/config/network-topology:network-topology/topology/ovsdb:1/node/ovsdb:%2F%2F192.168.1.181:6640%2Fbridge%2Fs1/termination-point/s1-eth1
Action=PUT
Content
{
"network-topology:termination-point": [
{
"ovsdb:name": "s1-eth1",
"tp-id": "s1-eth1",
"qos": "2d44e4f2-ce14-4d99-8608-53388481a6d4"
}
]
}
获取s1-eth1的信息
URL=http://127.0.0.1:8181/restconf/operational/network-topology:network-topology/topology/ovsdb:1/node/ovsdb:%2F%2F192.168.1.181:6640%2Fbridge%2Fs1/termination-point/s1-eth1
Action=GET
Return
可以看到QOS-1已经应用成功。
测试:
设置流表,在网桥openflow:1添加流表命令,并设置流表的优先级和队列号,使流量在指定的队列上转发出去,并测试流量的带宽。
URL:http://127.0.0.1:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:1/table/0/flow/1
Action=PUT
Content
第一次:
<queue-id>1</queue-id>
<queue>1</queue>
<flow xmlns="urn:opendaylight:flow:inventory">
<priority>20priority>
<flow-name>flow2flow-name>
<flags> SEND_FLOW_REM flags>
<match>
<in-port>openflow:1:2in-port>
match>
<hard-timeout>0hard-timeout>
<idle-timeout>0idle-timeout>
<COOKIE>30COOKIE>
<id>1id>
<table_id>0table_id>
<instructions>
<instruction>
<order>0order>
<apply-actions>
<action>
<order>1order>
<set-queue-action>
<queue-id>
1
queue-id>
<queue>
1
queue>
set-queue-action>
action>
<action>
<order>2order>
<output-action>
<output-node-connector>
openflow:1:1
output-node-connector>
output-action>
action>
apply-actions>
instruction>
instructions>
flow>
第二次:
<queue-id>2</queue-id>
<queue>2</queue>
下发流表项:
第三次:
3
3
由此,可以看到OoS确实被成功配置!
参考资料:
http://www.sdnlab.com/17601.html
http://docs.opendaylight.org/en/stable-boron/user-guide/ovsdb-user-guide.html
http://dannykim.me//danny/openflow/57771?ckattempt=1