bdi-network-resilience

Corrections Alberto's Model

9/2/2014 6:08:42 PM

Details

diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/BDINetRAgent.java b/network-resilience/src/br/ufrgs/inf/bdinetr/BDINetRAgent.java
index 2628e09..265db37 100644
--- a/network-resilience/src/br/ufrgs/inf/bdinetr/BDINetRAgent.java
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/BDINetRAgent.java
@@ -25,43 +25,51 @@ import bdi4jade.belief.Belief;
 import bdi4jade.belief.TransientBelief;
 import bdi4jade.core.Capability;
 import bdi4jade.core.SingleCapabilityAgent;
-import br.ufrgs.inf.bdinetr.domain.Device;
+import br.ufrgs.inf.bdinetr.capability.AnomalyDetectionCapability;
+import br.ufrgs.inf.bdinetr.capability.ClassifierCapability;
+import br.ufrgs.inf.bdinetr.capability.FlowExporterCapability;
+import br.ufrgs.inf.bdinetr.capability.LinkMonitorCapability;
+import br.ufrgs.inf.bdinetr.capability.RateLimiterCapability;
+import br.ufrgs.inf.bdinetr.domain.PReSETRole;
+import br.ufrgs.inf.bdinetr.domain.PReSETRouter;
 
 /**
  * @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 ROUTER_BELIEF = "router";
 
-		public static final String DEVICE_BELIEF = "device";
+		private static final long serialVersionUID = -2156730094556459899L;
 
 		@bdi4jade.annotation.Belief
-		private Belief<String, Device> device = new TransientBelief<>(
-				DEVICE_BELIEF);
+		private Belief<String, PReSETRouter> router = new TransientBelief<>(
+				ROUTER_BELIEF);
 
-		public RootCapability(Device device) {
-			this.device.setValue(device);
+		public RootCapability(PReSETRouter router) {
+			this.router.setValue(router);
 		}
 
 	}
 
-	public BDINetRAgent(Device device) {
-		this(device, new Capability[0]);
-	}
-
-	public BDINetRAgent(Device device, Capability capability) {
-		this(device, new Capability[] { capability });
-	}
+	private static final long serialVersionUID = 6534875498063013722L;
 
-	public BDINetRAgent(Device device, Capability[] capabilities) {
-		super(new RootCapability(device));
-		for (Capability capability : capabilities) {
-			this.getCapability().addPartCapability(capability);
+	public BDINetRAgent(PReSETRouter router) {
+		super(new RootCapability(router));
+		if (router.hasRole(PReSETRole.LINK_MONITOR)) {
+			this.getCapability().addPartCapability(new LinkMonitorCapability());
+		} else if (router.hasRole(PReSETRole.ANOMALY_DETECTION)) {
+			this.getCapability().addPartCapability(
+					new AnomalyDetectionCapability());
+		} else if (router.hasRole(PReSETRole.RATE_LIMITER)) {
+			this.getCapability().addPartCapability(new RateLimiterCapability());
+		} else if (router.hasRole(PReSETRole.FLOW_EXPORTER)) {
+			this.getCapability()
+					.addPartCapability(new FlowExporterCapability());
+		} else if (router.hasRole(PReSETRole.CLASSIFIER)) {
+			this.getCapability().addPartCapability(new ClassifierCapability());
 		}
 	}
 
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/BDINetRApp.java b/network-resilience/src/br/ufrgs/inf/bdinetr/BDINetRApp.java
index 1e9e39f..d9e3677 100644
--- a/network-resilience/src/br/ufrgs/inf/bdinetr/BDINetRApp.java
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/BDINetRApp.java
@@ -40,13 +40,13 @@ import org.apache.commons.logging.LogFactory;
 import org.apache.log4j.PropertyConfigurator;
 
 import bdi4jade.core.AbstractBDIAgent;
-import bdi4jade.core.Capability;
-import br.ufrgs.inf.bdinetr.capability.LinkMonitorCapability;
-import br.ufrgs.inf.bdinetr.capability.RateLimiterCapability;
-import br.ufrgs.inf.bdinetr.domain.Device;
+import bdi4jade.examples.BDI4JADEExamplesPanel;
 import br.ufrgs.inf.bdinetr.domain.IpAddress;
 import br.ufrgs.inf.bdinetr.domain.Link;
+import br.ufrgs.inf.bdinetr.domain.LinkMonitor;
 import br.ufrgs.inf.bdinetr.domain.Network;
+import br.ufrgs.inf.bdinetr.domain.PReSETRole;
+import br.ufrgs.inf.bdinetr.domain.PReSETRouter;
 
 /**
  * @author Ingrid Nunes
@@ -54,13 +54,25 @@ import br.ufrgs.inf.bdinetr.domain.Network;
 public class BDINetRApp {
 
 	class LinkUsageUpdater extends TimerTask {
+		private static final double OVER_USAGE_PROBABILITY = 0.3;
+
 		@Override
 		public void run() {
+			Map<Link, Boolean> overUsage = new HashMap<>();
 			Random random = new Random(System.currentTimeMillis());
-			log.info("Updating link usage");
 			for (Link link : NETWORK.getLinks()) {
-				link.setUsedBandwidth(random.nextDouble()
-						* link.getActualBandwidth());
+				double d = random.nextDouble();
+				overUsage.put(link, d < OVER_USAGE_PROBABILITY);
+			}
+			log.info("Updating link usage");
+			for (PReSETRouter router : NETWORK.getRouters()) {
+				if (router.hasRole(PReSETRole.LINK_MONITOR)) {
+					LinkMonitor lm = (LinkMonitor) router
+							.getRole(PReSETRole.LINK_MONITOR);
+					for (Link link : overUsage.keySet()) {
+						lm.setOverUsage(link, overUsage.get(link));
+					}
+				}
 			}
 			log.info("Restarting agents");
 			for (AbstractBDIAgent agent : AGENTS.values()) {
@@ -78,46 +90,18 @@ public class BDINetRApp {
 				.getResource("log4j.properties"));
 
 		NETWORK = new Network();
-		Device firewall1 = new Device(new IpAddress("Firewall 1"));
-		NETWORK.addDevice(firewall1);
-		/*
-		 * Device firewall2 = new Device(new IpAddress("Firewall 2"));
-		 * NETWORK.addDevice(firewall2); Device firewall3 = new Device(new
-		 * IpAddress("Firewall 3")); NETWORK.addDevice(firewall3);
-		 */
-		Device rateLimiter1 = new Device(new IpAddress("Rate Limiter 1"));
-		NETWORK.addDevice(rateLimiter1);
-		/*
-		 * Device rateLimiter2 = new Device(new IpAddress("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));
-		 */
+		PReSETRouter firewall = new PReSETRouter(new IpAddress("Firewall 1"),
+				PReSETRole.RATE_LIMITER.getId());
+		NETWORK.addRouter(firewall);
+		PReSETRouter linkMonitor = new PReSETRouter(new IpAddress(
+				"Rate Limiter 1"), PReSETRole.LINK_MONITOR.getId());
+		NETWORK.addRouter(linkMonitor);
+
+		NETWORK.addLink(new Link("F1_RL1"));
 
 		AGENTS = new HashMap<>();
