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


Java IPv4.getProtocol方法代码示例

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


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

示例1: isICMP

import net.floodlightcontroller.packet.IPv4; //导入方法依赖的package包/类
@Override
public boolean isICMP(FPContext cntx) {
	FloodlightContext flCntx = cntx.getFlowContext();
	
	Ethernet eth = IFloodlightProviderService.bcStore.get(flCntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
	if(eth.getEtherType() == EthType.IPv4)
	{	
		IPv4 ipv4 = (IPv4) eth.getPayload();
		return (ipv4.getProtocol() == IpProtocol.ICMP);
	}
	else
	{
		return false;
	}
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:16,代码来源:FP_LibFloodlight.java

示例2: isTCP

import net.floodlightcontroller.packet.IPv4; //导入方法依赖的package包/类
@Override
public boolean isTCP(FPContext cntx) {
	FloodlightContext flCntx = cntx.getFlowContext();
	
	Ethernet eth = IFloodlightProviderService.bcStore.get(flCntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
	if(eth.getEtherType() == EthType.IPv4)
	{	
		IPv4 ipv4 = (IPv4) eth.getPayload();
		return (ipv4.getProtocol() == IpProtocol.TCP);
	}
	else
	{
		return false;
	}
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:16,代码来源:FP_LibFloodlight.java

示例3: isUDP

import net.floodlightcontroller.packet.IPv4; //导入方法依赖的package包/类
@Override
public boolean isUDP(FPContext cntx) {
	FloodlightContext flCntx = cntx.getFlowContext();
	
	Ethernet eth = IFloodlightProviderService.bcStore.get(flCntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
	if(eth.getEtherType() == EthType.IPv4)
	{	
		IPv4 ipv4 = (IPv4) eth.getPayload();
		return (ipv4.getProtocol() == IpProtocol.UDP);
	}
	else
	{
		return false;
	}
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:16,代码来源:FP_LibFloodlight.java

示例4: getCountersKey

import net.floodlightcontroller.packet.IPv4; //导入方法依赖的package包/类
protected CounterKeyTuple getCountersKey(IOFSwitch sw, OFMessage m, Ethernet eth) {
    byte mtype = m.getType().getTypeValue();
    short l3type = 0;
    byte l4type = 0;

    if (eth != null) {
        l3type = eth.getEtherType();
        if (eth.getPayload() instanceof IPv4) {
            IPv4 ipV4 = (IPv4)eth.getPayload();
            l4type = ipV4.getProtocol();
        }
    }
    return new CounterKeyTuple(mtype, sw.getId(), l3type, l4type);
}
 
开发者ID:JianqingJiang,项目名称:QoS-floodlight,代码行数:15,代码来源:CounterStore.java

示例5: processTCP

import net.floodlightcontroller.packet.IPv4; //导入方法依赖的package包/类
public FP_Event processTCP(FPContext cntx){ 
	FloodlightContext flCntx = cntx.getFlowContext();
	
	Ethernet eth = IFloodlightProviderService.bcStore.get(flCntx,IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
	if(eth.getEtherType() == EthType.IPv4)
	{	
		IPv4 ipv4 = (IPv4) eth.getPayload();
		
		if (ipv4.getProtocol() == IpProtocol.TCP){
			TCP tcp = (TCP) ipv4.getPayload();
			short flag = tcp.getFlags();
			
			//We assume here we have visibility of all TCP handshake messages
			TCPSession session;
			
			if (flag == 2){
				session = new TCPSession(ipv4.getSourceAddress().getInt(),
					tcp.getSourcePort().getPort(), ipv4.getDestinationAddress().getInt(),
					tcp.getDestinationPort().getPort());
			}
			else{
				session = new TCPSession(ipv4.getDestinationAddress().getInt(),
						tcp.getDestinationPort().getPort(), ipv4.getSourceAddress().getInt(),
						tcp.getSourcePort().getPort());
			}
				
			//store current TCP session into runtime context
			curTCPSession.put(cntx, session);
			
			TCPSTATE state = tcpState.get(session);
			
			if (flag == 2){//SYN
				if (state == null){ 
					state = TCPSTATE.SYN;
					session = new TCPSession(ipv4.getSourceAddress().getInt(),
							tcp.getSourcePort().getPort(), ipv4.getDestinationAddress().getInt(),
							tcp.getDestinationPort().getPort());
					tcpState.put(session, state);
					return FP_Event.TCP;
				 }
			}
			else if (flag == 16){//ACK
				if (state == TCPSTATE.SYNACK){
					 state = TCPSTATE.ESTABLISHED;
					 tcpState.put(session, state);
					 return FP_Event.TCP_CONNECTION_SUCCESS;
				 }
			}
			else if (flag == 18){ //SYNACK
				 if (state == TCPSTATE.SYN){
					 state = TCPSTATE.SYNACK;
					 tcpState.put(session, state);
				 }
			 }
			else if (flag == 20){//RSTACK
				state = TCPSTATE.OTHERS;
			 	tcpState.put(session, state);
			 	return FP_Event.TCP_CONNECTION_FAIL;
			}
			 // we consider other flags are TCP connection disruptions
			 // we will raise TCP connection disruption events
			 //TODO: More options to distinguish different TCP flags
			 else { 
				 if (state != TCPSTATE.ESTABLISHED){
					state = TCPSTATE.OTHERS;
				 	tcpState.put(session, state);
				 	return FP_Event.TCP_CONNECTION_FAIL;
				 }
				 else{//state is TCPSTATE.ESTABLISHED
					 if (flag == 1){ // TCP FIN
						 state = TCPSTATE.OTHERS;
						 tcpState.put(session, state);
						 return FP_Event.TCP_CONNECTION_FAIL;
					 }
				 }
			 }
			 return FP_Event.TCP;
		}
	}
	return FP_Event.PACKET;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:82,代码来源:FP_LibFloodlight.java

示例6: processPacketIn

import net.floodlightcontroller.packet.IPv4; //导入方法依赖的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

示例7: processPacketIn

import net.floodlightcontroller.packet.IPv4; //导入方法依赖的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

示例8: processPacketIn

import net.floodlightcontroller.packet.IPv4; //导入方法依赖的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

示例9: processPacketIn

import net.floodlightcontroller.packet.IPv4; //导入方法依赖的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.IPv4.getProtocol方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。