-
Notifications
You must be signed in to change notification settings - Fork 34
Description
hello,
please I'm trying to write a python code which count number of packets received to pox controller by switch. But I have a problem when I wrote the Packet_in handler for example it doesn't invoked.
this is my code
standard includes
from pox.core import core
from pox.lib.util import dpidToStr
import pox.openflow.libopenflow_01 as of
log = core.getLogger()
class Packet_counter (object):
print("inside the function1")
def init (self, connection):
self.connection = connection
connection.addListeners(self)
print("inside the function222")
def _handle_PacketIn (self, event):
print("inside the packet_in handler")
#Num_packet = 0
#msg=of.ofp_packet_in()
#if msg == of.ofp_packet_in():
#log.warning("Ignoring incomplete packet")
#else:
#Num_packet = Num_packet+1
#print(" Number of (%s packets) are : ",Num_packet)
main function to launch the module
def launch ():
def start_switch (event):
log.debug("Controlling %s" % (event.connection))
Packet_counter(event.connection)
core.openflow.addListenerByName("ConnectionUp", start_switch)