-		AGENTS.put(firewall1.getIp(), new BDINetRAgent(firewall1,
-				new Capability[] { new LinkMonitorCapability(),
-						new RateLimiterCapability() }));
-		/*
-		 * AGENTS.put(firewall2.getIp(), new BDINetRAgent(firewall2, new
-		 * Capability[] { new LinkMonitorCapability(), new
-		 * RateLimiterCapability() })); AGENTS.put(firewall3.getIp(), new
-		 * BDINetRAgent(firewall3, new Capability[] { new
-		 * LinkMonitorCapability(), new RateLimiterCapability() }));
-		 */
-		AGENTS.put(rateLimiter1.getIp(), new BDINetRAgent(rateLimiter1,
-				new RateLimiterCapability()));
-		/*
-		 * AGENTS.put(rateLimiter2.getIp(), new BDINetRAgent(rateLimiter2, new
-		 * RateLimiterCapability()));
-		 */
+		AGENTS.put(firewall.getIp(), new BDINetRAgent(firewall));
+		AGENTS.put(linkMonitor.getIp(), new BDINetRAgent(linkMonitor));
 
 	}
 
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/capability/LinkMonitorCapability.java b/network-resilience/src/br/ufrgs/inf/bdinetr/capability/LinkMonitorCapability.java
index 338d9fb..4ec6a4d 100644
--- a/network-resilience/src/br/ufrgs/inf/bdinetr/capability/LinkMonitorCapability.java
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/capability/LinkMonitorCapability.java
@@ -31,12 +31,12 @@ 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.OverUsage;
 import br.ufrgs.inf.bdinetr.domain.LinkProposition.RegularUsage;
 import br.ufrgs.inf.bdinetr.domain.LinkProposition.Usage;
