Hi Iol,

I attached a sample code of simple_switch_15.py,
but OVS does not fully support OpenFlow1.5, this code does not work enough.

Certainly, Ryu can speak OpenFlow 1.5.
On the other hand, OVS may be working with the OpenFlow 1.4 or earlier 
implementation.

Thanks,
Iwase

On 2015年09月15日 03:45, iol mancon wrote:
> Hello.
> 
> I have created a python file to test with OpenFlow 1.5. My file is like the 
> simple_switch_14.py but I added the v15 parser and I change the version in 
> the app.
> 
> I create the topology, enable the switch to can support OpenFlow 1.5 and then 
> I open the application simple_switch_15.py. It come onto main mode but give 
> me this error:
> 
> *pack into requires exactly 4 arguments*
> 
> The Hello and config messages I think that are OK, but then they give me this 
> code when I am doing ping (I use ovs-ofctl snoop to capture the code).
> 
> *root@ryu-vm:~# ovs-ofctl snoop s1*
> *OFPT_FEATURES_REQUEST (OF1.5) (xid=0x1b0f89a3):*
> *OFPT_FEATURES_REPLY (OF1.5) (xid=0x1b0f89a3): dpid:0000000000000001*
> *n_tables:254, n_buffers:256*
> *capabilities: FLOW_STATS TABLE_STATS PORT_STATS GROUP_STATS QUEUE_STATS*
> *OFPT_SET_CONFIG (OF1.5) (xid=0x1b0f89a4): frags=normal miss_send_len=128*
> *OFPST_PORT_DESC request (OF1.5) (xid=0x1b0f89a5): port=ANY*
> *OFPST_PORT_DESC reply (OF1.5) (xid=0x1b0f89a5):*
> * 1(s1-eth1): addr:7a:d1:16:c2:be:8a*
> *     config:     0*
> *     state:      0*
> *     current:    10GB-FD COPPER*
> *     speed: 10000 Mbps now, 0 Mbps max*
> * 2(s1-eth2): addr:76:d2:87:51:2e:f3*
> *     config:     0*
> *     state:      0*
> *     current:    10GB-FD COPPER*
> *     speed: 10000 Mbps now, 0 Mbps max*
> * 3(s1-eth3): addr:7e:ce:f0:5d:d5:e5*
> *     config:     0*
> *     state:      0*
> *     current:    10GB-FD COPPER*
> *     speed: 10000 Mbps now, 0 Mbps max*
> * LOCAL(s1): addr:f2:0b:e8:13:31:4d*
> *     config:     PORT_DOWN*
> *     state:      LINK_DOWN*
> *     speed: 0 Mbps now, 0 Mbps max*
> *OFPT_FLOW_MOD (OF1.5) (xid=0x1b0f89a6): ADD priority=0 out_port:0 
> actions=CONTROLLER:65535*
> *OFPT_PACKET_IN (OF1.5) (xid=0x0): cookie=0x0 total_len=98 in_port=1 (via 
> no_match) data_len=98 buffer=0x00000100*
> *icmp,vlan_tci=0x0000,dl_src=00:00:00:00:00:01,dl_dst=00:00:00:00:00:02,nw_src=10.0.0.1,nw_dst=10.0.0.2,nw_tos=0,nw_ecn=0,nw_ttl=64,icmp_type=8,icmp_code=0
>  icmp_csum:1eb5*
> *OFPT_ECHO_REQUEST (OF1.5) (xid=0x0): 0 bytes of payload*
> *OFPT_ECHO_REPLY (OF1.5) (xid=0x0): 0 bytes of payload*
> *OFPT_PACKET_IN (OF1.5) (xid=0x0): cookie=0x0 total_len=98 in_port=1 (via 
> no_match) data_len=98 buffer=0x00000101*
> *icmp,vlan_tci=0x0000,dl_src=00:00:00:00:00:01,dl_dst=00:00:00:00:00:02,nw_src=10.0.0.1,nw_dst=10.0.0.2,nw_tos=0,nw_ecn=0,nw_ttl=64,icmp_type=8,icmp_code=0
>  icmp_csum:5596*
> *OFPT_PACKET_IN (OF1.5) (xid=0x0): cookie=0x0 total_len=98 in_port=1 (via 
> no_match) data_len=98 buffer=0x00000102*
> *icmp,vlan_tci=0x0000,dl_src=00:00:00:00:00:01,dl_dst=00:00:00:00:00:02,nw_src=10.0.0.1,nw_dst=10.0.0.2,nw_tos=0,nw_ecn=0,nw_ttl=64,icmp_type=8,icmp_code=0
>  icmp_csum:6d74*
> *OFPT_PACKET_IN (OF1.5) (xid=0x0): cookie=0x0 total_len=98 in_port=1 (via 
> no_match) data_len=98 buffer=0x00000103*
> *icmp,vlan_tci=0x0000,dl_src=00:00:00:00:00:01,dl_dst=00:00:00:00:00:02,nw_src=10.0.0.1,nw_dst=10.0.0.2,nw_tos=0,nw_ecn=0,nw_ttl=64,icmp_type=8,icmp_code=0
>  icmp_csum:8059*
> *
> *
> I am using master version of OvS and RYU.
> 
> Thanks for all,
> Iol
> 
> 
> ------------------------------------------------------------------------------
> 
> 
> 
> _______________________________________________
> Ryu-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/ryu-devel
> 
# Copyright (C) 2015 Nippon Telegraph and Telephone Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from ryu.base import app_manager
from ryu.controller import ofp_event
from ryu.controller.handler import CONFIG_DISPATCHER, MAIN_DISPATCHER
from ryu.controller.handler import set_ev_cls
from ryu.ofproto import ofproto_v1_5
from ryu.lib.packet import packet
from ryu.lib.packet import ethernet


