Dan Martino
Dan Martino

Reputation: 347

How to add flows in mininet with an OpenDayLight controller using Python

I'm working with a simple mininet topology, trying to learn how to manipulate flows with an ODL controller. The topology is:

Host1 -- OFSwitch1 -- OFSwitch2 -- Host 2 -- OFSwitch3 -- OFSwitch4 -- Host 3

I'm trying to achieve no connectivity from Host1 to Host3 by default, however, once a python script is run a flow is added that allows Host1 ping Host3.

I'm just starting to learn ODL and cannot seem to get this basic project working.

Upvotes: 1

Views: 4168

Answers (1)

Jayaprakash
Jayaprakash

Reputation: 763

Flows can be created by Opendaylight controller REST api which in turn get reflected in OVS switch where network simulation is done using mininet.

Please refer below steps to create flow in ODL and verify the same in ODL & OVS:

1) ODL Flow creation

curl -u admin:admin -H 'Content-Type: application/yang.data+xml' -X PUT -d @flow_data.xml http://192.168.1.196:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:1/table/0/flow/10

flow_date.xml file content:

<flow xmlns="urn:opendaylight:flow:inventory"> <priority>14865</priority> <flow-name>jpsampleFlow</flow-name> <idle-timeout>12000</idle-timeout> <match> <ethernet-match> <ethernet-type> <type>2048</type> </ethernet-type> </ethernet-match> <ipv4-source>10.0.0.1/32</ipv4-source><ipv4-destination>10.0.0.2/32</ipv4-destination><ip-match><ip-dscp>28</ip-dscp> </ip-match></match> <id>9</id> <table_id>0</table_id> <instructions> <instruction> <order>6555</order> </instruction> <instruction> <order>0</order> <apply-actions> <action> <order>0</order><drop-action/> <output-action> <output-node-connector>1</output-node-connector> </output-action> </action> </apply-actions> </instruction> </instructions> </flow>

2) Verify the created flow in ODL:

curl -u admin:admin -X GET http://192.168.1.196:8181/restconf/operational/opendaylight-inventory:nodes/node/openflow:1/table/0/flow/10

3) Verify the same in OVS:

sudo ovs-ofctl dump-flows <switch_id>

Refer this wiki page to know more about flow creation in ODL

Upvotes: 4

Related Questions