Giter Club home page Giter Club logo

pox's Introduction

POX

POX is a networking software platform written in Python.

POX started life as an OpenFlow controller, but can now also function as an OpenFlow switch, and can be useful for writing networking software in general. It currently supports OpenFlow 1.0 and includes special support for the Open vSwitch/Nicira extensions.

POX versions are named. Starting with POX "gar", POX officially requires Python 3. The last version with support for Python 2 was POX "fangtooth". POX should run under Linux, Mac OS, and Windows. (And just about anywhere else -- we've run it on Android phones, under FreeBSD, Haiku, and elsewhere. All you need is Python!) Some features are not available on all platforms. Linux is the most featureful.

This README contains some information to get you started, but is purposely brief. For more information, please see the full documentation.

Running POX

pox.py boots up POX. It takes a list of component names on the command line, locates the components, calls their launch() function (if it exists), and then transitions to the "up" state.

If you run ./pox.py, it will attempt to find an appropriate Python 3 interpreter itself. In particular, if there is a copy of PyPy in the main POX directory, it will use that (for a potentially large performance boost!). Otherwise it will look for things called python3 and fall back to python. You can also, of course, invoke the desired Python interpreter manually (e.g., python3 pox.py).

The POX commandline optionally starts with POX's own options (see below). This is followed by the name of a POX component, which may be followed by options for that component. This may be followed by further components and their options.

./pox.py [pox-options...] [component] [component-options...] ...

POX Options

While components' options are up to the component (see the component's documentation), as mentioned above, POX has some options of its own. Some useful ones are:

Option Meaning
--verbose print stack traces for initialization exceptions
--no-openflow don't start the openflow module automatically

Components

POX components are basically Python modules with a few POX-specific conventions. They are looked for everywhere that Python normally looks, plus the pox and ext directories. Thus, you can do the following:

./pox.py forwarding.l2_learning

As mentioned above, you can pass options to the components by specifying options after the component name. These are passed to the corresponding module's launch() funcion. For example, if you want to run POX as an OpenFlow controller and control address or port it uses, you can pass those as options to the openflow._01 component:

./pox.py openflow.of_01 --address=10.1.1.1 --port=6634

Further Documentation

The full POX documentation is available on GitHub at https://noxrepo.github.io/pox-doc/html/

pox's People

Contributors

abbbe avatar ahassany avatar alshabib avatar apanda avatar colin-scott avatar czeni avatar dorgival avatar eternia478 avatar hwmagic avatar jsommers avatar jta avatar murphymc avatar nbjsw avatar nemethf avatar ppershing avatar samrussell avatar samwhitlock avatar sstjohn avatar yamt avatar zarifis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pox's Issues

Small improvement in spanning_tree module

A good (altough small) improvement on spanning tree module would be blocking flood on all switch ports as soon as it connects.

The module, after calculating the tree, already unblocks ports that belongs the tree or are connected to hosts.

My sugestion is to put the code below somewhere in the _reset function which handles "ConnectionUp" events.

def _reset (event):

Configure all switch ports to NO_FLOOD

for p in event.connection.ports.itervalues():
if p.port_no < of.OFPP_MAX:
pm = of.ofp_port_mod( port_no=p.port_no,
hw_addr=p.hw_addr,
config = of.OFPPC_NO_FLOOD,
mask = of.OFPPC_NO_FLOOD )

any way of getting the port status using POX

wondering if there is a method to get the link up/down status of a given port on a given openflow switch managed by POX. even better if there was a webservice method for the same.

thanks!

Bad file descriptor in io_worker

Here's a stack trace from Sam:

File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner │
self.run() │
File "/usr/lib/python2.7/threading.py", line 505, in run │
self.__target(*self.__args, **self.__kwargs) │
File "/home/sam/code/debugger/sts/../pox/pox/lib/recoco/recoco.py", line 574, in _threadProc │
xl.keys(), timeout ) │
File "/home/sam/code/debugger/sts/../pox/pox/lib/ioworker/io_worker.py", line 77, in fileno │
return self.socket.fileno() │
File "/usr/lib/python2.7/socket.py", line 224, in meth │
return getattr(self._sock,name)(*args) │
File "/usr/lib/python2.7/socket.py", line 170, in _dummy │
raise error(EBADF, 'Bad file descriptor') │
error: [Errno 9] Bad file descriptor

l2_learning's drop() tries to consume nonexistent buffer

l2_learning's drop() function is sometimes called simply to make the switch consume a buffer by sending a packet_out. BUT, this is called regardless of whether the switch buffered the packet or not (i.e., if buffer_id is -1 or not). If there's no buffer, there's no point in doing this to begin with AND the switch will probably return an error, so in this case we just shouldn't do it. :)

Support OF 1.3

Hi guys, are you planning to support OF. 1.3?

If so, I would like to help you in this task.

Thanks!

Factor out deadlock-helper code from pox.py

ed54673 added some code to help find deadlocks. I don't love this actually living in pox.py. Could it be moved out to a module in misc or something? (The I-think-not-entirely-dissimilar recoco_spy is there in misc already.)

Messenger has a magic print statement?

279a9ec adds back a print statement that reportedly magically fixes a crash.

Can I get a dead-simple test case for this so we can fix it for real?

Or can we somehow address this?

What kind of a crash / failure would we get? Are there stack traces?

Anything?

Let's try to put this one to bed. :)

pox crashes when connection closes too soon

It appears that POX fails to handle a condition when client closes the connection spontaneously. I experience the following errors, which go away when I introduce a delay on the client side.