class SimpleSwitch15(app_manager.RyuApp):
    OFP_VERSIONS = [ofproto_v1_5.OFP_VERSION]

    def __init__(self, *args, **kwargs):
        super(SimpleSwitch15, self).__init__(*args, **kwargs)
        self.mac_to_port = {}

    @set_ev_cls(ofp_event.EventOFPSwitchFeatures, CONFIG_DISPATCHER)
    def switch_features_handler(self, ev):
        datapath = ev.msg.datapath
        ofproto = datapath.ofproto
        parser = datapath.ofproto_parser

        # install table-miss flow entry
        #
        # We specify NO BUFFER to max_len of the output action due to
        # OVS bug. At this moment, if we specify a lesser number, e.g.,
        # 128, OVS will send Packet-In with invalid buffer_id and
        # truncated packet data. In that case, we cannot output packets
        # correctly.  The bug has been fixed in OVS v2.1.0.
        match = parser.OFPMatch()
        actions = [parser.OFPActionOutput(ofproto.OFPP_CONTROLLER,
                                          ofproto.OFPCML_NO_BUFFER)]
        self.add_flow(datapath, 0, match, actions)

    def add_flow(self, datapath, priority, match, actions):
        ofproto = datapath.ofproto
        parser = datapath.ofproto_parser

        inst = [parser.OFPInstructionActions(ofproto.OFPIT_APPLY_ACTIONS,
                                             actions)]

        mod = parser.OFPFlowMod(datapath=datapath, priority=priority,
                                match=match, instructions=inst)
        datapath.send_msg(mod)

    @set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER)
    def _packet_in_handler(self, ev):
        msg = ev.msg
        datapath = msg.datapath
        ofproto = datapath.ofproto
        parser = datapath.ofproto_parser
        in_port = msg.match['in_port']

        pkt = packet.Packet(msg.data)
        eth = pkt.get_protocols(ethernet.ethernet)[0]

        dst = eth.dst
        src = eth.src

        dpid = datapath.id
        self.mac_to_port.setdefault(dpid, {})

        self.logger.info("packet in %s %s %s %s", dpid, src, dst, in_port)

        # learn a mac address to avoid FLOOD next time.
        self.mac_to_port[dpid][src] = in_port

        if dst in self.mac_to_port[dpid]:
            out_port = self.mac_to_port[dpid][dst]
        else:
            out_port = ofproto.OFPP_FLOOD

        actions = [parser.OFPActionOutput(out_port)]

        # install a flow to avoid packet_in next time
        if out_port != ofproto.OFPP_FLOOD:
            match = parser.OFPMatch(in_port=in_port, eth_dst=dst)
            self.add_flow(datapath, 1, match, actions)

        data = None
        if msg.buffer_id == ofproto.OFP_NO_BUFFER:
            data = msg.data

        match = parser.OFPMatch(in_port=in_port)
        out = parser.OFPPacketOut(datapath=datapath, buffer_id=msg.buffer_id,
                                  match=match, actions=actions, data=data)
        datapath.send_msg(out)
------------------------------------------------------------------------------
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to