Migrate to odlparent 1.9.0
[alto.git] / alto-extensions / simple-pce / README.md
1 # ALTO SPCE (Simple Path Computation Engine)
2
3 The ALTO SPCE module provides a simple path computation engine for ALTO and other projects. It works in the
4 OpenDaylight(ODL) SDN Controller.
5
6 ## Installation
7
8 One prerequisite for installing ALTO SPCE is that the ODL development environment should be setup by
9 following [this link](https://wiki.opendaylight.org/view/GettingStarted:Development_Environment_Setup).
10
11 With this prerequisite satisfied, execute `mvn clean install` in the directory of alto-spce project
12 to start the installation. After the installation, you can execute `./karaf/target/assembly/bin/karaf`
13 to start the alto-spce with ODL.
14
15 ## Deployment
16
17 You can also deploy this module into a running ODL controller without stopping the controller, by
18 running `./deploy.sh <distribution_directory>`, where `<distribution_directory>` is the path of your own running ODL distribution.
19
20 For example, if you start your ODL controller from `/root/distribution-karaf-0.4.0-SNAPSHOT/bin/karaf`, you can use the command `./deploy.sh /root/distribution-karaf-0.4.0-SNAP`.
21
22 > **NOTE:** If you have checked out the latest commit in master branch, you will need a `karaf-0.4.1-SNAPSHOT` distribution rather than `karaf-0.4.0-SNAPSHOT`.
23
24 And then, you can check whether the features of alto-spce are loaded in your karaf shell as follows:
25
26 ```
27 karaf@root()> feature:list | grep alto-spce
28 ```
29
30 If the features are loaded, you can install them by:
31
32 ```
33 karaf@root()> feature:install odl-alto-spce
34 ```
35
36 **Tip:**
37
38 ```
39 karaf@root()> log:tail
40 ```
41
42 You could use this command to get the tailing log. If you see **AltoSpceProvider Session Initiated!**,
43 it means that alto-spce has been installed successfully. 
44
45 ## Usage
46
47 ### Prerequisites
48
49 Please make sure that your have configured **l2switch** correctly. Two .xml files below could be found in `/karaf/target/assembly/etc/opendaylight/karaf`.
50
51 In **54-arphandler.xml**, please set
52
53 ```
54 <is-proactive-flood-mode>false</is-proactive-flood-mode>
55 ```
56
57 In **58-l2switchmain.xml**, please set
58
59 ```
60 <is-learning-only-mode>true</is-learning-only-mode>
61 ```
62
63 ### Creating a network using Mininet
64
65 ```
66 sudo mn --controller=remote,ip=<Controller IP> --mac --topo=linear,3 --switch ovsk,protocols=OpenFlow13
67 ```
68
69 The command above will create a virtual network consisting of 3 switches. And one host is attached to each switch.
70
71 ### Discover hosts
72
73 l2switch uses ARP packets to discover hosts. 
74
75 If we use mininet, we could use `ping` to let l2switch get the ARP packets it needs. 
76
77 ```
78 mininet> h1 ping h5
79 ```
80
81 After this command, l2switch will discover host1 and host5.
82
83
84 ### Setup/Remove a path with python-odl library
85
86 We have forked [python-odl](https://github.com/SPRACE/python-odl) project to support alto-spce. You could get the code [here](https://github.com/snlab/python-odl).
87
88 ```
89 # Import essential modules.
90 >>> import odl.instance
91 >>> import odl.altospce
92
93 # Initiate a ODLInstance object.
94 >>> myodl = odl.instance.ODLInstance("http://127.0.0.1:8181",("admin","admin"))
95
96 # Initiate a ALTOSpce object.
97 >>> myaltospce = odl.altospce.ALTOSpce(server="http://127.0.0.1:8181",credentials=("admin","admin"),odl_instance=myodl)
98
99 # Setup a path between host1(10.0.0.1) and host5(10.0.0.5)
100 >>> myaltospce.path_setup(src="10.0.0.1",dst="10.0.0.5",objective_metrics=["bandwidth"])
101 {'path': [u'10.0.0.5|openflow:6:3|openflow:5:3|openflow:1:1|openflow:2:1|openflow:3:1|10.0.0.1', u'10.0.0.1|openflow:3:3|openflow:2:3|openflow:1:2|openflow:5:1|openflow:6:1|10.0.0.5'], 'error-code': 'OK'}
102
103 # Remove the path between host1(10.0.0.1) and host5(10.0.0.5)
104 # To identify the path please use the 'path' indicated in myaltospce.path_setup
105 >>> myaltospce.path_remove(["10.0.0.5|openflow:6:3|openflow:5:3|openflow:1:1|openflow:2:1|openflow:3:1|10.0.0.1","10.0.0.1|openflow:3:3|openflow:2:3|openflow:1:2|openflow:5:1|openflow:6:1|10.0.0.5"])
106 {'error-code': 'OK'}
107 ```
108
109 Enjoy your alto-spce!
110
111 ## Try the demo system out
112
113 We have deploy a demo system in http://alto.yale.edu:8181/index.html and you can try it out. There is a brief usage:
114
115 You can setup or remove a path by using `python-odl` library. Just follow the section ["Setup/Remove a path with python-odl library"](#setupremove-a-path-with-python-odl-library) and replace `127.0.0.1` by `alto.yale.edu`.
116
117 Also you can send a HTTP request like the following template to query ALTO Endpoint Cost Service (ECS):
118
119 ```
120 curl -X POST -H "Content-type: application/alto-endpointcostfilter+json" \
121     -d '{"cost-type":{"cost-mode":"numerical","cost-metric":"hopcount"},"endpoints":{"srcs":[<SOURCE_IP_LIST>],"dsts":[<DESTINATION_IP_LIST>]}}' \
122     http://alto.yale.edu:8181/alto/endpointcost/default
123 ```