[pox-dev] add rules proactively - send flow to two or more ports
Murphy McCauley
murphy.mccauley at gmail.com
Wed May 15 12:41:00 PDT 2013
On May 15, 2013, at 8:13 AM, yona at gteccom.uff.br wrote:
> I´m using mininet and POX and I have two questions:
> II) How do I add a flow_mod without being involved in an event? I want to install proactively rules in the switches, but I only have achieved this when listening events. I didn't find any such thing on Internet. When I make simple applications like the one below, it works, but I need to install rules proactively.
As Lucas Brasilino said, you could do this from a timer, but... what's wrong with it being involved with an event? Don't you just need to pick the right event?
A common scenario is to install rules when a switch connects. In some sense, these are still "reactive". It's just that they're not reacting to PacketIn events -- they're reacting to ConnectionUp events. See misc.dnsspy for an example. It makes sense to install rules in response to this event, right? You're not going to install rules BEFORE the switch connects...
> II)How do I add a rule which sends a flow to two or more ports? Using dpctl just put the ports and it works well (e.g. in_port=2,actions=output:1,output:3), and in a application, how would I do that? I tried as above, which works weel when I have two ports, but when I need to install rules that sends flows to one and more ports together :
> ...
> self._install(event.connection.dpid,2,(1,3))
> self._install(event.connection.dpid,1,2))
> ...
>
> it doesn't work:
>
> File "/home/mininet/pox/pox/lib/revent/revent.py", line 234, in raiseEventNoErrors
> return self.raiseEvent(event, *args, **kw)
> File "/home/mininet/pox/pox/lib/revent/revent.py", line 281, in raiseEvent
> rv = event._invoke(handler, *args, **kw)
> File "/home/mininet/pox/pox/lib/revent/revent.py", line 159, in _invoke
> return handler(self, *args, **kw)
> File "/home/mininet/pox/ext/swbasico2.py", line 36, in _handle_ConnectionUp
> self._install(event.connection.dpid,3,1)
> File "/home/mininet/pox/ext/swbasico2.py", line 46, in _install
> for i in range(len(out_port)):
> TypeError: object of type 'int' has no len()
>
> Please, could you help me with that?
In the second example, you're passing out_port = 2. When line 46 does len(out_port), this is len(2), which doesn't make any sense. You could fix this function so that it does the right thing depending on whether it's passed an integer or a sequence, but you can also just pass it a sequence. Lucas almost had it right, except that (2) is not a tuple -- it's just a subexpression. Try this:
self._install(event.connection.dpid,1,(2,)))
or
self._install(event.connection.dpid,1,[2]))
-- Murphy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.noxrepo.org/pipermail/pox-dev-noxrepo.org/attachments/20130515/3c46b8a5/attachment-0002.htm>
More information about the pox-dev
mailing list