[pox-dev] Bind POX to Multiple IP Interfaces

Murphy McCauley murphy.mccauley at gmail.com
Mon Nov 11 03:05:45 PST 2013


Yeah, this was an outcome of the demand-loading of OpenFlow.  My testing didn't trigger the demand loading, so I didn't see it, but yours did.  The demand-loading code previously relied on of_01's launch() to prevent an additional launch, but I removed the check in there as part of making it possible to launch it multiple times (of course).  So I put that bit of logic into boot now.  I think that fixes things, and I've pushed the result to dart along with the start of a new section in the manual.

Thanks for the input!  Let me know if it doesn't work right. :)

-- Murphy

On Nov 11, 2013, at 1:03 AM, Anton Matsiuk <anton.matsiuk at gmail.com> wrote:

> On 8 November 2013 20:35, Murphy McCauley <murphy.mccauley at gmail.com> wrote:
> 
> I actually would have thought the code would stop it from registering multiple times using the same name.  Though it's possible there's also something that needs adjusting with dart's new on-demand loading of OpenFlow.  Or... are you specifying "of_01" in l2sw?  More generally, are you directly calling of_01's launch() from l2sw?  If so, can you post the code where you do?
> 
> Actually no, it is almost the same code as in tutorial. Inside l2sw I add usual listener for ConnectionUp event:
>  
> def launch ():
>   def start_controller (event):
>     log.info("Controlling conID=%s, dpid=%i" %(event.connection.ID, event.dpid))
>     TestController(event.connection)
>   core.openflow.addListenerByName("ConnectionUp", start_controller)
>  
> which then launch usual L2 Controller class:
>  
> class TestController (object):
>   def __init__ (self, connection):
>     self.connection = connection
>     connection.addListeners(self)
>     self.mac_to_port = {}
> 
> and TestController does usual L2 switching.
>  
> It was also wondering for me, because, if I specify of_01 task in CLI twice with addresses which I need and with default 6633 ports it returns an error (but shouldn't because default interface specified in of_01's launch() is 0.0.0.0:6633):
>  
> mininet at mininet-vm:~/pox$ ./pox.py  --unthreaded_sh log.level --DEBUG openflow.of_01 --address=192.168.10.1 openflow.of_01 --address=192.168.20.1 l2sw
> POX 0.3.0 (dart) / Copyright 2011-2013 James McCauley, et al.
> WARNING:core:Warning: Registered 'of_01' multipled times
> WARNING:core:Warning: Registered 'of_01' multipled times
> DEBUG:core:POX 0.3.0 (dart) going up...
> DEBUG:core:Running on CPython (2.7.3/Sep 26 2012 21:51:14)
> DEBUG:core:Platform is Linux-3.5.0-17-generic-x86_64-with-Ubuntu-13.04-raring
> INFO:core:POX 0.3.0 (dart) is up.
> DEBUG:openflow.of_01:Listening on 192.168.10.1:6633
> DEBUG:openflow.of_01:Listening on 192.168.20.1:6633
> ERROR:openflow.of_01:Error 98 while binding socket: Address already in use
> ERROR:openflow.of_01: You may have another controller running.
> ERROR:openflow.of_01: Use openflow.of_01 --port=<port> to run POX on another port.
>  
> and if I try to bind it with different ports, then it works, but it also adds listener to interface  by default specified in  of_01's launch() (0.0.0.0:6633):
>  
> mininet at mininet-vm:~/pox$ ./pox.py  --unthreaded_sh log.level --DEBUG openflow.of_01 --address=192.168.10.1 --port=6634 openflow.of_01 --address=192.168.20.1 --port=6635 l2sw
> POX 0.3.0 (dart) / Copyright 2011-2013 James McCauley, et al.
> WARNING:core:Warning: Registered 'of_01' multipled times
> WARNING:core:Warning: Registered 'of_01' multipled times
> DEBUG:core:POX 0.3.0 (dart) going up...
> DEBUG:core:Running on CPython (2.7.3/Sep 26 2012 21:51:14)
> DEBUG:core:Platform is Linux-3.5.0-17-generic-x86_64-with-Ubuntu-13.04-raring
> INFO:core:POX 0.3.0 (dart) is up.
> DEBUG:openflow.of_01:Listening on 192.168.10.1:6634
> DEBUG:openflow.of_01:Listening on 192.168.20.1:6635
> DEBUG:openflow.of_01:Listening on 0.0.0.0:6633
>  
> And without specified interfaces it binds listener to interface by default. That's why it seems, that one instance of of_01 task is launched directly from the core in this case: 
>  
> mininet at mininet-vm:~/pox$ ./pox.py  --unthreaded_sh log.level --DEBUG l2sw
> POX 0.3.0 (dart) / Copyright 2011-2013 James McCauley, et al.
> DEBUG:core:POX 0.3.0 (dart) going up...
> DEBUG:core:Running on CPython (2.7.3/Sep 26 2012 21:51:14)
> DEBUG:core:Platform is Linux-3.5.0-17-generic-x86_64-with-Ubuntu-13.04-raring
> INFO:core:POX 0.3.0 (dart) is up.
> DEBUG:openflow.of_01:Listening on 0.0.0.0:6633
> 
> 
> Probably very slightly, in theory.  IIRC, though, the same task currently listens for connections and also handles established connections.  The way it figures out which are which would require a bit of adjusting to do cheaply when there are multiple listening connections, or listeners could be put in their own task.  Running multiple tasks seemed a bit easier, pretty elegant, and I didn't expect the performance difference to be dramatic.  But I didn't benchmark it or anything. :)
> 
>> mininet at mininet-vm:~/pox$ ./pox.py --unthreaded_sh log.level --DEBUG openflow.of_01 --address=192.168.20.1 l2sw
>> POX 0.3.0 (dart) / Copyright 2011-2013 James McCauley, et al.
>> WARNING:core:Warning: Registered 'of_01' multipled times
>> DEBUG:core:POX 0.3.0 (dart) going up...
>> DEBUG:core:Running on CPython (2.7.3/Sep 26 2012 21:51:14)
>> DEBUG:core:Platform is Linux-3.5.0-17-generic-x86_64-with-Ubuntu-13.04-raring
>> INFO:core:POX 0.3.0 (dart) is up.
>> DEBUG:openflow.of_01:Listening on 192.168.20.1:6633
>> DEBUG:openflow.of_01:Listening on 192.168.10.1:6633
>> INFO:openflow.of_01:[00-00-00-00-00-02 1] connected
>> INFO:l2sw:Controlling conID=1, dpid=2
>> INFO:openflow.of_01:[00-00-00-00-00-01 2] connected
>> INFO:l2sw:Controlling conID=2, dpid=1
>> 
>> 
>> On 7 November 2013 20:56, Murphy McCauley <murphy.mccauley at gmail.com> wrote:
>> I think this MIGHT be as easy as making the launcher for of_01 multi-instance aware.  I don't have time to actually check, but here's a hacked version which at least doesn't crash immediately. :)  Maybe you can give it a shot?
>> 
>> def launch (port=6633, address="0.0.0.0", name=None, __INSTANCE__=None):
>>   if name is None:
>>     basename = "of_01"
>>     counter = 1
>>     name = basename
>>     while core.hasComponent(name):
>>       counter += 1
>>       name = "%s-%s" % (basename, counter)
>> 
>>   if core.hasComponent(name):
>>     log.warn("of_01 '%s' already started", name)
>>     return None
>> 
>>   global deferredSender
>>   if not deferredSender:
>>     deferredSender = DeferredSender()
>> 
>>   if of._logger is None:
>>     of._logger = core.getLogger('libopenflow_01')
>> 
>>   l = OpenFlow_01_Task(port = int(port), address = address)
>>   core.register(name, l)
>>   return l
>> 
>> -- Murphy
>> 
>> On Nov 7, 2013, at 5:30 AM, Anton Matsiuk <anton.matsiuk at gmail.com> wrote:
>> 
>> > Dear Murphy,
>> >
>> > I am asking about possibility to bind POX Controller to listen for OF messages on multiple IP Interfaces. In my case, I need to bind it to 2 interfaces: listening from Open vSwitch through Loopback, and Hardware switch from external eth, but, of course, the quantity doesn't mater.
>> >
>> > As I understood there is no possibility to run 2 instances of OpenFlow_01_Task concurrently (and to register them both on core) or to bind one instance of Task to 2 different IP's.
>> >
>> > I know that it is possible to solve the problem by proxying through iptables, but I am looking for a possibility to do it with POX in a straightforward and scalable way.
>> >
>> > --
>> > Best regards,
>> > Anton Matsiuk
>> 
>> 
>> 
>> 
>> -- 
>> Best regards,
>> Anton Matsiuk
> 
> 
> 
> 
> -- 
> Best regards,
> Anton Matsiuk

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.noxrepo.org/pipermail/pox-dev-noxrepo.org/attachments/20131111/3a38404a/attachment-0002.htm>


More information about the pox-dev mailing list