Yes, you can do this if what you want can be accomplished using the queue types 
available in your switch.  If that condition is true, then there are several 
ways to do it with different tradeoffs.  I'd suggest that you start off by 
modifying the l2_learning component to assign each new flow to the appropriate 
queue based on your criteria (e.g., protocol number).  To do this you:

1) Configure queues on your switch.  How you do this is switch-specific and not 
part of OpenFlow.  There's an article on how to configure some queues in Open 
vSwitch here (or read the OVS documentation for more):
http://openvswitch.org/support/config-cookbooks/qos-rate-limiting/

If you're not using OVS, you'll have to consult your switch's documentation.

When you set up the queues, each of them will have an integer ID.  You can use 
the OpenFlow enqueue action to direct traffic to these queues.

2) Modify l2_learning's flow installation.  Starting around line 169 in 
l2_learning.py, it creates new flow entries with an ofp_action_output action.  
You'd change this in two ways.  First, you'd decide which queue you wanted by 
inspecting the packet.  This is available in the .parsed attribute of the 
PacketIn event object, as I mentioned earlier.  For example, an easy way to 
determine if the packet is ipv4 is just "if event.parsed.find('ipv4'): ...".  
Once you determine which queue to assign to, use the ofp_action_enqueue action 
instead of ofp_action_output.  Altogether, this makes the modified code look 
something like this:

log.debug("installing flow for %s.%i -> %s.%i" %
          (packet.src, event.port, packet.dst, port))

if packet.find('tcp'):
  queue = 1 # TCP goes to queue 1
elif packet.find('ipv4'):
  queue = 2 # IP that isn't TCP goes to queue 2
else:
  queue = 3 # All other traffic goes to queue 3

msg = of.ofp_flow_mod()
msg.match = of.ofp_match.from_packet(packet, event.port)
msg.idle_timeout = 10
msg.hard_timeout = 30
msg.actions.append(of.ofp_action_enqueue(port = port, queue_id = queue))
msg.data = event.ofp # 6a
self.connection.send(msg)


Hope that helps.

-- Murphy

On Apr 5, 2013, at 12:58 AM, Sayed Qaiser Ali Shah Shah wrote:

> I think you mean that I want to achieve from this. I want to get IP protocol 
> number from packet and then on the basis of that protocol number I want to 
> assign bandwidth to flows/hosts on the basis of their needs. Like the 
> protocol number which needs high bandwidth should be allocated high bandwidth 
> or the one which needs less bandwidth should be allocated less bandwidth so, 
> that bandwidth doesn't waste. I am doing this for end user satisfaction. This 
> is related to QoS.
> Am I on Right direction? Can I do this?
> 
> On Fri, Apr 5, 2013 at 5:36 AM, Murphy McCauley <[email protected]> 
> wrote:
> On Apr 4, 2013, at 4:08 PM, Sayed Qaiser Ali Shah Shah wrote:
>> The link which you provide was very helpful and I found match class in that 
>> and I use this code
>> 
>> import pox.openflow.libopenflow_01 as of # POX convention
>> import pox.lib.packet as pkt # POX convention
>> my_match = of.ofp_match(dl_type = pkt.ethernet.IP_TYPE, nw_proto = 
>> pkt.ipv4.TCP_PROTOCOL, tp_dst = 80)
>> 
>> Which will create match to web servers but I don't know how this will work. 
>> Will it work automatically i.e. it will forward packets to server 
>> automatically when any packet having nw_proto=TCP_Protocol and tp_dst=80. If 
>> it does not forward the packet automatically then how it works?
> 
> You still haven't really explained what it is that you're trying to do.  What 
> is your high-level goal?  Are you trying to install flow table entries?  Do 
> you want packets from particular flows sent to the controller?  Are you 
> trying to block certain connections?
> 
> If you're trying to install flow entries on the switch, you need to send an 
> ofp_flow_mod (as per the OpenFlow spec).  This contains a match object and 
> then contains actions to tell the switch what to do with it (send it out of a 
> port, send it to the controller, etc.).  See the section of the manual wiki 
> on ofp_flow_mod, as well as the examples in the forwarding directory of POX 
> (for example, l2_learning).
> 
> -- Murphy
> 
> 
> 
> -- 
> Regards
> 
> Sayed Qaiser Ali Shah
> MSIT-12
> NUST (SEECS)

Reply via email to