当前位置: 首页>>代码示例>>Java>>正文


Java Ethernet.isMulticast方法代码示例

本文整理汇总了Java中net.floodlightcontroller.packet.Ethernet.isMulticast方法的典型用法代码示例。如果您正苦于以下问题:Java Ethernet.isMulticast方法的具体用法?Java Ethernet.isMulticast怎么用?Java Ethernet.isMulticast使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.floodlightcontroller.packet.Ethernet的用法示例。


在下文中一共展示了Ethernet.isMulticast方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processPacketIn

import net.floodlightcontroller.packet.Ethernet; //导入方法依赖的package包/类
/**
 * Processes an OFPacketIn message and decides if the OFPacketIn should be dropped
 * or the processing should continue.
 * @param sw The switch the PacketIn came from.
 * @param msg The OFPacketIn message from the switch.
 * @param cntx The FloodlightContext for this message.
 * @return Command.CONTINUE if processing should be continued, Command.STOP otherwise.
 */
protected Command processPacketIn(IOFSwitch sw, OFPacketIn msg, FloodlightContext cntx) {
	Ethernet eth = IFloodlightProviderService.bcStore.get(cntx,
			IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
	Command ret = Command.STOP;
	String srcNetwork = macToGuid.get(eth.getSourceMACAddress());
	// If the host is on an unknown network we deny it.
	// We make exceptions for ARP and DHCP.
	if (eth.isBroadcast() || eth.isMulticast() || isDefaultGateway(eth) || isDhcpPacket(eth)) {
		ret = Command.CONTINUE;
	} else if (srcNetwork == null) {
		log.trace("Blocking traffic from host {} because it is not attached to any network.",
				eth.getSourceMACAddress().toString());
		ret = Command.STOP;
	} else if (oneSameNetwork(eth.getSourceMACAddress(), eth.getDestinationMACAddress())) {
		// if they are on the same network continue
		ret = Command.CONTINUE;
	}

	if (log.isTraceEnabled())
		log.trace("Results for flow between {} and {} is {}",
				new Object[] {eth.getSourceMACAddress(), eth.getDestinationMACAddress(), ret});
	/*
	 * TODO - figure out how to still detect gateways while using
	 * drop mods
       if (ret == Command.STOP) {
           if (!(eth.getPayload() instanceof ARP))
               doDropFlow(sw, msg, cntx);
       }
	 */
	return ret;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:40,代码来源:VirtualNetworkFilter.java

示例2: processPacketIn

import net.floodlightcontroller.packet.Ethernet; //导入方法依赖的package包/类
/**
 * Processes an OFPacketIn message and decides if the OFPacketIn should be dropped
 * or the processing should continue.
 * @param sw The switch the PacketIn came from.
 * @param msg The OFPacketIn message from the switch.
 * @param cntx The FloodlightContext for this message.
 * @return Command.CONTINUE if processing should be continued, Command.STOP otherwise.
 */
protected Command processPacketIn(IOFSwitch sw, OFPacketIn msg, FloodlightContext cntx) {
    Ethernet eth = IFloodlightProviderService.bcStore.get(cntx,
                                          IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
    Command ret = Command.STOP;
    String srcNetwork = macToGuid.get(eth.getSourceMAC());
    // If the host is on an unknown network we deny it.
    // We make exceptions for ARP and DHCP.
    if (eth.isBroadcast() || eth.isMulticast() || isDefaultGateway(eth) || isDhcpPacket(eth)) {
        ret = Command.CONTINUE;
    } else if (srcNetwork == null) {
        log.trace("Blocking traffic from host {} because it is not attached to any network.",
                  HexString.toHexString(eth.getSourceMACAddress()));
        ret = Command.STOP;
    } else if (oneSameNetwork(eth.getSourceMAC(), eth.getDestinationMAC())) {
        // if they are on the same network continue
        ret = Command.CONTINUE;
    }

    if (log.isTraceEnabled())
        log.trace("Results for flow between {} and {} is {}",
                new Object[] {eth.getSourceMAC(), eth.getDestinationMAC(), ret});
    /*
     * TODO - figure out how to still detect gateways while using
     * drop mods
    if (ret == Command.STOP) {
        if (!(eth.getPayload() instanceof ARP))
            doDropFlow(sw, msg, cntx);
    }
    */
    return ret;
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:40,代码来源:VirtualNetworkFilter.java

示例3: processPacketInMessage

import net.floodlightcontroller.packet.Ethernet; //导入方法依赖的package包/类
@Override
public Command processPacketInMessage(IOFSwitch sw, OFPacketIn pi, IRoutingDecision decision, FloodlightContext cntx) {
	Ethernet eth = IFloodlightProviderService.bcStore.get(cntx, IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
	// We found a routing decision (i.e. Firewall is enabled... it's the only thing that makes RoutingDecisions)
	if (decision != null) {
		if (log.isTraceEnabled()) {
			log.trace("Forwarding decision={} was made for PacketIn={}", decision.getRoutingAction().toString(), pi);
		}
		switch(decision.getRoutingAction()) {
		case NONE:
			// don't do anything
			return Command.CONTINUE;
		case FORWARD_OR_FLOOD:
		case FORWARD:
			doForwardFlow(sw, pi, cntx, false);
			return Command.CONTINUE;
		case MULTICAST:
			// treat as broadcast
			doFlood(sw, pi, cntx);
			return Command.CONTINUE;
		case DROP:
			doDropFlow(sw, pi, decision, cntx);
			return Command.CONTINUE;
		default:
			log.error("Unexpected decision made for this packet-in={}", pi, decision.getRoutingAction());
			return Command.CONTINUE;
		}
	} else { // No routing decision was found. Forward to destination or flood if bcast or mcast.
		if (log.isTraceEnabled()) {
			log.trace("No decision was made for PacketIn={}, forwarding", pi);
		}

		if (eth.isBroadcast() || eth.isMulticast()) {
			doFlood(sw, pi, cntx);
		} else {
			doForwardFlow(sw, pi, cntx, false);
		}
	}

	return Command.CONTINUE;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:42,代码来源:Forwarding.java

示例4: processPacketIn

import net.floodlightcontroller.packet.Ethernet; //导入方法依赖的package包/类
private net.floodlightcontroller.core.IListener.Command processPacketIn(IOFSwitch sw, OFPacketIn pi, FloodlightContext cntx) {
    
    Ethernet eth = IFloodlightProviderService.bcStore.get(cntx, IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
    IPacket pkt = eth.getPayload(); 
 
    if (eth.isBroadcast() || eth.isMulticast()) {
        // handle ARP for VIP
        if (pkt instanceof ARP) {
            // retrieve arp to determine target IP address                                                       
            ARP arpRequest = (ARP) eth.getPayload();

            IPv4Address targetProtocolAddress = arpRequest.getTargetProtocolAddress();

            if (vipIpToId.containsKey(targetProtocolAddress.getInt())) {
                String vipId = vipIpToId.get(targetProtocolAddress.getInt());
                vipProxyArpReply(sw, pi, cntx, vipId);
                return Command.STOP;
            }
        }
    } else {
        // currently only load balance IPv4 packets - no-op for other traffic 
        if (pkt instanceof IPv4) {
            IPv4 ip_pkt = (IPv4) pkt;
            
            // If match Vip and port, check pool and choose member
            int destIpAddress = ip_pkt.getDestinationAddress().getInt();
            
            if (vipIpToId.containsKey(destIpAddress)){
                IPClient client = new IPClient();
                client.ipAddress = ip_pkt.getSourceAddress();
                client.nw_proto = ip_pkt.getProtocol();
                if (ip_pkt.getPayload() instanceof TCP) {
                    TCP tcp_pkt = (TCP) ip_pkt.getPayload();
                    client.srcPort = tcp_pkt.getSourcePort();
                    client.targetPort = tcp_pkt.getDestinationPort();
                }
                if (ip_pkt.getPayload() instanceof UDP) {
                    UDP udp_pkt = (UDP) ip_pkt.getPayload();
                    client.srcPort = udp_pkt.getSourcePort();
                    client.targetPort = udp_pkt.getDestinationPort();
                }
                if (ip_pkt.getPayload() instanceof ICMP) {
                    client.srcPort = TransportPort.of(8); 
                    client.targetPort = TransportPort.of(0); 
                }
                
                LBVip vip = vips.get(vipIpToId.get(destIpAddress));
                if (vip == null)			// fix dereference violations           
                	return Command.CONTINUE;
                LBPool pool = pools.get(vip.pickPool(client));
                if (pool == null)			// fix dereference violations
                	return Command.CONTINUE;
                LBMember member = members.get(pool.pickMember(client));
                if(member == null)			//fix dereference violations
                	return Command.CONTINUE;
                
                // for chosen member, check device manager and find and push routes, in both directions                    
                pushBidirectionalVipRoutes(sw, pi, cntx, client, member);
               
                // packet out based on table rule
                pushPacket(pkt, sw, pi.getBufferId(), (pi.getVersion().compareTo(OFVersion.OF_12) < 0) ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT), OFPort.TABLE,
                            cntx, true);

                return Command.STOP;
            }
        }
    }
    // bypass non-load-balanced traffic for normal processing (forwarding)
    return Command.CONTINUE;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:71,代码来源:LoadBalancer.java

示例5: processPacketInMessage

import net.floodlightcontroller.packet.Ethernet; //导入方法依赖的package包/类
@Override
@LogMessageDoc(level="ERROR",
message="Unexpected decision made for this packet-in={}",
explanation="An unsupported PacketIn decision has been " +
		"passed to the flow programming component",
		recommendation=LogMessageDoc.REPORT_CONTROLLER_BUG)
public Command processPacketInMessage(IOFSwitch sw, OFPacketIn pi, IRoutingDecision decision, FloodlightContext cntx) {
	Ethernet eth = IFloodlightProviderService.bcStore.get(cntx, IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
	// We found a routing decision (i.e. Firewall is enabled... it's the only thing that makes RoutingDecisions)
	if (decision != null) {
		if (log.isTraceEnabled()) {
			log.trace("Forwaring decision={} was made for PacketIn={}", decision.getRoutingAction().toString(), pi);
		}

		switch(decision.getRoutingAction()) {
		case NONE:
			// don't do anything
			return Command.CONTINUE;
		case FORWARD_OR_FLOOD:
		case FORWARD:
			doForwardFlow(sw, pi, cntx, false);
			return Command.CONTINUE;
		case MULTICAST:
			// treat as broadcast
			doFlood(sw, pi, cntx);
			return Command.CONTINUE;
		case DROP:
			doDropFlow(sw, pi, decision, cntx);
			return Command.CONTINUE;
		default:
			log.error("Unexpected decision made for this packet-in={}", pi, decision.getRoutingAction());
			return Command.CONTINUE;
		}
	} else { // No routing decision was found. Forward to destination or flood if bcast or mcast.
		if (log.isTraceEnabled()) {
			log.trace("No decision was made for PacketIn={}, forwarding", pi);
		}

		if (eth.isBroadcast() || eth.isMulticast()) {
			doFlood(sw, pi, cntx);
		} else {
			doForwardFlow(sw, pi, cntx, false);
		}
	}

	return Command.CONTINUE;
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:48,代码来源:Forwarding.java

示例6: processPacketIn

import net.floodlightcontroller.packet.Ethernet; //导入方法依赖的package包/类
private net.floodlightcontroller.core.IListener.Command processPacketIn(IOFSwitch sw, OFPacketIn pi, FloodlightContext cntx) {
    
    Ethernet eth = IFloodlightProviderService.bcStore.get(cntx, IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
    IPacket pkt = eth.getPayload(); 
 
    if (eth.isBroadcast() || eth.isMulticast()) {
        // handle ARP for VIP
        if (pkt instanceof ARP) {
            // retrieve arp to determine target IP address                                                       
            ARP arpRequest = (ARP) eth.getPayload();

            int targetProtocolAddress = IPv4.toIPv4Address(arpRequest
                                                           .getTargetProtocolAddress());

            if (vipIpToId.containsKey(targetProtocolAddress)) {
                String vipId = vipIpToId.get(targetProtocolAddress);
                vipProxyArpReply(sw, pi, cntx, vipId);
                return Command.STOP;
            }
        }
    } else {
        // currently only load balance IPv4 packets - no-op for other traffic 
        if (pkt instanceof IPv4) {
            IPv4 ip_pkt = (IPv4) pkt;
            
            // If match Vip and port, check pool and choose member
            int destIpAddress = ip_pkt.getDestinationAddress().getInt();
            
            if (vipIpToId.containsKey(destIpAddress)){
                IPClient client = new IPClient();
                client.ipAddress = ip_pkt.getSourceAddress();
                client.nw_proto = ip_pkt.getProtocol();
                if (ip_pkt.getPayload() instanceof TCP) {
                    TCP tcp_pkt = (TCP) ip_pkt.getPayload();
                    client.srcPort = tcp_pkt.getSourcePort();
                    client.targetPort = tcp_pkt.getDestinationPort();
                }
                if (ip_pkt.getPayload() instanceof UDP) {
                    UDP udp_pkt = (UDP) ip_pkt.getPayload();
                    client.srcPort = udp_pkt.getSourcePort();
                    client.targetPort = udp_pkt.getDestinationPort();
                }
                if (ip_pkt.getPayload() instanceof ICMP) {
                    client.srcPort = TransportPort.of(8); 
                    client.targetPort = TransportPort.of(0); 
                }
                
                LBVip vip = vips.get(vipIpToId.get(destIpAddress));
                LBPool pool = pools.get(vip.pickPool(client));
                LBMember member = members.get(pool.pickMember(client));

                // for chosen member, check device manager and find and push routes, in both directions                    
                pushBidirectionalVipRoutes(sw, pi, cntx, client, member);
               
                // packet out based on table rule
                pushPacket(pkt, sw, pi.getBufferId(), (pi.getVersion().compareTo(OFVersion.OF_12) < 0) ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT), OFPort.TABLE,
                            cntx, true);

                return Command.STOP;
            }
        }
    }
    // bypass non-load-balanced traffic for normal processing (forwarding)
    return Command.CONTINUE;
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:66,代码来源:LoadBalancer.java

示例7: processPacketInMessage

import net.floodlightcontroller.packet.Ethernet; //导入方法依赖的package包/类
@Override
public Command processPacketInMessage(IOFSwitch sw, OFPacketIn pi, IRoutingDecision decision, FloodlightContext cntx) {
	Ethernet eth = IFloodlightProviderService.bcStore.get(cntx, IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
	// We found a routing decision (i.e. Firewall is enabled... it's the only thing that makes RoutingDecisions)
	if (decision != null) {
		if (log.isTraceEnabled()) {
			log.trace("Forwarding decision={} was made for PacketIn={}", decision.getRoutingAction().toString(), pi);
		}

		switch(decision.getRoutingAction()) {
		case NONE:
			// don't do anything
			return Command.CONTINUE;
		case FORWARD_OR_FLOOD:
		case FORWARD:
			doForwardFlow(sw, pi, cntx, false);
			return Command.CONTINUE;
		case MULTICAST:
			// treat as broadcast
			doFlood(sw, pi, cntx);
			return Command.CONTINUE;
		case DROP:
			doDropFlow(sw, pi, decision, cntx);
			return Command.CONTINUE;
		default:
			log.error("Unexpected decision made for this packet-in={}", pi, decision.getRoutingAction());
			return Command.CONTINUE;
		}
	} else { // No routing decision was found. Forward to destination or flood if bcast or mcast.
		if (log.isTraceEnabled()) {
			log.trace("No decision was made for PacketIn={}, forwarding", pi);
		}

		if (eth.isBroadcast() || eth.isMulticast()) {
			doFlood(sw, pi, cntx);
		} else {
			doForwardFlow(sw, pi, cntx, false);
		}
	}

	return Command.CONTINUE;
}
 
开发者ID:hksoni,项目名称:SDN-Multicast,代码行数:43,代码来源:Forwarding.java

示例8: processPacketInMessage

import net.floodlightcontroller.packet.Ethernet; //导入方法依赖的package包/类
@Override
public Command processPacketInMessage(IOFSwitch sw, OFPacketIn pi, IRoutingDecision decision, FloodlightContext cntx) {
	Ethernet eth = IFloodlightProviderService.bcStore.get(cntx, IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
	/**********************************************************
	 * ARSCHEDULER MODIFICATION
	 * ADDED IF STATEMENT: FORWARDING MODULE ONLY HANDLES ARP
	 * PACKETS NOW. REMOVE THIS IF STATEMENT IF NOT USING
	 * ARSCHEDULER.
	 * 
	 **********************************************************/
	if(eth.getEtherType() != EthType.ARP){
		return Command.CONTINUE;
	}
	// We found a routing decision (i.e. Firewall is enabled... it's the only thing that makes RoutingDecisions)
	if (decision != null) {
		if (log.isTraceEnabled()) {
			log.trace("Forwarding decision={} was made for PacketIn={}", decision.getRoutingAction().toString(), pi);
		}

		switch(decision.getRoutingAction()) {
		case NONE:
			// don't do anything
			return Command.CONTINUE;
		case FORWARD_OR_FLOOD:
		case FORWARD:
			doForwardFlow(sw, pi, cntx, false);
			return Command.CONTINUE;
		case MULTICAST:
			// treat as broadcast
			doFlood(sw, pi, cntx);
			return Command.CONTINUE;
		case DROP:
			doDropFlow(sw, pi, decision, cntx);
			return Command.CONTINUE;
		default:
			log.error("Unexpected decision made for this packet-in={}", pi, decision.getRoutingAction());
			return Command.CONTINUE;
		}
	} else { // No routing decision was found. Forward to destination or flood if bcast or mcast.
		if (log.isTraceEnabled()) {
			log.trace("No decision was made for PacketIn={}, forwarding", pi);
		}

		if (eth.isBroadcast() || eth.isMulticast()) {
			doFlood(sw, pi, cntx);
		} else {
			doForwardFlow(sw, pi, cntx, false);
		}
	}

	return Command.CONTINUE;
}
 
开发者ID:DylanAPDavis,项目名称:arscheduler,代码行数:53,代码来源:Forwarding.java

示例9: PacketInType

import net.floodlightcontroller.packet.Ethernet; //导入方法依赖的package包/类
protected List<String> PacketInType(IOFSwitch sw, OFMessage m, Ethernet eth) {
      
     
  	
      int l3type = eth.getEtherType() & 0xffff;
      String switchIdHex = sw.getStringId();
      String etherType = String.format("%04x", eth.getEtherType());
      String packetName = m.getType().toClass().getName();
      packetName = packetName.substring(packetName.lastIndexOf('.')+1);
      
      
    

      // L2 Type
      String l2Type = null;
      if (eth.isBroadcast()) {
          l2Type = BROADCAST;
      }
      else if (eth.isMulticast()) {
          l2Type = MULTICAST;
      }
      else {
          l2Type = UNICAST;
      }

      
     //  Use alias for L3 type
     //  Valid EtherType must be greater than or equal to 0x0600
     //  It is V1 Ethernet Frame if EtherType < 0x0600
       
      if (l3type < 0x0600) {
          etherType = "0599";
      }
      if (TypeAnalyser.l3TypeAliasMap != null &&
      	TypeAnalyser.l3TypeAliasMap.containsKey(etherType)) {
          etherType = TypeAnalyser.l3TypeAliasMap.get(etherType);
      }
      else {
          etherType = "L3_" + etherType;
      }

 
      // L4 counters
      if (eth.getPayload() instanceof IPv4) {

          // resolve protocol alias
          IPv4 ipV4 = (IPv4)eth.getPayload();
          String l4name = String.format("%02x", ipV4.getProtocol());
          if (TypeAnalyser.l4TypeAliasMap != null &&
          	TypeAnalyser.l4TypeAliasMap.containsKey(l4name)) {
              l4name = TypeAnalyser.l4TypeAliasMap.get(l4name);
          }
          else {
              l4name = "L4_" + l4name;
          }
          
           List<String>list = new ArrayList<String>();
           list.add(l2Type);
           list.add(etherType);
           list.add(l4name);
           
	      //使用Iterator迭代器遍历出集合的元素并打印
	      for(Iterator<String> i = list.iterator();i.hasNext(); ){
	      String str = (String) i.next();
	      System.out.println(str);
	      }
      }
return null;
	      
	     
  }
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:72,代码来源:TrafficAnalyser.java

示例10: processPacketInMessage

import net.floodlightcontroller.packet.Ethernet; //导入方法依赖的package包/类
@Override
@LogMessageDoc(level="ERROR",
               message="Unexpected decision made for this packet-in={}",
               explanation="An unsupported PacketIn decision has been " +
               		"passed to the flow programming component",
               recommendation=LogMessageDoc.REPORT_CONTROLLER_BUG)
public Command processPacketInMessage(IOFSwitch sw, OFPacketIn pi, IRoutingDecision decision,
                                      FloodlightContext cntx) {
    Ethernet eth = IFloodlightProviderService.bcStore.get(cntx,
                               IFloodlightProviderService.CONTEXT_PI_PAYLOAD);

    // If a decision has been made we obey it
    // otherwise we just forward
    if (decision != null) {
        if (log.isTraceEnabled()) {
            log.trace("Forwaring decision={} was made for PacketIn={}",
                    decision.getRoutingAction().toString(),
                    pi);
        }

        switch(decision.getRoutingAction()) {
            case NONE:
                // don't do anything
                return Command.CONTINUE;
            case FORWARD_OR_FLOOD:
            case FORWARD:
                doForwardFlow(sw, pi, cntx, false);
                return Command.CONTINUE;
            case MULTICAST:
                // treat as broadcast
                doFlood(sw, pi, cntx);
                return Command.CONTINUE;
            case DROP:
                doDropFlow(sw, pi, decision, cntx);
                return Command.CONTINUE;
            default:
                log.error("Unexpected decision made for this packet-in={}",
                        pi, decision.getRoutingAction());
                return Command.CONTINUE;
        }
    } else {
        if (log.isTraceEnabled()) {
            log.trace("No decision was made for PacketIn={}, forwarding",
                    pi);
        }

        if (eth.isBroadcast() || eth.isMulticast()) {
            // For now we treat multicast as broadcast
            doFlood(sw, pi, cntx);
        } else {
            doForwardFlow(sw, pi, cntx, false);
        }
    }

    return Command.CONTINUE;
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:57,代码来源:Forwarding.java

示例11: processPacketIn

import net.floodlightcontroller.packet.Ethernet; //导入方法依赖的package包/类
private net.floodlightcontroller.core.IListener.Command
        processPacketIn(IOFSwitch sw, OFPacketIn pi,
                        FloodlightContext cntx) {
    
    Ethernet eth = IFloodlightProviderService.bcStore.get(cntx,
                                                          IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
    IPacket pkt = eth.getPayload();
 
    if (eth.isBroadcast() || eth.isMulticast()) {
        // handle ARP for VIP
        if (pkt instanceof ARP) {
            // retrieve arp to determine target IP address                                                       
            ARP arpRequest = (ARP) eth.getPayload();

            int targetProtocolAddress = IPv4.toIPv4Address(arpRequest
                                                           .getTargetProtocolAddress());

            if (vipIpToId.containsKey(targetProtocolAddress)) {
                String vipId = vipIpToId.get(targetProtocolAddress);
                vipProxyArpReply(sw, pi, cntx, vipId);
                return Command.STOP;
            }
        }
    } else {
        // currently only load balance IPv4 packets - no-op for other traffic 
        if (pkt instanceof IPv4) {
            IPv4 ip_pkt = (IPv4) pkt;
            
            // If match Vip and port, check pool and choose member
            int destIpAddress = ip_pkt.getDestinationAddress();
            
            if (vipIpToId.containsKey(destIpAddress)){
                IPClient client = new IPClient();
                client.ipAddress = ip_pkt.getSourceAddress();
                client.nw_proto = ip_pkt.getProtocol();
                if (ip_pkt.getPayload() instanceof TCP) {
                    TCP tcp_pkt = (TCP) ip_pkt.getPayload();
                    client.srcPort = tcp_pkt.getSourcePort();
                    client.targetPort = tcp_pkt.getDestinationPort();
                }
                if (ip_pkt.getPayload() instanceof UDP) {
                    UDP udp_pkt = (UDP) ip_pkt.getPayload();
                    client.srcPort = udp_pkt.getSourcePort();
                    client.targetPort = udp_pkt.getDestinationPort();
                }
                if (ip_pkt.getPayload() instanceof ICMP) {
                    client.srcPort = 8; 
                    client.targetPort = 0; 
                }
                
                LBVip vip = vips.get(vipIpToId.get(destIpAddress));
                LBPool pool = pools.get(vip.pickPool(client));
                LBMember member = members.get(pool.pickMember(client));

                // for chosen member, check device manager and find and push routes, in both directions                    
                pushBidirectionalVipRoutes(sw, pi, cntx, client, member);
               
                // packet out based on table rule
                pushPacket(pkt, sw, pi.getBufferId(), pi.getInPort(), OFPort.OFPP_TABLE.getValue(),
                            cntx, true);

                return Command.STOP;
            }
        }
    }
    // bypass non-load-balanced traffic for normal processing (forwarding)
    return Command.CONTINUE;
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:69,代码来源:LoadBalancer.java

示例12: processPacketIn

import net.floodlightcontroller.packet.Ethernet; //导入方法依赖的package包/类
private net.floodlightcontroller.core.IListener.Command processPacketIn(IOFSwitch sw, OFPacketIn pi, FloodlightContext cntx) {

        Ethernet eth = IFloodlightProviderService.bcStore.get(cntx, IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
        IPacket pkt = eth.getPayload();

        if (eth.isBroadcast() || eth.isMulticast()) {
            // handle ARP for VIP
            if (pkt instanceof ARP) {
                // retrieve arp to determine target IP address
                ARP arpRequest = (ARP) eth.getPayload();

                IPv4Address targetProtocolAddress = arpRequest.getTargetProtocolAddress();

                if (vipIpToId.containsKey(targetProtocolAddress.getInt())) {
                    String vipId = vipIpToId.get(targetProtocolAddress.getInt());
                    vipProxyArpReply(sw, pi, cntx, vipId);
                    return Command.STOP;
                }
            }
        } else {
            // currently only load balance IPv4 packets - no-op for other traffic
            if (pkt instanceof IPv4) {
                IPv4 ip_pkt = (IPv4) pkt;

                // If match Vip and port, check pool and choose member
                int destIpAddress = ip_pkt.getDestinationAddress().getInt();

                if (vipIpToId.containsKey(destIpAddress)){
                    IPClient client = new IPClient();
                    client.ipAddress = ip_pkt.getSourceAddress();
                    client.nw_proto = ip_pkt.getProtocol();
                    if (ip_pkt.getPayload() instanceof TCP) {
                        TCP tcp_pkt = (TCP) ip_pkt.getPayload();
                        client.srcPort = tcp_pkt.getSourcePort();
                        client.targetPort = tcp_pkt.getDestinationPort();
                    }
                    if (ip_pkt.getPayload() instanceof UDP) {
                        UDP udp_pkt = (UDP) ip_pkt.getPayload();
                        client.srcPort = udp_pkt.getSourcePort();
                        client.targetPort = udp_pkt.getDestinationPort();
                    }
                    if (ip_pkt.getPayload() instanceof ICMP) {
                        client.srcPort = TransportPort.of(8);
                        client.targetPort = TransportPort.of(0);
                    }

                    LBVip vip = vips.get(vipIpToId.get(destIpAddress));
                    if (vip == null)			// fix dereference violations
                    	return Command.CONTINUE;
                    LBPool pool = pools.get(vip.pickPool(client));
                    if (pool == null)			// fix dereference violations
                    	return Command.CONTINUE;
                    LBMember member = members.get(pool.pickMember(client));
                    if(member == null)			//fix dereference violations
                    	return Command.CONTINUE;

                    // for chosen member, check device manager and find and push routes, in both directions
                    pushBidirectionalVipRoutes(sw, pi, cntx, client, member);

                    // packet out based on table rule
                    pushPacket(pkt, sw, pi.getBufferId(), (pi.getVersion().compareTo(OFVersion.OF_12) < 0) ? pi.getInPort() : pi.getMatch().get(MatchField.IN_PORT), OFPort.TABLE,
                                cntx, true);

                    return Command.STOP;
                }
            }
        }
        // bypass non-load-balanced traffic for normal processing (forwarding)
        return Command.CONTINUE;
    }
 
开发者ID:zhenshengcai,项目名称:floodlight-hardware,代码行数:71,代码来源:LoadBalancer.java


注:本文中的net.floodlightcontroller.packet.Ethernet.isMulticast方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。