wiki:HowTo/WriteOFv3Rspecs/Examples

Version 11 (modified by nriga@bbn.com, 13 years ago) (diff)

--

If you have written any interested OFv3 rspecs, feel free to add them at the bottom of this page and help others:-)

A complete example rspec can be found here example rspec

Rspec with one group

If you want to apply your packet filters to the same set of dpids, then you just need to create one group and use it in all your matches. In this example we only match on Ethernet addresses.

<?xml version="1.1" encoding="UTF-8"?>
<rspec  xmlns="http://www.protogeni.net/resources/rspec/2"
        xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:openflow="http://www.geni.net/resources/rspec/ext/openflow/3"
        xs:schemaLocation="http://www.protogeni.net/resources/rspec/2
              http://www.protogeni.net/resources/rspec/2/request.xsd
              http://www.geni.net/resources/rspec/ext/openflow/3
              http://www.geni.net/resources/rspec/ext/openflow/3/of-resv.xsd"
    type="request">
    
    <openflow:sliver email="user@example.net" description="My GENI experiment"
ref="http://wiki.example.net/myproj" />

       <openflow:controller url="tcp:myctrl.example.net:9933" type="primary" />

       <openflow:group name="mygrp">

           <openflow:datapath
              component_id="urn:publicid:IDN+openflow:foam:uxmal.example.net+datapath:06:af:00:24:a8:c4:b9:00"
              component_manager_id="urn:publicid:IDN+openflow:foam:uxmal.example.net+authority+am">
             <openflow:port name="26" num="50"/>
             <openflow:port name="47" num="71"/>
           </openflow:datapath>

       </openflow:group>

       <openflow:match>
           <openflow:use-group name="mygrp" />
           <openflow:packet>
             <openflow:dl_src value="10:01:01:00:24:ef" />
           <openflow:packet />
       <openflow:match>
    
       <openflow:match>
           <openflow:use-group name="mygrp" />
           <openflow:packet>
             <openflow:dl_dst value="10:01:01:0:24:73" />
           <openflow:packet />
         <openflow:match>

    </openflow:sliver>

</rspec>

Rspec with multiple groups

If you need to apply different packet filters in different datapath sets, then you can create multiple groups and use them as needed in your matches. In this example we want all ARP packets of a specific vlan.

<?xml version="1.1" encoding="UTF-8"?>
<rspec  xmlns="http://www.protogeni.net/resources/rspec/2"
        xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:openflow="http://www.geni.net/resources/rspec/ext/openflow/3"
        xs:schemaLocation="http://www.protogeni.net/resources/rspec/2
              http://www.protogeni.net/resources/rspec/2/request.xsd
              http://www.geni.net/resources/rspec/ext/openflow/3
              http://www.geni.net/resources/rspec/ext/openflow/3/of-resv.xsd"
    type="request">
    
    <openflow:sliver email="user@example.net" description="My GENI experiment"
ref="http://wiki.example.net/myproj" />

       <openflow:controller url="tcp:myctrl.example.net:9933" type="primary" />

       <openflow:group name="mygrp1">

           <openflow:datapath
              component_id="urn:publicid:IDN+openflow:foam:uxmal.example.net+datapath:06:af:00:24:a8:c4:b9:00"
              component_manager_id="urn:publicid:IDN+openflow:foam:uxmal.example.net+authority+am">
             <openflow:port name="26" num="50"/>
             <openflow:port name="47" num="71"/>
           </openflow:datapath>

       </openflow:group>

       <openflow:group name="mygrp2">

           <openflow:datapath
              component_id="urn:publicid:IDN+openflow:foam:uxmal.example.net+datapath:06:af:00:24:a8:c4:b9:00" 
              component_manager_id="urn:publicid:IDN+openflow:foam:uxmal.example.net+authority+am"/>
           <openflow:datapath
              component_id="urn:publicid:IDN+openflow:foam:uxmal.example.net+datapath:06:ac:00:24:a8:c4:b9:ff" 
              component_manager_id="urn:publicid:IDN+openflow:foam:uxmal.example.net+authority+am">
             <openflow:port name="26" num="20"/>
             <openflow:port name="27" num="21"/>
             <openflow:port name="28" num="22"/>
           </openflow:datapath>

       </openflow:group>

       <openflow:match>
           <openflow:use-group name="mygrp1" />
           <openflow:use-group name="mygrp2" />
           <openflow:packet>
             <openflow:dl_vlan value="10" />
             <openflow:dl_type value="0x806" />
           <openflow:packet />
       <openflow:match>
    
       <openflow:match>
           <openflow:use-group name="mygrp2" />
           <openflow:packet>
             <openflow:nw_src dl_vlan="10-12" />
              <openflow:dl_type value="0x806" />
           <openflow:packet />
         <openflow:match>

    </openflow:sliver>

</rspec>

Rspec with groups and datapaths

