1 ==== How To Use VTN To Make Packets Take Different Paths
2 This example demonstrates on how to create a specific VTN Path Map information.
5 image::vtn/Pathmap.png["Pathmap" ,width= 500]
8 * Save the mininet script given below as pathmap_test.py and run the mininet script in the mininet environment where Mininet is installed.
10 * Create topology using the below mininet script:
13 from mininet.topo import Topo
15 "Simple topology example."
20 # Add hosts and switches
21 leftHost = self.addHost( 'h1' )
22 rightHost = self.addHost( 'h2' )
23 leftSwitch = self.addSwitch( 's1' )
24 middleSwitch = self.addSwitch( 's2' )
25 middleSwitch2 = self.addSwitch( 's4' )
26 rightSwitch = self.addSwitch( 's3' )
28 self.addLink( leftHost, leftSwitch )
29 self.addLink( leftSwitch, middleSwitch )
30 self.addLink( leftSwitch, middleSwitch2 )
31 self.addLink( middleSwitch, rightSwitch )
32 self.addLink( middleSwitch2, rightSwitch )
33 self.addLink( rightSwitch, rightHost )
34 topos = { 'mytopo': ( lambda: MyTopo() ) }
40 s1 lo: s1-eth1:h1-eth0 s1-eth2:s2-eth1 s1-eth3:s4-eth1
41 s2 lo: s2-eth1:s1-eth2 s2-eth2:s3-eth1
42 s3 lo: s3-eth1:s2-eth2 s3-eth2:s4-eth2 s3-eth3:h2-eth0
43 s4 lo: s4-eth1:s1-eth3 s4-eth2:s3-eth2
48 NOTE: Add the default flow to OVS to forward packets to controller when there is a table-miss:
51 ovs-ofctl --protocols=OpenFlow13 add-flow <switch-name> priority=0,actions=output:CONTROLLER
54 These flows need to be added only in case of OpenFlow1.3 or using OVS versions (>2.1.1).
56 Here the switch name is the switches in the topology such as s1,s2,s3.
58 * Generate traffic by pinging between hosts h1 and h2 before creating the portmaps respectively
62 PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.
63 From 10.0.0.1 icmp_seq=1 Destination Host Unreachable
64 From 10.0.0.1 icmp_seq=2 Destination Host Unreachable
65 From 10.0.0.1 icmp_seq=3 Destination Host Unreachable
66 From 10.0.0.1 icmp_seq=4 Destination Host Unreachable
73 curl --user admin:adminpass -H 'content-type: application/json' -X POST -d '{"controller": {"controller_id": "odc", "ipaddr":"10.100.9.42", "type": "odc", "version": "1.0", "auditstatus":"enable"}}' http://127.0.0.1:8083/vtn-webapi/controllers.json
79 curl --user admin:adminpass -H 'content-type: application/json' -X POST -d '{"vtn" : {"vtn_name":"vtn1","description":"test VTN" }}' http://127.0.0.1:8083/vtn-webapi/vtns.json
82 * Create a vBridge in the VTN
85 curl --user admin:adminpass -H 'content-type: application/json' -X POST -d '{"vbridge" : {"vbr_name":"vBridge1","controller_id":"odc","domain_id":"(DEFAULT)" }}' http://127.0.0.1:8083/vtn-webapi/vtns/vtn1/vbridges.json
88 * Create two Interfaces into the vBridge
91 curl --user admin:adminpass -H 'content-type: application/json' -X POST -d '{"interface": {"if_name": "if1","description": "if_desc1"}}' http://127.0.0.1:8083/vtn-webapi/vtns/vtn1/vbridges/vBridge1/interfaces.json
92 curl --user admin:adminpass -H 'content-type: application/json' -X POST -d '{"interface": {"if_name": "if2","description": "if_desc2"}}' http://127.0.0.1:8083/vtn-webapi/vtns/vtn1/vbridges/vBridge1/interfaces.json
95 * Configure two mappings on the interfaces
98 curl --user admin:adminpass -H 'content-type: application/json' -X PUT -d '{"portmap":{"logical_port_id": "PP-OF:00:00:00:00:00:00:00:01-s1-eth1"}}' http://127.0.0.1:8083/vtn-webapi/vtns/vtn1/vbridges/vBridge1/interfaces/if1/portmap.json
99 curl --user admin:adminpass -H 'content-type: application/json' -X PUT -d '{"portmap":{"logical_port_id": "PP-OF:00:00:00:00:00:00:00:03-s3-eth3"}}' http://127.0.0.1:8083/vtn-webapi/vtns/vtn1/vbridges/vBridge1/interfaces/if2/portmap.json
102 * Generate traffic by pinging between hosts h1 and h2 after creating the portmaps respectively
106 PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.
107 64 bytes from 10.0.0.2: icmp_req=1 ttl=64 time=36.4 ms
108 64 bytes from 10.0.0.2: icmp_req=2 ttl=64 time=0.880 ms
109 64 bytes from 10.0.0.2: icmp_req=3 ttl=64 time=0.073 ms
110 64 bytes from 10.0.0.2: icmp_req=4 ttl=64 time=0.081 ms
113 * Get the VTN Dataflows information
116 curl -X GET -H 'content-type: application/json' --user 'admin:adminpass' "http://127.0.0.1:8083/vtn-webapi/dataflows?&switch_id=00:00:00:00:00:00:00:01&port_name=s1-eth1&controller_id=odc&srcmacaddr=de3d.7dec.e4d2&no_vlan_id=true"
119 * Create a Flowcondition in the VTN
122 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"}]}}'
125 * Create a Pathmap in the VTN
128 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"}]}}'
131 * Get the Path policy information
134 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":"100000"},{"port-desc":"openflow:3,3,s3-eth3","cost":"10000"}]}}'
138 * Before applying Path policy information in the VTN
144 "in_port_name": "s1-eth1",
145 "out_port_name": "s1-eth3",
146 "switch_id": "openflow:1"
149 "in_port_name": "s4-eth1",
150 "out_port_name": "s4-eth2",
151 "switch_id": "openflow:4"
154 "in_port_name": "s3-eth2",
155 "out_port_name": "s3-eth3",
156 "switch_id": "openflow:3"
161 * After applying Path policy information in the VTN
167 "in_port_name": "s1-eth1",
168 "out_port_name": "s1-eth2",
169 "switch_id": "openflow:1"
172 "in_port_name": "s2-eth1",
173 "out_port_name": "s2-eth2",
174 "switch_id": "openflow:2"
177 "in_port_name": "s3-eth1",
178 "out_port_name": "s3-eth3",
179 "switch_id": "openflow:3"