abb@mitmer-testbed-mitmer:~/pox$ python pox.py --no-cli forwarding.l2_learning nm.test
POX 0.0.0 / Copyright 2011 James McCauley
test_9999_crash_on_rapid_close (pox.nm.test.TestController)
apparently this test upsets pox by closing connection too fast ... Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 551, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 504, in run
self.__arget(_self.__args, *_self.__kwargs)
File "/home/abb/pox/pox/lib/recoco/recoco.py", line 574, in _threadProc
xl.keys(), timeout )
File "/home/abb/pox/pox/openflow/of_01.py", line 506, in fileno
return self.sock.fileno()
File "/usr/lib/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
File "/usr/lib/python2.7/socket.py", line 170, in _dummy
raise error(EBADF, 'Bad file descriptor')
error: [Errno 9] Bad file descriptor

If I look at traffic dump, the difference between situation when POX crashes and when it does not crash appears to be TCP RST coming from the client too soon.

10:58:42.256758 IP 127.0.0.1.43080 > 127.0.0.1.6633: Flags [S], seq 1469518076, win 32792, options [mss 16396,sackOK,TS val 5768440 ecr 0,nop,wscale 4], length 0
10:58:42.256790 IP 127.0.0.1.6633 > 127.0.0.1.43080: Flags [S.], seq 1774215631, ack 1469518077, win 32768, options [mss 16396,sackOK,TS val 5768440 ecr 5768440,nop,wscale 4], length 0
10:58:42.256802 IP 127.0.0.1.43080 > 127.0.0.1.6633: Flags [.], ack 1, win 2050, options [nop,nop,TS val 5768440 ecr 5768440], length 0
10:58:42.259454 IP 127.0.0.1.43080 > 127.0.0.1.6633: Flags [P.], seq 1:9, ack 1, win 2050, options [nop,nop,TS val 5768440 ecr 5768440], length 8
10:58:42.259473 IP 127.0.0.1.6633 > 127.0.0.1.43080: Flags [.], ack 9, win 2048, options [nop,nop,TS val 5768440 ecr 5768440], length 0
10:58:42.273724 IP 127.0.0.1.43080 > 127.0.0.1.6633: Flags [F.], seq 9, ack 1, win 2050, options [nop,nop,TS val 5768444 ecr 5768440], length 0
10:58:42.287645 IP 127.0.0.1.6633 > 127.0.0.1.43080: Flags [P.], seq 1:9, ack 10, win 2048, options [nop,nop,TS val 5768447 ecr 5768444], length 8
10:58:42.287690 IP 127.0.0.1.43080 > 127.0.0.1.6633: Flags [R], seq 1469518086, win 0, length 0

graph.minigraph "object not iterable"

Line 47 of lib.graph.minigraph.py is throwing the following exception:

Traceback (most recent call last):
File "/Users/cs/Research/UCB/sdn-debugger/tests/unit/sts/topology_test.py", line 152, in setUp
self.g.link((self.switches[0], self.switches[0].ports[2]), (self.switches[1], self.switches[1].ports[2]))
File "/Users/cs/Research/UCB/sdn-debugger/sts/../pox/pox/lib/graph/graph.py", line 612, in link
self.disconnect_port(np1)
File "/Users/cs/Research/UCB/sdn-debugger/sts/../pox/pox/lib/graph/graph.py", line 550, in disconnect_port
for n1,n2,k,d in self._g.edges(np[0], data=True, keys=True):
File "/Users/cs/Research/UCB/sdn-debugger/sts/../pox/pox/lib/graph/minigraph.py", line 47, in edges
nbunch = set(nbunch)
TypeError: 'MockSwitch' object is not iterable

This issue can be reproduced by checkout out the debugger repo ([email protected]:noxrepo/sdn-debugger.git) and running tests.unit.sts.topology_test.py

I'll take a look later -- mostly just documenting this here for later reference.

syntax error in of_json.py

Hi, I'm trying to use the webservices application on pox. However, I get a syntax error in of_json.py

Could you point me in the right direction?

[root@papa pox]# ./pox.py openflow.webservice web.webcore
./pox.py: line 38: type: python2.7: not found
POX 0.1.0 (betta) / Copyright 2011-2013 James McCauley, et al.
Traceback (most recent call last):
File "/opt/oess-1.0.6/pox/pox/boot.py", line 89, in do_import2
import(name, globals(), locals())
File "/opt/oess-1.0.6/pox/pox/openflow/webservice.py", line 53, in
from pox.openflow.of_json import *
File "/opt/oess-1.0.6/pox/pox/openflow/of_json.py", line 111
_unfix_map = {k:_unfix_null for k in of.ofp_match_data.keys()}
^
SyntaxError: invalid syntax
Could not import module: openflow.webservice

install POX

I'm beginner to used pox, when i install the pox, it show the error message:
INFO:core:POX 0.2.0 (carp) is up.
ERROR:openflow.of_01:Error 99 while binding socket: Cannot assign requested address
ERROR:openflow.of_01: You may be specifying a local address which is not assigned to any interface.

what can i do?
thanks

Admin access for core developers

It looks like Andi, Kyriakos, and I don't have admin status on the repositories. This is problematic when someone needs write access to the repo, but Murphy is not around. Could someone add us as admins?

Thanks!
-Colin

Infinite flooding in l2_multi

In both betta and master, l2_multi fails to establish connectivity when run on a full mesh of four switches.

Tested in mininet with the following custom topology:

from mininet.topo import Topo

class MyTopo( Topo ):
    def __init__( self, num_switches=4 ):
        # Initialize topology
        Topo.__init__( self )

        switches = [ self.addSwitch('s' + str(switch_id))
                     for switch_id in range(1, num_switches+1) ]
        hosts = [ self.addHost('h' + str(host_id))
                  for host_id in range(1, num_switches+1) ]

        # Connect hosts to switches
        for i, sw in enumerate(switches):
          self.addLink(sw, hosts[i])

        # Connect switches to switches
        for i, switch_i in enumerate(switches):
          for switch_j in switches[i+1:]:
            self.addLink(switch_i, switch_j)

