Hi Marlon,

On 2015年01月10日 01:31, Marlon Olaya wrote:
> Hi dear experts, im trying to add a flow using mac src, dst, ip src and dst 
> and that flow needs to change this in the packet to send it to another pc, so 
> im using this code for add the flow:
> [CODE]
> 
> def add_flow(self, datapath, in_port, src_mac, dst_mac, 
> src_ip,dst_ip,dl_type, actions):
> 
> ofproto = datapath.ofproto
> 
> 
> match = datapath.ofproto_parser.OFPMatch(
> 
> in_port=in_port, dl_src=addrconv.mac.text_to_bin(src_mac), 
> dl_dst=addrconv.mac.text_to_bin(dst_mac), dl_type = dl_type, nw_src = 
> struct.unpack('!I', ipv4_to_bin(src_ip))[0], nw_dst=struct.unpack('!I', 
> ipv4_to_bin(dst_ip))[0])
> 
> print "****** match addflow********"
> 
> print match
> 
> print ""
> 
> 
> mod = datapath.ofproto_parser.OFPFlowMod(
> 
> datapath=datapath, match=match, cookie=0,
> 
> command=ofproto.OFPFC_ADD, idle_timeout=0, hard_timeout=0,
> 
> priority=ofproto.OFP_DEFAULT_PRIORITY,
> 
> flags=ofproto.OFPFF_SEND_FLOW_REM, actions=actions)
> 
> datapath.send_msg(mod)
> 
> print "****** Regla enviada al controlador********"
> 
> print ""
> 
> print ""
> 
> [/CODE]
> 
> and my actions are coded in a handler in this section:
> 
> [CODE]
> if dst_ip == self.ip_fake:
>             print ""
>             print "Mensaje HACIA el SERVIDOR"
>             print "tabla ip_to_port"
>             print self.ip_to_port
>             print ""
>        
>             (out_port, mac_server) = self.round_robin()
>             print ""
>             print "puerto de salida: ", out_port
>             print "type", type(out_port)
>             print "mac del Server: ", mac_server
>            
>           
>             actions = 
> [datapath.ofproto_parser.OFPActionSetDlDst(haddr_to_bin(mac_server)),
>                        
> datapath.ofproto_parser.OFPActionSetNwDst(struct.unpack('!I', 
> ipv4_to_bin(self.ip_servidores[out_port-1]))[0]),
>                        datapath.ofproto_parser.OFPActionOutput(out_port)]
>             #se anade regla al sw en el sentido user -> server
>             self.add_flow(datapath, port, pkt_eth.src, 
> self.mac_servidores[0],src_ip, self.ip_servidores[out_port-1], 
> ether.ETH_TYPE_IP, actions)
>            
>             out = datapath.ofproto_parser.OFPPacketOut(
>             datapath=datapath, buffer_id=buffer_id, in_port=port,
>             actions=actions, data = pkt.data)
>            
>             datapath.send_msg(out)
> [/CODE]
> 
> So, when I run my app, all seems to be ok, but when its the time to install 
> the flow, the console throws me this error:
> 
> error msg ev version: 0x1 msg_type 0x1 xid 0x98550208 
> OFPErrorMsg(code=0,data='\x01\x0e\x00h\x98U\x02\x08\x000\x00\xe2\x00\x02\x00\x19\xd1Z"\xdat\xd45\x07)\x04\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\xc0\xa8X_\xc0\xa8Xc\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00\xff\xff\xff\xff\xff\xff\x00\x01\x00\x05\x00\x10t\xd45\x07)\x04\x00\x00\x00\x00\x00\x00\x00\x07\x00\x08\xc0\xa8Xc\x00\x00\x00\x08\x00\x01\xff\xe5',type=3)
>  type 0x3 code 0x0 0x1 0xe 0x0 0x68 0x98 0x55 0x2 0x8 0x0 0x30 0x0 0xe2 0x0 
> 0x2 0x0 0x19 0xd1 0x5a 0x22 0xda 0x74 0xd4 0x35 0x7 0x29 0x4 0x0 0x0 0x0 0x0 
> 0x8 0x0 0x0 0x0 0x0 0x0 0xc0 0xa8 0x58 0x5f 0xc0 0xa8 0x58 0x63 0x0 0x0 0x0 
> 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x80 0x0 0xff 
> 0xff 0xff 0xff 0xff 0xff 0x0 0x1 0x0 0x5 0x0 0x10 0x74 0xd4 0x35 0x7 0x29 0x4 
> 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x7 0x0 0x8 0xc0 0xa8 0x58 0x63 0x0 0x0 0x0 0x8 
> 0x0 0x1 0xff 0xe5

OFPErrorMsg show the error with type = 3(OFPET_BAD_INSTRUCTION) and code = 
0(OFPBIC_UNKNOWN_INST).
---
OpenFlow Spec 1.3.4:
    If the instructions requested in a flow mod message are unknown the switch 
must return an
  ofp_error_msg with OFPET_BAD_INSTRUCTION type and OFPBIC_UNKNOWN_INST code.
---

I think you need to set actions into instruction at add_flow() function as 
folloing.
---
def add_flow(self, datapath, in_port, src_mac, dst_mac, src_ip,dst_ip,dl_type, 
actions):
    ...
    inst = 
[datapath.ofproto_parser.OFPInstructionActions(ofproto.OFPIT_APPLY_ACTIONS,
                                                          actions)]
    ...
    mod = datapath.ofproto_parser.OFPFlowMod(datapath=datapath, match=match, 
cookie=0,
                                             command=ofproto.OFPFC_ADD, 
idle_timeout=0,
                                             hard_timeout=0,
                                             
priority=ofproto.OFP_DEFAULT_PRIORITY,
                                             flags=ofproto.OFPFF_SEND_FLOW_REM,
                                             instructions=inst)
---

For more exmaple, please refer to add_flow() function in 
ryu/app/simple_switch_13.py.

Thanks

> 
> So please can anyone help me?
> I think its and error in the packet from controller to switch but I cant see 
> where is it in my code.
> 
> thanks
> Marlon
> 
> 
> ------------------------------------------------------------------------------
> Dive into the World of Parallel Programming! The Go Parallel Website,
> sponsored by Intel and developed in partnership with Slashdot Media, is your
> hub for all things parallel software development, from weekly thought
> leadership blogs to news, videos, case studies, tutorials and more. Take a
> look and join the conversation now. http://goparallel.sourceforge.net
> 
> 
> 
> _______________________________________________
> Ryu-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/ryu-devel
> 

------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to