+import br.ufrgs.inf.bdinetr.domain.PReSETRouter;
 
 /**
  * @author Ingrid Nunes
@@ -73,8 +73,9 @@ public class LinkMonitorCapability extends BDINetRAppCapability {
 				Belief<Usage, Double> linkUsage = (Belief<Usage, Double>) belief;
 				OverUsage overUsage = new OverUsage(linkUsage.getName()
 						.getLink());
-				double percentageUsed = linkUsage.getName().getLink()
-						.getUsedBandwidthPercentage();
+				double percentageUsed = 0;
+				// FIXME
+				// linkUsage.getName().getLink().getUsedBandwidthPercentage();
 				linkUsage.setValue(percentageUsed);
 				if (percentageUsed > overUsageThreshold.getValue()) {
 					PropositionalBelief<OverUsage> overUsageBelief = (PropositionalBelief<OverUsage>) getBeliefBase()
@@ -107,13 +108,14 @@ public class LinkMonitorCapability extends BDINetRAppCapability {
 
 	@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()));
-		}
+		Belief<String, PReSETRouter> device = (Belief<String, PReSETRouter>) getBeliefBase()
+				.getBelief(RootCapability.ROUTER_BELIEF);
+		// FIXME
+//		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
index eed9a26..0bca420 100644
--- a/network-resilience/src/br/ufrgs/inf/bdinetr/capability/RateLimiterCapability.java
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/capability/RateLimiterCapability.java
@@ -37,7 +37,6 @@ import bdi4jade.plan.planbody.BeliefGoalPlanBody;
 import bdi4jade.reasoning.AbstractReasoningStrategy;
 import bdi4jade.reasoning.OptionGenerationFunction;
 import br.ufrgs.inf.bdinetr.BDINetRAgent.RootCapability;
-import br.ufrgs.inf.bdinetr.domain.Device;
 import br.ufrgs.inf.bdinetr.domain.IpAddress;
 import br.ufrgs.inf.bdinetr.domain.IpPreposition.Anomalous;
 import br.ufrgs.inf.bdinetr.domain.IpPreposition.Benign;
@@ -48,6 +47,7 @@ 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.PReSETRouter;
 
 /**
  * @author Ingrid Nunes
@@ -57,13 +57,13 @@ public class RateLimiterCapability extends BDINetRAppCapability {
 	public class LimitIPRatePlan extends BeliefGoalPlanBody {
 		private static final long serialVersionUID = -3493377510830902961L;
 
-		@bdi4jade.annotation.Belief(name = RootCapability.DEVICE_BELIEF)
-		private Belief<String, Device> device;
+		@bdi4jade.annotation.Belief(name = RootCapability.ROUTER_BELIEF)
+		private Belief<String, PReSETRouter> device;
 		private IpAddress ip;
 
 		@Override
 		public void execute() {
-			device.getValue().limitIp(ip, IP_LIMIT_RATE);
+			// FIXME device.getValue().limitIp(ip, IP_LIMIT_RATE);
 			belief(new RateLimited(ip), true);
 			belief(new Restricted(ip), true);
 
@@ -103,7 +103,8 @@ public class RateLimiterCapability extends BDINetRAppCapability {
 
 		@Override
 		public void execute() {
-			link.setLimitedBandwidth(LINK_LIMIT_RATE * link.getBandwidth());
+			// FIXME link.setLimitedBandwidth(LINK_LIMIT_RATE *
+			// link.getBandwidth());
 			belief(new FullyOperational(link), false);
 			belief(new AttackPrevented(link), true);
 			log.info(getGoal());
@@ -114,7 +115,7 @@ public class RateLimiterCapability extends BDINetRAppCapability {
 			this.link = attackPrevented.getLink();
 		}
 	}
-	
+
 	private class ReasoningStrategy extends AbstractReasoningStrategy implements
 			OptionGenerationFunction {
 		@Override
@@ -141,13 +142,13 @@ public class RateLimiterCapability extends BDINetRAppCapability {
 	public class RestoreIPRatePlan extends BeliefGoalPlanBody {
 		private static final long serialVersionUID = -3493377510830902961L;
 
-		@bdi4jade.annotation.Belief(name = RootCapability.DEVICE_BELIEF)
-		private Belief<String, Device> device;
+		@bdi4jade.annotation.Belief(name = RootCapability.ROUTER_BELIEF)
+		private Belief<String, PReSETRouter> device;
 		private IpAddress ip;
 
 		@Override
 		public void execute() {
-			device.getValue().unlimitIp(ip);
+			// FIXME device.getValue().unlimitIp(ip);
 			belief(new RateLimited(ip), false);
 			belief(new Restricted(ip), false);
 			belief(new Anomalous(ip), null);
@@ -167,7 +168,7 @@ public class RateLimiterCapability extends BDINetRAppCapability {
 
 		@Override
 		public void execute() {
-			link.setLimitedBandwidth(null);
+			// FIXME link.setLimitedBandwidth(null);
 			belief(new FullyOperational(link), true);
 			belief(new AttackPrevented(link), null);
 			log.info(getGoal());
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/AbstractPReSETRole.java b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/AbstractPReSETRole.java
new file mode 100644
index 0000000..80e156a
--- /dev/null
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/AbstractPReSETRole.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.domain;
+
+/**
+ * @author Ingrid Nunes
+ */
+public abstract class AbstractPReSETRole {
+
+	protected final PReSETRouter router;
+
+	public AbstractPReSETRole(PReSETRouter router) {
+		this.router = router;
+	}
+
+}
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/AnomalyDetection.java b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/AnomalyDetection.java
new file mode 100644
index 0000000..b5f5fcc
--- /dev/null
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/AnomalyDetection.java
@@ -0,0 +1,41 @@
+//----------------------------------------------------------------------------
+// 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;
+
+/**
+ * ids
+ * 
+ * addOperation: "name:action:" remoteName: "togglereport".
+ * 
+ * event
+ * 
+ * at: "intrusion" put: (factory/event create: #( "value_victim" ));
+ * 
+ * @author Ingrid Nunes
+ */
+public class AnomalyDetection extends AbstractPReSETRole {
+
+	public AnomalyDetection(PReSETRouter router) {
+		super(router);
+	}
+
+}
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/Classifier.java b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/Classifier.java
new file mode 100644
index 0000000..8a864ed
--- /dev/null
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/Classifier.java
@@ -0,0 +1,38 @@
+//----------------------------------------------------------------------------
+// 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;
+
+/**
+ * event at:
+ * 
+ * "classification" put: (factory/event create: #( "value_name" "value_source"
+ * "value_destination" "value_protocol" ));
+ * 
+ * @author Ingrid Nunes
+ */
+public class Classifier extends AbstractPReSETRole {
+
+	public Classifier(PReSETRouter router) {
+		super(router);
+	}
+
+}
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/FlowExporter.java b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/FlowExporter.java
new file mode 100644
index 0000000..8f264cb
--- /dev/null
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/FlowExporter.java
@@ -0,0 +1,36 @@
+//----------------------------------------------------------------------------
+// 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;
+
+/**
+ * flowexporter addOperation: "victim:flow:idle:" remoteName: "setthreshold".
+ * 
+ * 
+ * @author Ingrid Nunes
+ */
+public class FlowExporter extends AbstractPReSETRole {
+
+	public FlowExporter(PReSETRouter router) {
+		super(router);
+	}
+
+}
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/Link.java b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/Link.java
index 53fcef6..9f35abe 100644
--- a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/Link.java
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/Link.java
@@ -26,26 +26,12 @@ package br.ufrgs.inf.bdinetr.domain;
  */
 public class Link {
 
-	private Double bandwidth;
 	private final String id;
-	private Double limitedBandwidth;
-	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.limitedBandwidth = null;
-		this.usedBandwidth = 0.0;
-		setSource(source);
-		setTarget(target);
-	}
-
 	@Override
 	public boolean equals(Object obj) {
 		if (obj instanceof Link) {
@@ -55,69 +41,11 @@ public class Link {
 		return false;
 	}
 
-	public Double getActualBandwidth() {
-		return limitedBandwidth == null ? bandwidth : limitedBandwidth;
-	}
-
-	public Double getBandwidth() {
-		return bandwidth;
-	}
-
-	public Double getLimitedBandwidth() {
-		return limitedBandwidth;
-	}
-
-	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 setLimitedBandwidth(Double limitedBandwidth) {
-		if (limitedBandwidth > bandwidth)
-			return;
-		this.limitedBandwidth = limitedBandwidth;
-	}
-
-	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/LinkMonitor.java b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/LinkMonitor.java
new file mode 100644
index 0000000..ff2d55b
--- /dev/null
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/LinkMonitor.java
@@ -0,0 +1,57 @@
+//----------------------------------------------------------------------------
+// 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.HashMap;
+import java.util.Map;
+
+/**
+ * event at:
+ * 
+ * "load" put: (factory/event create: #( "value_name" "value_index" ));
+ * 
+ * --> value_name: ???
+ * --> value_index: id do link
+ * 
+ * @author Ingrid Nunes
+ */
+public class LinkMonitor extends AbstractPReSETRole {
+
+	private final Map<Link, Boolean> overUsageLinks;
+
+	public LinkMonitor(PReSETRouter router) {
+		super(router);
+		this.overUsageLinks = new HashMap<>();
+	}
+
+	public boolean isOverUsage(Link link) {
+		Boolean overUsage = this.overUsageLinks.get(link);
+		if (overUsage == null)
+			overUsage = false;
+		return overUsage;
+	}
+
+	public void setOverUsage(Link link, boolean overUsage) {
+		this.overUsageLinks.put(link, overUsage);
+	}
+
+}
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/Network.java b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/Network.java
index f0af313..3990e19 100644
--- a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/Network.java
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/Network.java
@@ -29,28 +29,28 @@ import java.util.Set;
  */
 public class Network {
 
-	private final Set<Device> devices;
 	private final Set<Link> links;
+	private final Set<PReSETRouter> router;
 
 	public Network() {
-		this.devices = new HashSet<>();
+		this.router = 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 void addRouter(PReSETRouter router) {
+		this.router.add(router);
 	}
 
 	public Set<Link> getLinks() {
 		return links;
 	}
 
+	public Set<PReSETRouter> getRouters() {
+		return router;
+	}
+
 }
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/PReSETRole.java b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/PReSETRole.java
new file mode 100644
index 0000000..38674b2
--- /dev/null
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/PReSETRole.java
@@ -0,0 +1,46 @@
+//----------------------------------------------------------------------------
+// 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 enum PReSETRole {
+
+	ANOMALY_DETECTION(1), CLASSIFIER(2), FLOW_EXPORTER(4), LINK_MONITOR(8), RATE_LIMITER(
+			16);
+
+	private final int id;
+
+	private PReSETRole(int id) {
+		this.id = id;
+	}
+
+	public int getId() {
+		return id;
+	}
+
+	public boolean isPresent(int roles) {
+		return (roles & id) != 0;
+	}
+
+}
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/domain/RateLimiter.java b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/RateLimiter.java
new file mode 100644
index 0000000..f3b60d4
--- /dev/null
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/domain/RateLimiter.java
@@ -0,0 +1,76 @@
+//----------------------------------------------------------------------------
+// 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.HashMap;
+import java.util.Map;
+
+/**
+ * ratelimiter
+ * 
+ * addOperation: "name:index:rate:" remoteName: "limitlink";
+ * 
+ * addOperation: "name:ip:rate:" remoteName: "limitip";
+ * 
+ * addOperation: "name:source:destination:protocol:rate:" remoteName:
+ * "limitflow".
+ * 
+ * @author Ingrid Nunes
+ */
+public class RateLimiter extends AbstractPReSETRole {
+
+	private final Map<Flow, Double> rateLimitedflows;
+	private final Map<IpAddress, Double> rateLimitedIps;
+	private final Map<Link, Double> rateLimitedLinks;
+
+	public RateLimiter(PReSETRouter router) {
+		super(router);
+		this.rateLimitedLinks = new HashMap<>();
+		this.rateLimitedIps = new HashMap<>();
+		this.rateLimitedflows = new HashMap<>();
+	}
+
+	public void limitFlow(Flow flow, double rate) {
+		this.rateLimitedflows.put(flow, rate);
+	}
+
+	public void limitIp(IpAddress ip, double rate) {
+		this.rateLimitedIps.put(ip, rate);
+	}
+
+	public void limitLink(Link link, double rate) {
+		this.rateLimitedLinks.put(link, rate);
+	}
+
+	public void unlimitFlow(Flow flow) {
+		this.rateLimitedflows.remove(flow);
+	}
+
+	public void unlimitIp(IpAddress ip) {
+		this.rateLimitedIps.remove(ip);
+	}
+
+	public void unlimitLink(Link link) {
+		this.rateLimitedLinks.remove(link);
+	}
+
+}