Install flows in OpenDaylight using Java

Although I had already done a similar post for this here, guess there are a lot of folks who are not able get everything working together without the actual source code.

So I thought it might be helpful if I provide with some ready to use project/code for installing flows using java.

1. Download the source code.

Download the source code of project “OpenDaylightFlowInstall” from my GitHub here. This will give you the following:

  1. FlowManager Class – Responsible for adding/deleting flows
  2. Tester Class – Responsible for actually passing the data & calling FlowManager class to install/delete flows.
  3. ODL Class – Responsible for OpenDaylight settings.

2. Import/Setup the code

You can import the code into eclipse as a java project or setup your command. Whatever you prefer.

To import the code in eclipse use “Import as Java Project” option and make sure that your “Project –> Build Automatically” is switched on.

e1

Also make sure that the two jars in lib folder are in classpath else compilation will fail.

3. Network & OpenDaylight Setup

I have a mininet running with one switch and two hosts which are able to ping each other & connected to OpenDaylight.

2

odl

4 Running the program

If you are using eclipse, simply right clicking on the tester class and saying “Run as Java Application” should run the code. Make sure of two things:

  1. Supply the right Src/Dest IP & Node details in the Tester.java

  2. Correct values in ODL.java under settings.

Once you run the program, the action DROP will be installed and ping will stop working.

3 odl2

Let me know, if you get stuck & i’ll try to help.

Advertisements

14 thoughts on “Install flows in OpenDaylight using Java

  1. mitselino says:

    Hello Saurabh!!I appreciate your work..I am working on a load balancer service using java..Specificcaly i have 3 hosts (1 client two servers) connected to an Openflow switch and i want after 10s for example to stop the communication between h1 and h2 and start the communication between h1 an h3.
    In which way that can be done?Based on this code, i will install simply a flow or i have to use handle in packet events?Could you help me please? Do i have to create another class or something like that ?

    Thank you in advance..

    Like

    • If you want to specifically do this at a given time period like what you mentioned “i want after 10s for example”, in that case you don’t need to handle packet event or anything I think.

      In above case you can simply write the program to periodically install and delete required flows.

      I might have miss read your question though as I think there is more to what you are trying to achieve. Let me know.

      Like

      • mitselino says:

        Saurabh thanks for the response and sorry for the delay.
        Basically i want to make this load balancer service: https://wiki.opendaylight.org/view/OpenDaylight_Controller:Load_Balancer_Service using java language.

        More specific, i have 3 hosts h1 ping h2, h2 responses (using the right IPs and MACs) so h1 communicates h2.Then i use a timeout variable and after this timeout h1 tries to connect to h3.

        My problem is with the MAC addresses and the ARP resolution.Also do i have to create a pool and load balancer VIPs?

        Like

  2. Aishwarya L says:

    Hi,

    I just copied the entire code,but its not working! i.e its showing Failed to install flow.. 405 which mean “call status is not created”,what should i do? please do help me!

    Thank you in advance!!

    Like

  3. Daniel says:

    Hi!

    I followed your instructions from Install flows in OpenDaylight using Java, but i get the following error:

    failed to install flow.. 405

    Please help me!

    Thank you in advance.

    Like

  4. Tong says:

    Amazing work, Saurabh.I have one question.You set the { baseURL = ODL.URL + FLOW_PROGRAMMER_REST_API + nodeId + “/staticFlow/” + flowName } in FlowManager.java.I tried it on a different version of controller,which is “distribution-karaf-0.3.3-Lithium-SR3”,the login interface is 127.0.0.1:8181/index.html. Everything went well,including the controller and the mininet. But the project turned out to faliure 405. I’m wondering what is wrong with it. Did I set the wrong baseURL,or something is wrong with the controller?
    Can you do me a favour in this ? Thank you very much!

    Like

  5. Tong says:

    Amazing work ,Saurabh. I tried it on a different version of controller,which is “distribution-karaf-0.3.3-Lithium-SR3”,and it turned out to faliure 405.Maybe I set the wrong baseURL,you know ,in the file FlowManager.java in your project, the variable baseURL is {String baseURL = ODL.URL + FLOW_PROGRAMMER_REST_API + nodeId + “/staticFlow/” + flowName;}.
    Can you help me with this ? Thank you very much!

    Like

  6. Tong says:

    Amazing work, Saurabh.I got a different version of controller,which is “distribution-karaf-0.3.3-Lithium-SR3”,adn the login interface is 127.0.0.1:8181/index.html. But when I run your project,it turned out to failure 405.What’s the problem? Should I change the variable of FLOW_PROGRAMMER_REST_API in FlowManager.java?
    Can you help me with this? Thank you very much.

    Like

  7. Hello Saurabh,
    You have set variable as
    private static String FLOW_PROGRAMMER_REST_API = “/controller/nb/v2/flowprogrammer/default/node/OF/”;
    Please can you explain what these “controller/nb/v2/flowprogrammer” parameters are??
    Please let me know!

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s