summaryrefslogtreecommitdiffstats
path: root/Monitoring/MonitoringTool/PacketTracking/ipfix4java/ipfix-collector/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'Monitoring/MonitoringTool/PacketTracking/ipfix4java/ipfix-collector/src/test')
-rw-r--r--Monitoring/MonitoringTool/PacketTracking/ipfix4java/ipfix-collector/src/test/java/de/fhg/fokus/net/ipfix/IpfixCollectorTest.java71
-rw-r--r--Monitoring/MonitoringTool/PacketTracking/ipfix4java/ipfix-collector/src/test/java/de/fhg/fokus/net/ipfix/record/IpfixRecordFlow4.java138
-rw-r--r--Monitoring/MonitoringTool/PacketTracking/ipfix4java/ipfix-collector/src/test/java/de/fhg/fokus/net/ipfix/record/IpfixRecordSourceIpv4PacketDeltaCount.java94
-rw-r--r--Monitoring/MonitoringTool/PacketTracking/ipfix4java/ipfix-collector/src/test/resources/log4j.properties26
4 files changed, 329 insertions, 0 deletions
diff --git a/Monitoring/MonitoringTool/PacketTracking/ipfix4java/ipfix-collector/src/test/java/de/fhg/fokus/net/ipfix/IpfixCollectorTest.java b/Monitoring/MonitoringTool/PacketTracking/ipfix4java/ipfix-collector/src/test/java/de/fhg/fokus/net/ipfix/IpfixCollectorTest.java
new file mode 100644
index 0000000..ddeb714
--- /dev/null
+++ b/Monitoring/MonitoringTool/PacketTracking/ipfix4java/ipfix-collector/src/test/java/de/fhg/fokus/net/ipfix/IpfixCollectorTest.java
@@ -0,0 +1,71 @@
+/**
+*
+* Copyright (c) 2012, NOVI Consortium, European FP7 NOVI Project
+* Copyright according to BSD License
+* For full text of the license see: ./novi/Software/Monitoring/MonitoringTool/PacketTracking/license.txt
+*
+* @author <a href="mailto:ramon.masek@fokus.fraunhofer.de">Ramon Masek</a>, Fraunhofer FOKUS
+* @author <a href="mailto:c.henke@tu-berlin.de">Christian Henke</a>, Technical University Berlin
+* @author <a href="mailto:carsten.schmoll@fokus.fraunhofer.de">Carsten Schmoll</a>, Fraunhofer FOKUS
+* @author <a href="mailto:Julian.Vetter@campus.tu-berlin.de">Julian Vetter</a>, Fraunhofer FOKUS
+* @author <a href="mailto:">Jens Krenzin</a>, Fraunhofer FOKUS
+* @author <a href="mailto:">Michael Gehring</a>, Fraunhofer FOKUS
+* @author <a href="mailto:">Tacio Grespan Santos</a>, Fraunhofer FOKUS
+* @author <a href="mailto:">Fabian Wolff</a>, Fraunhofer FOKUS
+*
+*/
+
+package de.fhg.fokus.net.ipfix;
+
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import de.fhg.fokus.net.ipfix.api.IpfixCollectorListener;
+import de.fhg.fokus.net.ipfix.api.IpfixConnectionHandler;
+import de.fhg.fokus.net.ipfix.api.IpfixMessage;
+import de.fhg.fokus.net.ipfix.api.IpfixSet;
+import de.fhg.fokus.net.ipfix.record.IpfixRecordSourceIpv4PacketDeltaCount;
+
+/**
+ *
+ * @author FhG-FOKUS NETwork Research
+ */
+public class IpfixCollectorTest {
+ private final static Logger logger = LoggerFactory.getLogger(IpfixCollectorTest.class);
+ @Test
+ public void tcpCollector() throws Exception {
+ int sleep = 50;
+ logger.debug("--- IPFIX Collector test ---");
+ logger.debug("Shutting down in {}s",sleep);
+
+ IpfixCollector ic = new IpfixCollector();
+ ic.registerDataRecordReader(IpfixRecordSourceIpv4PacketDeltaCount.getReader());
+ ic.addEventListener(new IpfixCollectorListener() {
+ @Override
+ public void onMessage( IpfixConnectionHandler handler, IpfixMessage msg) {
+ logger.debug(msg+"");
+ for(IpfixSet set: msg){
+ for(Object rec: set){
+ logger.debug(rec+"");
+ }
+ }
+ }
+ @Override
+ public void onConnect(IpfixConnectionHandler hander) {
+ // TODO Auto-generated method stub
+ }
+ @Override
+ public void onDisconnect(IpfixConnectionHandler hander) {
+ // TODO Auto-generated method stub
+ }
+ });
+
+ //ic.bind(4739);
+ //Thread.sleep(sleep*1000);
+ ic.shutdow();
+
+
+ }
+
+}
diff --git a/Monitoring/MonitoringTool/PacketTracking/ipfix4java/ipfix-collector/src/test/java/de/fhg/fokus/net/ipfix/record/IpfixRecordFlow4.java b/Monitoring/MonitoringTool/PacketTracking/ipfix4java/ipfix-collector/src/test/java/de/fhg/fokus/net/ipfix/record/IpfixRecordFlow4.java
new file mode 100644
index 0000000..34636f8
--- /dev/null
+++ b/Monitoring/MonitoringTool/PacketTracking/ipfix4java/ipfix-collector/src/test/java/de/fhg/fokus/net/ipfix/record/IpfixRecordFlow4.java
@@ -0,0 +1,138 @@
+/**
+*
+* Copyright (c) 2012, NOVI Consortium, European FP7 NOVI Project
+* Copyright according to BSD License
+* For full text of the license see: ./novi/Software/Monitoring/MonitoringTool/PacketTracking/license.txt
+*
+* @author <a href="mailto:ramon.masek@fokus.fraunhofer.de">Ramon Masek</a>, Fraunhofer FOKUS
+* @author <a href="mailto:c.henke@tu-berlin.de">Christian Henke</a>, Technical University Berlin
+* @author <a href="mailto:carsten.schmoll@fokus.fraunhofer.de">Carsten Schmoll</a>, Fraunhofer FOKUS
+* @author <a href="mailto:Julian.Vetter@campus.tu-berlin.de">Julian Vetter</a>, Fraunhofer FOKUS
+* @author <a href="mailto:">Jens Krenzin</a>, Fraunhofer FOKUS
+* @author <a href="mailto:">Michael Gehring</a>, Fraunhofer FOKUS
+* @author <a href="mailto:">Tacio Grespan Santos</a>, Fraunhofer FOKUS
+* @author <a href="mailto:">Fabian Wolff</a>, Fraunhofer FOKUS
+*
+*/
+
+package de.fhg.fokus.net.ipfix.record;
+
+import java.math.BigInteger;
+import java.net.Inet4Address;
+import java.nio.ByteBuffer;
+
+import de.fhg.fokus.net.ipfix.api.IpfixDataRecordReader;
+import de.fhg.fokus.net.ipfix.api.IpfixMessage;
+import de.fhg.fokus.net.ipfix.api.IpfixTemplateForDataReader;
+import de.fhg.fokus.net.ipfix.model.ie.IpfixIeDestinationIPv4Address;
+import de.fhg.fokus.net.ipfix.model.ie.IpfixIeDestinationTransportPort;
+import de.fhg.fokus.net.ipfix.model.ie.IpfixIeFlowEndMilliseconds;
+import de.fhg.fokus.net.ipfix.model.ie.IpfixIeFlowStartMilliseconds;
+import de.fhg.fokus.net.ipfix.model.ie.IpfixIeIpClassOfService;
+import de.fhg.fokus.net.ipfix.model.ie.IpfixIeOctetDeltaCount;
+import de.fhg.fokus.net.ipfix.model.ie.IpfixIePacketDeltaCount;
+import de.fhg.fokus.net.ipfix.model.ie.IpfixIeProtocolIdentifier;
+import de.fhg.fokus.net.ipfix.model.ie.IpfixIeSourceIPv4Address;
+import de.fhg.fokus.net.ipfix.model.ie.IpfixIeSourceTransportPort;
+
+/**
+ * Record reader for LibIPFIX probe IPv4 flows
+ *
+ * @author FhG-FOKUS NETwork Research
+ *
+ */
+public final class IpfixRecordFlow4 {
+
+ private final BigInteger flowStartMilliseconds;
+ private final BigInteger flowEndMilliseconds;
+ private final Inet4Address sourceIPv4Address;
+ private final Inet4Address destinationIPv4Address;
+ private final int sourceTransportPort;
+ private final int destinationTransportPort;
+ private final short protocolIdentifier;
+ private final short ipClassOfService;
+ private final long packetDeltaCount;
+ private final long octetDeltaCount;
+
+ public IpfixRecordFlow4(BigInteger flowStartMilliseconds,
+ BigInteger flowEndMilliseconds, Inet4Address sourceIPv4Address,
+ Inet4Address destinationIPv4Address, int sourceTransportPort,
+ int destinationTransportPort, short protocolIdentifier,
+ short ipClassOfService, long packetDeltaCount, long octetDeltaCount) {
+
+ this.flowStartMilliseconds = flowStartMilliseconds;
+ this.flowEndMilliseconds = flowEndMilliseconds;
+ this.sourceIPv4Address = sourceIPv4Address;
+ this.destinationIPv4Address = destinationIPv4Address;
+ this.sourceTransportPort = sourceTransportPort;
+ this.destinationTransportPort = destinationTransportPort;
+ this.protocolIdentifier = protocolIdentifier;
+ this.ipClassOfService = ipClassOfService;
+ this.packetDeltaCount = packetDeltaCount;
+ this.octetDeltaCount = octetDeltaCount;
+ }
+
+ @Override
+ public String toString() {
+
+ return String
+ .format(
+ " {flowStartMilliseconds:%s, flowEndMilliseconds:%s, "
+ + "sourceIPv4Address:%s, destinationIPv4Address:%s, "
+ + "sourceTransportPort:%d, destinationTransportPort:%d, "
+ + "protocolIdentifier:%d, ipClassOfService:%d, "
+ + "packetDeltaCount:%d, octetDeltaCount:%d}",
+ flowStartMilliseconds, flowEndMilliseconds,
+ sourceIPv4Address, destinationIPv4Address,
+ sourceTransportPort, destinationTransportPort,
+ protocolIdentifier, ipClassOfService,
+ packetDeltaCount, octetDeltaCount);
+ }
+
+ private static final IpfixDataRecordReader reader = new IpfixDataRecordReader() {
+ private final IpfixIeFlowStartMilliseconds f0 = new IpfixIeFlowStartMilliseconds(
+ 8);
+ private final IpfixIeFlowEndMilliseconds f1 = new IpfixIeFlowEndMilliseconds(
+ 8);
+ private final IpfixIeSourceIPv4Address f2 = new IpfixIeSourceIPv4Address(
+ 4);
+ private final IpfixIeDestinationIPv4Address f3 = new IpfixIeDestinationIPv4Address(
+ 4);
+ private final IpfixIeSourceTransportPort f4 = new IpfixIeSourceTransportPort(
+ 2);
+ private final IpfixIeDestinationTransportPort f5 = new IpfixIeDestinationTransportPort(
+ 2);
+ private final IpfixIeProtocolIdentifier f6 = new IpfixIeProtocolIdentifier();
+ private final IpfixIeIpClassOfService f7 = new IpfixIeIpClassOfService();
+ private final IpfixIePacketDeltaCount f8 = new IpfixIePacketDeltaCount(
+ 4);
+ private final IpfixIeOctetDeltaCount f9 = new IpfixIeOctetDeltaCount(4);
+
+ private final IpfixTemplateForDataReader template = new IpfixTemplateForDataReader(
+ f0, f1, f2, f3, f4, f5, f6, f7, f8, f9);
+
+ @Override
+ public Object getRecord(IpfixMessage msg, ByteBuffer setBuffer) {
+ if (!setBuffer.hasRemaining()) {
+ return null;
+ }
+ return new IpfixRecordFlow4(f0.getBigInteger(setBuffer), f1
+ .getBigInteger(setBuffer), f2.getAddress(setBuffer), f3
+ .getAddress(setBuffer), f4.getInt(setBuffer), f5
+ .getInt(setBuffer), f6.getShort(setBuffer), f7
+ .getShort(setBuffer), f8.getLong(setBuffer), f9
+ .getLong(setBuffer));
+ }
+ public String toString() {
+ return "DRR(record flow 4)";
+ }
+ @Override
+ public IpfixTemplateForDataReader getTemplate() {
+ return template;
+ }
+ };
+ public final static IpfixDataRecordReader getReader(){
+ return reader;
+ }
+
+}
diff --git a/Monitoring/MonitoringTool/PacketTracking/ipfix4java/ipfix-collector/src/test/java/de/fhg/fokus/net/ipfix/record/IpfixRecordSourceIpv4PacketDeltaCount.java b/Monitoring/MonitoringTool/PacketTracking/ipfix4java/ipfix-collector/src/test/java/de/fhg/fokus/net/ipfix/record/IpfixRecordSourceIpv4PacketDeltaCount.java
new file mode 100644
index 0000000..7639ee2
--- /dev/null
+++ b/Monitoring/MonitoringTool/PacketTracking/ipfix4java/ipfix-collector/src/test/java/de/fhg/fokus/net/ipfix/record/IpfixRecordSourceIpv4PacketDeltaCount.java
@@ -0,0 +1,94 @@
+/**
+*
+* Copyright (c) 2012, NOVI Consortium, European FP7 NOVI Project
+* Copyright according to BSD License
+* For full text of the license see: ./novi/Software/Monitoring/MonitoringTool/PacketTracking/license.txt
+*
+* @author <a href="mailto:ramon.masek@fokus.fraunhofer.de">Ramon Masek</a>, Fraunhofer FOKUS
+* @author <a href="mailto:c.henke@tu-berlin.de">Christian Henke</a>, Technical University Berlin
+* @author <a href="mailto:carsten.schmoll@fokus.fraunhofer.de">Carsten Schmoll</a>, Fraunhofer FOKUS
+* @author <a href="mailto:Julian.Vetter@campus.tu-berlin.de">Julian Vetter</a>, Fraunhofer FOKUS
+* @author <a href="mailto:">Jens Krenzin</a>, Fraunhofer FOKUS
+* @author <a href="mailto:">Michael Gehring</a>, Fraunhofer FOKUS
+* @author <a href="mailto:">Tacio Grespan Santos</a>, Fraunhofer FOKUS
+* @author <a href="mailto:">Fabian Wolff</a>, Fraunhofer FOKUS
+*
+*/
+
+package de.fhg.fokus.net.ipfix.record;
+
+import java.math.BigInteger;
+import java.net.Inet4Address;
+import java.nio.ByteBuffer;
+
+import de.fhg.fokus.net.ipfix.api.IpfixDataRecordReader;
+import de.fhg.fokus.net.ipfix.api.IpfixMessage;
+import de.fhg.fokus.net.ipfix.api.IpfixTemplateForDataReader;
+import de.fhg.fokus.net.ipfix.model.ie.IpfixIePacketDeltaCount;
+import de.fhg.fokus.net.ipfix.model.ie.IpfixIeSourceIPv4Address;
+
+/**
+ *
+ * @author FhG-FOKUS NETwork Research
+ *
+ */
+public class IpfixRecordSourceIpv4PacketDeltaCount {
+ private final Inet4Address sourceIpv4Address;
+ private final BigInteger packetDeltaCount;
+
+ public IpfixRecordSourceIpv4PacketDeltaCount(
+ Inet4Address sourceIpv4Address, BigInteger packetDeltaCount) {
+ super();
+ this.sourceIpv4Address = sourceIpv4Address;
+ this.packetDeltaCount = packetDeltaCount;
+ }
+
+ public Inet4Address getSourceIpv4Address() {
+ return sourceIpv4Address;
+ }
+
+ public BigInteger getPacketDeltaCount() {
+ return packetDeltaCount;
+ }
+
+ @Override
+ public String toString() {
+ return String.format("{sourceIpv4Address:%s, packetDeltaCount:%d}",
+ sourceIpv4Address, packetDeltaCount);
+ }
+
+ /**
+ * IPFIX data record reader for
+ * {@link IpfixRecordSourceIpv4PacketDeltaCount }
+ */
+ private static final IpfixDataRecordReader reader = new IpfixDataRecordReader() {
+ private final IpfixIeSourceIPv4Address sourceIpv4Address = new IpfixIeSourceIPv4Address();
+ private final IpfixIePacketDeltaCount packetDeltaCount = new IpfixIePacketDeltaCount(4);
+ private final IpfixTemplateForDataReader template = new IpfixTemplateForDataReader(
+ sourceIpv4Address, packetDeltaCount);
+
+ @Override
+ public IpfixRecordSourceIpv4PacketDeltaCount getRecord( IpfixMessage msg,
+ ByteBuffer setBuffer) {
+
+ if (!setBuffer.hasRemaining()) {
+ return null;
+ }
+ return new IpfixRecordSourceIpv4PacketDeltaCount(
+ sourceIpv4Address.getAddress(setBuffer),
+ packetDeltaCount.getBigInteger(setBuffer));
+
+ }
+ public String toString() {
+ return "DRR(sourceIPv4_packetDeltaCount)";
+ }
+ @Override
+ public IpfixTemplateForDataReader getTemplate() {
+ return template;
+ }
+ };
+ public final static IpfixDataRecordReader getReader(){
+ return reader;
+ }
+
+}
diff --git a/Monitoring/MonitoringTool/PacketTracking/ipfix4java/ipfix-collector/src/test/resources/log4j.properties b/Monitoring/MonitoringTool/PacketTracking/ipfix4java/ipfix-collector/src/test/resources/log4j.properties
new file mode 100644
index 0000000..ca0cf05
--- /dev/null
+++ b/Monitoring/MonitoringTool/PacketTracking/ipfix4java/ipfix-collector/src/test/resources/log4j.properties
@@ -0,0 +1,26 @@
+# log4j settings
+#
+# The root logger is assigned priority level DEBUG and an appender
+# named rootAppender
+log4j.rootLogger=debug, rootAppender
+
+# Appenders: {FileAppender, ConsoleAppender, .. }
+log4j.appender.rootAppender=org.apache.log4j.ConsoleAppender
+
+# Layouts: {SimpleLayout, PatternLayout, ..}
+log4j.appender.rootAppender.layout=org.apache.log4j.PatternLayout
+
+# log4j.appender.rootAppender.layout.ConversionPattern=%d{MM-dd@HH:mm:ss} %-5p (%13F:%L) %3x - %m%n
+# Ex: 03-04@16:48:36 DEBUG ( App.java:27) - Test1
+
+#log4j.appender.rootAppender.layout.ConversionPattern=%d{HH:mm:ss,SSS} %C %p [%t] %m (%F:%L) %n
+
+# Ex: 16:49:30,231 DEBUG [main] Test1 (App.java:27)
+log4j.appender.rootAppender.layout.ConversionPattern=%d{HH:mm:ss,SSS} %5p [%t] %m (%F:%L) %n
+
+
+#log4j.logger.org.mortbay = INFO
+#log4j.logger.org.apache.cxf = OFF
+#log4j.logger.org.springframework = OFF
+
+