topos = { 'mytopo': ( lambda: MyTopo() ) }

Invoked with:

sudo mn --custom ~/mininet/custom/topo-2sw-2host.py --topo mytopo --controller=remote,ip=0.0.0.0,port=6633 --mac

And:

./pox.py --verbose forwarding.l2_multi

with Logging.level set to Logging.DEBUG.

It appears that POX floods packets indefinitely, and never learns the correct location for the hosts.

I noticed some strange behavior in l2_multi that might be the cause. Consider a simple case with two switches and two hosts. If host A sends a packet, the first switch will send a PacketIn, and POX will correctly learn that A is attached. It then floods the packet. The weird part is that when the packet arrives at the second switch, POX incorrectly thinks that A has migrated to the second switch... Perhaps this has something to do with why routes are never set up?

No OpenFlow version negotiation

POX currently just disconnects when the version number is not 0x01. Since switches start by sending their highest-supported version number, we should actually respond to high-numbered HELLOs with an 0x01 HELLO. We should then trap ofp_error_msgs with type OFPET_HELLO_FAILED and code OFPHFC_INCOMPATIBLE, and use that as the signal to disconnect.

kqueue instead of epoll

Mac OS X does not support epoll -- we may need to swap in kqueue under the hood for pox.lib.epoll_select if the OS is Mac.

For symptoms, run unit tests on a Mac.

Bug in make_type_to_unpacker_table

Hi,

With the patch to OVS fixing the bug for OFPT_QUEUE_GET_CONFIG_REQUEST (http://patchwork.openvswitch.org/patch/4959/) I believe I've noticed a bug in POX.

In pox/pox/openflow/util.py the function make_type_to_unpacker_table uses range(0, top), however this is one less than the number of entries in the dict (range is between 0 and top-1) preventing OFPT_QUEUE_GET_CONFIG_REPLY from being added to the unpackers.

Updating to top+1 it fixes the problem

r = [of._message_type_to_class[i].unpack_new for i in range(0, top+1)]

l2_multi blackholes traffic whenever hosts migrate

Just bumped into what seems to be an unimplemented scenario in l2_multi.

Suppose all hosts in the network ping each other, l2_multi correctly learn locations, and sets up up all-to-all paths. Then a host migrates to a new ingress switch, and sends one packet. l2_multi learns its new location, and sets up a path for that new packet.

The problem is that l2_multi does not appear to update the previously installed paths leading to the old host's migrations. In other words, traffic destined towards that host blacholes until the flow mods time out.

epoll in recoco needs minor refactor

Right now, SelectHub's loop calls select.select() unless self.epoll exists, in which case, self.epoll.select() is called.

I suggest we have a local variable ("select_function") which is set to one function or the other only once instead of inside the loop. We then just call select_function every time.

POX fires packetIn events before ConnectionUp - crashes l2_multi

Little bug I just found with STS (https://github.com/ucb-sts/experiments/tree/master/pox_early_packetin).

There is a window between the features_reply and the final barrier_reply in the handshake when POX doesn't consider the switch 'up' (i.e., hasn't yet informed it's listeners of its presence) but already delivers packetIn events.

(Note that the switch considers the connection to be established after the features_request and can raise any kind of messages).

In combination with openflow_discovery and l2_multi, this can lead to openflow_discovery raising a LinkEvent for a Switch that has not yet seen its connectionUp. This causes l2_multi's handle_LinkEvent to fail (l2_multi.py:436) with a KeyError.

Potential solutions:

  • of_01 could dispatch events only for 'up' switches
  • topology could validate the state of the switch it receives a PktIn on

Minor issues causing statistics messages to fail

In pox/openflow/libopenflow_01.py:
Line 2378:

    if (len(binaryString) < 48 + len(self.match())):

Should be:

    if (len(binaryString) < 48 + len(self.match)):

In pox/openflow/of_01.py:
Line 193:

    msg = of.ofp_aggregate_stats_reply()

Should be:

    msg = of.ofp_aggregate_stats()

Handler of messages ECHO_REPLY

Dear all,

I would like to suggest include a handler of OFPT_ECHO_REPLY in events handler of openflow messages in POX. This is important for applications that implements some kind of keepalive for their nodes. I known that this feature of keepalive was already part of POX project, but using the above approach, with a handler for echo-reply messages, is more flexible for applications.

Bellow is a patch propose for this feature.

Thanks for any help

Kind Regards, Italo

File: pox-handle-echo-reply.patch

diff --git a/pox/openflow/__init__.py b/pox/openflow/__init__.py
index 9a4d6d3..1930586 100644
--- a/pox/openflow/__init__.py
+++ b/pox/openflow/__init__.py
@@ -241,6 +241,14 @@ class ConnectionIn (Event):
     self.dpid = connection.dpid
     self.nexus = None

+class EchoReply (Event):
+  """
+  Event raised when an switch replies echo request.
+  """
+  def __init__ (self, connection, ofp):
+    Event.__init__(self)
+    self.connection = connection
+    self.dpid = connection.dpid


 class OpenFlowConnectionArbiter (EventMixin):
@@ -314,6 +322,7 @@ class OpenFlowNexus (EventMixin):
     PortStatsReceived,
     QueueStatsReceived,
     FlowRemoved,
+    EchoReply,
   ])

   # Bytes to send to controller when a packet misses all flows
diff --git a/pox/openflow/of_01.py b/pox/openflow/of_01.py
index 4096714..7d82a43 100644
--- a/pox/openflow/of_01.py
+++ b/pox/openflow/of_01.py
@@ -74,7 +74,9 @@ def handle_HELLO (con, msg): #S

 def handle_ECHO_REPLY (con, msg):
   #con.msg("Got echo reply")
-  pass
+  e = con.ofnexus.raiseEventNoErrors(EchoReply, con, msg)
+  if e is None or e.halt != True:
+    con.raiseEventNoErrors(EchoReply, con, msg)

 def handle_ECHO_REQUEST (con, msg): #S
   reply = msg
@@ -587,6 +589,7 @@ class Connection (EventMixin):
     PortStatsReceived,
     QueueStatsReceived,
     FlowRemoved,
+    EchoReply,
   ])

   # Globally unique identifier for the Connection instance

extensiveness of gitignore

Should the gitignore cover non-pox specific stuff? e.g. I just added the full rule to ignore vim swap files, but should emacs stuff be ignored there too? (just the simple #*# and *~ files it generates)

Regression in the module:argument CLI syntax

I get the following error with: 0085555

$ ./pox.py --no-openflow datapaths:softwareswitch 
POX 0.2.0 (carp) / Copyright 2011-2013 James McCauley, et al.
Module not found: datapaths:softwareswitch

But everything is OK with its parent (aef67f0)

$ ./pox.py --no-openflow datapaths:softwareswitch 
POX 0.2.0 (carp) / Copyright 2011-2013 James McCauley, et al.
INFO:dp.00-00-00-00-00-01:Connecting to 127.0.0.1:6633
INFO:core:POX 0.2.0 (carp) is up.
INFO:dp.00-00-00-00-00-01:Connected to controller

support cookies in ofp_match

Please add support for matching cookies to class ofp_match.

This could be useful to match set of rules (e.g. for removal) without keeping an history of inserted rules in the controller.

ValueError: list.remove(x): x not in list

I think this was Kyriakos' or Andi's original code:

The following exception is thrown:

c('127.0.0.1', 8888) [2877]   File "/Users/cs/Research/UCB/code/sts/pox/pox/lib/recoco/recoco.py", line 293, in cycle
c('127.0.0.1', 8888) [2877]     rv = t.execute()
c('127.0.0.1', 8888) [2877]   File "/Users/cs/Research/UCB/code/sts/pox/pox/lib/recoco/recoco.py", line 94, in execute
c('127.0.0.1', 8888) [2877]     return self.gen.send(v)
c('127.0.0.1', 8888) [2877]   File "/Users/cs/Research/UCB/code/sts/pox/pox/openflow/of_01.py", line 760, in run
c('127.0.0.1', 8888) [2877]     if con.read() is False:
c('127.0.0.1', 8888) [2877]   File "/Users/cs/Research/UCB/code/sts/pox/pox/openflow/of_01.py", line 622, in read
c('127.0.0.1', 8888) [2877]     h(self, msg)
c('127.0.0.1', 8888) [2877]   File "/Users/cs/Research/UCB/code/sts/pox/pox/openflow/of_01.py", line 165, in handle_BARRIER
c('127.0.0.1', 8888) [2877]     con.raiseEvent(BarrierIn, con, msg)
c('127.0.0.1', 8888) [2877]   File "/Users/cs/Research/UCB/code/sts/pox/pox/lib/revent/revent.py", line 280, in raiseEvent
c('127.0.0.1', 8888) [2877]     rv = event._invoke(handler, *args, **kw)
c('127.0.0.1', 8888) [2877]   File "/Users/cs/Research/UCB/code/sts/pox/pox/lib/revent/revent.py", line 158, in _invoke
c('127.0.0.1', 8888) [2877]     return handler(self, *args, **kw)
c('127.0.0.1', 8888) [2877]   File "/Users/cs/Research/UCB/code/sts/pox/pox/openflow/topology.py", line 286, in _handle_con_BarrierIn
c('127.0.0.1', 8888) [2877]     self.raiseEvent(event)
c('127.0.0.1', 8888) [2877]   File "/Users/cs/Research/UCB/code/sts/pox/pox/lib/revent/revent.py", line 280, in raiseEvent
c('127.0.0.1', 8888) [2877]     rv = event._invoke(handler, *args, **kw)
c('127.0.0.1', 8888) [2877]   File "/Users/cs/Research/UCB/code/sts/pox/pox/lib/revent/revent.py", line 158, in _invoke
c('127.0.0.1', 8888) [2877]     return handler(self, *args, **kw)
c('127.0.0.1', 8888) [2877]   File "/Users/cs/Research/UCB/code/sts/pox/pox/openflow/flow_table.py", line 383, in _handle_BarrierIn
c('127.0.0.1', 8888) [2877]     self._pending.remove(op)
c('127.0.0.1', 8888) [2877] ValueError: list.remove(x): x not in list

It's triggered by a SwitchFailure followed by a SwitchRecovery.

You can reproduce this bug by cloning sts and running:
$ ./simulator.py -c config/pox_list_mcs_final.py

Problem in the OpenFlow protocol packing

Hi,

I have downloaded betta branch and have started on Windows7:

python pox.py

Then started the following script (Pox software swich is deployed over real TCP connection to Pox controller):

# file: dataswitch_test.py

from pox.datapaths.switch import SoftwareSwitch
from pox.datapaths.switch import ofp_hello
from pox.openflow.util import make_type_to_unpacker_table
import logging
import socket
from binascii import hexlify

logging.basicConfig(filename = "pox.log",
                        level    = logging.DEBUG,
                        format   = "%(levelname)s - %(asctime)s - %(name)s - %(message)s")
logger = logging.getLogger("test")

class Connection():

    def __init__(self):
        self.initial_message = "hello"
        HOST, PORT = socket.gethostname(), 6633
        self.unpackers = make_type_to_unpacker_table()
        self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self.sock.connect((HOST, PORT))

    def serve(self):
        try:
            while True:
                msg = self.sock.recv(1024)
                print 'Message received', hexlify(msg)

                # OpenFlow parsing occurs here:
                ofp_type = ord(msg[1])
                packet_length = ord(msg[2]) << 8 | ord(msg[3])
                if packet_length > len(msg):
                    break
                new_offset, msg_obj = self.unpackers[ofp_type](msg, 0)
                print ' Decoded OF message is:\n', msg_obj
                self.on_message_received(self, msg_obj)
        finally:
            self.sock.close()

    def set_message_handler(self, handler):
        self.on_message_received = handler

    def send(self, msg):
        print 'OF message to send:\n', msg
        if type(msg) is not bytes:
            if hasattr(msg, 'pack'):
                msg = msg.pack()
        print ' Coded message is', hexlify(msg)
        self.sock.sendall(msg + "\n")

    def set_initial_message(self, msg):
        self.initial_message = msg

if __name__ == "__main__":
    switch = SoftwareSwitch(dpid=1, name="sw1")
    conn = Connection()
    switch.set_connection(conn)
    switch.send_hello()
    conn.serve()

It seams that there is some bug in the OpenFlow protocol packing (message generated by Pox soft switch - probably you don't have full unitest coverage in case of software softswitch generated OF messages). You are using Pox softswich without OF message packing to binary format.

pythonw -u "dataswitch_test.py"
OF message to send:
ofp_hello
header:
version: 1
type: 0 (OFPT_HELLO)
length: 8
xid: 0
Coded message is 0100000800000000
Message received 0100000800000001
Decoded OF message is:
ofp_hello
header:
version: 1
type: 0 (OFPT_HELLO)
length: 8
xid: 1
Message received 0105000800000002
Decoded OF message is:
ofp_features_request
header:
version: 1
type: 5 (OFPT_FEATURES_REQUEST)
length: 8
xid: 2
OF message to send:
ofp_features_reply
header:
version: 1
type: 6 (OFPT_FEATURES_REPLY)
length: 224
xid: 2
datapath_id: 1
n_buffers: 100
n_tables: 1
capabilities: 0
actions: 66
ports:
port_no: 1
hw_addr: 00:00:00:00:01:01
name: 00-00-00-00-00-01.1
config: 0
state: 0
curr: 1
advertised: 1
supported: 1
peer: 1
port_no: 2
hw_addr: 00:00:00:00:01:02
name: 00-00-00-00-00-01.2
config: 0
state: 0
curr: 1
advertised: 1
supported: 1
peer: 1
port_no: 3
hw_addr: 00:00:00:00:01:03
name: 00-00-00-00-00-01.3
config: 0
state: 0
curr: 1
advertised: 1
supported: 1
peer: 1
port_no: 4
hw_addr: 00:00:00:00:01:04
name: 00-00-00-00-00-01.4
config: 0
state: 0
curr: 1
advertised: 1
supported: 1
peer: 1
Traceback (most recent call last):
File "dataswitch_test.py", line 58, in
conn.serve()
File "dataswitch_test.py", line 35, in serve
self.on_message_received(self, msg_obj)
File "C:\Users\DamianP-PCSS\Downloads\pox-betta\pox-betta\pox\datapaths\switch.py", line 172, in rx_message
h(msg, connection=connection)
File "C:\Users\DamianP-PCSS\Downloads\pox-betta\pox-betta\pox\datapaths\switch.py", line 212, in _rx_features_request
self.send(msg)
File "C:\Users\DamianP-PCSS\Downloads\pox-betta\pox-betta\pox\datapaths\switch.py", line 187, in send
self._connection.send(message)
File "dataswitch_test.py", line 46, in send
msg = msg.pack()
File "C:\Users\DamianP-PCSS\Downloads\pox-betta\pox-betta\pox\openflow\libopenflow_01.py", line 2036, in pack
packed += i.pack()
File "C:\Users\DamianP-PCSS\Downloads\pox-betta\pox-betta\pox\openflow\libopenflow_01.py", line 678, in pack
assert self._assert()
File "C:\Users\DamianP-PCSS\Downloads\pox-betta\pox-betta\pox\openflow\libopenflow_01.py", line 166, in _assert
raise RuntimeError(r)
RuntimeError: name is too long

Is any change this will be corrected?

OpenFlow wildcard issues

Punting on a proper writeup and referring to pull request #21 where this issue started and where it's discussed.

AttributeError: 'Link' object has no attribute 'dpid1'

The following exception is thrown:

c('127.0.0.1', 8888) [1725] Traceback (most recent call last):
c('127.0.0.1', 8888) [1725]   File "./pox.py", line 420, in <module>
c('127.0.0.1', 8888) [1725]     main()
c('127.0.0.1', 8888) [1725]   File "./pox.py", line 387, in main
c('127.0.0.1', 8888) [1725]     core.scheduler.run()
c('127.0.0.1', 8888) [1725]   File "/Users/cs/Research/UCB/code/sts/pox/pox/lib/recoco/recoco.py", line 267, in run
c('127.0.0.1', 8888) [1725]     r = self.cycle()
c('127.0.0.1', 8888) [1725]   File "/Users/cs/Research/UCB/code/sts/pox/pox/lib/recoco/recoco.py", line 293, in cycle
c('127.0.0.1', 8888) [1725]     rv = t.execute()
c('127.0.0.1', 8888) [1725]   File "/Users/cs/Research/UCB/code/sts/pox/pox/lib/recoco/recoco.py", line 94, in execute
c('127.0.0.1', 8888) [1725]     return self.gen.send(v)
c('127.0.0.1', 8888) [1725]   File "/Users/cs/Research/UCB/code/sts/pox/pox/openflow/of_01.py", line 760, in run
c('127.0.0.1', 8888) [1725]     if con.read() is False:
c('127.0.0.1', 8888) [1725]   File "/Users/cs/Research/UCB/code/sts/pox/pox/openflow/of_01.py", line 622, in read
c('127.0.0.1', 8888) [1725]     h(self, msg)
c('127.0.0.1', 8888) [1725]   File "/Users/cs/Research/UCB/code/sts/pox/pox/openflow/of_01.py", line 151, in handle_PACKET_IN
c('127.0.0.1', 8888) [1725]     con.ofnexus.raiseEvent(PacketIn, con, msg)
c('127.0.0.1', 8888) [1725]   File "/Users/cs/Research/UCB/code/sts/pox/pox/lib/revent/revent.py", line 280, in raiseEvent
c('127.0.0.1', 8888) [1725]     rv = event._invoke(handler, *args, **kw)
c('127.0.0.1', 8888) [1725]   File "/Users/cs/Research/UCB/code/sts/pox/pox/lib/revent/revent.py", line 158, in _invoke
c('127.0.0.1', 8888) [1725]     return handler(self, *args, **kw)
c('127.0.0.1', 8888) [1725]   File "/Users/cs/Research/UCB/code/sts/pox/pox/openflow/discovery.py", line 383, in _handle_PacketIn
c('127.0.0.1', 8888) [1725]     self.raiseEvent(LinkEvent, True, newLink)
c('127.0.0.1', 8888) [1725]   File "/Users/cs/Research/UCB/code/sts/pox/pox/lib/revent/revent.py", line 280, in raiseEvent
c('127.0.0.1', 8888) [1725]     rv = event._invoke(handler, *args, **kw)
c('127.0.0.1', 8888) [1725]   File "/Users/cs/Research/UCB/code/sts/pox/pox/lib/revent/revent.py", line 158, in _invoke
c('127.0.0.1', 8888) [1725]     return handler(self, *args, **kw)
c('127.0.0.1', 8888) [1725]   File "/Users/cs/Research/UCB/code/sts/pox/pox/forwarding/l2_multi.py", line 342, in _handle_LinkEvent
c('127.0.0.1', 8888) [1725]     sw1 = switches[l.dpid1]
c('127.0.0.1', 8888) [1725] AttributeError: 'Link' object has no attribute 'dpid1'

You can reproduce it by cloning sts and running:
$ ./simulator.py -c config/pox_attr_error.py

Get IP from switch socket connection

Hello. Please help me with this issue. I need to retrieve the IP from a switch socket connection. I found that there is a socket for each switch connection in the connections list (i.e. core.components.get("openflow")._connections). However, I can't get the IP from this socket. How can I do that? Is there another way to do that? Thanks!!

standalone datapath problems on Windows

Hi,

I have downloaded the latests carp branch in order to test your last commits (many thanks for that work!). I'm trying to run "plain" version on Windows7.

First I have started Pox controller (python pox.py --verbose) and then 'plain' datapath (python pox.py --no-openflow -
-verbose datapaths:softwareswitch --addr=127.0.0.1)

Log from Pox controller:

C:\Users\DamianP-PCSS\Downloads\pox-carp2\pox-carp>python pox.py --verbose
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/Apr 10 2012 23:24:47)
DEBUG:core:Platform is Windows-7-6.1.7601-SP1
INFO:core:POX 0.2.0 (carp) is up.
DEBUG:openflow.of_01:Listening on 0.0.0.0:6633
ERROR:openflow.of_01:Exception reading connection [None 1]
Traceback (most recent call last):
File "C:\Users\DamianP-PCSS\Downloads\pox-carp2\pox-carp\pox\openflow\of_01.py
", line 905, in run
if con.read() is False:
File "C:\Users\DamianP-PCSS\Downloads\pox-carp2\pox-carp\pox\openflow\of_01.py
", line 724, in read
d = self.sock.recv(2048)
error: [Errno 10053] Connection establishment was cancelled by the host. (my translation from Polish).
INFO:openflow.of_01:[None 1] closed

Log from Pox 'plain' datapath:

C:\Users\DamianP-PCSS\Downloads\pox-carp2\pox-carp>python pox.py --no-openflow -
-verbose datapaths:softwareswitch --addr=127.0.0.1
POX 0.2.0 (carp) / Copyright 2011-2013 James McCauley, et al.
DEBUG:lib.ioworker:RecocoIOWorker.send_fast() not available
DEBUG:core:POX 0.2.0 (carp) going up...
DEBUG:core:Running on CPython (2.7.3/Apr 10 2012 23:24:47)
DEBUG:core:Platform is Windows-7-6.1.7601-SP1
DEBUG:dp.00-00-00-00-00-01:Attempting to connect to 127.0.0.1:6633
ERROR:lib.ioworker.workers:Couldn't connect to 127.0.0.1:6633
Traceback (most recent call last):
File "C:\Users\DamianP-PCSS\Downloads\pox-carp2\pox-carp\pox\boot.py", line 46
4, in boot
core.goUp()
File "C:\Users\DamianP-PCSS\Downloads\pox-carp2\pox-carp\pox\core.py", line 32
1, in goUp
self.raiseEvent(UpEvent())
File "C:\Users\DamianP-PCSS\Downloads\pox-carp2\pox-carp\pox\lib\revent\revent
.py", line 281, in raiseEvent
rv = event._invoke(handler, _args, *_kw)
File "C:\Users\DamianP-PCSS\Downloads\pox-carp2\pox-carp\pox\lib\revent\revent
.py", line 159, in _invoke
return handler(self, _args, *kw)
File "C:\Users\DamianP-PCSS\Downloads\pox-carp2\pox-carp\pox\datapaths__init

.py", line 88, in up
max_retry_delay=max_retry_delay, switch=switch)
File "C:\Users\DamianP-PCSS\Downloads\pox-carp2\pox-carp\pox\lib\ioworker\work
ers.py", line 165, in begin
w = cls(**kw)
File "C:\Users\DamianP-PCSS\Downloads\pox-carp2\pox-carp\pox\datapaths__init

