Note that there are some explanatory texts on larger screens.

plurals
  1. POimplement comparable interface for bidirectional flows
    primarykey
    data
    text
    <p>this piece of code is supposed to consider flows in both direction as one flow. for example:</p> <pre><code>srcAddr,dstAddr,srcPort,dstPort 192.168.1.65, 217.174.16.1, 123456,80 </code></pre> <p>should be the same as</p> <pre><code>217.174.16.1, 192.168.1.65,80,123456 </code></pre> <p>Another Example:</p> <pre><code>192.168.1.65, 217.174.16.1, 12345, 80, TCP 217.174.16.1, 192.168.1.65, 80, 12345, TCP 192.168.1.65, 217.174.16.1, 12345, 80, TCP 217.174.16.1, 192.168.1.65, 80, 12345, TCP </code></pre> <p>I want to keep i t like this:</p> <pre><code>Flow 1: key---&gt; value (keeps statistics about each packet, like length and timeArrival) [192.168.1.65, 217.174.16.1, 12345, 80] ----&gt; [(outgoing, 1,2)(incoming,3,4)()()...] </code></pre> <p><code>192.168.1.65, 69.100.70.80, 98521, 80 69.100.70.80, 192.168.1.65, 80, 98521 192.168.1.65, 69.100.70.80, 98521, 80 69.100.70.80, 192.168.1.65, 80, 98521 192.168.1.65, 69.100.70.80, 98521, 80 69.100.70.80, 192.168.1.65, 80, 98521</code></p> <p><code>Flow 2: [192.168.1.65, 69.100.70.80, 98521, 80] --&gt; [(outgoing, 1,2)(incoming,3,4)()()...]</code></p> <p>how should i change it in order to get the result? [im using a hashMap and this class of Flows are my keys]</p> <pre><code> package myclassifier; public class Flows implements Comparable&lt;Flows&gt; { String srcAddr = "", dstAddr = "", protocol = ""; int srcPort = 0, dstPort = 0; public Flows(String sIP, String dIP, int sPort, int dPort){ this.srcAddr = sIP; this.dstAddr = dIP; this.srcPort = sPort; this.dstPort = dPort; //this.protocol = protocol; } public Flows(){ } public int compareTo(Flows other) { int res = 1; if(this.equals(other)){ return res=0; }else return 1; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((dstAddr == null) ? 0 : dstAddr.hashCode()); result = prime * result + dstPort; result = prime * result + ((srcAddr == null) ? 0 : srcAddr.hashCode()); result = prime * result + srcPort; return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Flows other = (Flows) obj; if (dstAddr == null) { if (other.dstAddr != null) return false; } else if (!dstAddr.equals(other.dstAddr)) return false; if (dstPort != other.dstPort) return false; if (srcAddr == null) { if (other.srcAddr != null) return false; } else if (!srcAddr.equals(other.srcAddr)) return false; if (srcPort != other.srcPort) return false; return true; } @Override public String toString() { return String.format("[%s, %s, %s, %s, %s]", srcAddr, dstAddr, srcPort, dstPort, protocol); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload