Commit bb974f7a authored by yorn's avatar yorn

Simplified DOSRank, and added reverse version

The difference between DOSRank and ReverseDOSRank is how IPs are
scored; DOSRank gives high ranks to massive consumers, ReverseDOSRank
gives high ranks to large service providers.
parent 903f0882
package no.uninett.yorn.giraph.computation;
import java.io.IOException;
import java.util.Collection;
import org.apache.giraph.graph.BasicComputation;
import org.apache.giraph.graph.Vertex;
......@@ -12,6 +11,8 @@ import org.apache.hadoop.io.LongWritable;
* This computation will rank nodes on the amount of outgoing flows. A higher
* amount of flows may indicate a (D)DoS attack, but it may also be a very
* active host.
*
* This program will make a list of consumers of services
*
* This code is just a proof of concept on how Giraph can be used to run
* computations with preprocessed NetFlow data.
......@@ -23,27 +24,11 @@ public class DOSRank extends
* not used
*/
static final LongWritable NULL_WRITABLE = new LongWritable(0);
@Override
public void compute(Vertex<LongWritable, IntWritable, LongWritable> vertex,
Iterable<LongWritable> messages) throws IOException {
if (this.getSuperstep() == 0) {
this.sendMessageToAllEdges(vertex, NULL_WRITABLE);
} else {
int i;
if (messages instanceof Collection) {
i = ((Collection<?>) messages).size();
} else {
i = 0;
for (@SuppressWarnings("unused")
Object unused : messages) {
i++;
}
}
vertex.setValue(new IntWritable(i));
vertex.voteToHalt();
}
vertex.setValue(new IntWritable(vertex.getNumEdges()));
vertex.voteToHalt();
}
}
package no.uninett.yorn.giraph.computation;
import java.io.IOException;
import java.util.Collection;
import org.apache.giraph.edge.Edge;
import org.apache.giraph.graph.BasicComputation;
import org.apache.giraph.graph.Vertex;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
/**
* This computation will rank nodes on the amount of incoming flows. A higher
* amount of flows may indicate a (D)DoS attack, but it may also be a very
* active host.
*
* This program will make a list of providers of services
*
* This code is just a proof of concept on how Giraph can be used to run
* computations with preprocessed NetFlow data.
*/
public class ReverseDOSRank extends
BasicComputation<LongWritable, IntWritable, LongWritable, LongWritable> {
/*
* E is LongWritable for compatibility with SpreadRank, but edge value is
* not used
*/
static final LongWritable NULL_WRITABLE = new LongWritable(0);
@Override
public void compute(Vertex<LongWritable, IntWritable, LongWritable> vertex,
Iterable<LongWritable> messages) throws IOException {
if (this.getSuperstep() == 0) {
//sendMessageToAllEdges(vertex, NULL_WRITABLE);
for (Edge<LongWritable, LongWritable> e : vertex.getEdges()) {
sendMessage(e.getTargetVertexId(), NULL_WRITABLE);
}
} else {
int i;
if (messages instanceof Collection) {
i = ((Collection<?>) messages).size();
} else {
i = 0;
for (@SuppressWarnings("unused")
Object unused : messages) {
i++;
}
}
vertex.setValue(new IntWritable(i));
vertex.voteToHalt();
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment