Openflow / Floodlight:为两个不同的交换机安装不同的流

时间:2015-03-19 10:57:01

标签: openflow mininet

我有以下拓扑: topology

我试图从server2到server4执行iperf并出现问题:似乎(通过使用wireshark分析流量)它并没有在目标交换机上安装任何规则。如果我在同一个交换机的两个服务器之间尝试一个iperf,一切正常。我不明白为什么会出现这个问题。谁能帮我?任何建议都可能有用。 在交换机上安装流的代码如下:

//source Switch != destination Switch
IOFSwitch srcSwitch = sw;
IOFSwitch dstSwitch = this.floodlightProvider.getSwitch(destSwitchID);

/* Create match:                        
* source Mac: always host mac  
* dest Mac: always dest host mac 
* source Ip: vIP or external 
* dest Ip: rIP or vIP */

int srcIp = IPv4.toIPv4Address(toVirtualIp(sourceIp));

//get inPort of dest Switch on the inter-switch link 
  short inPort = topology.getInterSwitchPort(destSwitchID);

  OFMatch matchDst = createMatch(srcHostMac, destHostMac, srcIp, destIp, inPort);

  short[] actionsLengthDst = {0};

  int dstIp = IPv4.toIPv4Address(toRealIp(destIp));

  // Initialize list of actions
  //realSrcToVirtualSrc = false because sourceIp has not to be translated to realIp in the dest switch
  ArrayList<OFAction> actionsDst = createActions(false, 0, //vIP                                                              
                                                 virtualDestToRealDest, dstIp, //rIP
                                                 destHostMac, destSwitchID, actionsLengthDst,
                                                 false);

  OFFlowMod ruleDst = createRule(matchDst, actionsDst, actionsLengthDst[0]);

   System.out.println("Installing flows to dest OF switch ID " + dstSwitch.getId());
   try {
       dstSwitch.write(ruleDst, cntx);
   } catch (Exception e) {
        e.printStackTrace();
        return false;
    }

     /* Create match:                        
     * source Mac: always host mac  
     * dest Mac: gateway MAC or host MAC  
     * source Ip: rIP  
     * dest Ip: rIP or vIP */

     OFMatch matchSrc = createMatch(srcHostMac, destMac, sourceIp, destIp, pi.getInPort());

      short[] actionsLengthSrc = {0};

      // Initialize list of actions
      //virtualDestToRealDest = false because destIp has not to be translated to realIp int the source switch
      ArrayList<OFAction> actionsSrc = createActions(realSrcToVirtualSrc, sourceIp, //not translated (always)     
                                          false, 0, //not translated (rIP or vIP)                                 
                                          destHostMac, sw.getId(), actionsLengthSrc,                           
                                          false);

     OFFlowMod ruleSrc = createRule(matchSrc, actionsSrc, actionsLengthSrc[0]);

     System.out.println("Installing flows to source OF switch ID " + srcSwitch.getId());
      try {
           srcSwitch.write(ruleSrc, cntx);
      } catch (Exception e) {
           e.printStackTrace();
            return false;
      }

提前致谢。

0 个答案:

没有答案