title: Group table issue - Openflow, Mininet
body: <p>I have a fat tree topology, and I am using Mininet, OpenFlow 1.3, Ryu Controller to mimic ECMP based routing. I am using Group and Flow tables to do this. For example, s2 and s3 are connected to ports 1 and 2 of an aggregate switch, say as1, in which the following rules are installed:</p>
  <h1>Group Table definitions</h1>
  <pre><code>        # Create two actions that forwards packets to ports 1 and 2 that are connected to two core switches
          action1 = sw.ofproto_parser.OFPActionOutput(1)
          action2 = sw.ofproto_parser.OFPActionOutput(2)
  
          # Specify two action sets (buckets), each with one action
          bucket1 = sw.ofproto_parser.OFPBucket(weight=1, actions=[action1])
          bucket2 = sw.ofproto_parser.OFPBucket(weight=1, actions=[action2])
          
          # OFPGT_SELECT chooses between bucket1 and bucket2 based on
          # some logic implemented in the switch, typically, round-robin?!
          group_mod = sw.ofproto_parser.OFPGroupMod(
              datapath=sw, command=ofp.OFPGC_ADD,
              type_=ofp.OFPGT_SELECT, group_id=1,
              buckets=[bucket1, bucket2])
          sw.send_msg(group_mod)
  
  
  
         
  </code></pre>
  <h1>Install group table action in flow table</h1>
  <pre><code>        match = sw.ofproto_parser.OFPMatch(eth_type = \
                      0x0800)
          action = sw.ofproto_parser.OFPActionGroup(1)
  
  
          inst = [ofp_parser.OFPInstructionActions(
                  ofp.OFPIT_APPLY_ACTIONS, [action])]
          mod = sw.ofproto_parser.OFPFlowMod(
              datapath=sw, match=match, cookie=0, command=ofp.OFPFC_ADD,
              idle_timeout=0, hard_timeout=0, priority=100,
              flags=ofp.OFPFF_SEND_FLOW_REM, instructions=inst)
  
     # Other flow entries rules are added here ...
  </code></pre>
  <p>I confirm this using the <code>dpctl dump-flows</code> command in Mininet. Please note that for core switch s2, n_packets = n_bytes = 0, while it is not the case for the other core switch s3:</p>
  <pre><code>*** s2 ------------------------------------------------------------------------
  OFPST_FLOW reply (OF1.3) (xid=0x2):
   cookie=0x0, duration=71.556s, table=0, n_packets=0, n_bytes=0, send_flow_rem priority=1200,ip,nw_dst=10.0.0.1 actions=output:1
   cookie=0x0, duration=71.556s, table=0, n_packets=0, n_bytes=0, send_flow_rem priority=1200,ip,nw_dst=10.0.0.2 actions=output:1
   cookie=0x0, duration=71.556s, table=0, n_packets=0, n_bytes=0, send_flow_rem priority=1200,ip,nw_dst=10.0.0.3 actions=output:1
   cookie=0x0, duration=71.556s, table=0, n_packets=0, n_bytes=0, send_flow_rem priority=1200,ip,nw_dst=10.0.0.4 actions=output:1
   cookie=0x0, duration=71.556s, table=0, n_packets=0, n_bytes=0, send_flow_rem priority=1200,ip,nw_dst=10.0.0.5 actions=output:2
  </code></pre>
  <p>.....
  For core switch s3:</p>
  <pre><code>*** s3 ------------------------------------------------------------------------
  OFPST_FLOW reply (OF1.3) (xid=0x2):
   cookie=0x0, duration=71.582s, table=0, n_packets=4436, n_bytes=12043732, send_flow_rem priority=1200,ip,nw_dst=10.0.0.1 actions=output:1
   cookie=0x0, duration=71.582s, table=0, n_packets=6306, n_bytes=11448184, send_flow_rem priority=1200,ip,nw_dst=10.0.0.2 actions=output:1
   cookie=0x0, duration=71.582s, table=0, n_packets=870, n_bytes=1157688, send_flow_rem priority=1200,ip,nw_dst=10.0.0.3 actions=output:1
   cookie=0x0, duration=71.582s, table=0, n_packets=674, n_bytes=644616, send_flow_rem priority=1200,ip,nw_dst=10.0.0.4 actions=output:1
   cookie=0x0, duration=71.582s, table=0, n_packets=4475, n_bytes=11918478, send_flow_rem priority=1200,ip,nw_dst=10.0.0.5 actions=output:2
  </code></pre>
  <p>Like I have mentioned in the comments above, I believe OFPGT_SELECT chooses between bucket1 and bucket2 based on some logic implemented in the switch, like, round-robin? This seems to work fine in the lower level switches in the topology, i.e., both buckets are chosen alternatively with equal weights. But in the case of aggregate switches at the top, only one path (bucket) to the core switch is always chosen. Typically all packets pick only the first bucket (port) or the last bucket (port), but not alternating between both buckets!</p>
  <p>However, when giving unequal weights (1 and 2) to both the buckets, it does work. Not sure what the problem is with equal weights.</p>
  <p>Any help would be greatly appreciated. Thanks!</p>