/** * Gets the short session key. (5-tuple only) * * @param srcIp * the src ip * @param dstIp * the dst ip * @param protocol * the protocol * @param srcPort * the src port * @param dstPort * the dst port * @return the session key */ public static String getShortSessionKey(String srcIp, String dstIp, int protocol, int srcPort, int dstPort) { String keySeperator = "-"; StringBuffer sb = new StringBuffer(40); sb.append(convertIpv4IpToHex(srcIp)).append(keySeperator) .append(convertIpv4IpToHex(dstIp)).append(keySeperator) .append(protocol).append(keySeperator).append(srcPort) .append(keySeperator).append(dstPort); return sb.toString(); }
/** * Gets the session key. * * @param srcIp * the src ip * @param dstIp * the dst ip * @param protocol * the protocol * @param srcPort * the src port * @param dstPort * the dst port * @param ipId * the ip id * @param fragmentOffset * the fragment offset * @return the session key */ public static String getSessionKey(String srcIp, String dstIp, int protocol, int srcPort, int dstPort, int ipId, int fragmentOffset) { String keySeperator = "-"; StringBuffer sb = new StringBuffer(40); sb.append(convertIpv4IpToHex(srcIp)).append(keySeperator) .append(convertIpv4IpToHex(dstIp)).append(keySeperator) .append(protocol).append(keySeperator).append(srcPort) .append(keySeperator).append(dstPort).append(keySeperator).append(ipId) .append(keySeperator).append(fragmentOffset); return sb.toString(); }
sb.append(convertIpv4IpToHex(srcIp)).append(SESSION_KEY_SEPERATOR) .append(convertIpv4IpToHex(dstIp)).append(SESSION_KEY_SEPERATOR) .append(protocol == null ? "0" : protocol) .append(SESSION_KEY_SEPERATOR).append(srcPort == null ? "0" : srcPort)