bdi-network-resilience
Changes
network-resilience/.classpath 10(+10 -0)
network-resilience/.gitignore 1(+1 -0)
network-resilience/.project 17(+17 -0)
Details
network-resilience/.classpath 10(+10 -0)
diff --git a/network-resilience/.classpath b/network-resilience/.classpath
new file mode 100644
index 0000000..cec47e5
--- /dev/null
+++ b/network-resilience/.classpath
@@ -0,0 +1,10 @@
+<?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="output" path="bin"/>
+</classpath>
network-resilience/.gitignore 1(+1 -0)
diff --git a/network-resilience/.gitignore b/network-resilience/.gitignore
new file mode 100644
index 0000000..5e56e04
--- /dev/null
+++ b/network-resilience/.gitignore
@@ -0,0 +1 @@
+/bin
network-resilience/.project 17(+17 -0)
diff --git a/network-resilience/.project b/network-resilience/.project
new file mode 100644
index 0000000..93b6f47
--- /dev/null
+++ b/network-resilience/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>network-resilience</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/network-resilience/.settings/org.eclipse.jdt.core.prefs b/network-resilience/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..838bd9d
--- /dev/null
+++ b/network-resilience/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,11 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.7
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/BDINetRAgent.java b/network-resilience/src/br/ufrgs/inf/bdinetr/BDINetRAgent.java
new file mode 100644
index 0000000..2628e09
--- /dev/null
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/BDINetRAgent.java
@@ -0,0 +1,68 @@
+//----------------------------------------------------------------------------
+// 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;
+
+import bdi4jade.belief.Belief;
+import bdi4jade.belief.TransientBelief;
+import bdi4jade.core.Capability;
+import bdi4jade.core.SingleCapabilityAgent;
+import br.ufrgs.inf.bdinetr.domain.Device;
+
+/**
+ * @author Ingrid Nunes
+ */
+public class BDINetRAgent extends SingleCapabilityAgent {
+
+ private static final long serialVersionUID = 6534875498063013722L;
+
+ public static class RootCapability extends Capability {
+
+ private static final long serialVersionUID = -2156730094556459899L;
+
+ public static final String DEVICE_BELIEF = "device";
+
+ @bdi4jade.annotation.Belief
+ private Belief<String, Device> device = new TransientBelief<>(
+ DEVICE_BELIEF);
+
+ public RootCapability(Device device) {
+ this.device.setValue(device);
+ }
+
+ }
+
+ public BDINetRAgent(Device device) {
+ this(device, new Capability[0]);
+ }
+
+ public BDINetRAgent(Device device, Capability capability) {
+ this(device, new Capability[] { capability });
+ }
+
+ public BDINetRAgent(Device device, Capability[] capabilities) {
+ super(new RootCapability(device));
+ for (Capability capability : capabilities) {
+ this.getCapability().addPartCapability(capability);
+ }
+ }
+
+}
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/BDINetRApp.java b/network-resilience/src/br/ufrgs/inf/bdinetr/BDINetRApp.java
new file mode 100644
index 0000000..ca08a1b
--- /dev/null
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/BDINetRApp.java
@@ -0,0 +1,157 @@
+//----------------------------------------------------------------------------
+// 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;
+
+import jade.BootProfileImpl;
+import jade.core.ProfileImpl;
+import jade.wrapper.AgentContainer;
+import jade.wrapper.AgentController;
+import jade.wrapper.PlatformController;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.log4j.PropertyConfigurator;
+
+import bdi4jade.core.AbstractBDIAgent;
+import bdi4jade.examples.BDI4JADEExamplesPanel;
+import br.ufrgs.inf.bdinetr.capability.LinkMonitorCapability;
+import br.ufrgs.inf.bdinetr.capability.RateLimiterCapability;
+import br.ufrgs.inf.bdinetr.domain.Device;
+import br.ufrgs.inf.bdinetr.domain.Link;
+import br.ufrgs.inf.bdinetr.domain.Network;
+
+/**
+ * @author Ingrid Nunes
+ */
+public class BDINetRApp {
+
+ class LinkUsageUpdater extends TimerTask {
+ @Override
+ public void run() {
+ Random random = new Random(System.currentTimeMillis());
+ log.info("Updating link usage");
+ for (Link link : NETWORK.getLinks()) {
+ link.setUsedBandwidth(random.nextDouble() * link.getBandwidth());
+ }
+ log.info("Restarting agents");
+ for (AbstractBDIAgent agent : AGENTS.values()) {
+ agent.restart();
+ }
+ }
+ }
+
+ private static final Map<String, AbstractBDIAgent> AGENTS;
+
+ private static final Network NETWORK;
+
+ static {
+ PropertyConfigurator.configure(BDINetRApp.class
+ .getResource("log4j.properties"));
+
+ NETWORK = new Network();
+ Device firewall1 = new Device("Firewall 1");
+ NETWORK.addDevice(firewall1);
+ Device firewall2 = new Device("Firewall 2");
+ NETWORK.addDevice(firewall2);
+ Device firewall3 = new Device("Firewall 3");
+ NETWORK.addDevice(firewall3);
+ Device rateLimiter1 = new Device("Rate Limiter 1");
+ NETWORK.addDevice(rateLimiter1);
+ Device rateLimiter2 = new Device("Rate Limiter 2");
+ NETWORK.addDevice(rateLimiter2);
+
+ NETWORK.addLink(new Link("F1_RL1", 10.0, firewall1, rateLimiter1));
+ NETWORK.addLink(new Link("F2_RL2", 8.0, firewall2, rateLimiter2));
+ NETWORK.addLink(new Link("F3_RL1", 7.0, firewall3, rateLimiter1));
+ NETWORK.addLink(new Link("F1_RL2", 7.0, firewall1, rateLimiter2));
+ NETWORK.addLink(new Link("F2_RL1", 8.0, firewall2, rateLimiter1));
+ NETWORK.addLink(new Link("F3_RL2", 10.0, firewall3, rateLimiter2));
+
+ AGENTS = new HashMap<>();
+ AGENTS.put(firewall1.getId(), new BDINetRAgent(firewall1,
+ new LinkMonitorCapability()));
+ AGENTS.put(firewall2.getId(), new BDINetRAgent(firewall2,
+ new LinkMonitorCapability()));
+ AGENTS.put(firewall3.getId(), new BDINetRAgent(firewall3,
+ new LinkMonitorCapability()));
+ AGENTS.put(rateLimiter1.getId(), new BDINetRAgent(rateLimiter1,
+ new RateLimiterCapability()));
+ AGENTS.put(rateLimiter2.getId(), new BDINetRAgent(rateLimiter2,
+ new RateLimiterCapability()));
+
+ }
+
+ public static void main(String[] args) {
+ new BDINetRApp().run();
+ }
+
+ private ProfileImpl bootProfile;
+ private final Log log;
+ private jade.core.Runtime runtime;
+
+ private Timer timer;
+
+ public BDINetRApp() {
+ this.log = LogFactory.getLog(this.getClass());
+ this.timer = new Timer();
+
+ List<String> params = new ArrayList<String>();
+ params.add("-gui");
+ params.add("-detect-main:false");
+
+ log.info("Plataform parameters: " + params);
+
+ this.bootProfile = new BootProfileImpl(params.toArray(new String[0]));
+
+ this.runtime = jade.core.Runtime.instance();
+ PlatformController controller = runtime
+ .createMainContainer(bootProfile);
+
+ for (String agentName : AGENTS.keySet()) {
+ try {
+ AgentController ac = ((AgentContainer) controller)
+ .acceptNewAgent(agentName, AGENTS.get(agentName));
+ ac.start();
+ } catch (Exception e) {
+ log.error(e);
+ }
+ }
+ }
+
+ /**
+ * Creates and shows a GUI whose content pane is an
+ * {@link BDI4JADEExamplesPanel}.
+ */
+ public void run() {
+ int interval = 10 * 1000;
+ this.timer.schedule(new LinkUsageUpdater(), interval, interval);
+ }
+
+}
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/capability/AnomalyDetectionCapability.java b/network-resilience/src/br/ufrgs/inf/bdinetr/capability/AnomalyDetectionCapability.java
new file mode 100644
index 0000000..ac3d5c3
--- /dev/null
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/capability/AnomalyDetectionCapability.java
@@ -0,0 +1,99 @@
+//----------------------------------------------------------------------------
+// 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.capability;
+
+import java.util.Set;
+
+import bdi4jade.belief.Belief;
+import bdi4jade.belief.PropositionalBelief;
+import bdi4jade.core.Capability;
+import bdi4jade.core.GoalUpdateSet;
+import bdi4jade.goal.BeliefGoal;
+import bdi4jade.goal.PropositionalBeliefValueGoal;
+import bdi4jade.reasoning.AbstractReasoningStrategy;
+import bdi4jade.reasoning.OptionGenerationFunction;
+import br.ufrgs.inf.bdinetr.domain.IpPreposition.Anomalous;
+import br.ufrgs.inf.bdinetr.domain.IpPreposition.Benign;
+import br.ufrgs.inf.bdinetr.domain.IpPreposition.Restricted;
+
+/**
+ * @author Ingrid Nunes
+ */
+public class AnomalyDetectionCapability extends Capability {
+
+ private class ReasoningStrategy extends AbstractReasoningStrategy implements
+ OptionGenerationFunction {
+ @Override
+ public void generateGoals(GoalUpdateSet goalUpdateSet) {
+ Set<Belief<?, ?>> anomalousIpBeliefs = getBeliefBase()
+ .getBeliefsByType(Anomalous.class);
+ for (Belief<?, ?> belief : anomalousIpBeliefs) {
+ PropositionalBelief<Anomalous> anomalous = (PropositionalBelief<Anomalous>) belief;
+ if (anomalous.getValue()) {
+ getMyAgent()
+ .addGoal(
+ AnomalyDetectionCapability.this,
+ new PropositionalBeliefValueGoal<Restricted>(
+ new Restricted(anomalous.getName()
+ .getIp()), Boolean.TRUE));
+ log.debug("goal(restricted(" + anomalous.getName().getIp()
+ + "))");
+ getMyAgent().addGoal(
+ AnomalyDetectionCapability.this,
+ new BeliefGoal<Benign>(new Benign(anomalous
+ .getName().getIp())));
+ log.debug("goal(?benign(" + anomalous.getName().getIp()
+ + "))");
+ }
+ }
+
+ Set<Belief<?, ?>> restrictedBeliefs = getBeliefBase()
+ .getBeliefsByType(Restricted.class);
+ for (Belief<?, ?> belief : restrictedBeliefs) {
+ PropositionalBelief<Restricted> restricted = (PropositionalBelief<Restricted>) belief;
+ if (restricted.getValue()) {
+ PropositionalBelief<Anomalous> anomalous = (PropositionalBelief<Anomalous>) getBeliefBase()
+ .getBelief(
+ new Anomalous(restricted.getName().getIp()));
+ if (anomalous != null && !anomalous.getValue()) {
+ getMyAgent().addGoal(
+ AnomalyDetectionCapability.this,
+ new PropositionalBeliefValueGoal<Restricted>(
+ new Restricted(restricted.getName()
+ .getIp()), Boolean.FALSE));
+ log.debug("goal(not restricted("
+ + restricted.getName().getIp() + "))");
+ }
+
+ }
+ }
+ }
+ }
+
+ private static final long serialVersionUID = -1705728861020677126L;
+
+ public AnomalyDetectionCapability() {
+ ReasoningStrategy strategy = new ReasoningStrategy();
+ setOptionGenerationFunction(strategy);
+ }
+
+}
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/capability/ClassifierCapability.java b/network-resilience/src/br/ufrgs/inf/bdinetr/capability/ClassifierCapability.java
new file mode 100644
index 0000000..150bef6
--- /dev/null
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/capability/ClassifierCapability.java
@@ -0,0 +1,69 @@
+//----------------------------------------------------------------------------
+// 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.capability;
+
+import java.util.Set;
+
+import bdi4jade.belief.Belief;
+import bdi4jade.belief.PropositionalBelief;
+import bdi4jade.core.Capability;
+import bdi4jade.core.GoalUpdateSet;
+import bdi4jade.goal.PropositionalBeliefValueGoal;
+import bdi4jade.reasoning.AbstractReasoningStrategy;
+import bdi4jade.reasoning.OptionGenerationFunction;
+import br.ufrgs.inf.bdinetr.domain.FlowPreposition.Threat;
+import br.ufrgs.inf.bdinetr.domain.FlowPreposition.ThreatResponded;
+
+/**
+ * @author Ingrid Nunes
+ */
+public class ClassifierCapability extends Capability {
+
+ private class ReasoningStrategy extends AbstractReasoningStrategy implements
+ OptionGenerationFunction {
+ @Override
+ public void generateGoals(GoalUpdateSet goalUpdateSet) {
+ Set<Belief<?, ?>> threatBeliefs = getBeliefBase().getBeliefsByType(
+ Threat.class);
+ for (Belief<?, ?> belief : threatBeliefs) {
+ PropositionalBelief<Threat> threat = (PropositionalBelief<Threat>) belief;
+ if (threat.getValue()) {
+ getMyAgent().addGoal(
+ ClassifierCapability.this,
+ new PropositionalBeliefValueGoal<ThreatResponded>(
+ new ThreatResponded(threat.getName()
+ .getFlow()), Boolean.TRUE));
+ log.debug("goal(threatResponded("
+ + threat.getName().getFlow() + "))");
+ }
+ }
+ }
+ }
+
+ private static final long serialVersionUID = -1705728861020677126L;
+
+ public ClassifierCapability() {
+ ReasoningStrategy strategy = new ReasoningStrategy();
+ setOptionGenerationFunction(strategy);
+ }
+
+}
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/capability/FlowExporterCapability.java b/network-resilience/src/br/ufrgs/inf/bdinetr/capability/FlowExporterCapability.java
new file mode 100644
index 0000000..19e51de
--- /dev/null
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/capability/FlowExporterCapability.java
@@ -0,0 +1,35 @@
+//----------------------------------------------------------------------------
+// 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.capability;
+
+import bdi4jade.core.Capability;
+import bdi4jade.reasoning.AbstractReasoningStrategy;
+import bdi4jade.reasoning.BeliefRevisionStrategy;
+
+/**
+ * @author Ingrid Nunes
+ */
+public class FlowExporterCapability extends Capability {
+
+ private static final long serialVersionUID = -1705728861020677126L;
+
+}
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/capability/LinkMonitorCapability.java b/network-resilience/src/br/ufrgs/inf/bdinetr/capability/LinkMonitorCapability.java
new file mode 100644
index 0000000..7370a56
--- /dev/null
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/capability/LinkMonitorCapability.java
@@ -0,0 +1,162 @@
+//----------------------------------------------------------------------------
+// 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.capability;
+
+import java.util.Set;
+
+import bdi4jade.belief.Belief;
+import bdi4jade.belief.PropositionalBelief;
+import bdi4jade.belief.TransientBelief;
+import bdi4jade.belief.TransientPropositionalBelief;
+import bdi4jade.core.Capability;
+import bdi4jade.core.GoalUpdateSet;
+import bdi4jade.goal.BeliefGoal;
+import bdi4jade.goal.PropositionalBeliefValueGoal;
+import bdi4jade.reasoning.AbstractReasoningStrategy;
+import bdi4jade.reasoning.BeliefRevisionStrategy;
+import bdi4jade.reasoning.OptionGenerationFunction;
+import br.ufrgs.inf.bdinetr.BDINetRAgent.RootCapability;
+import br.ufrgs.inf.bdinetr.domain.Device;
+import br.ufrgs.inf.bdinetr.domain.Link;
+import br.ufrgs.inf.bdinetr.domain.LinkProposition.AttackPrevented;
+import br.ufrgs.inf.bdinetr.domain.LinkProposition.FullyOperational;
+import br.ufrgs.inf.bdinetr.domain.LinkProposition.OverUsage;
+import br.ufrgs.inf.bdinetr.domain.LinkProposition.RegularUsage;
+import br.ufrgs.inf.bdinetr.domain.LinkProposition.Usage;
+
+/**
+ * @author Ingrid Nunes
+ */
+public class LinkMonitorCapability extends Capability {
+
+ private class ReasoningStrategy extends AbstractReasoningStrategy implements
+ BeliefRevisionStrategy, OptionGenerationFunction {
+ @Override
+ public void generateGoals(GoalUpdateSet goalUpdateSet) {
+ Set<Belief<?, ?>> overUsageBeliefs = getBeliefBase()
+ .getBeliefsByType(OverUsage.class);
+ for (Belief<?, ?> belief : overUsageBeliefs) {
+ PropositionalBelief<OverUsage> overUsage = (PropositionalBelief<OverUsage>) belief;
+ if (overUsage.getValue()) {
+ getMyAgent().addGoal(
+ LinkMonitorCapability.this,
+ new PropositionalBeliefValueGoal<AttackPrevented>(
+ new AttackPrevented(overUsage.getName()
+ .getLink()), Boolean.TRUE));
+ log.debug("goal(attackPrevented("
+ + overUsage.getName().getLink() + "))");
+ getMyAgent().addGoal(
+ LinkMonitorCapability.this,
+ new BeliefGoal<RegularUsage>(new RegularUsage(
+ overUsage.getName().getLink())));
+ log.debug("goal(?regularUsage("
+ + overUsage.getName().getLink() + "))");
+ }
+ }
+
+ Set<Belief<?, ?>> fullyOperationalBeliefs = getBeliefBase()
+ .getBeliefsByType(FullyOperational.class);
+ for (Belief<?, ?> belief : fullyOperationalBeliefs) {
+ PropositionalBelief<FullyOperational> fullyOperational = (PropositionalBelief<FullyOperational>) belief;
+ if (!fullyOperational.getValue()) {
+ PropositionalBelief<RegularUsage> regularUsage = (PropositionalBelief<RegularUsage>) getBeliefBase()
+ .getBelief(
+ new RegularUsage(fullyOperational.getName()
+ .getLink()));
+ if (regularUsage != null && regularUsage.getValue()) {
+ getMyAgent()
+ .addGoal(
+ LinkMonitorCapability.this,
+ new PropositionalBeliefValueGoal<FullyOperational>(
+ new FullyOperational(
+ fullyOperational
+ .getName()
+ .getLink()),
+ Boolean.TRUE));
+ log.debug("goal(fullyOperational("
+ + fullyOperational.getName().getLink() + "))");
+ }
+
+ }
+ }
+ }
+
+ @Override
+ public void reviewBeliefs() {
+ Set<Belief<?, ?>> linkUsageBeliefs = getBeliefBase()
+ .getBeliefsByType(Usage.class);
+ for (Belief<?, ?> belief : linkUsageBeliefs) {
+ Belief<Usage, Double> linkUsage = (Belief<Usage, Double>) belief;
+ double percentageUsed = linkUsage.getName().getLink()
+ .getUsedBandwidthPercentage();
+ linkUsage.setValue(percentageUsed);
+ if (percentageUsed > overUsageThreshold.getValue()) {
+ getBeliefBase()
+ .addOrUpdateBelief(
+ new TransientPropositionalBelief<OverUsage>(
+ new OverUsage(linkUsage.getName()
+ .getLink()), Boolean.TRUE));
+ log.debug("belief(overUsage("
+ + linkUsage.getName().getLink() + "))");
+ getBeliefBase().removeBelief(
+ new RegularUsage(linkUsage.getName().getLink()));
+ log.debug("belief(~regularUsage("
+ + linkUsage.getName().getLink() + "))");
+ } else {
+ getBeliefBase()
+ .addOrUpdateBelief(
+ new TransientPropositionalBelief<OverUsage>(
+ new OverUsage(linkUsage.getName()
+ .getLink()), Boolean.FALSE));
+ log.debug("belief(not overUsage("
+ + linkUsage.getName().getLink() + "))");
+ }
+ }
+ }
+ }
+
+ public static final double OVER_USAGE_THRESHOLD = 0.8;
+
+ private static final long serialVersionUID = -1705728861020677126L;
+
+ @bdi4jade.annotation.Belief
+ private Belief<String, Double> overUsageThreshold = new TransientBelief<>(
+ "threshold", OVER_USAGE_THRESHOLD);
+
+ public LinkMonitorCapability() {
+ ReasoningStrategy strategy = new ReasoningStrategy();
+ setBeliefRevisionStrategy(strategy);
+ setOptionGenerationFunction(strategy);
+ }
+
+ @Override
+ protected void setup() {
+ Belief<String, Device> device = (Belief<String, Device>) getBeliefBase()
+ .getBelief(RootCapability.DEVICE_BELIEF);
+ for (Link link : device.getValue().getConnectedLinks()) {
+ getBeliefBase().addBelief(
+ new TransientBelief<Usage, Double>(new Usage(link), link
+ .getUsedBandwidthPercentage()));
+ }
+ }
+
+}
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/capability/RateLimiterCapability.java b/network-resilience/src/br/ufrgs/inf/bdinetr/capability/RateLimiterCapability.java
new file mode 100644
index 0000000..d1e5822
--- /dev/null
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/capability/RateLimiterCapability.java
@@ -0,0 +1,37 @@
+//----------------------------------------------------------------------------
+// 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.capability;
+
+import bdi4jade.core.Capability;
+
+/**
+ * @author Ingrid Nunes
+ */
+public class RateLimiterCapability extends Capability {
+
+ private static final long serialVersionUID = -1705728861020677126L;
+
+ public static final String LINK_USAGE = "linkUsage";
+ public static final String LINK_OVER_USAGE = "overUsage";
+ public static final String LINK_REGULAR_USAGE = "regularUsage";
+
+}
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/Device.java b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/Device.java
new file mode 100644
index 0000000..5e18984
--- /dev/null
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/Device.java
@@ -0,0 +1,75 @@
+//----------------------------------------------------------------------------
+// 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;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author Ingrid Nunes
+ */
+public class Device {
+
+ private final Set<Link> connectedLinks;
+ private final String id;
+
+ public Device(final String id) {
+ this.id = id;
+ this.connectedLinks = new HashSet<>();
+ }
+
+ public void connectLink(Link link) {
+ connectedLinks.add(link);
+ }
+
+ public void disconnectLink(Link link) {
+ connectedLinks.remove(link);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof Device) {
+ Device d = (Device) obj;
+ return this.id.equals(d.id);
+ }
+ return false;
+ }
+
+ public Set<Link> getConnectedLinks() {
+ return connectedLinks;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ @Override
+ public int hashCode() {
+ return id == null ? 0 : id.hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return id;
+ }
+
+}
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/Flow.java b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/Flow.java
new file mode 100644
index 0000000..0853dbf
--- /dev/null
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/Flow.java
@@ -0,0 +1,54 @@
+//----------------------------------------------------------------------------
+// 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;
+
+/**
+ * @author Ingrid Nunes
+ */
+public class Flow {
+
+ private final String id;
+
+ public Flow(String id) {
+ this.id = id;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof Flow) {
+ Flow f = (Flow) obj;
+ return this.id.equals(f.id);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return id == null ? 0 : id.hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return id;
+ }
+
+}
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/FlowPreposition.java b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/FlowPreposition.java
new file mode 100644
index 0000000..255576f
--- /dev/null
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/FlowPreposition.java
@@ -0,0 +1,84 @@
+//----------------------------------------------------------------------------
+// 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;
+
+/**
+ * @author Ingrid Nunes
+ */
+public class FlowPreposition {
+
+ public static class FlowRateLimited extends FlowPreposition {
+ public FlowRateLimited(Flow flow) {
+ super(flow);
+ }
+ }
+
+ public static class Threat extends FlowPreposition {
+ public Threat(Flow flow) {
+ super(flow);
+ }
+ }
+
+ public static class ThreatResponded extends FlowPreposition {
+ public ThreatResponded(Flow flow) {
+ super(flow);
+ }
+ }
+
+ protected Flow flow;
+
+ public FlowPreposition(Flow flow) {
+ this.flow = flow;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj != null && this.getClass().equals(obj.getClass())) {
+ FlowPreposition fp = (FlowPreposition) obj;
+ return this.flow.equals(fp.flow);
+ }
+ return false;
+ }
+
+ public Flow getFlow() {
+ return flow;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result
+ + ((this.getClass() == null) ? 0 : this.getClass().hashCode());
+ result = prime * result + ((flow == null) ? 0 : flow.hashCode());
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ sb.append(this.getClass().getSimpleName());
+ sb.append("(").append(flow).append(")");
+ return sb.toString();
+ }
+
+}
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/IpAddress.java b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/IpAddress.java
new file mode 100644
index 0000000..6cbbf4b
--- /dev/null
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/IpAddress.java
@@ -0,0 +1,54 @@
+//----------------------------------------------------------------------------
+// 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;
+
+/**
+ * @author Ingrid Nunes
+ */
+public class IpAddress {
+
+ private final String id;
+
+ public IpAddress(String id) {
+ this.id = id;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof IpAddress) {
+ IpAddress ip = (IpAddress) obj;
+ return this.id.equals(ip.id);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return id == null ? 0 : id.hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return id;
+ }
+
+}
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/IpPreposition.java b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/IpPreposition.java
new file mode 100644
index 0000000..a6730d8
--- /dev/null
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/IpPreposition.java
@@ -0,0 +1,96 @@
+//----------------------------------------------------------------------------
+// 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;
+
+/**
+ * @author Ingrid Nunes
+ */
+public class IpPreposition {
+
+ public static class Anomalous extends IpPreposition {
+ public Anomalous(IpAddress ip) {
+ super(ip);
+ }
+ }
+
+ public static class Benign extends IpPreposition {
+ public Benign(IpAddress ip) {
+ super(ip);
+ }
+ }
+
+ public static class FlowRecord extends IpPreposition {
+ public FlowRecord(IpAddress ip) {
+ super(ip);
+ }
+ }
+
+ public static class RateLimited extends IpPreposition {
+ public RateLimited(IpAddress ip) {
+ super(ip);
+ }
+ }
+
+ public static class Restricted extends IpPreposition {
+ public Restricted(IpAddress ip) {
+ super(ip);
+ }
+ }
+
+ protected IpAddress ip;
+
+ public IpPreposition(IpAddress ip) {
+ this.ip = ip;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj != null && this.getClass().equals(obj.getClass())) {
+ IpPreposition lp = (IpPreposition) obj;
+ return this.ip.equals(lp.ip);
+ }
+ return false;
+ }
+
+ public IpAddress getIp() {
+ return ip;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result
+ + ((this.getClass() == null) ? 0 : this.getClass().hashCode());
+ result = prime * result + ((ip == null) ? 0 : ip.hashCode());
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ sb.append(this.getClass().getSimpleName());
+ sb.append("(").append(ip).append(")");
+ return sb.toString();
+ }
+
+}
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/Link.java b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/Link.java
new file mode 100644
index 0000000..b1807f6
--- /dev/null
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/Link.java
@@ -0,0 +1,110 @@
+//----------------------------------------------------------------------------
+// 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;
+
+/**
+ * @author Ingrid Nunes
+ */
+public class Link {
+
+ private Double bandwidth;
+ private final String id;
+ private Device source;
+ private Device target;
+ private Double usedBandwidth;
+
+ public Link(String id) {
+ this.id = id;
+ }
+
+ public Link(String id, Double bandwidth, Device source, Device target) {
+ this(id);
+ this.bandwidth = bandwidth;
+ this.usedBandwidth = 0.0;
+ setSource(source);
+ setTarget(target);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof Link) {
+ Link l = (Link) obj;
+ return this.id.equals(l.id);
+ }
+ return false;
+ }
+
+ public Double getBandwidth() {
+ return bandwidth;
+ }
+
+ public Device getSource() {
+ return source;
+ }
+
+ public Device getTarget() {
+ return target;
+ }
+
+ public Double getUsedBandwidth() {
+ return usedBandwidth;
+ }
+
+ public Double getUsedBandwidthPercentage() {
+ return usedBandwidth / bandwidth;
+ }
+
+ @Override
+ public int hashCode() {
+ return id == null ? 0 : id.hashCode();
+ }
+
+ public void setBandwidth(Double bandwidth) {
+ this.bandwidth = bandwidth;
+ }
+
+ public void setSource(Device source) {
+ if (this.source != null) {
+ this.source.disconnectLink(this);
+ }
+ this.source = source;
+ this.source.connectLink(this);
+ }
+
+ public void setTarget(Device target) {
+ if (this.target != null) {
+ this.target.disconnectLink(this);
+ }
+ this.target = source;
+ this.target.connectLink(this);
+ }
+
+ public void setUsedBandwidth(Double usedBandwidth) {
+ this.usedBandwidth = usedBandwidth;
+ }
+
+ @Override
+ public String toString() {
+ return id;
+ }
+
+}
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/LinkProposition.java b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/LinkProposition.java
new file mode 100644
index 0000000..ce4bc3f
--- /dev/null
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/LinkProposition.java
@@ -0,0 +1,96 @@
+//----------------------------------------------------------------------------
+// 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;
+
+/**
+ * @author Ingrid Nunes
+ */
+public class LinkProposition {
+
+ public static class AttackPrevented extends LinkProposition {
+ public AttackPrevented(Link link) {
+ super(link);
+ }
+ }
+
+ public static class FullyOperational extends LinkProposition {
+ public FullyOperational(Link link) {
+ super(link);
+ }
+ }
+
+ public static class OverUsage extends LinkProposition {
+ public OverUsage(Link link) {
+ super(link);
+ }
+ }
+
+ public static class RegularUsage extends LinkProposition {
+ public RegularUsage(Link link) {
+ super(link);
+ }
+ }
+
+ public static class Usage extends LinkProposition {
+ public Usage(Link link) {
+ super(link);
+ }
+ }
+
+ protected Link link;
+
+ public LinkProposition(Link link) {
+ this.link = link;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj != null && this.getClass().equals(obj.getClass())) {
+ LinkProposition lp = (LinkProposition) obj;
+ return this.link.equals(lp.link);
+ }
+ return false;
+ }
+
+ public Link getLink() {
+ return link;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result
+ + ((this.getClass() == null) ? 0 : this.getClass().hashCode());
+ result = prime * result + ((link == null) ? 0 : link.hashCode());
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ sb.append(this.getClass().getSimpleName());
+ sb.append("(").append(link).append(")");
+ return sb.toString();
+ }
+
+}
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/Network.java b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/Network.java
new file mode 100644
index 0000000..f0af313
--- /dev/null
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/Network.java
@@ -0,0 +1,56 @@
+//----------------------------------------------------------------------------
+// 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;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author Ingrid Nunes
+ */
+public class Network {
+
+ private final Set<Device> devices;
+ private final Set<Link> links;
+
+ public Network() {
+ this.devices = new HashSet<>();
+ this.links = new HashSet<>();
+ }
+
+ public void addDevice(Device device) {
+ this.devices.add(device);
+ }
+
+ public void addLink(Link link) {
+ this.links.add(link);
+ }
+
+ public Set<Device> getDevices() {
+ return devices;
+ }
+
+ public Set<Link> getLinks() {
+ return links;
+ }
+
+}
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/log4j.properties b/network-resilience/src/br/ufrgs/inf/bdinetr/log4j.properties
new file mode 100644
index 0000000..4e28233
--- /dev/null
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/log4j.properties
@@ -0,0 +1,34 @@
+#
+# Log4J Settings for log4j 1.2.x (via jakarta-commons-logging)
+#
+# The five logging levels used by Log are (in order):
+#
+# 1. DEBUG (the least serious)
+# 2. INFO
+# 3. WARN
+# 4. ERROR
+# 5. FATAL (the most serious)
+
+
+# Set root logger level to WARN and append to stdout
+log4j.rootLogger=WARN, stdout
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+
+# Pattern to output the caller's file name and line number.
+log4j.appender.stdout.layout.ConversionPattern=%d{HH:mm:ss,SSS} %5p (%c{1}:%L) - %m%n
+
+# Print only messages of level ERROR or above in the package noModule.
+log4j.logger.noModule=FATAL
+
+# OpenSymphony Stuff
+log4j.logger.com.opensymphony=FATAL
+log4j.logger.org.apache.struts2=FATAL
+
+# Spring Stuff
+log4j.logger.org.springframework=FATAL
+
+log4j.logger.bdi4jade=WARN
+log4j.logger.br.ufrgs.inf.bdinetr=DEBUG
+