summaryrefslogtreecommitdiffstats
path: root/Monitoring/MonitoringTool/PacketTracking/netview/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'Monitoring/MonitoringTool/PacketTracking/netview/src/main/java')
-rw-r--r--Monitoring/MonitoringTool/PacketTracking/netview/src/main/java/META-INF/services/org.jdesktop.application.Application1
-rw-r--r--Monitoring/MonitoringTool/PacketTracking/netview/src/main/java/de/fhg/fokus/net/netview/control/DataSourcesController.java156
-rw-r--r--Monitoring/MonitoringTool/PacketTracking/netview/src/main/java/de/fhg/fokus/net/netview/control/MainController.java143
-rw-r--r--Monitoring/MonitoringTool/PacketTracking/netview/src/main/java/de/fhg/fokus/net/netview/control/NoviDBInterface.java352
-rw-r--r--Monitoring/MonitoringTool/PacketTracking/netview/src/main/java/de/fhg/fokus/net/netview/control/PacketTrackCollector.java233
-rw-r--r--Monitoring/MonitoringTool/PacketTracking/netview/src/main/java/de/fhg/fokus/net/netview/model/Model.java81
-rw-r--r--Monitoring/MonitoringTool/PacketTracking/netview/src/main/java/de/fhg/fokus/net/netview/model/db/InterfaceStats.java266
-rw-r--r--Monitoring/MonitoringTool/PacketTracking/netview/src/main/java/de/fhg/fokus/net/netview/model/db/NetViewDB.java124
-rw-r--r--Monitoring/MonitoringTool/PacketTracking/netview/src/main/java/de/fhg/fokus/net/netview/model/db/ProbeStats.java245
-rw-r--r--Monitoring/MonitoringTool/PacketTracking/netview/src/main/java/de/fhg/fokus/net/netview/model/db/RawTrackData.java269
-rw-r--r--Monitoring/MonitoringTool/PacketTracking/netview/src/main/java/de/fhg/fokus/net/netview/model/db/TrackData.java142
-rw-r--r--Monitoring/MonitoringTool/PacketTracking/netview/src/main/java/de/fhg/fokus/net/netview/model/db/TrackRepository.java257
12 files changed, 2269 insertions, 0 deletions
diff --git a/Monitoring/MonitoringTool/PacketTracking/netview/src/main/java/META-INF/services/org.jdesktop.application.Application b/Monitoring/MonitoringTool/PacketTracking/netview/src/main/java/META-INF/services/org.jdesktop.application.Application
new file mode 100644
index 0000000..53e6dcd
--- /dev/null
+++ b/Monitoring/MonitoringTool/PacketTracking/netview/src/main/java/META-INF/services/org.jdesktop.application.Application
@@ -0,0 +1 @@
+de.fhg.fokus.net.netview.controller.MainController \ No newline at end of file
diff --git a/Monitoring/MonitoringTool/PacketTracking/netview/src/main/java/de/fhg/fokus/net/netview/control/DataSourcesController.java b/Monitoring/MonitoringTool/PacketTracking/netview/src/main/java/de/fhg/fokus/net/netview/control/DataSourcesController.java
new file mode 100644
index 0000000..8f82e3c
--- /dev/null
+++ b/Monitoring/MonitoringTool/PacketTracking/netview/src/main/java/de/fhg/fokus/net/netview/control/DataSourcesController.java
@@ -0,0 +1,156 @@
+/**
+*
+* 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
+*
+*/
+
+/* Netview - a software component to visualize packet tracks, hop-by-hop delays,
+ * sampling stats and resource consumption. Netview requires the deployment of
+ * distributed probes (impd4e) and a central packet matcher to correlate the
+ * obervations.
+ *
+ * The probe can be obtained at http://impd4e.sourceforge.net/downloads.html
+ *
+ * Copyright (c) 2011
+ *
+ * Fraunhofer FOKUS
+ * www.fokus.fraunhofer.de
+ *
+ * in cooperation with
+ *
+ * Technical University Berlin
+ * www.av.tu-berlin.de
+ *
+ * Ramon Masek <ramon.masek@fokus.fraunhofer.de>
+ * Christian Henke <c.henke@tu-berlin.de>
+ * Carsten Schmoll <carsten.schmoll@fokus.fraunhofer.de>
+ * Julian Vetter <julian.vetter@fokus.fraunhofer.de>
+ * Jens Krenzin <jens.krenzin@fokus.fraunhofer.de>
+ * Michael Gehring <michael.gehring@fokus.fraunhofer.de>
+ * Tacio Grespan Santos
+ * Fabian Wolff
+ *
+ * For questions/comments contact packettracking@fokus.fraunhofer.de
+ *
+ */
+package de.fhg.fokus.net.netview.control;
+
+import de.fhg.fokus.net.netview.model.Model;
+import de.fhg.fokus.net.netview.model.db.NetViewDB;
+import java.net.Socket;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.concurrent.ExecutorService;
+import java.util.prefs.Preferences;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Data source controller
+ *
+ * @author FhG-FOKUS NETwork Research
+ *
+ */
+public class DataSourcesController {
+ // sys
+
+ private final Logger logger = LoggerFactory.getLogger(getClass());
+ private final Timer timer = new Timer("Datasources");
+ private final Preferences prefs = Preferences.userNodeForPackage(getClass());
+
+ private static enum PrefKeys {
+
+ LAST_VISITED_NODES_DIRECTORY,
+ LAST_VISITED_TRACKS_DIRECTORY,
+ COLLECTOR_PORT,
+ START_COLLECTOR
+ }
+ private final ExecutorService executor;
+
+ public static enum EventType {
+
+ CONTROLLER_STARTED
+ }
+ // ctrl
+ private int collectorPort;
+ // view
+ private static SimpleDateFormat iso8601s = new SimpleDateFormat(
+ "yyyy-MM-dd HH:mm:ss.S");
+ // --
+
+ public static class EventData {
+ }
+ private final NetViewDB db;
+ private final PacketTrackCollector collector;
+ private final Model model;
+
+ public DataSourcesController(ExecutorService executor, Model model) {
+ super();
+
+ this.model = model;
+ this.executor = executor;
+ this.collector = new PacketTrackCollector(model.getTrackRepository(), this.executor);
+ this.db = this.model.getDb();
+ }
+
+ private void updateCollectorStatus() {
+ if (collector.isBound()) {
+ logger.debug(String.format("Bound to:\t%s \n", collector.getLocalAddress()));
+ logger.debug(String.format("Started at:\t%s \n", iso8601s.format(new Date(collector.getStartedAt()))));
+ logger.debug(String.format("Records:\t%d\n", collector.getNumberOfRecords()));
+ if (collector.getClients().size() > 0) {
+ logger.debug(String.format("Packet Track Exporters: %d ", collector.getClients().size()));
+ int i = 1;
+ for (Socket socket : collector.getClients()) {
+ logger.debug(String.format("\n - %d: %s ", i++, socket));
+ }
+ }
+ } else {
+ logger.debug("Not running!");
+ }
+ }
+
+ public void init() {
+ setupCollector();
+ }
+ private final TimerTask timerTaskUpdateCollectorStatus = new TimerTask() {
+
+ @Override
+ public void run() {
+ if (collector.isBound()) {
+ updateCollectorStatus();
+ }
+ }
+ };
+
+ private void setupCollector() {
+ try {
+ collectorPort = Integer.parseInt("40123");
+ } catch (Exception e) {
+ logger.error("Invalid port format!");
+ }
+ logger.debug("Starting collector..");
+ collector.bind(collectorPort);
+ }
+
+ public NetViewDB getDB() {
+ return this.db;
+ }
+
+ public Model getModel() {
+ return this.model;
+ }
+}
diff --git a/Monitoring/MonitoringTool/PacketTracking/netview/src/main/java/de/fhg/fokus/net/netview/control/MainController.java b/Monitoring/MonitoringTool/PacketTracking/netview/src/main/java/de/fhg/fokus/net/netview/control/MainController.java
new file mode 100644
index 0000000..01cbccd
--- /dev/null
+++ b/Monitoring/MonitoringTool/PacketTracking/netview/src/main/java/de/fhg/fokus/net/netview/control/MainController.java
@@ -0,0 +1,143 @@
+/**
+*
+* 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
+*
+*/
+
+/* Netview - a software component to visualize packet tracks, hop-by-hop delays,
+ * sampling stats and resource consumption. Netview requires the deployment of
+ * distributed probes (impd4e) and a central packet matcher to correlate the
+ * obervations.
+ *
+ * The probe can be obtained at http://impd4e.sourceforge.net/downloads.html
+ *
+ * Copyright (c) 2011
+ *
+ * Fraunhofer FOKUS
+ * www.fokus.fraunhofer.de
+ *
+ * in cooperation with
+ *
+ * Technical University Berlin
+ * www.av.tu-berlin.de
+ *
+ * Ramon Masek <ramon.masek@fokus.fraunhofer.de>
+ * Christian Henke <c.henke@tu-berlin.de>
+ * Carsten Schmoll <carsten.schmoll@fokus.fraunhofer.de>
+ * Julian Vetter <julian.vetter@fokus.fraunhofer.de>
+ * Jens Krenzin <jens.krenzin@fokus.fraunhofer.de>
+ * Michael Gehring <michael.gehring@fokus.fraunhofer.de>
+ * Tacio Grespan Santos
+ * Fabian Wolff
+ *
+ * For questions/comments contact packettracking@fokus.fraunhofer.de
+ *
+ */
+package de.fhg.fokus.net.netview.control;
+
+import de.fhg.fokus.net.netview.model.Model;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import org.jdesktop.application.Application;
+import org.jdesktop.application.SingleFrameApplication;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The main class of the application.
+ *
+ * @author FhG-FOKUS NETwork Research
+ *
+ *
+ */
+public final class MainController extends SingleFrameApplication {
+ //==[ external services / utilities ]===
+
+ private static final Logger logger = LoggerFactory.getLogger(MainController.class);
+
+
+ private DataSourcesController dataSourcesController;
+ private Model model;
+
+ private final ExecutorService executor = Executors.newCachedThreadPool();
+ private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(3);
+
+ @Override
+ protected void initialize(String[] args) {
+ logger.debug("=== Initializing NetView === ");
+ model = new Model();
+ }
+
+
+ @Override
+ protected void startup() {
+
+ executor.execute(new Runnable() {
+
+ @Override
+ public void run() {
+ try {
+ initializeControllers();
+ } catch (Exception e) {
+ logger.error(e.getMessage());
+ }
+ }
+ });
+ }
+
+
+ private void initializeControllers() {
+
+ this.dataSourcesController = new DataSourcesController(executor, model);
+ this.dataSourcesController.init();
+
+ if (this.dataSourcesController != null) {
+ //logger.debug("DSC beim MainController!");
+ }
+
+ this.model.setDataSourcesController(this.dataSourcesController);
+
+ if (this.model.getDataSourcesController() != null) {
+ //logger.debug("DSC beim Model!");
+ }
+
+ }
+
+ public static MainController getApplication() {
+ return Application.getInstance(MainController.class);
+ }
+
+ public Model getModel() {
+ return model;
+ }
+
+ /**
+ * Main method launching the application.
+ */
+ public static void main(String[] args) {
+
+ launch(MainController.class, args);
+ }
+
+ @Override
+ protected void shutdown() {
+ super.shutdown();
+
+ executor.shutdown();
+ scheduler.shutdown();
+
+
+ }
+}
diff --git a/Monitoring/MonitoringTool/PacketTracking/netview/src/main/java/de/fhg/fokus/net/netview/control/NoviDBInterface.java b/Monitoring/MonitoringTool/PacketTracking/netview/src/main/java/de/fhg/fokus/net/netview/control/NoviDBInterface.java
new file mode 100644
index 0000000..9503bef
--- /dev/null
+++ b/Monitoring/MonitoringTool/PacketTracking/netview/src/main/java/de/fhg/fokus/net/netview/control/NoviDBInterface.java
@@ -0,0 +1,352 @@
+/**
+*
+* 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.netview.control;
+
+import de.fhg.fokus.net.ptapi.PtProbeStats;
+import java.math.BigInteger;
+import java.sql.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class NoviDBInterface
+{
+
+private long uid = 0;
+private long hdid = 0;
+private long pdid = 0;
+private String host = null;
+private String port = null;
+private String db = null;
+private String user = null;
+private String password = null;
+private Connection connection = null;
+private final Logger logger = LoggerFactory.getLogger (getClass ());
+
+
+public NoviDBInterface (String host, String port, String db,
+ String user, String password)
+ throws SQLException, ClassNotFoundException
+{
+ this.host = host;
+ this.port = port;
+ this.db = db;
+ this.user = user;
+ this.password = password;
+
+ try
+ {
+ Class.forName ("org.postgresql.Driver");
+ } catch (ClassNotFoundException e) {
+ logger.debug ("PostgreSQL JDBC Driver not found!");
+ throw e;
+ }
+
+ this.connection = DriverManager.getConnection
+ ("jdbc:postgresql://" + host + ":" + port + "/" + db, user, password);
+
+ // Creating the SQL tables if they doesn't exist already.
+ createHopDelaysTable ();
+ createPathDelaysTable ();
+ createNodeStatsTable ();
+}
+
+
+protected void finalize() throws Throwable
+{
+ if (connection != null)
+ connection.close();
+}
+
+
+
+private long getMaxIDfromDB (String tableName, String idColumn)
+throws java.sql.SQLException
+{
+ if (this.connection == null) {
+ throw new SQLException("not connected!");
+ }
+
+ // fetch the biggest id number (key) from the table
+ String query = "SELECT max(" + idColumn + ") FROM " + tableName + ";";
+ ResultSet res = this.connection.createStatement().executeQuery(query);
+
+ if (res.next ()) {
+ return res.getLong (1);
+ } else {
+ return 0;
+ }
+}
+
+
+private void createHopDelaysTable ()
+throws SQLException
+{
+ try
+ {
+ hdid = getMaxIDfromDB ("hop_delays", "hdid") + 1;
+ logger.debug ("hop_delays-table exists.");
+ logger.debug ("hop_delays-table: using as next hdid = " + (hdid));
+
+ } catch (SQLException ex) {
+ logger.debug (ex.toString());
+ logger.debug ("Creating hop_delays-table ...");
+
+ try
+ {
+ String update = "CREATE TABLE hop_delays (hdid bigint NOT NULL, "
+ + "id bigint, ts bigint, src bigint, dst bigint, "
+ + "num bigint, hits double precision, "
+ + "sumdelay bigint, sumbytes bigint, "
+ + "mindelay bigint, maxdelay bigint, "
+ + "CONSTRAINT hop_delays_pkey PRIMARY KEY (hdid) );";
+
+ connection.createStatement().executeUpdate (update);
+
+ } catch (SQLException ex1) {
+ logger.debug
+ ("createHopDelaysTable-Error: Wasn't able to create hop_delays-table");
+ throw ex1;
+ }
+ }
+}
+
+
+private void createPathDelaysTable ()
+throws SQLException
+{
+ try
+ {
+ pdid = getMaxIDfromDB ("path_delays", "pdid") + 1;
+ logger.debug ("path_delays-table exists.");
+ logger.debug ("path_delays-table: using as next pdid = " + (pdid));
+
+ } catch (SQLException ex) {
+ logger.debug (ex.toString());
+ logger.debug ("Creating path_delays-table ...");
+
+ try
+ {
+ String update = "CREATE TABLE path_delays (pdid bigint NOT NULL, "
+ + "id bigint, ts bigint, src bigint, dst bigint, "
+ + "num bigint, path text, "
+ + "sumdelay bigint, sumbytes bigint, "
+ + "mindelay bigint, maxdelay bigint, "
+ + "CONSTRAINT path_delays_pkey PRIMARY KEY (pdid) );";
+
+ connection.createStatement().executeUpdate (update);
+ } catch (SQLException ex1) {
+ logger.debug
+ ("createPathDelaysTable-Error: Wasn't able to create path_delays-table");
+ throw ex1;
+ }
+ }
+}
+
+
+private void createNodeStatsTable ()
+throws SQLException
+{
+ try
+ {
+ uid = getMaxIDfromDB ("node_stats", "uid") + 1;
+ logger.debug ("node_stats-table exists.");
+ logger.debug ("node_stats-table: using as next pdid = " + (uid));
+
+ } catch (SQLException ex) {
+ logger.debug (ex.toString());
+ logger.debug ("Creating node_stats-table ...");
+
+ try
+ {
+ String update = "CREATE TABLE node_stats ( "
+ + "uid bigint NOT NULL, "
+ + "oid bigint, "
+ + "exporttime bigint,"
+ + "observationtimemilliseconds bigint, "
+ + "systemcpuidle double precision,"
+ + "systemmemfree bigint, "
+ + "processcpuuser double precision, "
+ + "processcpusys double precision, "
+ + "processmemvzs bigint,"
+ + "processmemrss bigint, "
+ + "CONSTRAINT node_stats_pkex PRIMARY KEY (uid) );";
+
+ connection.createStatement().executeUpdate (update);
+ }
+ catch (SQLException ex1)
+ {
+ logger.debug
+ ("createNodeStatsTable-Error: Wasn't able to create node_stats-table");
+ throw ex1;
+ }
+ }
+}
+
+
+public ResultSet getContent (String selection, String options, String table)
+throws SQLException
+{
+ if (!(table.equals ("hop_delays")) && !(table.equals ("path_delays")))
+ {
+ logger.debug
+ ("getContent-Error: parameter table has unexpected content");
+ return null;
+ }
+
+ try
+ {
+ String query = "SELECT " + selection +
+ " FROM " + table + " " + options + " ;";
+ //logger.debug("getContent-query: "+query);
+ return connection.createStatement().executeQuery (query);
+
+ } catch (SQLException ex) {
+ logger.debug (ex.toString());
+ logger.debug
+ ("getContent-Error: Wasn't able to fetch content from database");
+ throw ex;
+ }
+}
+
+
+public void updateRow (long did, long sumdelay, long num, float hits,
+ long sumbytes, long mindelay, long maxdelay,
+ String table)
+throws SQLException
+{
+ if (!(table.equals ("hop_delays")) && !(table.equals ("path_delays")))
+ {
+ logger.debug
+ ("updateRow-Error: request for table '"+table+"' not supported");
+ return;
+ }
+
+ String update = "";
+ if (table.equals ("hop_delays"))
+ {
+ update = "UPDATE hop_delays "
+ + "SET num = " + num
+ + ", hits = " + hits
+ + ", sumdelay = " + sumdelay
+ + ", sumbytes = " + sumbytes
+ + ", mindelay = " + mindelay
+ + ", maxdelay = " + maxdelay + " WHERE hdid = " + did + " ;";
+ }
+ else if (table.equals ("path_delays"))
+ {
+ update = "UPDATE path_delays "
+ + "SET num = " + num
+ + ", sumdelay = " + sumdelay
+ + ", sumbytes = " + sumbytes
+ + ", mindelay = " + mindelay
+ + ", maxdelay = " + maxdelay + " WHERE pdid = " + did + " ;";
+ }
+
+ logger.debug ("updateRow-Update: " + update);
+ connection.createStatement().executeUpdate (update);
+}
+
+
+public void writeRow (long id, long timestamp, long src, long dst,
+ long numberOfDelays, float hitcounter, String path,
+ long sumDelays, long sumBytes, long mindelay,
+ long maxdelay, String table)
+throws SQLException
+{
+ if (table.equals ("hop_delays"))
+ {
+ hdid++;
+ }
+ else if (table.equals ("path_delays"))
+ {
+ pdid++;
+ }
+ else
+ {
+ logger.debug
+ ("writeRow-Error: request for table '"+table+"' not supported");
+ return;
+ }
+
+ String update = "";
+ if (table.equals ("hop_delays"))
+ {
+ update = "INSERT INTO hop_delays "
+ + "VALUES ( "
+ + hdid + ", "
+ + id + ", "
+ + timestamp + ", "
+ + src + ", "
+ + dst + ", "
+ + numberOfDelays + ", "
+ + hitcounter + ", "
+ + sumDelays + ", "
+ + sumBytes + ", " + mindelay + ", " + maxdelay + " " + ");";
+ }
+ else if (table.equals ("path_delays"))
+ {
+ update = "INSERT INTO path_delays "
+ + "VALUES ( "
+ + pdid + ", "
+ + id + ", "
+ + timestamp + ", "
+ + src + ", "
+ + dst + ", "
+ + numberOfDelays + ", "
+ + path + ", "
+ + sumDelays + ", "
+ + sumBytes + ", " + mindelay + ", " + maxdelay + " " + ");";
+ }
+
+ logger.debug ("writeRow-Update: " + update);
+ connection.createStatement().executeUpdate (update);
+}
+
+
+public void exportNodeStats (PtProbeStats probeStats)
+throws SQLException
+{
+ this.uid++;
+
+ try
+ {
+ String update = "INSERT INTO node_stats "
+ + "VALUES ("
+ + uid + ", "
+ + probeStats.getOid() + ", "
+ + probeStats.getExportTime () + ", "
+ + probeStats.getObservationTimeMilliseconds() + ", "
+ + probeStats.getSystemCpuIdle() + ", "
+ + probeStats.getSystemMemFree() + ", "
+ + probeStats.getProcessCpuUser() + ", "
+ + probeStats.getProcessCpuSys() + ", "
+ + probeStats.getProcessMemVzs () + ", "
+ + probeStats.getProcessMemRss() + ");";
+
+ logger.debug ("exportNodeStats-Update: " + update);
+ connection.createStatement ().executeUpdate (update);
+ }
+ catch (SQLException ex)
+ {
+ logger.debug
+ ("exportNodeStats-Error: update of node_stats failed");
+ throw ex;
+ }
+}
+
+}
diff --git a/Monitoring/MonitoringTool/PacketTracking/netview/src/main/java/de/fhg/fokus/net/netview/control/PacketTrackCollector.java b/Monitoring/MonitoringTool/PacketTracking/netview/src/main/java/de/fhg/fokus/net/netview/control/PacketTrackCollector.java
new file mode 100644
index 0000000..8fc4aec
--- /dev/null
+++ b/Monitoring/MonitoringTool/PacketTracking/netview/src/main/java/de/fhg/fokus/net/netview/control/PacketTrackCollector.java
@@ -0,0 +1,233 @@
+/**
+*
+* 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
+*
+*/
+
+/* Netview - a software component to visualize packet tracks, hop-by-hop delays,
+ * sampling stats and resource consumption. Netview requires the deployment of
+ * distributed probes (impd4e) and a central packet matcher to correlate the
+ * obervations.
+ *
+ * The probe can be obtained at http://impd4e.sourceforge.net/downloads.html
+ *
+ * Copyright (c) 2011
+ *
+ * Fraunhofer FOKUS
+ * www.fokus.fraunhofer.de
+ *
+ * in cooperation with
+ *
+ * Technical University Berlin
+ * www.av.tu-berlin.de
+ *
+ * Ramon Masek <ramon.masek@fokus.fraunhofer.de>
+ * Christian Henke <c.henke@tu-berlin.de>
+ * Carsten Schmoll <carsten.schmoll@fokus.fraunhofer.de>
+ * Julian Vetter <julian.vetter@fokus.fraunhofer.de>
+ * Jens Krenzin <jens.krenzin@fokus.fraunhofer.de>
+ * Michael Gehring <michael.gehring@fokus.fraunhofer.de>
+ * Tacio Grespan Santos
+ * Fabian Wolff
+ *
+ * For questions/comments contact packettracking@fokus.fraunhofer.de
+ *
+ */
+package de.fhg.fokus.net.netview.control;
+
+import de.fhg.fokus.net.netview.model.db.TrackRepository;
+import de.fhg.fokus.net.ptapi.PacketTrackRecord;
+import de.fhg.fokus.net.ptapi.PtProbeStats;
+import java.io.InputStream;
+import java.io.ObjectInput;
+import java.io.ObjectInputStream;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.SocketAddress;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.ExecutorService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Default packet track collector implementation
+ *
+ * @author FhG-FOKUS NETwork Research
+ *
+ */
+public class PacketTrackCollector {
+
+ public static enum PtcEventType {
+
+ /**
+ * eventData: clientAddress
+ */
+ CLIENT_CONNECTED,
+ /**
+ * eventData: null
+ */
+ CLIENT_DISCONNECTED,
+ /**
+ * eventData: null
+ */
+ STARTED,
+ STOPPED
+ }
+
+ public static class PtcEventData {
+
+ public SocketAddress clientAddress;
+
+ public PtcEventData() {
+ }
+
+ public PtcEventData(SocketAddress clientAddress) {
+ this.clientAddress = clientAddress;
+ }
+ }
+
+ private final ExecutorService executor;
+ private final TrackRepository db;
+ private final Logger logger = LoggerFactory.getLogger(getClass());
+ // model
+ private final List<Socket> clients = new CopyOnWriteArrayList<Socket>();
+ private long numberOfRecords = 0;
+ private long startedAt = 0;
+
+ public PacketTrackCollector(TrackRepository db, ExecutorService executor) {
+ this.executor = executor;
+ this.db = db;
+ }
+
+ private void handleConnection(final Socket socket) {
+ final SocketAddress remote = socket.getRemoteSocketAddress();
+ clients.add(socket);
+
+ try {
+ InputStream inStream = socket.getInputStream();
+ ObjectInput inObjectStream = new ObjectInputStream(inStream);
+
+ Object obj;
+// socket.getRemoteSocketAddress();
+ while (true) {
+ obj = inObjectStream.readObject();
+ if (obj != null) {
+ if (obj instanceof PacketTrackRecord) {
+ db.addPacketTrackRecord((PacketTrackRecord) obj);
+ numberOfRecords++;
+ } else if (obj instanceof PtProbeStats) {
+ db.addPtProbeStats((PtProbeStats) obj);
+ // } else if (obj instanceof PtNodeStats) {
+ // TODO implement handling of node stats later
+ } else {
+ //logger.warn("Unexpected object of class " + obj.getClass() + " received.");
+ }
+ }
+
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ logger.debug(e.getMessage());
+ e.printStackTrace();
+ try {
+ socket.getInputStream().close();
+ socket.close();
+ } catch (Exception e1) {
+ logger.debug(e1.getMessage());
+ }
+ clients.remove(socket);
+ }
+ }
+ private ServerSocket serverSocket;
+
+ public boolean isBound() {
+ if (serverSocket == null) {
+ return false;
+ }
+ return serverSocket.isBound();
+ }
+
+ public String getLocalAddress() {
+ if (isBound()) {
+ return serverSocket.getLocalSocketAddress().toString();
+ }
+ return "";
+ }
+ private boolean shouldRun = true;
+
+ /**
+ * Bind collector to a port
+ *
+ * @param port
+ * @throws Exception
+ */
+ public void bind(int port) {
+ shouldRun = true;
+ numberOfRecords = 0;
+ try {
+ serverSocket = new ServerSocket(port);
+ startedAt = System.currentTimeMillis();
+ while (shouldRun) {
+ final Socket client = serverSocket.accept();
+ executor.execute(
+ new Runnable() {
+
+ @Override
+ public void run() {
+ handleConnection(client);
+ }
+ });
+ }
+ } catch (Exception e) {
+ logger.debug(e.getMessage());
+ } finally {
+ serverSocket = null;
+ }
+ }
+
+ public long getStartedAt() {
+ return startedAt;
+ }
+
+ public long getNumberOfRecords() {
+ return numberOfRecords;
+ }
+
+ /**
+ * Stop collector
+ */
+ public void stop() {
+ logger.debug("=> stopping collector...");
+ shouldRun = false;
+ for (Socket socket : clients) {
+ logger.debug("Closing client: {}", socket);
+ try {
+ socket.getInputStream().close();
+ socket.close();
+ } catch (Exception e) {
+ logger.debug(e.getMessage());
+ }
+ }
+ try {
+ serverSocket.close();
+ } catch (Exception e) {
+ logger.debug(e.getMessage());
+ }
+ }
+
+ public List<Socket> getClients() {
+ return clients;
+ }
+}
diff --git a/Monitoring/MonitoringTool/PacketTracking/netview/src/main/java/de/fhg/fokus/net/netview/model/Model.java b/Monitoring/MonitoringTool/PacketTracking/netview/src/main/java/de/fhg/fokus/net/netview/model/Model.java
new file mode 100644
index 0000000..a53a2ed
--- /dev/null
+++ b/Monitoring/MonitoringTool/PacketTracking/netview/src/main/java/de/fhg/fokus/net/netview/model/Model.java
@@ -0,0 +1,81 @@
+/**
+*
+* 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
+*
+*/
+
+/* Netview - a software component to visualize packet tracks, hop-by-hop delays,
+ * sampling stats and resource consumption. Netview requires the deployment of
+ * distributed probes (impd4e) and a central packet matcher to correlate the
+ * obervations.
+ *
+ * The probe can be obtained at http://impd4e.sourceforge.net/downloads.html
+ *
+ * Copyright (c) 2011
+ *
+ * Fraunhofer FOKUS
+ * www.fokus.fraunhofer.de
+ *
+ * in cooperation with
+ *
+ * Technical University Berlin
+ * www.av.tu-berlin.de
+ *
+ * Ramon Masek <ramon.masek@fokus.fraunhofer.de>
+ * Christian Henke <c.henke@tu-berlin.de>
+ * Carsten Schmoll <carsten.schmoll@fokus.fraunhofer.de>
+ * Julian Vetter <julian.vetter@fokus.fraunhofer.de>
+ * Jens Krenzin <jens.krenzin@fokus.fraunhofer.de>
+ * Michael Gehring <michael.gehring@fokus.fraunhofer.de>
+ * Tacio Grespan Santos
+ * Fabian Wolff
+ *
+ * For questions/comments contact packettracking@fokus.fraunhofer.de
+ *
+ */
+package de.fhg.fokus.net.netview.model;
+
+import de.fhg.fokus.net.netview.control.DataSourcesController;
+import de.fhg.fokus.net.netview.model.db.NetViewDB;
+import de.fhg.fokus.net.netview.model.db.TrackRepository;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public final class Model {
+
+ private final static Logger logger = LoggerFactory.getLogger(Model.class);
+ private final NetViewDB db;
+ private DataSourcesController dsc = null;
+
+ public Model() {
+ this.db = new NetViewDB();
+ }
+
+ public TrackRepository getTrackRepository() {
+ return db.getTrackRepository();
+ }
+
+ public NetViewDB getDb() {
+ return db;
+ }
+
+ public void setDataSourcesController(DataSourcesController dsc) {
+ this.dsc = dsc;
+ this.db.getTrackRepository().dsc = dsc;
+ }
+
+ public DataSourcesController getDataSourcesController() {
+ return this.dsc;
+ }
+}
diff --git a/Monitoring/MonitoringTool/PacketTracking/netview/src/main/java/de/fhg/fokus/net/netview/model/db/InterfaceStats.java b/Monitoring/MonitoringTool/PacketTracking/netview/src/main/java/de/fhg/fokus/net/netview/model/db/InterfaceStats.java
new file mode 100644
index 0000000..5022613
--- /dev/null
+++ b/Monitoring/MonitoringTool/PacketTracking/netview/src/main/java/de/fhg/fokus/net/netview/model/db/InterfaceStats.java
@@ -0,0 +1,266 @@
+/**
+*
+* 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
+*
+*/
+
+/* Netview - a software component to visualize packet tracks, hop-by-hop delays,
+ * sampling stats and resource consumption. Netview requires the deployment of
+ * distributed probes (impd4e) and a central packet matcher to correlate the
+ * obervations.
+ *
+ * The probe can be obtained at http://impd4e.sourceforge.net/downloads.html
+ *
+ * Copyright (c) 2011
+ *
+ * Fraunhofer FOKUS
+ * www.fokus.fraunhofer.de
+ *
+ * in cooperation with
+ *
+ * Technical University Berlin
+ * www.av.tu-berlin.de
+ *
+ * Ramon Masek <ramon.masek@fokus.fraunhofer.de>
+ * Christian Henke <c.henke@tu-berlin.de>
+ * Carsten Schmoll <carsten.schmoll@fokus.fraunhofer.de>
+ * Julian Vetter <julian.vetter@fokus.fraunhofer.de>
+ * Jens Krenzin <jens.krenzin@fokus.fraunhofer.de>
+ * Michael Gehring <michael.gehring@fokus.fraunhofer.de>
+ * Tacio Grespan Santos
+ * Fabian Wolff
+ *
+ * For questions/comments contact packettracking@fokus.fraunhofer.de
+ *
+ */
+
+package de.fhg.fokus.net.netview.model.db;
+
+import java.io.Serializable;
+import java.math.BigInteger;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+
+import de.fhg.fokus.net.ptapi.PtInterfaceStats;
+
+/**
+ * Sampling
+ *
+ * @author FhG-FOKUS NETwork Research
+ *
+ */
+@Entity
+public class InterfaceStats implements Serializable {
+
+ private static final long serialVersionUID = -4426394645556449457L;
+
+ /**
+ * Unique Id. The uid id local o the program, i.e. it won't be transfered
+ * over the network and must therefore be set by the persistence layer in
+ * case one is available.
+ *
+ */
+ @Id
+ public long uid;
+
+ /**
+ * Observation Domain Id. Note that if you are using ipfix4java as transport you'll currently
+ * need to get this value from the ipfix message;
+ */
+ @Column
+ public long oid;
+
+ /**
+ * Export Timestamp.
+ */
+ @Column
+ public long timestamp;
+
+ /**
+ * Sampling Size (n)
+ */
+ @Column
+ public long samplingSize;
+
+ /**
+ * Packet Delta Count (N)
+ */
+ @Column
+ public long packetDeltaCount;
+
+ /**
+ * number of packets received by pcap
+ */
+ @Column
+ public long pcapStatRecv;
+
+ /**
+ * number of packets dropped by pcap
+ */
+ @Column
+ public long pcapStatDrop;
+
+ /**
+ * A short name uniquely describing an interface, e.g. "eth0".
+ * May be the string "not available" on decoding failures.
+ */
+ @Column
+ public String interfaceName;
+
+ /**
+ * A generic description of the interface, e.g. "Ethernet (10.0.0.1/24)"
+ * May be the string "not available" on decoding failures.
+ */
+ @Column
+ public String interfaceDescription;
+
+
+
+ public InterfaceStats() {
+ }
+
+
+ public InterfaceStats(PtInterfaceStats sample) {
+ super();
+ this.oid = sample.oid;
+ this.timestamp = sample.observationTimeMilliseconds;
+ this.samplingSize = sample.samplingSize;
+ this.packetDeltaCount = sample.packetDeltaCount.longValue();
+ this.pcapStatRecv = sample.pcapStatRecv;
+ this.pcapStatDrop = sample.pcapStatDrop;
+ this.interfaceName= sample.interfaceName;
+ this.interfaceDescription= sample.interfaceDescription;
+ }
+
+ public InterfaceStats(long oid, long timestamp, long samplingSize,
+ BigInteger packetDeltaCount, long pcapStatRecv, long pcapStatDrop,
+ String interfaceName, String interfaceDescription) {
+ super();
+ this.oid = oid;
+ this.timestamp = timestamp;
+ this.samplingSize = samplingSize;
+ this.packetDeltaCount = packetDeltaCount.longValue();
+ this.pcapStatRecv = pcapStatRecv;
+ this.pcapStatDrop = pcapStatDrop;
+ this.interfaceName = interfaceName;
+ this.interfaceDescription = interfaceDescription;
+ }
+
+
+ public long getUid() {
+ return uid;
+ }
+
+
+ public void setUid(long uid) {
+ this.uid = uid;
+ }
+
+
+ public long getOid() {
+ return oid;
+ }
+
+
+ public void setOid(long oid) {
+ this.oid = oid;
+ }
+
+
+ public long getTimestamp() {
+ return timestamp;
+ }
+
+
+ public void setTimestamp(long timestamp) {
+ this.timestamp = timestamp;
+ }
+
+ public long getSamplingSize() {
+ return samplingSize;
+ }
+
+
+ public void setSamplingSize(long samplingSize) {
+ this.samplingSize = samplingSize;
+ }
+
+
+ public long getPacketDeltaCount() {
+ return packetDeltaCount;
+ }
+
+
+ public void setPacketDeltaCount(long packetDeltaCount) {
+ this.packetDeltaCount = packetDeltaCount;
+ }
+
+
+ public static long getSerialversionuid() {
+ return serialVersionUID;
+ }
+
+ public long getPcapStatRecv() {
+ return pcapStatRecv;
+ }
+
+
+ public void setPcapStatRecv(long pcapStatRecv) {
+ this.pcapStatRecv = pcapStatRecv;
+ }
+
+
+ public long getPcapStatDrop() {
+ return pcapStatDrop;
+ }
+
+
+ public void setPcapStatDrop(long pcapStatDrop) {
+ this.pcapStatDrop = pcapStatDrop;
+ }
+
+ public String getInterfaceName() {
+ return interfaceName;
+ }
+
+
+ public void setInterfaceName(String interfaceName) {
+ this.interfaceName = interfaceName;
+ }
+
+
+ public String getInterfaceDescription() {
+ return interfaceDescription;
+ }
+
+
+ public void setInterfaceDescription(String interfaceDescription) {
+ this.interfaceDescription = interfaceDescription;
+ }
+
+
+
+
+// @Override
+// public String toString() {
+// return String.format("{uid:%d, oid: %d, timestamp: %d, "
+// + "samplingSize: %d, packetDeltaCount: %s}", uid, oid,
+// timestamp,
+// samplingSize,
+// packetDeltaCount.toString());
+// }
+
+}
diff --git a/Monitoring/MonitoringTool/PacketTracking/netview/src/main/java/de/fhg/fokus/net/netview/model/db/NetViewDB.java b/Monitoring/MonitoringTool/PacketTracking/netview/src/main/java/de/fhg/fokus/net/netview/model/db/NetViewDB.java
new file mode 100644
index 0000000..8c62617
--- /dev/null
+++ b/Monitoring/MonitoringTool/PacketTracking/netview/src/main/java/de/fhg/fokus/net/netview/model/db/NetViewDB.java
@@ -0,0 +1,124 @@
+/**
+*
+* 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
+*
+*/
+
+/* Netview - a software component to visualize packet tracks, hop-by-hop delays,
+ * sampling stats and resource consumption. Netview requires the deployment of
+ * distributed probes (impd4e) and a central packet matcher to correlate the
+ * obervations.
+ *
+ * The probe can be obtained at http://impd4e.sourceforge.net/downloads.html
+ *
+ * Copyright (c) 2011
+ *
+ * Fraunhofer FOKUS
+ * www.fokus.fraunhofer.de
+ *
+ * in cooperation with
+ *
+ * Technical University Berlin
+ * www.av.tu-berlin.de
+ *
+ * Ramon Masek <ramon.masek@fokus.fraunhofer.de>
+ * Christian Henke <c.henke@tu-berlin.de>
+ * Carsten Schmoll <carsten.schmoll@fokus.fraunhofer.de>
+ * Julian Vetter <julian.vetter@fokus.fraunhofer.de>
+ * Jens Krenzin <jens.krenzin@fokus.fraunhofer.de>
+ * Michael Gehring <michael.gehring@fokus.fraunhofer.de>
+ * Tacio Grespan Santos
+ * Fabian Wolff
+ *
+ * For questions/comments contact packettracking@fokus.fraunhofer.de
+ *
+ */
+package de.fhg.fokus.net.netview.model.db;
+
+import de.fhg.fokus.net.ptapi.PacketTrackRecord;
+import de.fhg.fokus.net.ptapi.PtProbeStats;
+import java.io.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ * @author FhG-FOKUS NETwork Research
+ *
+ */
+public class NetViewDB {
+
+ private final Logger logger = LoggerFactory.getLogger(getClass());
+ private TrackRepository trackRepository;
+
+ public NetViewDB() {
+ try {
+ this.trackRepository = new TrackRepository();
+ } catch (Exception ex) {
+ logger.error("failed to create trackRepository: " + ex);
+ ex.printStackTrace();
+ }
+ }
+
+ public void shutdown() {
+ this.trackRepository = null; // gc on this will trigger database connection close
+ }
+
+ public TrackRepository getTrackRepository() {
+ return trackRepository;
+ }
+
+ public int importTracks(File file) {
+ ObjectInputStream ois = null;
+ Object obj = null;
+ int count = 0;
+
+ try {
+ ois = new ObjectInputStream(new FileInputStream(file));
+
+ while (true) {
+ obj = ois.readObject();
+ if (obj != null) {
+ if (obj instanceof PacketTrackRecord) {
+ trackRepository.addPacketTrackRecord((PacketTrackRecord) obj);
+ count++;
+ } else if (obj instanceof PtProbeStats) {
+ trackRepository.addPtProbeStats((PtProbeStats) obj);
+ count++;
+ } else {
+ logger.warn("Unexpected object of class " + obj.getClass() + " in object stream.");
+ }
+ }
+
+ }
+ } catch (EOFException eof) {
+ /* NOP */
+ } catch (IOException ioe) {
+ logger.warn("IO error while reading " + file.getAbsolutePath());
+ ioe.printStackTrace();
+ } catch (ClassNotFoundException cnfe) {
+ logger.warn("Unknown class in object stream.");
+ cnfe.printStackTrace();
+ } finally {
+ if (ois != null) {
+ try {
+ ois.close();
+ } catch (IOException e) {
+ /* NOP */
+ }
+ }
+ }
+ return count;
+ }
+}
diff --git a/Monitoring/MonitoringTool/PacketTracking/netview/src/main/java/de/fhg/fokus/net/netview/model/db/ProbeStats.java b/Monitoring/MonitoringTool/PacketTracking/netview/src/main/java/de/fhg/fokus/net/netview/model/db/ProbeStats.java
new file mode 100644
index 0000000..55009f7
--- /dev/null
+++ b/Monitoring/MonitoringTool/PacketTracking/netview/src/main/java/de/fhg/fokus/net/netview/model/db/ProbeStats.java
@@ -0,0 +1,245 @@
+/**
+*
+* 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
+*
+*/
+
+/* Netview - a software component to visualize packet tracks, hop-by-hop delays,
+ * sampling stats and resource consumption. Netview requires the deployment of
+ * distributed probes (impd4e) and a central packet matcher to correlate the
+ * obervations.
+ *
+ * The probe can be obtained at http://impd4e.sourceforge.net/downloads.html
+ *
+ * Copyright (c) 2011
+ *
+ * Fraunhofer FOKUS
+ * www.fokus.fraunhofer.de
+ *
+ * in cooperation with
+ *
+ * Technical University Berlin
+ * www.av.tu-berlin.de
+ *
+ * Ramon Masek <ramon.masek@fokus.fraunhofer.de>
+ * Christian Henke <c.henke@tu-berlin.de>
+ * Carsten Schmoll <carsten.schmoll@fokus.fraunhofer.de>
+ * Julian Vetter <julian.vetter@fokus.fraunhofer.de>
+ * Jens Krenzin <jens.krenzin@fokus.fraunhofer.de>
+ * Michael Gehring <michael.gehring@fokus.fraunhofer.de>
+ * Tacio Grespan Santos
+ * Fabian Wolff
+ *
+ * For questions/comments contact packettracking@fokus.fraunhofer.de
+ *
+ */
+
+package de.fhg.fokus.net.netview.model.db;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+
+import de.fhg.fokus.net.ptapi.PtProbeStats;
+
+/**
+ * Probe statistics.
+ *
+ * @author FhG-FOKUS NETwork Research
+ *
+ */
+@Entity
+public class ProbeStats implements Serializable {
+
+ private static final long serialVersionUID = 7100984799313833995L;
+ /**
+ * Unique Id. The uid id local o the program, i.e. it won't be transfered
+ * over the network and must therefore be set by the persistence layer in
+ * case one is available.
+ *
+ */
+
+ @Id
+ public long uid;
+
+ /**
+ * Observation Domain Id.
+ */
+ @Column
+ public long oid;
+
+ /**
+ * Export Timestamp.
+ *
+ */
+ @Column
+ public long timestamp;
+
+ /**
+ * System idle CPU, see "man mpstat" for more information.
+ */
+ @Column
+ public float systemCpuIdle;
+
+ /**
+ * System free memory in kilobytes, see "man pidstat" for more information.
+ */
+ @Column
+ public long systemMemFree;
+
+ /**
+ * percentage of CPU used in user level (application), see "man pidstat" for
+ * more information"
+ */
+ @Column
+ public float processCpuUser;
+
+ /**
+ * percentage of CPU used in system level (kernel), see "man pidstat" for
+ * more information"
+ */
+ @Column
+ public float processCpuSys;
+
+ /**
+ * the process virtual memory used in kilobytes, see "man pidstat" for more
+ * information"
+ */
+ @Column
+ public long processMemVzs;
+
+ /**
+ * the process resident set size in kilobytes, see "man pidstat" for more
+ * information"
+ */
+ @Column
+ public long processMemRss;
+
+
+ public ProbeStats() {
+ }
+
+ public ProbeStats(PtProbeStats probe) {
+ super();
+ this.oid = probe.oid;
+ this.timestamp = probe.observationTimeMilliseconds;
+ this.systemCpuIdle = probe.systemCpuIdle;
+ this.systemMemFree = probe.systemMemFree.longValue();
+ this.processCpuUser = probe.processCpuUser;
+ this.processCpuSys = probe.processCpuSys;
+ this.processMemVzs = probe.processMemVzs.longValue();
+ this.processMemRss = probe.processMemRss.longValue();
+ }
+
+ public ProbeStats(long oid, long timestamp, float systemCpuIdle,
+ long systemMemFree, float processCpuUser,
+ float processCpuSys, long processMemVzs,
+ long processMemRss, long pcapStatRecv,
+ long pcapStatDrop) {
+ super();
+ this.oid = oid;
+ this.timestamp = timestamp;
+ this.systemCpuIdle = systemCpuIdle;
+ this.systemMemFree = systemMemFree;
+ this.processCpuUser = processCpuUser;
+ this.processCpuSys = processCpuSys;
+ this.processMemVzs = processMemVzs;
+ this.processMemRss = processMemRss;
+ }
+
+// @Override
+// public String toString() {
+// return String.format("{uid:%d, oid: %d, timestamp: %d, "
+// + "systemCpuIdle: %f, systemMemFree: %d, "
+// + "processCpuUser: %f, processMemVzs: %d, "
+// + "processMemRss: %d, pcapStatRecv: %s, pcapStatDrop: %s}",
+// uid, oid, timestamp, systemCpuIdle, systemMemFree,
+// processCpuUser, processCpuSys, processMemVzs, processMemRss,
+// pcapStatRecv.toString(), pcapStatDrop.toString());
+// }
+
+ public long getUid() {
+ return uid;
+ }
+
+ public void setUid(long uid) {
+ this.uid = uid;
+ }
+
+ public long getOid() {
+ return oid;
+ }
+
+ public void setOid(long oid) {
+ this.oid = oid;
+ }
+
+ public long getTimestamp() {
+ return timestamp;
+ }
+
+ public void setTimestamp(long timestamp) {
+ this.timestamp = timestamp;
+ }
+
+ public float getSystemCpuIdle() {
+ return systemCpuIdle;
+ }
+
+ public void setSystemCpuIdle(float systemCpuIdle) {
+ this.systemCpuIdle = systemCpuIdle;
+ }
+
+ public long getSystemMemFree() {
+ return systemMemFree;
+ }
+
+ public void setSystemMemFree(long systemMemFree) {
+ this.systemMemFree = systemMemFree;
+ }
+
+ public float getProcessCpuUser() {
+ return processCpuUser;
+ }
+
+ public void setProcessCpuUser(float processCpuUser) {
+ this.processCpuUser = processCpuUser;
+ }
+
+ public float getProcessCpuSys() {
+ return processCpuSys;
+ }
+
+ public void setProcessCpuSys(float processCpuSys) {
+ this.processCpuSys = processCpuSys;
+ }
+
+ public long getProcessMemVzs() {
+ return processMemVzs;
+ }
+
+ public void setProcessMemVzs(long processMemVzs) {
+ this.processMemVzs = processMemVzs;
+ }
+
+ public long getProcessMemRss() {
+ return processMemRss;
+ }
+
+ public void setProcessMemRss(long processMemRss) {
+ this.processMemRss = processMemRss;
+ }
+}
diff --git a/Monitoring/MonitoringTool/PacketTracking/netview/src/main/java/de/fhg/fokus/net/netview/model/db/RawTrackData.java b/Monitoring/MonitoringTool/PacketTracking/netview/src/main/java/de/fhg/fokus/net/netview/model/db/RawTrackData.java
new file mode 100644
index 0000000..f8f04ab
--- /dev/null
+++ b/Monitoring/MonitoringTool/PacketTracking/netview/src/main/java/de/fhg/fokus/net/netview/model/db/RawTrackData.java
@@ -0,0 +1,269 @@
+/**
+*
+* 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
+*
+*/
+
+/* Netview - a software component to visualize packet tracks, hop-by-hop delays,
+ * sampling stats and resource consumption. Netview requires the deployment of
+ * distributed probes (impd4e) and a central packet matcher to correlate the
+ * obervations.
+ *
+ * The probe can be obtained at http://impd4e.sourceforge.net/downloads.html
+ *
+ * Copyright (c) 2011
+ *
+ * Fraunhofer FOKUS
+ * www.fokus.fraunhofer.de
+ *
+ * in cooperation with
+ *
+ * Technical University Berlin
+ * www.av.tu-berlin.de
+ *
+ * Ramon Masek <ramon.masek@fokus.fraunhofer.de>
+ * Christian Henke <c.henke@tu-berlin.de>
+ * Carsten Schmoll <carsten.schmoll@fokus.fraunhofer.de>
+ * Julian Vetter <julian.vetter@fokus.fraunhofer.de>
+ * Jens Krenzin <jens.krenzin@fokus.fraunhofer.de>
+ * Michael Gehring <michael.gehring@fokus.fraunhofer.de>
+ * Tacio Grespan Santos
+ * Fabian Wolff
+ *
+ * For questions/comments contact packettracking@fokus.fraunhofer.de
+ *
+ */
+
+package de.fhg.fokus.net.netview.model.db;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+
+import de.fhg.fokus.net.ptapi.PacketTrackRecord;
+
+@Entity
+public class RawTrackData {
+
+
+ public RawTrackData() {
+
+ }
+
+ public RawTrackData(int uID, int trackID, int packetID, int recordID, int probeID,
+ long ts, int ttl, int nextHop, int delay, int hopNumber) {
+ this.uid = uID;
+ this.trackID = trackID;
+ this.packetID = packetID;
+ this.recordID = recordID;
+ this.probeID = probeID;
+ this.ts = ts;
+ this.ttl = ttl;
+ this.nextHop = nextHop;
+ this.delay = delay;
+ this.hopNumber = hopNumber;
+ }
+
+
+ public RawTrackData(PacketTrackRecord record, int i, long recordID){
+ this.trackID= record.trackid;
+ this.packetID = record.pktid;
+ this.probeID = record.oids[i];
+ this.recordID = recordID;
+ this.ttl = record.ttl[i];
+ this.ts = record.ts[i];
+ this.hopNumber = i;
+ if (i<record.oids.length-1){
+ this.nextHop = record.oids[i+1];
+ this.delay = record.ts[i+1]-record.ts[i];
+ }
+
+ // Not all records contain source addresses
+ if(record.sourceAddress != null){
+ this.sourceAddress = record.sourceAddress.toString().substring(1);
+ }
+ else{
+ this.sourceAddress = "unkown source";
+ }
+
+ // Not all records contain destination addresses
+ if(record.destinationAddress != null){
+ this.destinationAddress = record.destinationAddress.toString().substring(1);
+ }
+ else{
+ this.destinationAddress = "unkown destination";
+ }
+
+ this.sourcePort = record.sourcePort;
+ this.destinationPort = record.destinationPort;
+ }
+
+ /**
+ * Unique Id
+ */
+ @Id
+ private int uid;
+
+ @Column
+ private int trackID;
+
+ @Column
+ private int packetID;
+
+ @Column
+ private long recordID;
+
+ @Column
+ private long probeID;
+
+ @Column
+ private long ts;
+
+ @Column
+ private int ttl;
+
+ @Column
+ private long nextHop;
+
+ @Column
+ private long delay;
+
+ @Column
+ private int hopNumber;
+
+ @Column
+ private String sourceAddress;
+
+ @Column
+ private int sourcePort;
+
+ @Column
+ private String destinationAddress;
+
+ @Column
+ private int destinationPort;
+
+ public int getUid() {
+ return uid;
+ }
+
+ public void setUid(int uid) {
+ this.uid = uid;
+ }
+
+ public int getTrackID() {
+ return trackID;
+ }
+
+ public void setTrackID(int trackID) {
+ this.trackID = trackID;
+ }
+
+ public int getPacketID() {
+ return packetID;
+ }
+
+ public void setPacketID(int packetID) {
+ this.packetID = packetID;
+ }
+
+ public long getRecordID() {
+ return recordID;
+ }
+
+ public void setRecordID(long recordID) {
+ this.recordID = recordID;
+ }
+
+ public long getProbeID() {
+ return probeID;
+ }
+
+ public void setProbeID(long probeID) {
+ this.probeID = probeID;
+ }
+
+ public long getTs() {
+ return ts;
+ }
+
+ public void setTs(long ts) {
+ this.ts = ts;
+ }
+
+ public int getTtl() {
+ return ttl;
+ }
+
+ public void setTtl(int ttl) {
+ this.ttl = ttl;
+ }
+
+ public long getNextHop() {
+ return nextHop;
+ }
+
+ public void setNextHop(long nextHop) {
+ this.nextHop = nextHop;
+ }
+
+ public long getDelay() {
+ return delay;
+ }
+
+ public void setDelay(long delay) {
+ this.delay = delay;
+ }
+
+ public int getHopNumber() {
+ return hopNumber;
+ }
+
+ public void setHopNumber(int hopNumber) {
+ this.hopNumber = hopNumber;
+ }
+
+ public String getDestinationAddress() {
+ return destinationAddress;
+ }
+
+ public void setDestinationAddress(String destinationAddress) {
+ this.destinationAddress = destinationAddress;
+ }
+
+ public int getDestinationPort() {
+ return destinationPort;
+ }
+
+ public void setDestinationPort(int destinationPort) {
+ this.destinationPort = destinationPort;
+ }
+
+ public String getSourceAddress() {
+ return sourceAddress;
+ }
+
+ public void setSourceAddress(String sourceAddress) {
+ this.sourceAddress = sourceAddress;
+ }
+
+ public int getSourcePort() {
+ return sourcePort;
+ }
+
+ public void setSourcePort(int sourcePort) {
+ this.sourcePort = sourcePort;
+ }
+
+}
diff --git a/Monitoring/MonitoringTool/PacketTracking/netview/src/main/java/de/fhg/fokus/net/netview/model/db/TrackData.java b/Monitoring/MonitoringTool/PacketTracking/netview/src/main/java/de/fhg/fokus/net/netview/model/db/TrackData.java
new file mode 100644
index 0000000..f150329
--- /dev/null
+++ b/Monitoring/MonitoringTool/PacketTracking/netview/src/main/java/de/fhg/fokus/net/netview/model/db/TrackData.java
@@ -0,0 +1,142 @@
+/**
+*
+* 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
+*
+*/
+
+/* Netview - a software component to visualize packet tracks, hop-by-hop delays,
+ * sampling stats and resource consumption. Netview requires the deployment of
+ * distributed probes (impd4e) and a central packet matcher to correlate the
+ * obervations.
+ *
+ * The probe can be obtained at http://impd4e.sourceforge.net/downloads.html
+ *
+ * Copyright (c) 2011
+ *
+ * Fraunhofer FOKUS
+ * www.fokus.fraunhofer.de
+ *
+ * in cooperation with
+ *
+ * Technical University Berlin
+ * www.av.tu-berlin.de
+ *
+ * Ramon Masek <ramon.masek@fokus.fraunhofer.de>
+ * Christian Henke <c.henke@tu-berlin.de>
+ * Carsten Schmoll <carsten.schmoll@fokus.fraunhofer.de>
+ * Julian Vetter <julian.vetter@fokus.fraunhofer.de>
+ * Jens Krenzin <jens.krenzin@fokus.fraunhofer.de>
+ * Michael Gehring <michael.gehring@fokus.fraunhofer.de>
+ * Tacio Grespan Santos
+ * Fabian Wolff
+ *
+ * For questions/comments contact packettracking@fokus.fraunhofer.de
+ *
+ */
+
+package de.fhg.fokus.net.netview.model.db;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+
+import de.fhg.fokus.net.ptapi.PacketTrackRecord;
+
+@Entity
+public class TrackData {
+
+ public TrackData() {
+
+ }
+
+ public TrackData(int uID, int trackID, long start_ts, long stop_ts, int delay) {
+ this.uid = uID;
+ this.trackID = trackID;
+ this.start_ts = start_ts;
+ this.stop_ts = stop_ts;
+ this.delay = delay;
+ }
+
+
+ public TrackData(PacketTrackRecord record){
+ this.trackID = record.trackid;
+ this.start_ts = record.ts[0];
+ this.stop_ts = record.ts[record.ts.length-1];
+ this.delay = record.ts[record.ts.length-1] - record.ts[0];
+ }
+
+
+ /**
+ * Unique Id
+ */
+ @Id
+ private int uid;
+
+ @Column
+ private int trackID;
+
+ @Column
+ private long start_ts;
+
+ @Column
+ private long stop_ts;
+
+ @Column
+ private long delay;
+
+
+ public int getUid() {
+ return uid;
+ }
+
+ public void setUid(int uid) {
+ this.uid = uid;
+ }
+
+ public int getTrackID() {
+ return trackID;
+ }
+
+ public void setTrackID(int trackID) {
+ this.trackID = trackID;
+ }
+
+ public long getStart_ts() {
+ return start_ts;
+ }
+
+ public void setStart_ts(long start_ts) {
+ this.start_ts = start_ts;
+ }
+
+ public long getStop_ts() {
+ return stop_ts;
+ }
+
+ public void setStop_ts(long stop_ts) {
+ this.stop_ts = stop_ts;
+ }
+
+ public long getDelay() {
+ return delay;
+ }
+
+ public void setDelay(long delay) {
+ this.delay = delay;
+ }
+
+
+
+
+}
diff --git a/Monitoring/MonitoringTool/PacketTracking/netview/src/main/java/de/fhg/fokus/net/netview/model/db/TrackRepository.java b/Monitoring/MonitoringTool/PacketTracking/netview/src/main/java/de/fhg/fokus/net/netview/model/db/TrackRepository.java
new file mode 100644
index 0000000..158e06a
--- /dev/null
+++ b/Monitoring/MonitoringTool/PacketTracking/netview/src/main/java/de/fhg/fokus/net/netview/model/db/TrackRepository.java
@@ -0,0 +1,257 @@
+/**
+*
+* 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.netview.model.db;
+
+
+import de.fhg.fokus.net.netview.control.DataSourcesController;
+import de.fhg.fokus.net.netview.control.NoviDBInterface;
+import de.fhg.fokus.net.ptapi.PacketTrackRecord;
+import de.fhg.fokus.net.ptapi.PtProbeStats;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ * @author FhG-FOKUS NETwork Research
+ *
+ */
+public class TrackRepository {
+
+ private final Logger logger = LoggerFactory.getLogger(getClass());
+ private final int binsize = 100;
+ private final NoviDBInterface novidbinterface;
+
+ public DataSourcesController dsc = null;
+
+ public TrackRepository() throws SQLException, java.lang.ClassNotFoundException {
+ super();
+ this.novidbinterface = new NoviDBInterface("127.0.0.1",
+ "5432", "noviDB", "novi_user", "novi123");
+
+ }
+
+ private String getPath(long[] oids) {
+ String path = "\'";
+ for (int i = 0; i < oids.length - 1; i++) {
+ path = path + oids[i] + "-";
+ }
+ path = path + oids[oids.length - 1] + "\'";
+
+ return path;
+ }
+
+ public void addPacketTrackRecord(PacketTrackRecord record) {
+
+ if (record == null) {
+ logger.warn("could not create (Raw)TrackData object, returning null");
+ } else {
+ // ---- Save data in Novi database ----
+
+ // ------------------
+ // PATH DELAYS
+ // ------------------
+ long pathDelayTimestamp = record.ts[0];
+ long pathDelayId = pathDelayTimestamp / (1000 * binsize);
+ long pathDelaySrc = record.oids[0];
+ long pathDelayDst = record.oids[record.oids.length - 1];
+ long pathDelayNum = 1;
+ long pathDelaySumDelay = Math.abs(record.ts[0] - record.ts[record.oids.length - 1]);
+ long pathDelaySumbytes = (long) record.size;
+ long pathDelayMindelay;
+ long pathDelayMaxdelay;
+ String pathDelayPath = getPath(record.oids);
+
+ try {
+ ResultSet content_path_delays = novidbinterface.getContent(
+ "pdid, id, ts, src, dst, num, path, sumdelay, sumbytes, mindelay, maxdelay",
+ " WHERE ((id = " + pathDelayId + ") AND (src = " + pathDelaySrc + ") AND (dst = " + pathDelayDst + "))",
+ "path_delays");
+
+ if (content_path_delays.next()) {
+ // Update Row
+ try {
+ long pdid = content_path_delays.getLong("pdid");
+ long pathDelayOldSumOfDelays = content_path_delays.getLong("sumdelay");
+ long pathDelayOldNumberOfDelays = content_path_delays.getLong("num");
+ long pathDelayOldSumBytes = content_path_delays.getLong("sumbytes");
+ long pathDelayOldMinDelay = content_path_delays.getLong("mindelay");
+ long pathDelayOldMaxDelay = content_path_delays.getLong("maxdelay");
+ pathDelayMindelay = pathDelayOldMinDelay;
+ if (pathDelaySumDelay < pathDelayMindelay) {
+ pathDelayMindelay = pathDelaySumDelay;
+ }
+ pathDelayMaxdelay = pathDelayOldMaxDelay;
+ if (pathDelaySumDelay > pathDelayMaxdelay) {
+ pathDelayMaxdelay = pathDelaySumDelay;
+ }
+ novidbinterface.updateRow(
+ pdid,
+ pathDelaySumDelay + pathDelayOldSumOfDelays,
+ pathDelayNum + pathDelayOldNumberOfDelays,
+ 0,
+ pathDelaySumbytes + pathDelayOldSumBytes,
+ pathDelayMindelay,
+ pathDelayMaxdelay,
+ "path_delays");
+ } catch (SQLException ex) {
+ ex.printStackTrace();
+ }
+ } else {
+ pathDelayMindelay = pathDelaySumDelay;
+ pathDelayMaxdelay = pathDelaySumDelay;
+ // Write new Row
+ novidbinterface.writeRow(
+ pathDelayId,
+ pathDelayTimestamp,
+ pathDelaySrc,
+ pathDelayDst,
+ pathDelayNum,
+ 0,
+ pathDelayPath,
+ pathDelaySumDelay,
+ pathDelaySumbytes,
+ pathDelayMindelay,
+ pathDelayMaxdelay,
+ "path_delays");
+ }
+ } catch (SQLException ex) {
+ ex.printStackTrace();
+ }
+
+ // ------------------
+ // HOP DELAYS
+ // ------------------
+ float numberOfNodes = (float) record.oids.length;
+ int currSrc;
+ int currDst;
+ long id;
+ long timestamp;
+ long srcNode;
+ long dstNode;
+ long sumOfDelays;
+ long numberOfDelays;
+ float hitcounter = 1 / (numberOfNodes - 1);
+ long sumbytes;
+ long mindelay;
+ long maxdelay;
+
+ for (currSrc = 0; currSrc < (numberOfNodes); currSrc++) {
+ for (currDst = currSrc + 1; currDst < (numberOfNodes); currDst++) {
+
+ // --- 1) Setting the values ---
+ // Timestamp
+ timestamp = record.ts[currSrc];
+
+ // Source and Destination
+ srcNode = record.oids[currSrc];
+ dstNode = record.oids[currDst];
+
+ // Sum of delays and number of delays
+ sumOfDelays = 0;
+ int i = currSrc;
+ numberOfDelays = 1;
+ for (; i < (currDst); i++) {
+ sumOfDelays = sumOfDelays + Math.abs(record.ts[i + 1] - record.ts[i]);
+ }
+
+ // ID
+ id = timestamp / (1000 * binsize);
+
+ // SumBytes
+ //logger.debug("record.size = "+record.size);
+ sumbytes = (long) record.size;
+
+ // --- 2) Read out the current content ---
+ try {
+ ResultSet content_hop_delays = novidbinterface.getContent(
+ "hdid, id, ts, src, dst, num, hits, sumdelay, sumbytes, mindelay, maxdelay",
+ " WHERE ((id = " + id + ") AND (src = " + srcNode + ") AND (dst = " + dstNode + "))",
+ "hop_delays");
+
+ // --- 3) Write the new content ---
+ if (content_hop_delays.next()) {
+ // Update Row
+ try {
+ long hdid = content_hop_delays.getLong("hdid");
+ long oldSumOfDelays = content_hop_delays.getLong("sumdelay");
+ long oldNumberOfDelays = content_hop_delays.getLong("num");
+ float oldHitcounter = content_hop_delays.getFloat("hits");
+ long oldSumBytes = content_hop_delays.getLong("sumbytes");
+ long oldMinDelay = content_hop_delays.getLong("mindelay");
+ long oldMaxDelay = content_hop_delays.getLong("maxdelay");
+ mindelay = oldMinDelay;
+ if (sumOfDelays < mindelay) {
+ mindelay = sumOfDelays;
+ }
+ maxdelay = oldMaxDelay;
+ if (sumOfDelays > maxdelay) {
+ maxdelay = sumOfDelays;
+ }
+ novidbinterface.updateRow(
+ hdid,
+ sumOfDelays + oldSumOfDelays,
+ numberOfDelays + oldNumberOfDelays,
+ hitcounter + oldHitcounter,
+ sumbytes + oldSumBytes,
+ mindelay,
+ maxdelay,
+ "hop_delays");
+ } catch (SQLException ex) {
+ ex.printStackTrace();
+ }
+ } else {
+ mindelay = sumOfDelays;
+ maxdelay = sumOfDelays;
+ // Write new Row
+ novidbinterface.writeRow(
+ id,
+ timestamp,
+ srcNode,
+ dstNode,
+ numberOfDelays,
+ hitcounter,
+ "",
+ sumOfDelays,
+ sumbytes,
+ mindelay,
+ maxdelay,
+ "hop_delays");
+ }
+ } catch (SQLException ex) {
+ ex.printStackTrace();
+ }
+ }
+ }
+ }
+ }
+
+ public void addPtProbeStats(PtProbeStats probeStats) {
+ if (probeStats == null) {
+ logger.warn("could not create ProbeStats object, returning null");
+ } else {
+ // ---- Save data in Novi database ----
+ try {
+ novidbinterface.exportNodeStats(probeStats);
+ } catch (SQLException ex) {
+ logger.warn("could not write stats to database: "+ex);
+ }
+ }
+ }
+}