If for only one of your matches you need a different set of datapaths, you don't need to create a group you can just add the datapaths directly in your match. In this example we match all ssh (TCP port 22) traffic.

<?xml version="1.1" encoding="UTF-8"?>
<rspec  xmlns="http://www.protogeni.net/resources/rspec/2"
        xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:openflow="http://www.geni.net/resources/rspec/ext/openflow/3"
        xs:schemaLocation="http://www.protogeni.net/resources/rspec/2
              http://www.protogeni.net/resources/rspec/2/request.xsd
              http://www.geni.net/resources/rspec/ext/openflow/3
              http://www.geni.net/resources/rspec/ext/openflow/3/of-resv.xsd"
    type="request">
    
    <openflow:sliver email="user@example.net" description="My GENI experiment"
ref="http://wiki.example.net/myproj" />

       <openflow:controller url="tcp:myctrl.example.net:9933" type="primary" />

       <openflow:group name="mygrp">

           <openflow:datapath
              component_id="urn:publicid:IDN+openflow:foam:uxmal.example.net+datapath:06:af:00:24:a8:c4:b9:00" 
              component_manager_id="urn:publicid:IDN+openflow:foam:uxmal.example.net+authority+am">
             <openflow:port name="26" num="50"/>
             <openflow:port name="47" num="71"/>
           </openflow:datapath>

       </openflow:group>

       <openflow:match>
           <openflow:use-group name="mygrp" />
            <openflow:datapath
              component_id="urn:publicid:IDN+openflow:foam:uxmal.example.net+datapath:06:af:00:24:a8:c4:b9:00" 
              component_manager_id="urn:publicid:IDN+openflow:foam:uxmal.example.net+authority+am"/>
           <openflow:datapath
              component_id="urn:publicid:IDN+openflow:foam:uxmal.example.net+datapath:06:ac:00:24:a8:c4:b9:ff" 
              component_manager_id="urn:publicid:IDN+openflow:foam:uxmal.example.net+authority+am">
             <openflow:port name="26" num="20"/>
             <openflow:port name="27" num="21"/>
             <openflow:port name="28" num="22"/>
           </openflow:datapath>

           <openflow:packet>
             <openflow:dl_type value="0x800" />
             <openflow:nw_proto value="6" />
             <openflow:tp_dst value="22" />
           <openflow:packet />
       <openflow:match>
    
       <openflow:match>
           <openflow:use-group name="mygrp" />
           <openflow:packet>
             <openflow:dl_type value="0x800" />
             <openflow:nw_proto value="6" />
             <openflow:tp_src value="22" />
           <openflow:packet />
         <openflow:match>

    </openflow:sliver>

</rspec>

Rspec for ICMP traffic from all the datapaths

<?xml version="1.1" encoding="UTF-8"?>
<rspec  xmlns="http://www.protogeni.net/resources/rspec/2"
        xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:openflow="http://www.geni.net/resources/rspec/ext/openflow/3"
        xs:schemaLocation="http://www.protogeni.net/resources/rspec/2
              http://www.protogeni.net/resources/rspec/2/request.xsd
              http://www.geni.net/resources/rspec/ext/openflow/3
              http://www.geni.net/resources/rspec/ext/openflow/3/of-resv.xsd"
    type="request">
    
    <openflow:sliver email="user@example.net" description="My GENI experiment"
ref="http://wiki.example.net/myproj" />

       <openflow:controller url="tcp:myctrl.example.net:9933" type="primary" />

       <openflow:group name="all" />

       <openflow:match>
           <openflow:use-group name="all" />

           <openflow:packet>
             <openflow:dl_type value="0x800" />
             <openflow:nw_proto value="1" />
           <openflow:packet />
       <openflow:match>

    </openflow:sliver>

</rspec>

Rspec to get all traffic for an IP subnet including ARP

<?xml version="1.1" encoding="UTF-8"?>
<rspec  xmlns="http://www.protogeni.net/resources/rspec/2"
        xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:openflow="http://www.geni.net/resources/rspec/ext/openflow/3"
        xs:schemaLocation="http://www.protogeni.net/resources/rspec/2
              http://www.protogeni.net/resources/rspec/2/request.xsd
              http://www.geni.net/resources/rspec/ext/openflow/3
              http://www.geni.net/resources/rspec/ext/openflow/3/of-resv.xsd"
    type="request">
    
    <openflow:sliver email="user@example.net" description="My GENI experiment"
ref="http://wiki.example.net/myproj" />

       <openflow:controller url="tcp:myctrl.example.net:9933" type="primary" />

       <openflow:group name="all" />

       <openflow:match>
           <openflow:use-group name="all" />

           <openflow:packet>
             <openflow:dl_type value="0x800, 0x806" />
             <openflow:nw_src value="10.10.10.0/24" />
             <openflow:nw_dst value="10.10.10.0/24" />
           <openflow:packet />
       <openflow:match>

    </openflow:sliver>

</rspec>