_.py", line 32, in init
super(OpenFlowWorker, self).init(switch=switch,**kw)
File "C:\Users\DamianP-PCSS\Downloads\pox-carp2\pox-carp\pox\lib\ioworker\work
ers.py", line 193, in init
super(BackoffWorker,self).init(**kw)
File "C:\Users\DamianP-PCSS\Downloads\pox-carp2\pox-carp\pox\lib\ioworker\work
ers.py", line 129, in init
self._make_connection(**kw)
File "C:\Users\DamianP-PCSS\Downloads\pox-carp2\pox-carp\pox\lib\ioworker\work
ers.py", line 152, in _make_connection
raise RuntimeError("Couldn't connect")
RuntimeError: Couldn't connect

I also find another bug when I have started Pox datapath with additional argument:

C:\Users\DamianP-PCSS\Downloads\pox-carp2\pox-carp>python pox.py --no-openflow -
-verbose datapaths:softwareswitch --addr=127.0.0.1 --dpid=1
POX 0.2.0 (carp) / Copyright 2011-2013 James McCauley, et al.
DEBUG:lib.ioworker:RecocoIOWorker.send_fast() not available
Traceback (most recent call last):
File "C:\Users\DamianP-PCSS\Downloads\pox-carp2\pox-carp\pox\boot.py", line 46
2, in boot
if _do_launch(argv):
File "C:\Users\DamianP-PCSS\Downloads\pox-carp2\pox-carp\pox\boot.py", line 20
2, in do_launch
f(**params)
File "C:\Users\DamianP-PCSS\Downloads\pox-carp2\pox-carp\pox\datapaths__init

