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'