Example #1
0
 public boolean delExplicitTagGenerate(int srcIP, int dstIP) {
   try {
     Flow f = null;
     for (Flow flow : this.explicitFlow) {
       Match match = flow.getMatch();
       if (match
               .getField(MatchType.NW_SRC)
               .toString()
               .contains(FTUtil.IPAddressStringFromInt(srcIP))
           && match
               .getField(MatchType.NW_DST)
               .toString()
               .contains(FTUtil.IPAddressStringFromInt(dstIP))) {
         f = flow;
         break;
       }
     }
     if (f != null) {
       this.removeFlowRule(f);
       this.explicitFlow.remove(f);
     }
   } catch (UnknownHostException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   return true;
 }
Example #2
0
  public boolean setTestSenderRule(
      int testTag, int returnTag, int testGeneratorSrcIP, int testSrcIP) {
    Flow flow = new Flow();
    Match match = new Match();
    List<Action> actions = new ArrayList<Action>();
    try {
      System.out.println(
          "TestTag:"
              + testTag
              + " returnTag:"
              + returnTag
              + " testSrcIP:"
              + FTUtil.IPAddressStringFromInt(testSrcIP)
              + " testGenIP:"
              + FTUtil.IPAddressStringFromInt(testGeneratorSrcIP));
    } catch (UnknownHostException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }
    match.setField(MatchType.DL_TYPE, (short) 0x0800);
    match.setField(MatchType.NW_TOS, (byte) (testTag / 4));
    try {
      actions.add(new SetNwTos((byte) 0));
      actions.add(new SetNwSrc(FTUtil.InetAddressFromInt(testSrcIP)));
      actions.add(new Loopback());
    } catch (UnknownHostException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    flow.setMatch(match);
    flow.setActions(actions);
    flow.setPriority((short) 200);
    this.addFlowRule(flow);

    flow = new Flow();
    match = new Match();
    actions = new ArrayList<Action>();
    try {
      match.setField(MatchType.DL_TYPE, (short) 0x0800);
      match.setField(MatchType.NW_DST, (FTUtil.InetAddressFromInt(testSrcIP)));
      actions.add(new SetNwTos((byte) returnTag));
      actions.add(new SetNwDst(FTUtil.InetAddressFromInt(testGeneratorSrcIP)));
      actions.add(new Loopback());
    } catch (UnknownHostException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    flow.setMatch(match);
    flow.setActions(actions);
    flow.setPriority((short) 200);
    this.addFlowRule(flow);

    return true;
  }
Example #3
0
 private byte[] getMacAddressFromDPID() {
   String dpid = this.node.getNodeIDString();
   String[] dpids = dpid.split(":");
   StringBuffer bb = new StringBuffer();
   for (int index = 2; index < dpids.length - 1; index++) {
     bb.append(dpids[index]);
     bb.append(":");
   }
   bb.append(dpids[dpids.length - 1]);
   return FTUtil.MacAddressBytesFromString(bb.toString());
 }
Example #4
0
 public boolean setExplicitTagGenerate(
     int srcIP, int dstIP, int tpSrcPort, int tpDstPort, int proto, int tag) {
   Flow flow = new Flow();
   Match match = new Match();
   List<Action> actions = new ArrayList<Action>();
   match.setField(MatchType.DL_TYPE, (short) 0x0800);
   try {
     if (srcIP != 0) {
       match.setField(MatchType.NW_SRC, FTUtil.InetAddressFromInt(srcIP));
     }
     if (dstIP != 0) {
       match.setField(MatchType.NW_DST, FTUtil.InetAddressFromInt(dstIP));
     }
     match.setField(MatchType.IN_PORT, this.hostPort);
     if (proto != 0) {
       match.setField(MatchType.NW_PROTO, (byte) proto);
     }
     if (tpSrcPort != 0) {
       match.setField(MatchType.TP_SRC, (short) tpSrcPort);
     }
     if (tpDstPort != 0) {
       match.setField(MatchType.TP_DST, (short) tpDstPort);
     }
   } catch (UnknownHostException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   if (tag != 0) {
     flow.setPriority((short) 150);
     actions.add(new SetNwTos((byte) tag));
     actions.add(new Output(this.netPort));
   } else {
     flow.setPriority((short) 200);
   }
   flow.setMatch(match);
   flow.setActions(actions);
   this.explicitFlow.add(flow);
   return this.addFlowRule(flow);
 }