public static byte getProtocolNumberByte(String name) { IPProtocols p = fromString(name); if (p != null) { return p.byteValue(); } //This method should be called after validation only throw new IllegalArgumentException("Illegal IP protocol value: " + name); }
public static String getProtocolName(int number) { return getProtocolNameInternal(number); }
public static short getProtocolNumberShort(String name) { IPProtocols p = fromString(name); if (p != null) { return p.shortValue(); } //This method should be called after validation only throw new IllegalArgumentException("Illegal IP protocol value: " + name); }
public static int getProtocolNumberInt(String name) { IPProtocols p = fromString(name); if (p != null) { return p.intValue(); } //This method should be called after validation only throw new IllegalArgumentException("Illegal IP protocol value: " + name); }
/** * Extract the details of the source machine that sent this packet 'inPkt' * @param inPkt Packet that is received by the controller * @return Details of the source machine in Client object. */ public Client getClientFromPacket(IPv4 inPkt){ lbuLogger.trace("Find client information from packet : {}",inPkt.toString()); String ip = NetUtils.getInetAddress(inPkt.getSourceAddress()).getHostAddress(); String protocol = IPProtocols.getProtocolName(inPkt.getProtocol()); lbuLogger.trace("client ip {} and protocl {}",ip,protocol); Packet tpFrame= inPkt.getPayload(); lbuLogger.trace("Get protocol layer {}",tpFrame.toString()); short port = 0; if(protocol.equals(IPProtocols.TCP.toString())){ TCP tcpFrame = (TCP)tpFrame; port = tcpFrame.getSourcePort(); }else{ UDP udpFrame = (UDP)tpFrame; port = udpFrame.getSourcePort(); } lbuLogger.trace("Found port {}",port); Client source = new Client(ip, protocol,port); lbuLogger.trace("Client information : {}",source.toString()); return source; }
public void setStatsFromFlow(FlowOnNode flow) { MatchField protocolField = flow.getFlow().getMatch().getField(MatchType.NW_PROTO); Byte protocolNumber; if (protocolField == null) protocolNumber = IPProtocols.ANY.byteValue(); else protocolNumber = (Byte) protocolField.getValue(); // Prevent stats from getting overwritten by zero-byte flows. Long currentByteCount = this.byteCounts.get(protocolNumber); Long thisByteCount = flow.getByteCount(); Long thisPacketCount = flow.getPacketCount(); if (thisByteCount > 0 && (currentByteCount == null || currentByteCount <= thisByteCount)) { this.byteCounts.put(protocolNumber, thisByteCount); this.packetCounts.put(protocolNumber, thisPacketCount); this.durations.put(protocolNumber, flow.getDurationSeconds() + .000000001 * flow.getDurationNanoseconds()); } } }
if (dstString.equals("null/null")) dstString = null; long byteCount = analyticsManager.getByteCount(srcString, dstString, IPProtocols.getProtocolNumberByte(protocol)); long packetCount = analyticsManager.getByteCount(srcString, dstString, IPProtocols.getProtocolNumberByte(protocol)); double duration = analyticsManager.getDuration(srcString, dstString, IPProtocols.getProtocolNumberByte(protocol)); double bitRate = analyticsManager.getBitRate(srcString, dstString, IPProtocols.getProtocolNumberByte(protocol));
match.setField(MatchType.NW_DST, ip, mask); if (IPProtocols.fromString(this.protocol) != IPProtocols.ANY) { match.setField(MatchType.NW_PROTO, IPProtocols.getProtocolNumberByte(this.protocol));
public boolean isProtocolValid(String protocol) { IPProtocols proto = IPProtocols.fromString(protocol); return (proto != null); }
IPProtocols.getProtocolName(((Byte) flow.getMatch() .getField(MatchType.NW_PROTO).getValue()))); } else {
String protocol = IPProtocols.getProtocolName(inPkt.getProtocol()); if(protocol.equals(IPProtocols.TCP.toString())){ TCP tcpFrame = (TCP)tpFrame; port = tcpFrame.getDestinationPort();
byte vlanPr = 3; Byte tos = 4; byte proto = IPProtocols.TCP.byteValue(); short src = (short) 55000; short dst = 80;
long byteCount = analyticsManager.getByteCount(al, IPProtocols.getProtocolNumberByte(protocol)); long packetCount = analyticsManager.getPacketCount(al, IPProtocols.getProtocolNumberByte(protocol)); double duration = analyticsManager.getDuration(al, IPProtocols.getProtocolNumberByte(protocol)); double bitRate = analyticsManager.getBitRate(al, IPProtocols.getProtocolNumberByte(protocol));
.toString()); IPv4 ipv4Pkt = (IPv4) ipPkt; if (IPProtocols.getProtocolName(ipv4Pkt.getProtocol()).equals(IPProtocols.TCP.toString()) || IPProtocols.getProtocolName(ipv4Pkt.getProtocol()).equals(IPProtocols.UDP.toString())) { lbsLogger.debug("Packet protocol : {}", IPProtocols.getProtocolName(ipv4Pkt.getProtocol())); Client client = new LBUtil().getClientFromPacket(ipv4Pkt); VIP vip = new LBUtil().getVIPFromPacket(ipv4Pkt);
byte vlanPr = 3; Byte tos = 4; byte proto = IPProtocols.TCP.byteValue(); short src = (short) 55000; short dst = 80;
long byteCount = analyticsManager.getByteCount(srcHost, dstHost, IPProtocols.getProtocolNumberByte(protocol)); long packetCount = analyticsManager.getPacketCount(srcHost, dstHost, IPProtocols.getProtocolNumberByte(protocol)); double duration = analyticsManager.getDuration(srcHost, dstHost, IPProtocols.getProtocolNumberByte(protocol)); double bitRate = analyticsManager.getBitRate(srcHost, dstHost, IPProtocols.getProtocolNumberByte(protocol));
public static String getProtocolName(byte number) { return getProtocolNameInternal(number & 0xff); }