Ask Your Question

How to write flow in Karaf?

asked 2015-06-22 22:58:40 -0700

ShreshthaJoshi gravatar image

I have an OVS switch configured along with integration karaf.

To push a flow, I am following the Wiki-Page:

Pushed the flow with the following details:

With PostMan: Set headers: Content-Type: application/xml Accept: application/xml Authentication Use URL: http://<controller ip="">:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:1/table/0/flow/1 PUT Use Body: <flow xmlns="urn:opendaylight:flow:inventory"> <priority>2</priority> <flow-name>Foo</flow-name> <match> <ethernet-match> <ethernet-type> <type>2048</type> </ethernet-type> </ethernet-match> <ipv4-destination></ipv4-destination> </match> <id>1</id> <table_id>0</table_id> <instructions> <instruction> <order>0</order> <apply-actions> <action> <order>0</order> <dec-nw-ttl> </dec-nw-ttl></action> </apply-actions> </instruction> </instructions> </flow></controller>

It returns 200 OK.

  • When checked the same in config datastore "http://<controller ip="">:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:1/table/0/flow/1", it gives the response body that was pushed above.</controller>

  • But when checked in operational datastore at "http://<controller ip="">:8181/restconf/operational/opendaylight-inventory:nodes/node/openflow:1/table/0/flow/1", it returns 404 Not found.</controller>

  • Also when checked by executing command ovs-ofctl -o OpenFlow13 dump-flows br0, there are no flows found,

Please suggest, what more is required to push these flows in config to be pushed onto the switch and operational datastores.


edit retag flag offensive close merge delete


http://<controller ip="">:8181/restconf/operational/opendaylight-inventory:nodes/node/openflow:1 Do you get a reply from that? Also are you sure that the switch ID is 1?

Chris O'Shea ( 2015-06-23 02:58:07 -0700 )edit

6 answers

Sort by ยป oldest newest most voted

answered 2015-06-29 12:46:49 -0700

updated 2015-06-29 18:10:12 -0700


As Chris O'Shea suggested, openflow:1 is the default node created in OpenDaylight. First, get the node list with this request:

Method: GET
URL: http://CONTROLLERIP:8181/restconf/operational/opendaylight-inventory:nodes/
Content-Type: application/xml
Accept: application/xml

This will return a list of nodes (other than openflow:1). The node you are looking for should have a flow-node-inventory:description that correspond to your Open Flow device. Once you find that field, look 1 field above and you should see id:"openflow:xxxxxxxxxxxxxx" (x = number). Now send your PUT with the node id:

Method: PUT
URL: http://CONTROLLERIP:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:xxxxxxxxxxxxxx/table/0/flow/1
Content-Type: application/xml
Accept: application/xml

That should do the trick,


edit flag offensive delete publish link more


I was checking for the switch ID already and it exists. I think I'm in the same position as Edu. We followed the tutorial on the wiki step by step :/ Could be possible that that I'm working with helium 0.2.3 and OpenFlow 1.0?

Wayko ( 2015-07-02 10:58:37 -0700 )edit

answered 2015-06-30 05:11:27 -0700

Edu gravatar image

updated 2015-06-30 05:12:09 -0700

I have the same problem, and I have made the GET that you are saing, I recive the next reply:

enter code here<nodes xmlns="urn:opendaylight:inventory">
    <serial-number xmlns="urn:opendaylight:flow:inventory">None</serial-number>
    <switch-features xmlns="urn:opendaylight:flow:inventory">
        <x:capabilities xmlns:x="urn:opendaylight:flow:inventory">x:flow-feature-capability-flow-stats</x:capabilities>
        <x:capabilities xmlns:x="urn:opendaylight:flow:inventory">x:flow-feature-capability-port-stats</x:capabilities>
        <x:capabilities xmlns:x="urn:opendaylight:flow:inventory">x:flow-feature-capability-queue-stats</x:capabilities>
        <x:capabilities xmlns:x="urn:opendaylight:flow:inventory">x:flow-feature-capability-table-stats</x:capabilities>
    <description xmlns="urn:opendaylight:flow:inventory">None</description>
    <hardware xmlns="urn:opendaylight:flow:inventory">Open vSwitch</hardware>
    <manufacturer xmlns="urn:opendaylight:flow:inventory">Nicira, Inc.</manufacturer>
    <software xmlns="urn:opendaylight:flow:inventory">2.0.2</software>
    <table xmlns="urn:opendaylight:flow:inventory">
        <aggregate-flow-statistics xmlns="urn:opendaylight:flow:statistics">
        <flow-table-statistics xmlns="urn:opendaylight:flow:table:statistics">
    <table xmlns="urn:opendaylight:flow:inventory">

This sais that my switch really it is the openflow:1?

edit flag offensive delete publish link more