.py", line 106, in softwareswitch
do_launch(SoftwareSwitch, addr, port, max_retry_delay, dpid)
File "C:\Users\DamianP-PCSS\Downloads\pox-carp2\pox-carp\pox\datapaths__init

_.py", line 73, in do_launch
dpid = str_to_dpid(dpid)
NameError: global name 'str_to_dpid' is not defined

Clean up branches

I thing we need to clean up the branches in the main repository. I've commented on the existing branches; if you have a stake, please comment back. :)

debugger: Maybe we want to keep this. I know it has some debugger-specific stuff. The IO loop stuff (or its equivalent) should still get mainlined at some point. Though the mass of development on this is now in another fork, maybe?

debugger_legacy, debugger_legacy_2012-06-27: These haven't changed in a year. Do we need them?

fix_license: Any relevant changes should be in carp now. Delete.

master: The master branch should never have existed in the first place and should be equivalent to angler. Delete.

upgrade_switch / upgrade_switch_2: carp has moved so far ahead of these and fixed so many bugs that I claim anything relying on these should unquestionably be fixed to use carp. Delete.

subscribing to OFPT_FLOW_MOD messages

Hi, I'm trying to write my own module in the ext directory that listens for OFPT_FLOW_MOD messages going from the POX controller to switches. I notice there are a lot of events already built in the core like ConnectionUp, PortStatus, etc., but I didn't see an event that would fire on adding and deleting flows.

