Migrate ALTO user docs to rst
[docs.git] / manuals / user-guide / src / main / asciidoc / vtn / VTN_Manager_How_To_Use_VTN_to_change_the_path_of_the_packet_flow.adoc
1 ==== How to use VTN to change the path of the packet flow
2
3 ===== Overview
4
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.
6
7 .Pathmap
8 image::vtn/Pathmap.png["Pathmap",width=500]
9
10 ===== Requirement
11
12 * Save the mininet script given below as pathmap_test.py and run the mininet script in the mininet environment where Mininet is installed.
13
14 * Create topology using the below mininet script:
15
16 ----
17  from mininet.topo import Topo
18  class MyTopo( Topo ):
19     "Simple topology example."
20     def __init__( self ):
21         "Create custom topo."
22         # Initialize topology
23         Topo.__init__( self )
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' )
31         # Add links
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() ) }
39 ----
40
41 * After creating new file with the above script start the mininet as below,
42
43 ----
44 sudo mn --controller=remote,ip=10.106.138.124 --custom pathmap_test.py --topo mytopo
45 ----
46
47 NOTE: Replace "10.106.138.124" with the IP address of OpenDaylight controller based on your environment.
48
49 ----
50  mininet> net
51  h1 h1-eth0:s1-eth1
52  h2 h2-eth0:s3-eth3
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
57  c0
58 ----
59
60 * Generate traffic by pinging between host h1 and host h2 before creating the portmaps respectively.
61
62 ----
63  mininet> h1 ping h2
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
69 ----
70
71 ===== Configuration
72
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.
74
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].
77
78 ----
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"}}'
80 ----
81
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].
84
85 ----
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"}}'
87 ----
88
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].
91
92 ----
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"}}'
94 ----
95
96
97 ----
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"}}'
99 ----
100
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].
103
104 ** The interface if1 of the virtual bridge will be mapped to the port "s2-eth1" of the switch "openflow:1" of the Mininet.
105
106 *** The h1 is connected to the port "s1-eth1".
107
108 ** The interface if2 of the virtual bridge will be mapped to the port "s3-eth1" of the switch "openflow:3" of the Mininet.
109
110 *** The h3 is connected to the port "s3-eth3".
111
112 ----
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"}}'
114 ----
115
116 ----
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"}}'
118 ----
119
120 * Genarate traffic by pinging between host h1 and host h2 after creating the portmaps respectively.
121
122 ----
123  mininet> h1 ping h2
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
128 ----
129
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].
132
133 ----
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"}}}'
135 ----
136
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].
139
140 ** For option source and destination-network, get inet address of host h1 or host h2 from mininet
141
142 ----
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"}]}}'
144 ----
145
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].
148
149 ----
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"}]}}'
151 ----
152
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].
155
156 ----
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"}]}}'
158 ----
159
160 ===== Verification
161
162 * Before applying Path policy get node information by executing get dataflow command.
163
164 ----
165 "data-flow-info": [
166 {
167   "physical-route": [
168   {
169     "physical-ingress-port": {
170       "port-name": "s3-eth3",
171         "port-id": "3"
172     },
173       "physical-egress-port": {
174         "port-name": "s3-eth1",
175         "port-id": "1"
176       },
177       "node": "openflow:3",
178       "order": 0
179   },
180   {
181     "physical-ingress-port": {
182       "port-name": "s2-eth2",
183       "port-id": "2"
184     },
185     "physical-egress-port": {
186       "port-name": "s2-eth1",
187       "port-id": "1"
188     },
189     "node": "openflow:2",
190     "order": 1
191   },
192   {
193     "physical-ingress-port": {
194       "port-name": "s1-eth2",
195       "port-id": "2"
196     },
197     "physical-egress-port": {
198       "port-name": "s1-eth1",
199       "port-id": "1"
200     },
201     "node": "openflow:1",
202     "order": 2
203   }
204   ],
205     "data-egress-node": {
206       "interface-name": "if1",
207       "bridge-name": "vbr1",
208       "tenant-name": "vtn1"
209     },
210     "data-egress-port": {
211       "node": "openflow:1",
212       "port-name": "s1-eth1",
213       "port-id": "1"
214     },
215     "data-ingress-node": {
216       "interface-name": "if2",
217       "bridge-name": "vbr1",
218       "tenant-name": "vtn1"
219     },
220     "data-ingress-port": {
221       "node": "openflow:3",
222       "port-name": "s3-eth3",
223       "port-id": "3"
224     },
225     "flow-id": 32
226   },
227 }
228 ----
229
230 * After applying Path policy get node information by executing get dataflow command.
231
232 ----
233 "data-flow-info": [
234 {
235   "physical-route": [
236   {
237     "physical-ingress-port": {
238       "port-name": "s1-eth1",
239         "port-id": "1"
240     },
241       "physical-egress-port": {
242         "port-name": "s1-eth3",
243         "port-id": "3"
244       },
245       "node": "openflow:1",
246       "order": 0
247   },
248   {
249     "physical-ingress-port": {
250       "port-name": "s4-eth1",
251       "port-id": "1"
252     },
253     "physical-egress-port": {
254       "port-name": "s4-eth2",
255       "port-id": "2"
256     },
257     "node": "openflow:4",
258     "order": 1
259   },
260   {
261     "physical-ingress-port": {
262       "port-name": "s3-eth2",
263       "port-id": "2"
264     },
265     "physical-egress-port": {
266       "port-name": "s3-eth3",
267       "port-id": "3"
268     },
269     "node": "openflow:3",
270     "order": 2
271   }
272   ],
273     "data-egress-node": {
274       "interface-name": "if2",
275       "bridge-name": "vbr1",
276       "tenant-name": "vtn1"
277     },
278     "data-egress-port": {
279       "node": "openflow:3",
280       "port-name": "s3-eth3",
281       "port-id": "3"
282     },
283     "data-ingress-node": {
284       "interface-name": "if1",
285       "bridge-name": "vbr1",
286       "tenant-name": "vtn1"
287     },
288     "data-ingress-port": {
289       "node": "openflow:1",
290       "port-name": "s1-eth1",
291       "port-id": "1"
292     },
293 }
294 ----
295
296 ===== Cleaning Up
297
298 * To clean up both VTN and flowcondition.
299
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].
302
303 ----
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"}}'
305 ----
306
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].
309
310 ----
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"}}'
312 ----
313