Yes, you are correct, your switch is openflow:1 indeed. I notice the version of OVS is 2.0.2, do you mind trying to update it ? Also, do you notice any logs in karaf ? When the flows do not get copied over from config to operational, it means ODL wasn't able to push the flow.

grmontpetit ( 2015-06-30 07:31:54 -0700 )edit

answered 2015-06-30 22:26:54 -0700

ShreshthaJoshi gravatar image

In my case switch was not 1. Thanks to Gabriel, I was able to figure that out. I am pushing flows with correct "openflow:xxxxxxxxxxxxxx", I still can't see the flows in operational datastore.

When the flow was traced with wireshark, there is a OFTP - FLOW MOD error saying [Message : Malformed Packet [Exception occurred]] [Severity level: error] [Group: Malformed]

I am using the XML body given in the Wiki.

is there anything else missing.

edit flag offensive delete publish link more


Which XML in the wiki?

Chris O'Shea ( 2015-07-09 19:14:14 -0700 )edit

answered 2015-07-09 09:09:49 -0700

Ashwini_Mhatre gravatar image

hi all, I m facing same issue. I have configure br0,its getting id as openflow:xxxxxxxxx the flow is successfully added in config data store.but its not present in operational data store. as when i checked flows on br0 with ovs-ofctl dump-flows command my flow is not there. is it related to openflow version??? I am using ODL helium sr3.

please provide your hints,if you have....


edit flag offensive delete publish link more


What is your flow doing? also have you check tcpdump to see if it being push from ODL but reject from OVS?, also which version of OVS you running and are u connecting via OF1.0 or OF1.3?

Chris O'Shea ( 2015-07-09 19:14:59 -0700 )edit

Hi charies, following are the version of openvswitch and openflow we are using: ovs-vsctl (Open vSwitch) 2.3.90 Compiled Jun 18 2015 07:06:24 DB Schema 7.12.1 openflow 1.4 please let me know if you required any further information. thanks

Ashwini_Mhatre ( 2015-07-09 20:46:10 -0700 )edit

I'm not sure ODL supports OpenFlow 1.4 i would try 1.3, Also what was the flow doing?

Chris O'Shea ( 2015-07-10 02:25:27 -0700 )edit

I have tried with 1.3 also.with existing br0. still its not working.:( do i need to delete br0 and then apply ovs-vsctl set bridge br0 protocols=OpenFlow13 this command??? also that rule is just forwording rule: <flow xmlns="urn:opendaylight:flow:inventory"><id>7</id><priority>105</priority><flow-name>myflow</flow-name><table_id>0</table_id><hard-timeout>35656</hard-timeout><idle-timeout>35656</idle-timeout><instructions><instruction><order>0</order><apply-actions><action><order>0</order><output-action><output-node-connector>2</output-node-connector></output-action></action></apply-actions></instruction></instructions><match><ipv4-destination></ipv4-destination><ethernet-match><ethernet-type><type>2048</type></ethernet-type></ethernet-match><ip-match><ip-protocol>1</ip-protocol></ip-match></match></flow>

Ashwini_Mhatre ( 2015-07-10 02:31:52 -0700 )edit

chris also following are the steps by which m configuring openvswitch let me know if m correct or not: root@srijit141:~# ovs-vsctl add-br br0 root@srijit141:~# ovs-vsctl set-manager tcp:<controller>:6633 root@srijit141:~# ovs-vsctl set-controller br0 tcp:<controller>:6633 root@srijit141:~# ovs-vsctl set bridge br0 protocols=OpenFlow13 root@srijit141:~# ovs-ofctl dump-flows br0

Ashwini_Mhatre ( 2015-07-10 02:46:28 -0700 )edit

answered 2015-07-15 07:36:51 -0700

Wayko gravatar image

May be this other answer helps you:

edit flag offensive delete publish link more

answered 2015-07-15 15:15:52 -0700

runamuck gravatar image

Try to add an ip-match. For example:


So, use this command (Notice I added an ip-protocol stanza):

With PostMan: Set headers: Content-Type: application/xml Accept: application/xml Authentication Use URL: http://<controller ip="">:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:1/table/0/flow/1 PUT Use Body: <flow xmlns="urn:opendaylight:flow:inventory"> <priority>2</priority> <flow-name>Foo</flow-name> <match> <ethernet-match> <ethernet-type> <type>2048</type> </ethernet-type> </ethernet-match> <ipv4-destination></ipv4-destination><ip-match><ip-protocol>6</ip-protocol></ip-match></match></match> <id>1</id> <table_id>0</table_id> <instructions> <instruction> <order>0</order> <apply-actions> <action> <order>0</order> <dec-nw-ttl> </dec-nw-ttl></action> </apply-actions> </instruction> </instructions> </flow></controller>
edit flag offensive delete publish link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

[hide preview]

Question Tools



Asked: 2015-06-22 22:58:40 -0700

Seen: 1,389 times

Last updated: Jul 15 '15