Basically, I need to keep track of what flows have been added and deleted using the webservices module. I guess I could copy the module to ext and make my changes, but I wanted to explore this solution first.

thanks

recoco: select error

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 808, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 761, in run
    self.__target(*self.__args, **self.__kwargs)
  File "[...]/pox/pox/lib/recoco/recoco.py", line 571, in _threadProc
    xl.keys(), timeout )
error: (4, 'Interrupted system call')

IPv6 support in Open vSwitch

I've not had a chance to delve into the details, but it looks like OVS now supports enough of OpenFlow 1.2 to handle IPv6 flows (and I'm told that the latest Pica8 implementation for the Pronto switches supports this too) - http://openvswitch.org/cgi-bin/gitweb.cgi?p=openvswitch;a=commit;h=aa6305ea678ab889d7418c90371c72ead2c8e1e8

What do people think is the best way to handle this in POX? It looks like it'll need a minimum amount of OpenFlow 1.2 - is it worth implementing enough to do IPv6 flows as a special case and leave the rest for the current 1.0 implementation?

KeyError in discovery.py

POX throws the following exception when a socket error errno.EWOULDBLOCK is returned:

Traceback (most recent call last):
  File "/home/rcs/Research/UCB/sts/pox/pox/openflow/of_01.py", line 623, in read
    h(self, msg)
  File "/home/rcs/Research/UCB/sts/pox/pox/openflow/of_01.py", line 135, in handle_FEATURES_REPLY
    con.ofnexus.miss_send_len))
  File "/home/rcs/Research/UCB/sts/pox/pox/openflow/of_01.py", line 591, in send
    self.disconnect()
  File "/home/rcs/Research/UCB/sts/pox/pox/openflow/of_01.py", line 543, in disconnect
    self.ofnexus.raiseEvent(ConnectionDown(self))
  File "/home/rcs/Research/UCB/sts/pox/pox/lib/revent/revent.py", line 280, in raiseEvent
    rv = event._invoke(handler, *args, **kw)
  File "/home/rcs/Research/UCB/sts/pox/pox/lib/revent/revent.py", line 158, in _invoke
    return handler(self, *args, **kw)
  File "/home/rcs/Research/UCB/sts/pox/pox/openflow/discovery.py", line 224, in _handle_ConnectionDown
    self._dps.remove(event.dpid)
KeyError: 1

int/long EthAddr type?

