1 ==== How to use VTN to change the path of the packet flow
5 * This page explains how to create specific VTN Pathmap using VTN Manager. This page targets Beryllium release, so the procedure described here does not work in other releases.
8 image::vtn/Pathmap.png["Pathmap",width=500]
12 * Save the mininet script given below as pathmap_test.py and run the mininet script in the mininet environment where Mininet is installed.
14 * Create topology using the below mininet script:
17 from mininet.topo import Topo
19 "Simple topology example."
24 # Add hosts and switches
25 leftHost = self.addHost( 'h1' )
26 rightHost = self.addHost( 'h2' )
27 leftSwitch = self.addSwitch( 's1' )
28 middleSwitch = self.addSwitch( 's2' )
29 middleSwitch2 = self.addSwitch( 's4' )
30 rightSwitch = self.addSwitch( 's3' )
32 self.addLink( leftHost, leftSwitch )
33 self.addLink( leftSwitch, middleSwitch )
34 self.addLink( leftSwitch, middleSwitch2 )
35 self.addLink( middleSwitch, rightSwitch )
36 self.addLink( middleSwitch2, rightSwitch )
37 self.addLink( rightSwitch, rightHost )
38 topos = { 'mytopo': ( lambda: MyTopo() ) }
41 * After creating new file with the above script start the mininet as below,
44 sudo mn --controller=remote,ip=10.106.138.124 --custom pathmap_test.py --topo mytopo
47 NOTE: Replace "10.106.138.124" with the IP address of OpenDaylight controller based on your environment.
53 s1 lo: s1-eth1:h1-eth0 s1-eth2:s2-eth1 s1-eth3:s4-eth1
54 s2 lo: s2-eth1:s1-eth2 s2-eth2:s3-eth1
55 s3 lo: s3-eth1:s2-eth2 s3-eth2:s4-eth2 s3-eth3:h2-eth0
56 s4 lo: s4-eth1:s1-eth3 s4-eth2:s3-eth2
60 * Generate traffic by pinging between host h1 and host h2 before creating the portmaps respectively.
64 PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.
65 From 10.0.0.1 icmp_seq=1 Destination Host Unreachable
66 From 10.0.0.1 icmp_seq=2 Destination Host Unreachable
67 From 10.0.0.1 icmp_seq=3 Destination Host Unreachable
68 From 10.0.0.1 icmp_seq=4 Destination Host Unreachable
73 * To change the path of the packet flow, execute REST API provided by VTN Manager as follows. It uses curl command to call the REST API.
75 * Create a virtual tenant named vtn1 by executing
76 https://jenkins.opendaylight.org/releng/view/vtn/job/vtn-merge-beryllium/lastSuccessfulBuild/artifact/manager/model/target/site/models/vtn.html#update-vtn[the update-vtn RPC].
79 curl --user "admin":"admin" -H "Content-type: application/json" -X POST http://localhost:8181/restconf/operations/vtn:update-vtn -d '{"input":{"tenant-name":"vtn1"}}'
82 * Create a virtual bridge named vbr1 in the tenant vtn1 by executing
83 https://jenkins.opendaylight.org/releng/view/vtn/job/vtn-merge-beryllium/lastSuccessfulBuild/artifact/manager/model/target/site/models/vtn-vbridge.html#update-vbridge[the update-vbridge RPC].
86 curl --user "admin":"admin" -H "Content-type: application/json" -X POST http://localhost:8181/restconf/operations/vtn-vbridge:update-vbridge -d '{"input":{"tenant-name":"vtn1","bridge-name":"vbr1"}}'
89 * Create two interfaces into the virtual bridge by executing
90 https://jenkins.opendaylight.org/releng/view/vtn/job/vtn-merge-beryllium/lastSuccessfulBuild/artifact/manager/model/target/site/models/vtn-vinterface.html#update-vinterface[the update-vinterface RPC].
93 curl --user "admin":"admin" -H "Content-type: application/json" -X POST http://localhost:8181/restconf/operations/vtn-vinterface:update-vinterface -d '{"input":{"tenant-name":"vtn1","bridge-name":"vbr1","interface-name":"if1"}}'
98 curl --user "admin":"admin" -H "Content-type: application/json" -X POST http://localhost:8181/restconf/operations/vtn-vinterface:update-vinterface -d '{"input":{"tenant-name":"vtn1","bridge-name":"vbr1","interface-name":"if2"}}'
101 * Configure two mappings on the interfaces by executing
102 https://jenkins.opendaylight.org/releng/view/vtn/job/vtn-merge-beryllium/lastSuccessfulBuild/artifact/manager/model/target/site/models/vtn-port-map.html#set-port-map[the set-port-map RPC].
104 ** The interface if1 of the virtual bridge will be mapped to the port "s2-eth1" of the switch "openflow:1" of the Mininet.
106 *** The h1 is connected to the port "s1-eth1".
108 ** The interface if2 of the virtual bridge will be mapped to the port "s3-eth1" of the switch "openflow:3" of the Mininet.
110 *** The h3 is connected to the port "s3-eth3".
113 curl --user "admin":"admin" -H "Content-type: application/json" -X POST http://localhost:8181/restconf/operations/vtn-port-map:set-port-map -d '{"input":{"tenant-name":"vtn1", "bridge-name":"vbr1", "interface-name":"if1", "node":"openflow:1", "port-name":"s1-eth1"}}'
117 curl --user "admin":"admin" -H "Content-type: application/json" -X POST http://localhost: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-eth3"}}'
120 * Genarate traffic by pinging between host h1 and host h2 after creating the portmaps respectively.
124 PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.
125 64 bytes from 10.0.0.2: icmp_seq=1 ttl=64 time=0.861 ms
126 64 bytes from 10.0.0.2: icmp_seq=2 ttl=64 time=0.101 ms
127 64 bytes from 10.0.0.2: icmp_seq=3 ttl=64 time=0.101 ms
130 * Get the Dataflows information by executing
131 https://jenkins.opendaylight.org/releng/view/vtn/job/vtn-merge-beryllium/lastSuccessfulBuild/artifact/manager/model/target/site/models/vtn-flow.html#get-data-flow[the get-data-flow RPC].
134 curl --user "admin":"admin" -H "Content-type: application/json" -X POST http://localhost:8181/restconf/operations/vtn-flow:get-data-flow -d '{"input":{"tenant-name":"vtn1","mode":"DETAIL","node":"openflow:1","data-flow-port":{"port-id":1,"port-name":"s1-eth1"}}}'
137 * Create flowcondition named cond_1 by executing
138 https://jenkins.opendaylight.org/releng/view/vtn/job/vtn-merge-beryllium/lastSuccessfulBuild/artifact/manager/model/target/site/models/vtn-flow-condition.html#set-flow-condition[the set-flow-condition RPC].
140 ** For option source and destination-network, get inet address of host h1 or host h2 from mininet
143 curl --user "admin":"admin" -H "Content-type: application/json" -X POST http://localhost:8181/restconf/operations/vtn-flow-condition:set-flow-condition -d '{"input":{"operation":"SET","present":"false","name":"cond_1", "vtn-flow-match":[{"vtn-ether-match":{},"vtn-inet-match":{"source-network":"10.0.0.1/32","protocol":1,"destination-network":"10.0.0.2/32"},"index":"1"}]}}'
146 * Create pathmap with flowcondition cond_1 by executing
147 https://jenkins.opendaylight.org/releng/view/vtn/job/vtn-merge-beryllium/lastSuccessfulBuild/artifact/manager/model/target/site/models/vtn-path-map.html#set-path-map[the set-path-map RPC].
150 curl --user "admin":"admin" -H "Content-type: application/json" -X POST http://localhost:8181/restconf/operations/vtn-path-map:set-path-map -d '{"input":{"tenant-name":"vtn1","path-map-list":[{"condition":"cond_1","policy":"1","index": "1","idle-timeout":"300","hard-timeout":"0"}]}}'
153 * Create pathpolicy by executing
154 https://jenkins.opendaylight.org/releng/view/vtn/job/vtn-merge-beryllium/lastSuccessfulBuild/artifact/manager/model/target/site/models/vtn-path-policy.html#set-path-policy[the set-path-policy RPC].
157 curl --user "admin":"admin" -H "Content-type: application/json" -X POST http://localhost:8181/restconf/operations/vtn-path-policy:set-path-policy -d '{"input":{"operation":"SET","id": "1","default-cost": "10000","vtn-path-cost": [{"port-desc":"openflow:1,3,s1-eth3","cost":"1000"},{"port-desc":"openflow:4,2,s4-eth2","cost":"1000"},{"port-desc":"openflow:3,3,s3-eth3","cost":"100000"}]}}'
162 * Before applying Path policy get node information by executing get dataflow command.
169 "physical-ingress-port": {
170 "port-name": "s3-eth3",
173 "physical-egress-port": {
174 "port-name": "s3-eth1",
177 "node": "openflow:3",
181 "physical-ingress-port": {
182 "port-name": "s2-eth2",
185 "physical-egress-port": {
186 "port-name": "s2-eth1",
189 "node": "openflow:2",
193 "physical-ingress-port": {
194 "port-name": "s1-eth2",
197 "physical-egress-port": {
198 "port-name": "s1-eth1",
201 "node": "openflow:1",
205 "data-egress-node": {
206 "interface-name": "if1",
207 "bridge-name": "vbr1",
208 "tenant-name": "vtn1"
210 "data-egress-port": {
211 "node": "openflow:1",
212 "port-name": "s1-eth1",
215 "data-ingress-node": {
216 "interface-name": "if2",
217 "bridge-name": "vbr1",
218 "tenant-name": "vtn1"
220 "data-ingress-port": {
221 "node": "openflow:3",
222 "port-name": "s3-eth3",
230 * After applying Path policy get node information by executing get dataflow command.
237 "physical-ingress-port": {
238 "port-name": "s1-eth1",
241 "physical-egress-port": {
242 "port-name": "s1-eth3",
245 "node": "openflow:1",
249 "physical-ingress-port": {
250 "port-name": "s4-eth1",
253 "physical-egress-port": {
254 "port-name": "s4-eth2",
257 "node": "openflow:4",
261 "physical-ingress-port": {
262 "port-name": "s3-eth2",
265 "physical-egress-port": {
266 "port-name": "s3-eth3",
269 "node": "openflow:3",
273 "data-egress-node": {
274 "interface-name": "if2",
275 "bridge-name": "vbr1",
276 "tenant-name": "vtn1"
278 "data-egress-port": {
279 "node": "openflow:3",
280 "port-name": "s3-eth3",
283 "data-ingress-node": {
284 "interface-name": "if1",
285 "bridge-name": "vbr1",
286 "tenant-name": "vtn1"
288 "data-ingress-port": {
289 "node": "openflow:1",
290 "port-name": "s1-eth1",
298 * To clean up both VTN and flowcondition.
300 * You can delete the virtual tenant vtn1 by executing
301 https://jenkins.opendaylight.org/releng/view/vtn/job/vtn-merge-beryllium/lastSuccessfulBuild/artifact/manager/model/target/site/models/vtn.html#remove-vtn[the remove-vtn RPC].
304 curl --user "admin":"admin" -H "Content-type: application/json" -X POST http://localhost:8181/restconf/operations/vtn:remove-vtn -d '{"input":{"tenant-name":"vtn1"}}'
307 * You can delete the flowcondition cond_1 by executing
308 https://jenkins.opendaylight.org/releng/view/vtn/job/vtn-merge-beryllium/lastSuccessfulBuild/artifact/manager/model/target/site/models/vtn-flow-condition.html#remove-flow-condition[the remove-flow-condition RPC].
311 curl --user "admin":"admin" -H "Content-type: application/json" -X POST http://localhost:8181/restconf/operations/vtn-flow-condition:remove-flow-condition -d '{"input":{"name":"cond_1"}}'