bdi-network-resilience
Changes
.DS_Store 0(+0 -0)
network-resilience/.classpath 26(+15 -11)
Details
.DS_Store 0(+0 -0)
diff --git a/.DS_Store b/.DS_Store
new file mode 100644
index 0000000..14879d8
Binary files /dev/null and b/.DS_Store differ
network-resilience/.classpath 26(+15 -11)
diff --git a/network-resilience/.classpath b/network-resilience/.classpath
index eb69e2a..0f45fde 100644
--- a/network-resilience/.classpath
+++ b/network-resilience/.classpath
@@ -1,11 +1,15 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
- <classpathentry combineaccessrules="false" kind="src" path="/bdi-jade"/>
- <classpathentry kind="lib" path="/bdi-jade/lib/commons-logging-1.1.3.jar"/>
- <classpathentry kind="lib" path="/bdi-jade/lib/jade-4.3.2.jar"/>
- <classpathentry kind="lib" path="/bdi-jade/lib/log4j-1.2.17.jar"/>
- <classpathentry kind="lib" path="/bdi-jade/lib/commons-codec-1.9.jar"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/bdi-jade"/>
+ <classpathentry kind="lib" path="/bdi-jade/lib/commons-logging-1.1.3.jar"/>
+ <classpathentry kind="lib" path="/bdi-jade/lib/jade-4.3.2.jar"/>
+ <classpathentry kind="lib" path="/bdi-jade/lib/log4j-1.2.17.jar"/>
+ <classpathentry kind="lib" path="/bdi-jade/lib/commons-codec-1.9.jar"/>
+ <classpathentry kind="lib" path="lib/ws-commons-util-1.0.2.jar"/>
+ <classpathentry kind="lib" path="lib/xmlrpc-client-3.1.3.jar"/>
+ <classpathentry kind="lib" path="lib/xmlrpc-common-3.1.3.jar"/>
+ <classpathentry kind="lib" path="lib/xmlrpc-server-3.1.3.jar"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/network-resilience/lib/ws-commons-util-1.0.2.jar b/network-resilience/lib/ws-commons-util-1.0.2.jar
new file mode 100755
index 0000000..3fc364e
Binary files /dev/null and b/network-resilience/lib/ws-commons-util-1.0.2.jar differ
diff --git a/network-resilience/lib/xmlrpc-client-3.1.3.jar b/network-resilience/lib/xmlrpc-client-3.1.3.jar
new file mode 100755
index 0000000..38e3359
Binary files /dev/null and b/network-resilience/lib/xmlrpc-client-3.1.3.jar differ
diff --git a/network-resilience/lib/xmlrpc-common-3.1.3.jar b/network-resilience/lib/xmlrpc-common-3.1.3.jar
new file mode 100755
index 0000000..b5eb9df
Binary files /dev/null and b/network-resilience/lib/xmlrpc-common-3.1.3.jar differ
diff --git a/network-resilience/lib/xmlrpc-server-3.1.3.jar b/network-resilience/lib/xmlrpc-server-3.1.3.jar
new file mode 100755
index 0000000..2f930f1
Binary files /dev/null and b/network-resilience/lib/xmlrpc-server-3.1.3.jar differ
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/agent/LinkMonitorCapability.java b/network-resilience/src/br/ufrgs/inf/bdinetr/agent/LinkMonitorCapability.java
index eff3b80..6196db8 100644
--- a/network-resilience/src/br/ufrgs/inf/bdinetr/agent/LinkMonitorCapability.java
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/agent/LinkMonitorCapability.java
@@ -21,7 +21,6 @@
//----------------------------------------------------------------------------
package br.ufrgs.inf.bdinetr.agent;
-import java.util.HashSet;
import java.util.Set;
import bdi4jade.annotation.Parameter;
@@ -136,8 +135,6 @@ public class LinkMonitorCapability extends RouterAgentCapability implements
@bdi4jade.annotation.Plan
private Plan limitLinkRate;
- @bdi4jade.annotation.TransientBeliefSet
- private final Set<Link> linkEvents;
@bdi4jade.annotation.Plan
private Plan restoreLinkRate;
@bdi4jade.annotation.TransientBelief
@@ -147,7 +144,6 @@ public class LinkMonitorCapability extends RouterAgentCapability implements
GoalRequestPlan beliefGoalRequestPlan) {
this.role = linkMonitor;
role.attachObserver(this);
- this.linkEvents = new HashSet<>();
setBeliefRevisionStrategy(this);
setOptionGenerationFunction(this);
@@ -248,29 +244,24 @@ public class LinkMonitorCapability extends RouterAgentCapability implements
@Override
public void reviewBeliefs() {
- synchronized (linkEvents) {
- for (Link link : linkEvents) {
- OverUsage overUsage = new OverUsage(link);
- if (role.isOverUsage(link)) {
- Predicate<OverUsage> overUsageBelief = (Predicate<OverUsage>) getBeliefBase()
- .getBelief(overUsage);
- if (overUsageBelief == null || !overUsageBelief.getValue()) {
- belief(overUsage, true);
- belief(new AnomalousUsage(link), null);
- }
- } else {
- belief(overUsage, null);
+ for (Link link : role.getLinks()) {
+ OverUsage overUsage = new OverUsage(link);
+ if (role.isOverUsage(link)) {
+ Predicate<OverUsage> overUsageBelief = (Predicate<OverUsage>) getBeliefBase()
+ .getBelief(overUsage);
+ if (overUsageBelief == null || !overUsageBelief.getValue()) {
+ belief(overUsage, true);
+ belief(new AnomalousUsage(link), null);
}
+ } else {
+ belief(overUsage, null);
+ role.removeLink(link);
}
- linkEvents.clear();
}
}
@Override
public void update(Object o, Object arg) {
- synchronized (linkEvents) {
- this.linkEvents.add((Link) arg);
- }
getMyAgent().restart();
}
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/AnomalyDetection.java b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/AnomalyDetection.java
index c7e8681..820a6ff 100644
--- a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/AnomalyDetection.java
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/AnomalyDetection.java
@@ -28,10 +28,6 @@ import java.util.Set;
*
* addOperation: "name:action:" remoteName: "togglereport".
*
- * event
- *
- * at: "intrusion" put: (factory/event create: #( "value_victim" ));
- *
* @author Ingrid Nunes
*/
public interface AnomalyDetection extends RouterComponent {
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/Classifier.java b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/Classifier.java
index a138cb7..ea36695 100644
--- a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/Classifier.java
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/Classifier.java
@@ -24,11 +24,6 @@ package br.ufrgs.inf.bdinetr.domain;
import java.util.Set;
/**
- * event at:
- *
- * "classification" put: (factory/event create: #( "value_name" "value_source"
- * "value_destination" "value_protocol" ));
- *
* @author Ingrid Nunes
*/
public interface Classifier extends RouterComponent {
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/dummy/AbstractRouterComponent.java b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/dummy/AbstractRouterComponent.java
new file mode 100644
index 0000000..12f05f1
--- /dev/null
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/dummy/AbstractRouterComponent.java
@@ -0,0 +1,40 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2011 Ingrid Nunes
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// To contact the authors:
+// http://inf.ufrgs.br/prosoft/bdi4jade/
+//
+//----------------------------------------------------------------------------
+package br.ufrgs.inf.bdinetr.domain.dummy;
+
+import br.ufrgs.inf.bdinetr.domain.ObservableImpl;
+import br.ufrgs.inf.bdinetr.domain.Router;
+import br.ufrgs.inf.bdinetr.domain.RouterComponent;
+
+/**
+ * @author Ingrid Nunes
+ */
+public abstract class AbstractRouterComponent extends ObservableImpl implements
+ RouterComponent {
+
+ protected final Router router;
+
+ public AbstractRouterComponent(Router router) {
+ this.router = router;
+ }
+
+}
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/dummy/DummyAnomalyDetection.java b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/dummy/DummyAnomalyDetection.java
index 2adbfd6..4266967 100644
--- a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/dummy/DummyAnomalyDetection.java
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/dummy/DummyAnomalyDetection.java
@@ -28,7 +28,6 @@ import br.ufrgs.inf.bdinetr.domain.AnomalyDetection;
import br.ufrgs.inf.bdinetr.domain.Ip;
import br.ufrgs.inf.bdinetr.domain.Link;
import br.ufrgs.inf.bdinetr.domain.Router;
-import br.ufrgs.inf.bdinetr.domain.AbstractRouterComponent;
/**
* @author Ingrid Nunes
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/dummy/DummyClassifier.java b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/dummy/DummyClassifier.java
index 4ebd1fa..0f8de5b 100644
--- a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/dummy/DummyClassifier.java
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/dummy/DummyClassifier.java
@@ -28,7 +28,6 @@ import br.ufrgs.inf.bdinetr.domain.Classifier;
import br.ufrgs.inf.bdinetr.domain.Flow;
import br.ufrgs.inf.bdinetr.domain.Ip;
import br.ufrgs.inf.bdinetr.domain.Router;
-import br.ufrgs.inf.bdinetr.domain.AbstractRouterComponent;
/**
* @author Ingrid Nunes
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/dummy/DummyFlowExporter.java b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/dummy/DummyFlowExporter.java
index c63ea9a..3cdc395 100644
--- a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/dummy/DummyFlowExporter.java
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/dummy/DummyFlowExporter.java
@@ -24,7 +24,6 @@ package br.ufrgs.inf.bdinetr.domain.dummy;
import br.ufrgs.inf.bdinetr.domain.FlowExporter;
import br.ufrgs.inf.bdinetr.domain.Ip;
import br.ufrgs.inf.bdinetr.domain.Router;
-import br.ufrgs.inf.bdinetr.domain.AbstractRouterComponent;
/**
* @author Ingrid Nunes
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/dummy/DummyLinkMonitor.java b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/dummy/DummyLinkMonitor.java
index 130a8ed..912b70f 100644
--- a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/dummy/DummyLinkMonitor.java
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/dummy/DummyLinkMonitor.java
@@ -28,12 +28,12 @@ import java.util.Set;
import br.ufrgs.inf.bdinetr.domain.Link;
import br.ufrgs.inf.bdinetr.domain.LinkMonitor;
import br.ufrgs.inf.bdinetr.domain.Router;
-import br.ufrgs.inf.bdinetr.domain.AbstractRouterComponent;
/**
* @author Ingrid Nunes
*/
-public class DummyLinkMonitor extends AbstractRouterComponent implements LinkMonitor {
+public class DummyLinkMonitor extends AbstractRouterComponent implements
+ LinkMonitor {
private final Map<Link, Boolean> overUsageLinks;
@@ -56,6 +56,11 @@ public class DummyLinkMonitor extends AbstractRouterComponent implements LinkMon
}
@Override
+ public void removeLink(Link link) {
+ this.overUsageLinks.remove(link);
+ }
+
+ @Override
public void setOverUsage(Link link, boolean overUsage) {
this.overUsageLinks.put(link, overUsage);
notifyObservers(link);
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/dummy/DummyRateLimiter.java b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/dummy/DummyRateLimiter.java
index 36a9941..8f31ae2 100644
--- a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/dummy/DummyRateLimiter.java
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/dummy/DummyRateLimiter.java
@@ -24,7 +24,6 @@ package br.ufrgs.inf.bdinetr.domain.dummy;
import java.util.HashMap;
import java.util.Map;
-import br.ufrgs.inf.bdinetr.domain.AbstractRouterComponent;
import br.ufrgs.inf.bdinetr.domain.Flow;
import br.ufrgs.inf.bdinetr.domain.Ip;
import br.ufrgs.inf.bdinetr.domain.LimitLinkEvent;
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/dummy/OMNeTRouterComponentFactory.java b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/dummy/OMNeTRouterComponentFactory.java
new file mode 100644
index 0000000..ecc89b0
--- /dev/null
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/dummy/OMNeTRouterComponentFactory.java
@@ -0,0 +1,67 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2011 Ingrid Nunes
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// To contact the authors:
+// http://inf.ufrgs.br/prosoft/bdi4jade/
+//
+//----------------------------------------------------------------------------
+package br.ufrgs.inf.bdinetr.domain.dummy;
+
+import br.ufrgs.inf.bdinetr.domain.AbstractRouterComponentFactory;
+import br.ufrgs.inf.bdinetr.domain.AnomalyDetection;
+import br.ufrgs.inf.bdinetr.domain.Classifier;
+import br.ufrgs.inf.bdinetr.domain.FlowExporter;
+import br.ufrgs.inf.bdinetr.domain.LinkMonitor;
+import br.ufrgs.inf.bdinetr.domain.RateLimiter;
+import br.ufrgs.inf.bdinetr.domain.Router;
+import br.ufrgs.inf.bdinetr.domain.omnet.OMNeTAnomalyDetection;
+import br.ufrgs.inf.bdinetr.domain.omnet.OMNeTClassifier;
+import br.ufrgs.inf.bdinetr.domain.omnet.OMNeTFlowExporter;
+import br.ufrgs.inf.bdinetr.domain.omnet.OMNeTLinkMonitor;
+import br.ufrgs.inf.bdinetr.domain.omnet.OMNeTRateLimiter;
+
+/**
+ * @author Ingrid Nunes
+ */
+public class OMNeTRouterComponentFactory extends AbstractRouterComponentFactory {
+
+ @Override
+ public AnomalyDetection createAnomalyDetection(Router router) {
+ return new OMNeTAnomalyDetection(router);
+ }
+
+ @Override
+ public Classifier createClassifier(Router router) {
+ return new OMNeTClassifier(router);
+ }
+
+ @Override
+ public FlowExporter createFlowExporter(Router router) {
+ return new OMNeTFlowExporter(router);
+ }
+
+ @Override
+ public LinkMonitor createLinkMonitor(Router router) {
+ return new OMNeTLinkMonitor(router);
+ }
+
+ @Override
+ public RateLimiter createRateLimiter(Router router) {
+ return new OMNeTRateLimiter(router);
+ }
+
+}
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/LinkMonitor.java b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/LinkMonitor.java
index 8eb6e87..de6c118 100644
--- a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/LinkMonitor.java
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/LinkMonitor.java
@@ -38,6 +38,8 @@ public interface LinkMonitor extends RouterComponent, Observable {
public boolean isOverUsage(Link link);
+ public void removeLink(Link link);
+
public void setOverUsage(Link link, boolean overUsage);
}
\ No newline at end of file
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/omnet/event/AnomalousEvent.java b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/omnet/event/AnomalousEvent.java
new file mode 100644
index 0000000..62c3f10
--- /dev/null
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/omnet/event/AnomalousEvent.java
@@ -0,0 +1,48 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2011 Ingrid Nunes
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// To contact the authors:
+// http://inf.ufrgs.br/prosoft/bdi4jade/
+//
+//----------------------------------------------------------------------------
+package br.ufrgs.inf.bdinetr.domain.omnet.event;
+
+import br.ufrgs.inf.bdinetr.domain.Ip;
+
+/**
+ * event
+ *
+ * at: "intrusion" put: (factory/event create: #( "value_victim" ));
+ *
+ * @author Alberto Egon and Ingrid Nunes
+ */
+public class AnomalousEvent implements OMNeTEvent {
+
+ public static final String NAME = "intrusion";
+
+ private Ip ip;
+
+ public AnomalousEvent(String s) {
+ String[] parts = s.split(";");
+ this.ip = new Ip(parts[1]);
+ }
+
+ public Ip getIp() {
+ return ip;
+ }
+
+}
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/omnet/event/OMNeTEvent.java b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/omnet/event/OMNeTEvent.java
new file mode 100644
index 0000000..e4309c8
--- /dev/null
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/omnet/event/OMNeTEvent.java
@@ -0,0 +1,29 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2011 Ingrid Nunes
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// To contact the authors:
+// http://inf.ufrgs.br/prosoft/bdi4jade/
+//
+//----------------------------------------------------------------------------
+package br.ufrgs.inf.bdinetr.domain.omnet.event;
+
+/**
+ * @author Alberto Egon and Ingrid Nunes
+ */
+public interface OMNeTEvent {
+
+}
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/omnet/event/OverUsageEvent.java b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/omnet/event/OverUsageEvent.java
new file mode 100644
index 0000000..c8ca7bc
--- /dev/null
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/omnet/event/OverUsageEvent.java
@@ -0,0 +1,50 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2011 Ingrid Nunes
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// To contact the authors:
+// http://inf.ufrgs.br/prosoft/bdi4jade/
+//
+//----------------------------------------------------------------------------
+package br.ufrgs.inf.bdinetr.domain.omnet.event;
+
+import br.ufrgs.inf.bdinetr.domain.Link;
+
+/**
+ * event at:
+ *
+ * "load" put: (factory/event create: #( "value_name" "value_index" ));
+ *
+ * --> value_name: ??? --> value_index: id do link
+ *
+ * @author Alberto Egon and Ingrid Nunes
+ */
+public class OverUsageEvent implements OMNeTEvent {
+
+ public static final String NAME = "load";
+
+ private Link link;
+
+ public OverUsageEvent(String s) {
+ String[] parts = s.split(";");
+ this.link = new Link(parts[2]);
+ }
+
+ public Link getLink() {
+ return link;
+ }
+
+}
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/omnet/event/ThreatEvent.java b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/omnet/event/ThreatEvent.java
new file mode 100644
index 0000000..c2cc5cc
--- /dev/null
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/omnet/event/ThreatEvent.java
@@ -0,0 +1,50 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2011 Ingrid Nunes
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// To contact the authors:
+// http://inf.ufrgs.br/prosoft/bdi4jade/
+//
+//----------------------------------------------------------------------------
+package br.ufrgs.inf.bdinetr.domain.omnet.event;
+
+import br.ufrgs.inf.bdinetr.domain.Flow;
+import br.ufrgs.inf.bdinetr.domain.Ip;
+
+/**
+ * event at:
+ *
+ * "classification" put: (factory/event create: #( "value_name" "value_source"
+ * "value_destination" "value_protocol" ));
+ *
+ * @author Alberto Egon and Ingrid Nunes
+ */
+public class ThreatEvent implements OMNeTEvent {
+
+ public static final String NAME = "classification";
+
+ private Flow flow;
+
+ public ThreatEvent(String s) {
+ String[] parts = s.split(";");
+ this.flow = new Flow(new Ip(parts[2]), 0, new Ip(parts[3]), 0, parts[4]);
+ }
+
+ public Flow getFlow() {
+ return flow;
+ }
+
+}
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/omnet/EventBroker.java b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/omnet/EventBroker.java
new file mode 100644
index 0000000..86335a6
--- /dev/null
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/omnet/EventBroker.java
@@ -0,0 +1,119 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2011 Ingrid Nunes
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// To contact the authors:
+// http://inf.ufrgs.br/prosoft/bdi4jade/
+//
+//----------------------------------------------------------------------------
+package br.ufrgs.inf.bdinetr.domain.omnet;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.ServerSocket;
+import java.net.Socket;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import br.ufrgs.inf.bdinetr.domain.ObservableImpl;
+import br.ufrgs.inf.bdinetr.domain.omnet.event.AnomalousEvent;
+import br.ufrgs.inf.bdinetr.domain.omnet.event.OMNeTEvent;
+import br.ufrgs.inf.bdinetr.domain.omnet.event.OverUsageEvent;
+import br.ufrgs.inf.bdinetr.domain.omnet.event.ThreatEvent;
+
+/**
+ * @author Alberto Egon and Ingrid Nunes
+ */
+public class EventBroker extends ObservableImpl {
+
+ private class BrokerThread extends Thread {
+
+ Socket eventSource = null;
+
+ public BrokerThread(Socket s) {
+ eventSource = s;
+ }
+
+ public void run() {
+ try {
+ // read the event via the socket
+ BufferedReader in = new BufferedReader(new InputStreamReader(
+ eventSource.getInputStream()));
+ String inputLine = in.readLine();
+ log.info("Read event from socket = " + inputLine);
+
+ OMNeTEvent event = null;
+ if (inputLine.startsWith(OverUsageEvent.NAME)) {
+ event = new OverUsageEvent(inputLine);
+ } else if (inputLine.startsWith(AnomalousEvent.NAME)) {
+ event = new AnomalousEvent(inputLine);
+ } else if (inputLine.startsWith(ThreatEvent.NAME)) {
+ event = new ThreatEvent(inputLine);
+ }
+
+ // notify observers
+ if (event != null) {
+ notifyObservers(event);
+ }
+
+ // close stuff
+ in.close();
+ eventSource.close();
+ } catch (IOException ioe) {
+ ioe.printStackTrace();
+ }
+ }
+ }
+
+ private static final EventBroker INSTANCE = new EventBroker();
+ private static final Log log = LogFactory.getLog(EventBroker.class);
+ private static final int SOCKET_PORT = 4444;
+
+ public static EventBroker getInstance() {
+ return INSTANCE;
+ }
+
+ private ServerSocket serverSocket = null;
+
+ public EventBroker() {
+ try {
+ // creates the server socket
+ serverSocket = new ServerSocket(SOCKET_PORT);
+ log.info("EventBroker is ready...");
+ } catch (IOException ioe) {
+ ioe.printStackTrace();
+ }
+
+ // creates a thread that will keep the socket open and will spawn new
+ // threads for handling each new connection
+ (new Thread() {
+ public void run() {
+ while (true) {
+ try {
+ Socket eventSource = serverSocket.accept();
+ // FIXME events order?
+ new BrokerThread(eventSource).start();
+ } catch (IOException ioe) {
+ ioe.printStackTrace();
+ }
+ }
+ }
+ }).start();
+ }
+
+}
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/omnet/OMNeTAnomalyDetection.java b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/omnet/OMNeTAnomalyDetection.java
new file mode 100644
index 0000000..e0c644d
--- /dev/null
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/omnet/OMNeTAnomalyDetection.java
@@ -0,0 +1,62 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2011 Ingrid Nunes
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// To contact the authors:
+// http://inf.ufrgs.br/prosoft/bdi4jade/
+//
+//----------------------------------------------------------------------------
+package br.ufrgs.inf.bdinetr.domain.omnet;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import br.ufrgs.inf.bdinetr.domain.AnomalyDetection;
+import br.ufrgs.inf.bdinetr.domain.Ip;
+import br.ufrgs.inf.bdinetr.domain.Link;
+import br.ufrgs.inf.bdinetr.domain.Observer;
+import br.ufrgs.inf.bdinetr.domain.Router;
+import br.ufrgs.inf.bdinetr.domain.omnet.event.AnomalousEvent;
+
+/**
+ * @author Alberto Egon and Ingrid Nunes
+ */
+public class OMNeTAnomalyDetection extends OMNeTRouterComponent implements
+ AnomalyDetection, Observer {
+
+ public OMNeTAnomalyDetection(Router router) {
+ super(router);
+ EventBroker.getInstance().attachObserver(this);
+ }
+
+ @Override
+ public Set<Ip> detectIntrusion(Link link) {
+ Set<Ip> intrusions = new HashSet<>();
+ if (link.getId().equals("AFFECTED_LINK")) {
+ intrusions.add(new Ip("victim1"));
+ intrusions.add(new Ip("victim2"));
+ }
+ return intrusions;
+ }
+
+ @Override
+ public void update(Object o, Object arg) {
+ if (arg instanceof AnomalousEvent) {
+ // TODO Auto-generated method stub
+ }
+ }
+
+}
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/omnet/OMNeTClassifier.java b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/omnet/OMNeTClassifier.java
new file mode 100644
index 0000000..e9333b3
--- /dev/null
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/omnet/OMNeTClassifier.java
@@ -0,0 +1,67 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2011 Ingrid Nunes
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// To contact the authors:
+// http://inf.ufrgs.br/prosoft/bdi4jade/
+//
+//----------------------------------------------------------------------------
+package br.ufrgs.inf.bdinetr.domain.omnet;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import br.ufrgs.inf.bdinetr.domain.Classifier;
+import br.ufrgs.inf.bdinetr.domain.Flow;
+import br.ufrgs.inf.bdinetr.domain.Ip;
+import br.ufrgs.inf.bdinetr.domain.Observer;
+import br.ufrgs.inf.bdinetr.domain.Router;
+import br.ufrgs.inf.bdinetr.domain.omnet.event.ThreatEvent;
+
+/**
+ * @author Alberto Egon and Ingrid Nunes
+ */
+public class OMNeTClassifier extends OMNeTRouterComponent implements
+ Classifier, Observer {
+
+ public OMNeTClassifier(Router router) {
+ super(router);
+ EventBroker.getInstance().attachObserver(this);
+ }
+
+ @Override
+ public Set<Flow> classifyFlows(Ip ip) {
+ Set<Flow> flows = new HashSet<>();
+ if (ip.getAddress().equals("victim1")) {
+ flows.add(new Flow(new Ip("DDoS1"), 80, new Ip("victim1"), 80,
+ "http"));
+ flows.add(new Flow(new Ip("DDoS2"), 80, new Ip("victim1"), 80,
+ "http"));
+ } else if (ip.getAddress().equals("victim2")) {
+ flows.add(new Flow(new Ip("DDoS3"), 80, new Ip("victim2"), 80,
+ "http"));
+ }
+ return flows;
+ }
+
+ @Override
+ public void update(Object o, Object arg) {
+ if (arg instanceof ThreatEvent) {
+ // TODO Auto-generated method stub
+ }
+ }
+
+}
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/omnet/OMNeTFlowExporter.java b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/omnet/OMNeTFlowExporter.java
new file mode 100644
index 0000000..a901561
--- /dev/null
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/omnet/OMNeTFlowExporter.java
@@ -0,0 +1,47 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2011 Ingrid Nunes
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// To contact the authors:
+// http://inf.ufrgs.br/prosoft/bdi4jade/
+//
+//----------------------------------------------------------------------------
+package br.ufrgs.inf.bdinetr.domain.omnet;
+
+import br.ufrgs.inf.bdinetr.domain.FlowExporter;
+import br.ufrgs.inf.bdinetr.domain.Ip;
+import br.ufrgs.inf.bdinetr.domain.Router;
+
+/**
+ * @author Alberto Egon and Ingrid Nunes
+ */
+public class OMNeTFlowExporter extends OMNeTRouterComponent implements
+ FlowExporter {
+
+ public OMNeTFlowExporter(Router router) {
+ super(router);
+ }
+
+ @Override
+ public void turnFlowExporterOn(Ip ip) {
+ Object[] params = new Object[3];
+ params[0] = "Inet.sas1.core0.flowExporter";
+ params[1] = new Integer(60);
+ params[2] = new Integer(10);
+ invoke("setthreshold", params);
+ }
+
+}
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/omnet/OMNeTLinkMonitor.java b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/omnet/OMNeTLinkMonitor.java
new file mode 100644
index 0000000..921f3d9
--- /dev/null
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/omnet/OMNeTLinkMonitor.java
@@ -0,0 +1,79 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2011 Ingrid Nunes
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// To contact the authors:
+// http://inf.ufrgs.br/prosoft/bdi4jade/
+//
+//----------------------------------------------------------------------------
+package br.ufrgs.inf.bdinetr.domain.omnet;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import br.ufrgs.inf.bdinetr.domain.Link;
+import br.ufrgs.inf.bdinetr.domain.LinkMonitor;
+import br.ufrgs.inf.bdinetr.domain.Observer;
+import br.ufrgs.inf.bdinetr.domain.Router;
+import br.ufrgs.inf.bdinetr.domain.omnet.event.OverUsageEvent;
+
+/**
+ * @author Alberto Egon and Ingrid Nunes
+ */
+public class OMNeTLinkMonitor extends OMNeTRouterComponent implements
+ LinkMonitor, Observer {
+
+ private final Map<Link, Boolean> overUsageLinks;
+
+ public OMNeTLinkMonitor(Router router) {
+ super(router);
+ this.overUsageLinks = new HashMap<>();
+ EventBroker.getInstance().attachObserver(this);
+ }
+
+ @Override
+ public Set<Link> getLinks() {
+ return overUsageLinks.keySet();
+ }
+
+ @Override
+ public boolean isOverUsage(Link link) {
+ Boolean overUsage = this.overUsageLinks.get(link);
+ if (overUsage == null)
+ overUsage = false;
+ return overUsage;
+ }
+
+ @Override
+ public void removeLink(Link link) {
+ this.overUsageLinks.remove(link);
+ }
+
+ @Override
+ public void setOverUsage(Link link, boolean overUsage) {
+ this.overUsageLinks.put(link, overUsage);
+ notifyObservers(link);
+ }
+
+ @Override
+ public void update(Object o, Object arg) {
+ if (arg instanceof OverUsageEvent) {
+ setOverUsage(((OverUsageEvent) o).getLink(), true);
+ }
+ }
+
+}
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/omnet/OMNeTRateLimiter.java b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/omnet/OMNeTRateLimiter.java
new file mode 100644
index 0000000..396b75a
--- /dev/null
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/omnet/OMNeTRateLimiter.java
@@ -0,0 +1,87 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2011 Ingrid Nunes
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// To contact the authors:
+// http://inf.ufrgs.br/prosoft/bdi4jade/
+//
+//----------------------------------------------------------------------------
+package br.ufrgs.inf.bdinetr.domain.omnet;
+
+import br.ufrgs.inf.bdinetr.domain.Flow;
+import br.ufrgs.inf.bdinetr.domain.Ip;
+import br.ufrgs.inf.bdinetr.domain.LimitLinkEvent;
+import br.ufrgs.inf.bdinetr.domain.Link;
+import br.ufrgs.inf.bdinetr.domain.RateLimiter;
+import br.ufrgs.inf.bdinetr.domain.Router;
+
+/**
+ * @author Alberto Egon and Ingrid Nunes
+ */
+public class OMNeTRateLimiter extends OMNeTRouterComponent implements
+ RateLimiter {
+
+ public OMNeTRateLimiter(Router router) {
+ super(router);
+ }
+
+ @Override
+ public void limitFlow(Flow flow, double rate) {
+ Object[] params = new Object[5];
+ params[0] = "Inet.sas1.core0.rateLimiter";
+ params[1] = flow.getSrcIp().getAddress();
+ params[2] = flow.getDstIp().getAddress();
+ params[3] = flow.getProtocol();
+ params[4] = new Integer(90); // FIXME
+ invoke("limitflow", params);
+ }
+
+ @Override
+ public void limitIp(Ip ip, double rate) {
+ Object[] params = new Object[3];
+ params[0] = "Inet.sas1.core0.rateLimiter";
+ params[1] = ip.getAddress();
+ params[2] = new Integer(50); // FIXME
+ invoke("limitip", params);
+ }
+
+ @Override
+ public void limitLink(Link link, double rate) {
+ Object[] params = new Object[3];
+ params[0] = "Inet.sas1.core0.rateLimiter";
+ params[1] = link.getId();
+ params[2] = new Integer(90); // FIXME
+ invoke("limitlink", params);
+
+ notifyObservers(new LimitLinkEvent(link));
+ }
+
+ @Override
+ public void unlimitFlow(Flow flow) {
+ // TODO unsupported by OMNeT
+ }
+
+ @Override
+ public void unlimitIp(Ip ip) {
+ // TODO unsupported by OMNeT
+ }
+
+ @Override
+ public void unlimitLink(Link link) {
+ // TODO unsupported by OMNeT
+ }
+
+}
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/omnet/OMNeTRouterComponent.java b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/omnet/OMNeTRouterComponent.java
new file mode 100644
index 0000000..f1120ab
--- /dev/null
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/omnet/OMNeTRouterComponent.java
@@ -0,0 +1,82 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2011 Ingrid Nunes
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// To contact the authors:
+// http://inf.ufrgs.br/prosoft/bdi4jade/
+//
+//----------------------------------------------------------------------------
+package br.ufrgs.inf.bdinetr.domain.omnet;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.xmlrpc.XmlRpcException;
+import org.apache.xmlrpc.client.XmlRpcClient;
+import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
+
+import br.ufrgs.inf.bdinetr.domain.ObservableImpl;
+import br.ufrgs.inf.bdinetr.domain.Router;
+import br.ufrgs.inf.bdinetr.domain.RouterComponent;
+
+/**
+ * @author Alberto Egon and Ingrid Nunes
+ */
+public abstract class OMNeTRouterComponent extends ObservableImpl implements
+ RouterComponent {
+
+ private final XmlRpcClient adaptorRPC;
+ protected final Log log;
+ protected final Router router;
+
+ public OMNeTRouterComponent(Router router) {
+ this.router = router;
+ this.log = LogFactory.getLog(getClass());
+
+ XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
+
+ try {
+ config.setServerURL(new URL(router.getIp().getAddress()));
+ } catch (MalformedURLException mue) {
+ mue.printStackTrace();
+ }
+
+ this.adaptorRPC = new XmlRpcClient();
+ this.adaptorRPC.setConfig(config);
+ }
+
+ public Object invoke(String remoteOp, Object[] args) {
+ log.info("Invoking operation: " + remoteOp);
+ for (int i = 0; i < args.length; i++) {
+ log.info("args[" + i + "] = " + args[i]);
+ }
+
+ Object result = null;
+
+ try {
+ result = this.adaptorRPC.execute(router.getType() + "." + remoteOp,
+ args);
+ } catch (XmlRpcException xre) {
+ xre.printStackTrace();
+ }
+
+ log.info("Done");
+ return result;
+ }
+
+}
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/Router.java b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/Router.java
index 58ba016..acd8e7a 100644
--- a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/Router.java
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/Router.java
@@ -31,9 +31,16 @@ public class Router {
private final Map<Role, RouterComponent> components;
private final Ip ip;
+ private final String type;
- public Router(final Ip id, int roles, AbstractRouterComponentFactory factory) {
- this.ip = id;
+ public Router(final Ip ip, int roles, AbstractRouterComponentFactory factory) {
+ this(ip, null, roles, factory);
+ }
+
+ public Router(final Ip ip, final String type, int roles,
+ AbstractRouterComponentFactory factory) {
+ this.ip = ip;
+ this.type = type;
this.components = new HashMap<>();
for (Role role : Role.values()) {
if (role.isPresent(roles)) {
@@ -47,7 +54,7 @@ public class Router {
public boolean equals(Object obj) {
if (obj instanceof Router) {
Router d = (Router) obj;
- return this.ip.equals(d.ip);
+ return (this.ip + this.type).equals((d.ip + type));
}
return false;
}
@@ -60,9 +67,13 @@ public class Router {
return components.get(role);
}
+ public String getType() {
+ return type;
+ }
+
@Override
public int hashCode() {
- return ip == null ? 0 : ip.hashCode();
+ return (this.ip + this.type).hashCode();
}
public boolean hasRole(Role role) {