08ea075 adds int/long reading to EthAddr's init. I had specifically omitted this because I think it doesn't make much sense and I want to discourage it. My feeling is pretty much that an EthAddr should NEVER be in an integer type. IP addresses are bad enough and at least they're a reasonable size. Do we have a use case for this?

8bc63c9 alters how the integer is interpreted (not too surprising since, in my opinion, there is no good way to interpret how an ethernet address fits into an integer type). (And it incorrectly references me as having done this in the first place!)

If we do have a use case for this functionality, the code from 8bc63c9 could be improved. But if we have a use case for this functionality, I may need to be convinced that the fact that we have such a use case doesn't indicate that the code using it has a bug. :)

No support for strip VLAN?

It seems like libopenflow_01.py is missing support for the strip VLAN action. Is there some way to easily add this or use ofp_action_vlan_vid to have the same effect?

We're awfully cavalier about using the optional OFPP_FLOOD

Sam Russell pointed out in pull request #33 that we are making liberal usage of OFPP_FLOOD even though it's actually optional, whereas OFPP_ALL is required. However, there are known cases where OFPP_FLOOD is a win, and we have not had any cases where people have complained about it not being supported, so switching from FLOOD to ALL wholesale doesn't seem like a good idea.

There's more discussion on this in the above-mentioned pull request, but the proposed solution is:

  • Add comments in l2_learning and l2_multi near OFPP_FLOOD usage. Maybe something along the lines of "Use OFPP_FLOOD instead of OFPP_ALL here so that, e.g., spanning_tree will work".
  • In l2_learning_tutorial, switch to OFPP_ALL. This is a simpler beast than the other two and is meant to be used in quite controlled environments where loops won't be problematic (e.g., tutorials, duh). We can put in a comment about how OFPP_FLOOD would be useful for topologies with loops.

Comments in general and on specific language are welcome.

Link down event causes topology to crash

Start POX with topology and discovery:

$ ./pox.py openflow topology openflow.topology openflow.discovery

Start Mininet:

$ sudo mn --controller=remote --topo=tree,depth=2,fanout=2 --ip=[...] --port=6633

Wait for all links to be detected and run:

mininet> s5 ifconfig s5-eth2 down

Wait a while and this happens:

INFO:openflow.discovery:link timeout: 00-00-00-00-00-05.2 -> 00-00-00-00-00-07.3
INFO:openflow.discovery:link timeout: 00-00-00-00-00-07.3 -> 00-00-00-00-00-05.2
Task <Timer/tid1> caused exception and was de-scheduled
Traceback (most recent call last):
  File "/home/user/pox/pox/lib/recoco/recoco.py", line 276, in cycle
    rv = t.execute()
  File "/home/user/pox/pox/lib/recoco/recoco.py", line 94, in execute
    return self.gen.send(v)
  File "/home/user/pox/pox/lib/recoco/recoco.py", line 751, in run
    rv = self._callback(*self._args,**self._kw)
  File "/home/user/pox/pox/openflow/discovery.py", line 262, in _expireLinks
    self._deleteLinks(deleteme)
  File "/home/user/pox/pox/openflow/discovery.py", line 387, in _deleteLinks
    self.raiseEvent(LinkEvent, False, link)
  File "/home/user/pox/pox/lib/revent/revent.py", line 280, in raiseEvent
    rv = event._invoke(handler, *args, **kw)
  File "/home/user/pox/pox/lib/revent/revent.py", line 158, in _invoke
    return handler(self, *args, **kw)
  File "/home/user/pox/pox/openflow/topology.py", line 85, in _handle_openflow_discovery_LinkEvent
    sw1.ports[link.port1].entities.remove(sw2)
KeyError: <OpenFlowSwitch 00-00-00-00-00-05>

I believe this is happening because the link timeout event is symmetric, and the link is already removed when it happens the second time, causing the exception. A simple check would probably solve this problem:

In pox/openflow/topology.py:
Line 85 to 88 could be:

  if sw2 in sw1.ports[link.port1].entities:
    sw1.ports[link.port1].entities.remove(sw2)
  if sw1 in sw2.ports[link.port2].entities:
    sw2.ports[link.port2].entities.remove(sw1)

Extract mac header in pox

Hi, I'm working on wireless in pox. I want to extract the mac header of 802.11 of the packets that arrive at the controller. I cannot find a way to do that, I can extract the Ethernet header but that only gives me the mac addresses and the type, I need to extract the frame control bytes. Can someone please help me with this. Any help is appreciated. Thank you in advance.

LLC not included in pox.lib.packet by default

If you "import pox.lib.packet as pkt" as per convention, LLC isn't in there.

We may just need to add a couple lines similar to:

import llc as LLC

and

from llc import * 

.. to pox/lib/packet/init.py

But someone needs to check that it doesn't immediately break anything.

Bad sequence increment in Javascript messenger lib

The little JS library for communicating over the HTTP transport for messenger increments the sequence number even for keepalive messages, but the transport itself doesn't expect this. Thus, a keepalive message ruins the sequence number synchronization and the connection dies.

The two options here are: 1) Fix the Python code to have keepalives increment the sequence number, or 2) Fix the JS not have keepalives not increment the sequence number. (Third option: Actually rework the protocol, the JS, and the Python since none of them are actually that great. I'd recommend leaving this until after I finally push the new messenger stuff, though.)

I actually did the second one, and gave Junaid the patch, but on further reflection I think maybe the first option is the better one.

listen_to_dependencies() should save EIDs

I don't think there's an easy way to remove listeners set by listen_to_dependencies(), but this feature might be nice (see recent "How to unregister a component" on pox-dev).

It seems like they could just be stored somehow in an attribute on the listening object, probably as a dictionary. In addition, we might want an unlisten_to_dependencies() on core.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.