[pox-dev] event parsed error
Hi all, I want to manually set a flow for test. The switch sends a packet_in message to pox controller. This is the code: from pox.core import core import pox.openflow.libopenflow_01 as of from pox.lib.revent import * from pox.lib.addresses import IPAddr, EthAddr from collections import namedtuple from pox.lib.util import str_to_bool, dpid_to_str from pox.lib.packet.ipv4 import ipv4 from pox.lib.packet.ethernet import ethernet from pox.lib.packet.tcp import * from pox.lib.packet.udp import * import os log = core.getLogger() class Test_output_port (EventMixin): def __init__ (self): self.listenTo(core.openflow) def _handle_ConnectionUp (self, event): packet = event.parsed msg = of.ofp_flow_mod() msg.match = of.ofp_match.from_packet(packet, event.port); msg.buffer_id = event.ofp.buffer_id msg.idle_timeout = 10 msg.idle_timeout = 30 msg.actions.append(of.ofp_action_output(port = 1)) msg.data = event.ofp event.connection.send(msg), def launch (): ''' Starting the Firewall module ''' core.registerNew(Test_output_port) When test, it shows the following error. If anybody knows the reason, and can give some help, I will appreciate. POX 0.2.0 (carp) / Copyright 2011-2013 James McCauley, et al. DEBUG:core:POX 0.2.0 (carp) going up... DEBUG:core:Running on CPython (2.7.3/Sep 26 2013 20:03:06) DEBUG:core:Platform is Linux-3.2.0-58-generic-x86_64-with-Ubuntu-12.04-precise INFO:core:POX 0.2.0 (carp) is up. DEBUG:openflow.of_01:Listening on 0.0.0.0:6633 WARNING:openflow.of_01:class 'pox.openflow.PacketIn' raised on dummy OpenFlow nexus INFO:openflow.of_01:[00-00-00-00-00-01 1] connected ERROR:core:Exception while handling OpenFlowNexus!ConnectionUp... Traceback (most recent call last): File /home/guest/controller/pox/pox/lib/revent/revent.py, line 231, in raiseEventNoErrors return self.raiseEvent(event, *args, **kw) File /home/guest/controller/pox/pox/lib/revent/revent.py, line 278, in raiseEvent rv = event._invoke(handler, *args, **kw) File /home/guest/controller/pox/pox/lib/revent/revent.py, line 156, in _invoke return handler(self, *args, **kw) File /home/guest/controller/pox/pox/misc/test_flow_miss.py, line 25, in _handle_ConnectionUp packet = event.parsed AttributeError: 'ConnectionUp' object has no attribute 'parsed'
Re: [pox-dev] event parsed error
It seems like you want to be listening to the PacketIn event, not the ConnectionUp event. -- Murphy On Aug 19, 2014, at 12:35 PM, zhang...@126.com wrote: Hi all, I want to manually set a flow for test. The switch sends a packet_in message to pox controller. This is the code: from pox.core import core import pox.openflow.libopenflow_01 as of from pox.lib.revent import * from pox.lib.addresses import IPAddr, EthAddr from collections import namedtuple from pox.lib.util import str_to_bool, dpid_to_str from pox.lib.packet.ipv4 import ipv4 from pox.lib.packet.ethernet import ethernet from pox.lib.packet.tcp import * from pox.lib.packet.udp import * import os log = core.getLogger() class Test_output_port (EventMixin): def __init__ (self): self.listenTo(core.openflow) def _handle_ConnectionUp (self, event): packet = event.parsed msg = of.ofp_flow_mod() msg.match = of.ofp_match.from_packet(packet, event.port); msg.buffer_id = event.ofp.buffer_id msg.idle_timeout = 10 msg.idle_timeout = 30 msg.actions.append(of.ofp_action_output(port = 1)) msg.data = event.ofp event.connection.send(msg), def launch (): ''' Starting the Firewall module ''' core.registerNew(Test_output_port) When test, it shows the following error. If anybody knows the reason, and can give some help, I will appreciate. POX 0.2.0 (carp) / Copyright 2011-2013 James McCauley, et al. DEBUG:core:POX 0.2.0 (carp) going up... DEBUG:core:Running on CPython (2.7.3/Sep 26 2013 20:03:06) DEBUG:core:Platform is Linux-3.2.0-58-generic-x86_64-with-Ubuntu-12.04-precise INFO:core:POX 0.2.0 (carp) is up. DEBUG:openflow.of_01:Listening on 0.0.0.0:6633 WARNING:openflow.of_01:class 'pox.openflow.PacketIn' raised on dummy OpenFlow nexus INFO:openflow.of_01:[00-00-00-00-00-01 1] connected ERROR:core:Exception while handling OpenFlowNexus!ConnectionUp... Traceback (most recent call last): File /home/guest/controller/pox/pox/lib/revent/revent.py, line 231, in raiseEventNoErrors return self.raiseEvent(event, *args, **kw) File /home/guest/controller/pox/pox/lib/revent/revent.py, line 278, in raiseEvent rv = event._invoke(handler, *args, **kw) File /home/guest/controller/pox/pox/lib/revent/revent.py, line 156, in _invoke return handler(self, *args, **kw) File /home/guest/controller/pox/pox/misc/test_flow_miss.py, line 25, in _handle_ConnectionUp packet = event.parsed AttributeError: 'ConnectionUp' object has no attribute 'parsed'
Re: [pox-dev] event parsed error
Yes, just now I change the event to like that def _handle_PacketIn (event): packet = event.parsed msg = of.ofp_flow_mod() msg.match = of.ofp_match.from_packet(packet, event.port); msg.buffer_id = event.ofp.buffer_id msg.idle_timeout = 10 msg.idle_timeout = 30 msg.actions.append(of.ofp_action_output(port = 1)) msg.data = event.ofp event.connection.send(msg) def launch (): ''' Starting the Firewall module ''' core.openflow.addListenerByName(PacketIn, _handle_PacketIn) log.info(test miss flow) It seems it can work. However, pox still gives this warning: INFO:packet:(udp parse) warning UDP packet data shorter than UDP len: 96 962 INFO:packet:(udp parse) warning UDP packet data shorter than UDP len: 96 962 Can you give some guidance, why it has this warning. This is my packet_in message void get_header(struct request *req, struct ofp_packet_in *pi) { char *header; struct rte_mbuf *pkt = req-pkt; header = (char *)(rte_pktmbuf_mtod(pkt, unsigned char *)); memcpy(pi-data, header, OFP_DEFAULT_MISS_SEND_LEN); } static int make_packet_in(int xid, int buffer_id, char *buf) { struct ofp_packet_in *pi; struct request *req; int len; pi = (struct ofp_packet_in *)buf; pi-header.version = OFP_VERSION; pi-header.type = OFPT_PACKET_IN; pi-header.xid = htonl(xid); req = (struct request *)ring_peek(to_channel, buffer_id); if (req == NULL) { fprintf(stderr, req NULL pointer.\n); return 0; } else { pi-in_port = req-in_port; pi-buffer_id = htonl(req-buffer_id); pi-reason = OFPR_NO_MATCH; pi-pad = 0; get_header(req, pi); } len = sizeof(*pi) + OFP_DEFAULT_MISS_SEND_LEN; pi-header.length = htons(len); pi-total_len = htons(len); return len; } Whehter the len is not correct? At 2014-08-20 04:10:54, Murphy McCauley murphy.mccau...@gmail.com wrote: It seems like you want to be listening to the PacketIn event, not the ConnectionUp event. -- Murphy On Aug 19, 2014, at 12:35 PM, zhang...@126.com wrote: Hi all, I want to manually set a flow for test. The switch sends a packet_in message to pox controller. This is the code: from pox.core import core import pox.openflow.libopenflow_01 as of from pox.lib.revent import * from pox.lib.addresses import IPAddr, EthAddr from collections import namedtuple from pox.lib.util import str_to_bool, dpid_to_str from pox.lib.packet.ipv4 import ipv4 from pox.lib.packet.ethernet import ethernet from pox.lib.packet.tcp import * from pox.lib.packet.udp import * import os log = core.getLogger() class Test_output_port (EventMixin): def __init__ (self): self.listenTo(core.openflow) def _handle_ConnectionUp (self, event): packet = event.parsed msg = of.ofp_flow_mod() msg.match = of.ofp_match.from_packet(packet, event.port); msg.buffer_id = event.ofp.buffer_id msg.idle_timeout = 10 msg.idle_timeout = 30 msg.actions.append(of.ofp_action_output(port = 1)) msg.data = event.ofp event.connection.send(msg), def launch (): ''' Starting the Firewall module ''' core.registerNew(Test_output_port) When test, it shows the following error. If anybody knows the reason, and can give some help, I will appreciate. POX 0.2.0 (carp) / Copyright 2011-2013 James McCauley, et al. DEBUG:core:POX 0.2.0 (carp) going up... DEBUG:core:Running on CPython (2.7.3/Sep 26 2013 20:03:06) DEBUG:core:Platform is Linux-3.2.0-58-generic-x86_64-with-Ubuntu-12.04-precise INFO:core:POX 0.2.0 (carp) is up. DEBUG:openflow.of_01:Listening on 0.0.0.0:6633 WARNING:openflow.of_01:class 'pox.openflow.PacketIn' raised on dummy OpenFlow nexus INFO:openflow.of_01:[00-00-00-00-00-01 1] connected ERROR:core:Exception while handling OpenFlowNexus!ConnectionUp... Traceback (most recent call last): File /home/guest/controller/pox/pox/lib/revent/revent.py, line 231, in raiseEventNoErrors return self.raiseEvent(event, *args, **kw) File /home/guest/controller/pox/pox/lib/revent/revent.py, line 278, in raiseEvent rv = event._invoke(handler, *args, **kw) File /home/guest/controller/pox/pox/lib/revent/revent.py, line 156, in _invoke return handler(self, *args, **kw) File /home/guest/controller/pox/pox/misc/test_flow_miss.py, line 25, in _handle_ConnectionUp packet = event.parsed AttributeError: 'ConnectionUp' object has no attribute 'parsed'
Re: [pox-dev] event parsed error
Please see What are these log messages from the packet subsystem? in the POX FAQ. -- Murphy On Aug 19, 2014, at 1:29 PM, 张伟 zhang...@126.com wrote: Yes, just now I change the event to like that def _handle_PacketIn (event): packet = event.parsed msg = of.ofp_flow_mod() msg.match = of.ofp_match.from_packet(packet, event.port); msg.buffer_id = event.ofp.buffer_id msg.idle_timeout = 10 msg.idle_timeout = 30 msg.actions.append(of.ofp_action_output(port = 1)) msg.data = event.ofp event.connection.send(msg) def launch (): ''' Starting the Firewall module ''' core.openflow.addListenerByName(PacketIn, _handle_PacketIn) log.info(test miss flow) It seems it can work. However, pox still gives this warning: INFO:packet:(udp parse) warning UDP packet data shorter than UDP len: 96 962 INFO:packet:(udp parse) warning UDP packet data shorter than UDP len: 96 962 Can you give some guidance, why it has this warning. This is my packet_in message void get_header(struct request *req, struct ofp_packet_in *pi) { char *header; struct rte_mbuf *pkt = req-pkt; header = (char *)(rte_pktmbuf_mtod(pkt, unsigned char *)); memcpy(pi-data, header, OFP_DEFAULT_MISS_SEND_LEN); } static int make_packet_in(int xid, int buffer_id, char *buf) { struct ofp_packet_in *pi; struct request *req; int len; pi = (struct ofp_packet_in *)buf; pi-header.version = OFP_VERSION; pi-header.type = OFPT_PACKET_IN; pi-header.xid = htonl(xid); req = (struct request *)ring_peek(to_channel, buffer_id); if (req == NULL) { fprintf(stderr, req NULL pointer.\n); return 0; } else { pi-in_port = req-in_port; pi-buffer_id = htonl(req-buffer_id); pi-reason = OFPR_NO_MATCH; pi-pad = 0; get_header(req, pi); } len = sizeof(*pi) + OFP_DEFAULT_MISS_SEND_LEN; pi-header.length = htons(len); pi-total_len = htons(len); return len; } Whehter the len is not correct? At 2014-08-20 04:10:54, Murphy McCauley murphy.mccau...@gmail.com wrote: It seems like you want to be listening to the PacketIn event, not the ConnectionUp event. -- Murphy On Aug 19, 2014, at 12:35 PM, zhang...@126.com wrote: Hi all, I want to manually set a flow for test. The switch sends a packet_in message to pox controller. This is the code: from pox.core import core import pox.openflow.libopenflow_01 as of from pox.lib.revent import * from pox.lib.addresses import IPAddr, EthAddr from collections import namedtuple from pox.lib.util import str_to_bool, dpid_to_str from pox.lib.packet.ipv4 import ipv4 from pox.lib.packet.ethernet import ethernet from pox.lib.packet.tcp import * from pox.lib.packet.udp import * import os log = core.getLogger() class Test_output_port (EventMixin): def __init__ (self): self.listenTo(core.openflow) def _handle_ConnectionUp (self, event): packet = event.parsed msg = of.ofp_flow_mod() msg.match = of.ofp_match.from_packet(packet, event.port); msg.buffer_id = event.ofp.buffer_id msg.idle_timeout = 10 msg.idle_timeout = 30 msg.actions.append(of.ofp_action_output(port = 1)) msg.data = event.ofp event.connection.send(msg), def launch (): ''' Starting the Firewall module ''' core.registerNew(Test_output_port) When test, it shows the following error. If anybody knows the reason, and can give some help, I will appreciate. POX 0.2.0 (carp) / Copyright 2011-2013 James McCauley, et al. DEBUG:core:POX 0.2.0 (carp) going up... DEBUG:core:Running on CPython (2.7.3/Sep 26 2013 20:03:06) DEBUG:core:Platform is Linux-3.2.0-58-generic-x86_64-with-Ubuntu-12.04-precise INFO:core:POX 0.2.0 (carp) is up. DEBUG:openflow.of_01:Listening on 0.0.0.0:6633 WARNING:openflow.of_01:class 'pox.openflow.PacketIn' raised on dummy OpenFlow nexus INFO:openflow.of_01:[00-00-00-00-00-01 1] connected ERROR:core:Exception while handling OpenFlowNexus!ConnectionUp... Traceback (most recent call last): File /home/guest/controller/pox/pox/lib/revent/revent.py, line 231, in raiseEventNoErrors return self.raiseEvent(event, *args, **kw) File /home/guest/controller/pox/pox/lib/revent/revent.py, line 278, in raiseEvent rv = event._invoke(handler, *args, **kw) File /home/guest/controller/pox/pox/lib/revent/revent.py, line 156, in _invoke return handler(self, *args, **kw) File /home/guest/controller/pox/pox/misc/test_flow_miss.py, line 25, in _handle_ConnectionUp packet = event.parsed AttributeError: 'ConnectionUp' object has no
[pox-dev] pox app multi-thread or single-thread, why buffer_id in controller side sometimes is not sequence
Hi all, I want to know for the application eg l2_learning. If we run this component, l2_learning is single thread or multi-thread? My simple test: def _handle_PacketIn (event): packet = event.parsed msg = of.ofp_flow_mod() msg.match = of.ofp_match.from_packet(packet, event.port); msg.buffer_id = event.ofp.buffer_id log.info(buffer_id %i, msg.buffer_id); msg.idle_timeout = 10 msg.hard_timeout = 30 msg.actions.append(of.ofp_action_output(port = 0)) msg.data = event.ofp event.connection.send(msg) When I print out the buffer_id message, sometimes it is not sequence. I got the result like that: INFO:packet:(udp parse) warning UDP packet data shorter than UDP len: 96 962 INFO:misc.test_flow_miss:buffer_id 0 INFO:openflow.of_01:[00-00-00-00-00-01 2] connected INFO:packet:(udp parse) warning UDP packet data shorter than UDP len: 96 962 INFO:misc.test_flow_miss:buffer_id 2 This makes me very confused. At first, I thought just one single thread for the app. app processed the requests according to FIFO mode. Can anybody give some help and explain some reason for my result? Another question: In pox wiki, when we want to install a flow entry: if the tcp port is 8080, why in python code, we do not need to do htons translation. However, the switch side receives the port is network endian.