Details
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/agent/AnomalyDetectionCapability.java b/network-resilience/src/br/ufrgs/inf/bdinetr/agent/AnomalyDetectionCapability.java
index b5bc5ef..9ae6fa9 100644
--- a/network-resilience/src/br/ufrgs/inf/bdinetr/agent/AnomalyDetectionCapability.java
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/agent/AnomalyDetectionCapability.java
@@ -90,6 +90,481 @@ public class AnomalyDetectionCapability extends RouterAgentCapability implements
}
}
+ public class AnalyseLinkStatistics1 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -349337710830902961L;
+
+ private Link link;
+
+ @Override
+ public void execute() {
+ Set<Ip> outliers = role.detectIntrusion(link);
+ BeliefSet<OverUsageCause, Ip> overUsageCause = new TransientBeliefSet<OverUsageCause, Ip>(
+ new OverUsageCause(link));
+ if (outliers != null && !outliers.isEmpty()) {
+ for (Ip outlier : outliers) {
+ belief(new Anomalous(outlier), true);
+ belief(new Benign(outlier), null);
+ overUsageCause.addValue(outlier);
+ }
+ }
+ addBelief(overUsageCause);
+ addBelief(new AnomalousUsageBelief(new AnomalousUsage(link)));
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(AnomalousUsage anomalousUsage) {
+ this.link = anomalousUsage.getConcept();
+ }
+ }
+
+ public class AnalyseLinkStatistics2 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -349337710830902961L;
+
+ private Link link;
+
+ @Override
+ public void execute() {
+ Set<Ip> outliers = role.detectIntrusion(link);
+ BeliefSet<OverUsageCause, Ip> overUsageCause = new TransientBeliefSet<OverUsageCause, Ip>(
+ new OverUsageCause(link));
+ if (outliers != null && !outliers.isEmpty()) {
+ for (Ip outlier : outliers) {
+ belief(new Anomalous(outlier), true);
+ belief(new Benign(outlier), null);
+ overUsageCause.addValue(outlier);
+ }
+ }
+ addBelief(overUsageCause);
+ addBelief(new AnomalousUsageBelief(new AnomalousUsage(link)));
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(AnomalousUsage anomalousUsage) {
+ this.link = anomalousUsage.getConcept();
+ }
+ }
+
+
+ public class AnalyseLinkStatistics3 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -349337710830902961L;
+
+ private Link link;
+
+ @Override
+ public void execute() {
+ Set<Ip> outliers = role.detectIntrusion(link);
+ BeliefSet<OverUsageCause, Ip> overUsageCause = new TransientBeliefSet<OverUsageCause, Ip>(
+ new OverUsageCause(link));
+ if (outliers != null && !outliers.isEmpty()) {
+ for (Ip outlier : outliers) {
+ belief(new Anomalous(outlier), true);
+ belief(new Benign(outlier), null);
+ overUsageCause.addValue(outlier);
+ }
+ }
+ addBelief(overUsageCause);
+ addBelief(new AnomalousUsageBelief(new AnomalousUsage(link)));
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(AnomalousUsage anomalousUsage) {
+ this.link = anomalousUsage.getConcept();
+ }
+ }
+
+
+ public class AnalyseLinkStatistics4 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -349337710830902961L;
+
+ private Link link;
+
+ @Override
+ public void execute() {
+ Set<Ip> outliers = role.detectIntrusion(link);
+ BeliefSet<OverUsageCause, Ip> overUsageCause = new TransientBeliefSet<OverUsageCause, Ip>(
+ new OverUsageCause(link));
+ if (outliers != null && !outliers.isEmpty()) {
+ for (Ip outlier : outliers) {
+ belief(new Anomalous(outlier), true);
+ belief(new Benign(outlier), null);
+ overUsageCause.addValue(outlier);
+ }
+ }
+ addBelief(overUsageCause);
+ addBelief(new AnomalousUsageBelief(new AnomalousUsage(link)));
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(AnomalousUsage anomalousUsage) {
+ this.link = anomalousUsage.getConcept();
+ }
+ }
+
+
+ public class AnalyseLinkStatistics5 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -349337710830902961L;
+
+ private Link link;
+
+ @Override
+ public void execute() {
+ Set<Ip> outliers = role.detectIntrusion(link);
+ BeliefSet<OverUsageCause, Ip> overUsageCause = new TransientBeliefSet<OverUsageCause, Ip>(
+ new OverUsageCause(link));
+ if (outliers != null && !outliers.isEmpty()) {
+ for (Ip outlier : outliers) {
+ belief(new Anomalous(outlier), true);
+ belief(new Benign(outlier), null);
+ overUsageCause.addValue(outlier);
+ }
+ }
+ addBelief(overUsageCause);
+ addBelief(new AnomalousUsageBelief(new AnomalousUsage(link)));
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(AnomalousUsage anomalousUsage) {
+ this.link = anomalousUsage.getConcept();
+ }
+ }
+
+
+ public class AnalyseLinkStatistics6 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -349337710830902961L;
+
+ private Link link;
+
+ @Override
+ public void execute() {
+ Set<Ip> outliers = role.detectIntrusion(link);
+ BeliefSet<OverUsageCause, Ip> overUsageCause = new TransientBeliefSet<OverUsageCause, Ip>(
+ new OverUsageCause(link));
+ if (outliers != null && !outliers.isEmpty()) {
+ for (Ip outlier : outliers) {
+ belief(new Anomalous(outlier), true);
+ belief(new Benign(outlier), null);
+ overUsageCause.addValue(outlier);
+ }
+ }
+ addBelief(overUsageCause);
+ addBelief(new AnomalousUsageBelief(new AnomalousUsage(link)));
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(AnomalousUsage anomalousUsage) {
+ this.link = anomalousUsage.getConcept();
+ }
+ }
+
+
+ public class AnalyseLinkStatistics7 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -349337710830902961L;
+
+ private Link link;
+
+ @Override
+ public void execute() {
+ Set<Ip> outliers = role.detectIntrusion(link);
+ BeliefSet<OverUsageCause, Ip> overUsageCause = new TransientBeliefSet<OverUsageCause, Ip>(
+ new OverUsageCause(link));
+ if (outliers != null && !outliers.isEmpty()) {
+ for (Ip outlier : outliers) {
+ belief(new Anomalous(outlier), true);
+ belief(new Benign(outlier), null);
+ overUsageCause.addValue(outlier);
+ }
+ }
+ addBelief(overUsageCause);
+ addBelief(new AnomalousUsageBelief(new AnomalousUsage(link)));
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(AnomalousUsage anomalousUsage) {
+ this.link = anomalousUsage.getConcept();
+ }
+ }
+
+
+
+ public class AnalyseLinkStatistics8 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -349337710830902961L;
+
+ private Link link;
+
+ @Override
+ public void execute() {
+ Set<Ip> outliers = role.detectIntrusion(link);
+ BeliefSet<OverUsageCause, Ip> overUsageCause = new TransientBeliefSet<OverUsageCause, Ip>(
+ new OverUsageCause(link));
+ if (outliers != null && !outliers.isEmpty()) {
+ for (Ip outlier : outliers) {
+ belief(new Anomalous(outlier), true);
+ belief(new Benign(outlier), null);
+ overUsageCause.addValue(outlier);
+ }
+ }
+ addBelief(overUsageCause);
+ addBelief(new AnomalousUsageBelief(new AnomalousUsage(link)));
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(AnomalousUsage anomalousUsage) {
+ this.link = anomalousUsage.getConcept();
+ }
+ }
+
+
+ public class AnalyseLinkStatistics9 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -349337710830902961L;
+
+ private Link link;
+
+ @Override
+ public void execute() {
+ Set<Ip> outliers = role.detectIntrusion(link);
+ BeliefSet<OverUsageCause, Ip> overUsageCause = new TransientBeliefSet<OverUsageCause, Ip>(
+ new OverUsageCause(link));
+ if (outliers != null && !outliers.isEmpty()) {
+ for (Ip outlier : outliers) {
+ belief(new Anomalous(outlier), true);
+ belief(new Benign(outlier), null);
+ overUsageCause.addValue(outlier);
+ }
+ }
+ addBelief(overUsageCause);
+ addBelief(new AnomalousUsageBelief(new AnomalousUsage(link)));
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(AnomalousUsage anomalousUsage) {
+ this.link = anomalousUsage.getConcept();
+ }
+ }
+
+
+ public class AnalyseLinkStatistics10 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -349337710830902961L;
+
+ private Link link;
+
+ @Override
+ public void execute() {
+ Set<Ip> outliers = role.detectIntrusion(link);
+ BeliefSet<OverUsageCause, Ip> overUsageCause = new TransientBeliefSet<OverUsageCause, Ip>(
+ new OverUsageCause(link));
+ if (outliers != null && !outliers.isEmpty()) {
+ for (Ip outlier : outliers) {
+ belief(new Anomalous(outlier), true);
+ belief(new Benign(outlier), null);
+ overUsageCause.addValue(outlier);
+ }
+ }
+ addBelief(overUsageCause);
+ addBelief(new AnomalousUsageBelief(new AnomalousUsage(link)));
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(AnomalousUsage anomalousUsage) {
+ this.link = anomalousUsage.getConcept();
+ }
+ }
+
+
+ public class AnalyseLinkStatistics11 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -349337710830902961L;
+
+ private Link link;
+
+ @Override
+ public void execute() {
+ Set<Ip> outliers = role.detectIntrusion(link);
+ BeliefSet<OverUsageCause, Ip> overUsageCause = new TransientBeliefSet<OverUsageCause, Ip>(
+ new OverUsageCause(link));
+ if (outliers != null && !outliers.isEmpty()) {
+ for (Ip outlier : outliers) {
+ belief(new Anomalous(outlier), true);
+ belief(new Benign(outlier), null);
+ overUsageCause.addValue(outlier);
+ }
+ }
+ addBelief(overUsageCause);
+ addBelief(new AnomalousUsageBelief(new AnomalousUsage(link)));
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(AnomalousUsage anomalousUsage) {
+ this.link = anomalousUsage.getConcept();
+ }
+ }
+
+
+
+ public class AnalyseLinkStatistics12 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -349337710830902961L;
+
+ private Link link;
+
+ @Override
+ public void execute() {
+ Set<Ip> outliers = role.detectIntrusion(link);
+ BeliefSet<OverUsageCause, Ip> overUsageCause = new TransientBeliefSet<OverUsageCause, Ip>(
+ new OverUsageCause(link));
+ if (outliers != null && !outliers.isEmpty()) {
+ for (Ip outlier : outliers) {
+ belief(new Anomalous(outlier), true);
+ belief(new Benign(outlier), null);
+ overUsageCause.addValue(outlier);
+ }
+ }
+ addBelief(overUsageCause);
+ addBelief(new AnomalousUsageBelief(new AnomalousUsage(link)));
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(AnomalousUsage anomalousUsage) {
+ this.link = anomalousUsage.getConcept();
+ }
+ }
+
+
+ public class AnalyseLinkStatistics13 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -349337710830902961L;
+
+ private Link link;
+
+ @Override
+ public void execute() {
+ Set<Ip> outliers = role.detectIntrusion(link);
+ BeliefSet<OverUsageCause, Ip> overUsageCause = new TransientBeliefSet<OverUsageCause, Ip>(
+ new OverUsageCause(link));
+ if (outliers != null && !outliers.isEmpty()) {
+ for (Ip outlier : outliers) {
+ belief(new Anomalous(outlier), true);
+ belief(new Benign(outlier), null);
+ overUsageCause.addValue(outlier);
+ }
+ }
+ addBelief(overUsageCause);
+ addBelief(new AnomalousUsageBelief(new AnomalousUsage(link)));
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(AnomalousUsage anomalousUsage) {
+ this.link = anomalousUsage.getConcept();
+ }
+ }
+
+
+ public class AnalyseLinkStatistics14 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -349337710830902961L;
+
+ private Link link;
+
+ @Override
+ public void execute() {
+ Set<Ip> outliers = role.detectIntrusion(link);
+ BeliefSet<OverUsageCause, Ip> overUsageCause = new TransientBeliefSet<OverUsageCause, Ip>(
+ new OverUsageCause(link));
+ if (outliers != null && !outliers.isEmpty()) {
+ for (Ip outlier : outliers) {
+ belief(new Anomalous(outlier), true);
+ belief(new Benign(outlier), null);
+ overUsageCause.addValue(outlier);
+ }
+ }
+ addBelief(overUsageCause);
+ addBelief(new AnomalousUsageBelief(new AnomalousUsage(link)));
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(AnomalousUsage anomalousUsage) {
+ this.link = anomalousUsage.getConcept();
+ }
+ }
+
+
+ public class AnalyseLinkStatistics15 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -349337710830902961L;
+
+ private Link link;
+
+ @Override
+ public void execute() {
+ Set<Ip> outliers = role.detectIntrusion(link);
+ BeliefSet<OverUsageCause, Ip> overUsageCause = new TransientBeliefSet<OverUsageCause, Ip>(
+ new OverUsageCause(link));
+ if (outliers != null && !outliers.isEmpty()) {
+ for (Ip outlier : outliers) {
+ belief(new Anomalous(outlier), true);
+ belief(new Benign(outlier), null);
+ overUsageCause.addValue(outlier);
+ }
+ }
+ addBelief(overUsageCause);
+ addBelief(new AnomalousUsageBelief(new AnomalousUsage(link)));
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(AnomalousUsage anomalousUsage) {
+ this.link = anomalousUsage.getConcept();
+ }
+ }
+
+
+ public class AnalyseLinkStatistics16 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -349337710830902961L;
+
+ private Link link;
+
+ @Override
+ public void execute() {
+ Set<Ip> outliers = role.detectIntrusion(link);
+ BeliefSet<OverUsageCause, Ip> overUsageCause = new TransientBeliefSet<OverUsageCause, Ip>(
+ new OverUsageCause(link));
+ if (outliers != null && !outliers.isEmpty()) {
+ for (Ip outlier : outliers) {
+ belief(new Anomalous(outlier), true);
+ belief(new Benign(outlier), null);
+ overUsageCause.addValue(outlier);
+ }
+ }
+ addBelief(overUsageCause);
+ addBelief(new AnomalousUsageBelief(new AnomalousUsage(link)));
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(AnomalousUsage anomalousUsage) {
+ this.link = anomalousUsage.getConcept();
+ }
+ }
+
+
+ public class AnalyseLinkStatistics17 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -349337710830902961L;
+
+ private Link link;
+
+ @Override
+ public void execute() {
+ Set<Ip> outliers = role.detectIntrusion(link);
+ BeliefSet<OverUsageCause, Ip> overUsageCause = new TransientBeliefSet<OverUsageCause, Ip>(
+ new OverUsageCause(link));
+ if (outliers != null && !outliers.isEmpty()) {
+ for (Ip outlier : outliers) {
+ belief(new Anomalous(outlier), true);
+ belief(new Benign(outlier), null);
+ overUsageCause.addValue(outlier);
+ }
+ }
+ addBelief(overUsageCause);
+ addBelief(new AnomalousUsageBelief(new AnomalousUsage(link)));
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(AnomalousUsage anomalousUsage) {
+ this.link = anomalousUsage.getConcept();
+ }
+ }
public class LimitIPRatePlan extends BeliefGoalPlanBody {
private static final long serialVersionUID = -3493377510830902961L;
@@ -181,7 +656,7 @@ public class AnomalyDetectionCapability extends RouterAgentCapability implements
private static final long serialVersionUID = -1705728861020677126L;
@bdi4jade.annotation.Plan
- private Plan analyseLinkStatistics;
+ private Plan analyseLinkStatistics, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17;
@bdi4jade.annotation.Plan
private Plan limitIpRate;
@bdi4jade.annotation.Plan
@@ -209,6 +684,60 @@ public class AnomalyDetectionCapability extends RouterAgentCapability implements
this.analyseLinkStatistics = new DefaultPlan(
GoalTemplateFactory.hasBeliefOfType(AnomalousUsage.class),
AnalyseLinkStatistics.class);
+
+ this.a1 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfType(AnomalousUsage.class),
+ AnalyseLinkStatistics1.class);
+ this.a2 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfType(AnomalousUsage.class),
+ AnalyseLinkStatistics2.class);
+ this.a3 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfType(AnomalousUsage.class),
+ AnalyseLinkStatistics3.class);
+ this.a4 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfType(AnomalousUsage.class),
+ AnalyseLinkStatistics4.class);
+ this.a5 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfType(AnomalousUsage.class),
+ AnalyseLinkStatistics5.class);
+ this.a6 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfType(AnomalousUsage.class),
+ AnalyseLinkStatistics6.class);
+ this.a7 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfType(AnomalousUsage.class),
+ AnalyseLinkStatistics7.class);
+ this.a8 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfType(AnomalousUsage.class),
+ AnalyseLinkStatistics8.class);
+ this.a9 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfType(AnomalousUsage.class),
+ AnalyseLinkStatistics9.class);
+ this.a10 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfType(AnomalousUsage.class),
+ AnalyseLinkStatistics10.class);
+ this.a11 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfType(AnomalousUsage.class),
+ AnalyseLinkStatistics11.class);
+ this.a12 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfType(AnomalousUsage.class),
+ AnalyseLinkStatistics12.class);
+ this.a13 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfType(AnomalousUsage.class),
+ AnalyseLinkStatistics13.class);
+ this.a14 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfType(AnomalousUsage.class),
+ AnalyseLinkStatistics14.class);
+ this.a15 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfType(AnomalousUsage.class),
+ AnalyseLinkStatistics15.class);
+ this.a16= new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfType(AnomalousUsage.class),
+ AnalyseLinkStatistics16.class);
+ this.a17 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfType(AnomalousUsage.class),
+ AnalyseLinkStatistics17.class);
+
+
this.limitIpRate = new DefaultPlan(
GoalTemplateFactory.hasBeliefOfTypeWithValue(Restricted.class,
Boolean.TRUE), LimitIPRatePlan.class);
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/agent/ClassifierCapability.java b/network-resilience/src/br/ufrgs/inf/bdinetr/agent/ClassifierCapability.java
index d12c3cd..527f3a0 100644
--- a/network-resilience/src/br/ufrgs/inf/bdinetr/agent/ClassifierCapability.java
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/agent/ClassifierCapability.java
@@ -143,12 +143,641 @@ public class ClassifierCapability extends RouterAgentCapability implements
}
}
+ public class LimitFlowRatePlan1 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Flow flow;
+ private boolean subgoalDispatched;
+
+ @Override
+ public void execute() {
+ if (!subgoalDispatched) {
+ dispatchSubgoalAndListen(new BeliefValueGoal<>(
+ new FlowRateLimited(flow), true));
+ this.subgoalDispatched = true;
+ } else {
+ GoalEvent event = getGoalEvent();
+ if (event != null) {
+ if (GoalStatus.ACHIEVED.equals(event.getStatus())) {
+ addBelief(((BeliefGoal<?>) event.getGoal())
+ .getOutputBelief());
+ belief(new Threat(flow), null);
+ } else {
+ setEndState(EndState.FAILED);
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void init() {
+ this.subgoalDispatched = false;
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(Threat threat) {
+ this.flow = threat.getConcept();
+ }
+ }
+
+ public class LimitFlowRatePlan2 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Flow flow;
+ private boolean subgoalDispatched;
+
+ @Override
+ public void execute() {
+ if (!subgoalDispatched) {
+ dispatchSubgoalAndListen(new BeliefValueGoal<>(
+ new FlowRateLimited(flow), true));
+ this.subgoalDispatched = true;
+ } else {
+ GoalEvent event = getGoalEvent();
+ if (event != null) {
+ if (GoalStatus.ACHIEVED.equals(event.getStatus())) {
+ addBelief(((BeliefGoal<?>) event.getGoal())
+ .getOutputBelief());
+ belief(new Threat(flow), null);
+ } else {
+ setEndState(EndState.FAILED);
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void init() {
+ this.subgoalDispatched = false;
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(Threat threat) {
+ this.flow = threat.getConcept();
+ }
+ }
+
+ public class LimitFlowRatePlan3 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Flow flow;
+ private boolean subgoalDispatched;
+
+ @Override
+ public void execute() {
+ if (!subgoalDispatched) {
+ dispatchSubgoalAndListen(new BeliefValueGoal<>(
+ new FlowRateLimited(flow), true));
+ this.subgoalDispatched = true;
+ } else {
+ GoalEvent event = getGoalEvent();
+ if (event != null) {
+ if (GoalStatus.ACHIEVED.equals(event.getStatus())) {
+ addBelief(((BeliefGoal<?>) event.getGoal())
+ .getOutputBelief());
+ belief(new Threat(flow), null);
+ } else {
+ setEndState(EndState.FAILED);
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void init() {
+ this.subgoalDispatched = false;
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(Threat threat) {
+ this.flow = threat.getConcept();
+ }
+ }
+
+ public class LimitFlowRatePlan4 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Flow flow;
+ private boolean subgoalDispatched;
+
+ @Override
+ public void execute() {
+ if (!subgoalDispatched) {
+ dispatchSubgoalAndListen(new BeliefValueGoal<>(
+ new FlowRateLimited(flow), true));
+ this.subgoalDispatched = true;
+ } else {
+ GoalEvent event = getGoalEvent();
+ if (event != null) {
+ if (GoalStatus.ACHIEVED.equals(event.getStatus())) {
+ addBelief(((BeliefGoal<?>) event.getGoal())
+ .getOutputBelief());
+ belief(new Threat(flow), null);
+ } else {
+ setEndState(EndState.FAILED);
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void init() {
+ this.subgoalDispatched = false;
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(Threat threat) {
+ this.flow = threat.getConcept();
+ }
+ }
+
+ public class LimitFlowRatePlan5 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Flow flow;
+ private boolean subgoalDispatched;
+
+ @Override
+ public void execute() {
+ if (!subgoalDispatched) {
+ dispatchSubgoalAndListen(new BeliefValueGoal<>(
+ new FlowRateLimited(flow), true));
+ this.subgoalDispatched = true;
+ } else {
+ GoalEvent event = getGoalEvent();
+ if (event != null) {
+ if (GoalStatus.ACHIEVED.equals(event.getStatus())) {
+ addBelief(((BeliefGoal<?>) event.getGoal())
+ .getOutputBelief());
+ belief(new Threat(flow), null);
+ } else {
+ setEndState(EndState.FAILED);
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void init() {
+ this.subgoalDispatched = false;
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(Threat threat) {
+ this.flow = threat.getConcept();
+ }
+ }
+
+ public class LimitFlowRatePlan6 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Flow flow;
+ private boolean subgoalDispatched;
+
+ @Override
+ public void execute() {
+ if (!subgoalDispatched) {
+ dispatchSubgoalAndListen(new BeliefValueGoal<>(
+ new FlowRateLimited(flow), true));
+ this.subgoalDispatched = true;
+ } else {
+ GoalEvent event = getGoalEvent();
+ if (event != null) {
+ if (GoalStatus.ACHIEVED.equals(event.getStatus())) {
+ addBelief(((BeliefGoal<?>) event.getGoal())
+ .getOutputBelief());
+ belief(new Threat(flow), null);
+ } else {
+ setEndState(EndState.FAILED);
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void init() {
+ this.subgoalDispatched = false;
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(Threat threat) {
+ this.flow = threat.getConcept();
+ }
+ }
+
+ public class LimitFlowRatePlan7 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Flow flow;
+ private boolean subgoalDispatched;
+
+ @Override
+ public void execute() {
+ if (!subgoalDispatched) {
+ dispatchSubgoalAndListen(new BeliefValueGoal<>(
+ new FlowRateLimited(flow), true));
+ this.subgoalDispatched = true;
+ } else {
+ GoalEvent event = getGoalEvent();
+ if (event != null) {
+ if (GoalStatus.ACHIEVED.equals(event.getStatus())) {
+ addBelief(((BeliefGoal<?>) event.getGoal())
+ .getOutputBelief());
+ belief(new Threat(flow), null);
+ } else {
+ setEndState(EndState.FAILED);
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void init() {
+ this.subgoalDispatched = false;
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(Threat threat) {
+ this.flow = threat.getConcept();
+ }
+ }
+
+ public class LimitFlowRatePlan8 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Flow flow;
+ private boolean subgoalDispatched;
+
+ @Override
+ public void execute() {
+ if (!subgoalDispatched) {
+ dispatchSubgoalAndListen(new BeliefValueGoal<>(
+ new FlowRateLimited(flow), true));
+ this.subgoalDispatched = true;
+ } else {
+ GoalEvent event = getGoalEvent();
+ if (event != null) {
+ if (GoalStatus.ACHIEVED.equals(event.getStatus())) {
+ addBelief(((BeliefGoal<?>) event.getGoal())
+ .getOutputBelief());
+ belief(new Threat(flow), null);
+ } else {
+ setEndState(EndState.FAILED);
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void init() {
+ this.subgoalDispatched = false;
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(Threat threat) {
+ this.flow = threat.getConcept();
+ }
+ }
+
+ public class LimitFlowRatePlan9 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Flow flow;
+ private boolean subgoalDispatched;
+
+ @Override
+ public void execute() {
+ if (!subgoalDispatched) {
+ dispatchSubgoalAndListen(new BeliefValueGoal<>(
+ new FlowRateLimited(flow), true));
+ this.subgoalDispatched = true;
+ } else {
+ GoalEvent event = getGoalEvent();
+ if (event != null) {
+ if (GoalStatus.ACHIEVED.equals(event.getStatus())) {
+ addBelief(((BeliefGoal<?>) event.getGoal())
+ .getOutputBelief());
+ belief(new Threat(flow), null);
+ } else {
+ setEndState(EndState.FAILED);
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void init() {
+ this.subgoalDispatched = false;
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(Threat threat) {
+ this.flow = threat.getConcept();
+ }
+ }
+
+ public class LimitFlowRatePlan10 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Flow flow;
+ private boolean subgoalDispatched;
+
+ @Override
+ public void execute() {
+ if (!subgoalDispatched) {
+ dispatchSubgoalAndListen(new BeliefValueGoal<>(
+ new FlowRateLimited(flow), true));
+ this.subgoalDispatched = true;
+ } else {
+ GoalEvent event = getGoalEvent();
+ if (event != null) {
+ if (GoalStatus.ACHIEVED.equals(event.getStatus())) {
+ addBelief(((BeliefGoal<?>) event.getGoal())
+ .getOutputBelief());
+ belief(new Threat(flow), null);
+ } else {
+ setEndState(EndState.FAILED);
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void init() {
+ this.subgoalDispatched = false;
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(Threat threat) {
+ this.flow = threat.getConcept();
+ }
+ }
+
+ public class LimitFlowRatePlan11 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Flow flow;
+ private boolean subgoalDispatched;
+
+ @Override
+ public void execute() {
+ if (!subgoalDispatched) {
+ dispatchSubgoalAndListen(new BeliefValueGoal<>(
+ new FlowRateLimited(flow), true));
+ this.subgoalDispatched = true;
+ } else {
+ GoalEvent event = getGoalEvent();
+ if (event != null) {
+ if (GoalStatus.ACHIEVED.equals(event.getStatus())) {
+ addBelief(((BeliefGoal<?>) event.getGoal())
+ .getOutputBelief());
+ belief(new Threat(flow), null);
+ } else {
+ setEndState(EndState.FAILED);
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void init() {
+ this.subgoalDispatched = false;
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(Threat threat) {
+ this.flow = threat.getConcept();
+ }
+ }
+
+ public class LimitFlowRatePlan12 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Flow flow;
+ private boolean subgoalDispatched;
+
+ @Override
+ public void execute() {
+ if (!subgoalDispatched) {
+ dispatchSubgoalAndListen(new BeliefValueGoal<>(
+ new FlowRateLimited(flow), true));
+ this.subgoalDispatched = true;
+ } else {
+ GoalEvent event = getGoalEvent();
+ if (event != null) {
+ if (GoalStatus.ACHIEVED.equals(event.getStatus())) {
+ addBelief(((BeliefGoal<?>) event.getGoal())
+ .getOutputBelief());
+ belief(new Threat(flow), null);
+ } else {
+ setEndState(EndState.FAILED);
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void init() {
+ this.subgoalDispatched = false;
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(Threat threat) {
+ this.flow = threat.getConcept();
+ }
+ }
+
+ public class LimitFlowRatePlan13 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Flow flow;
+ private boolean subgoalDispatched;
+
+ @Override
+ public void execute() {
+ if (!subgoalDispatched) {
+ dispatchSubgoalAndListen(new BeliefValueGoal<>(
+ new FlowRateLimited(flow), true));
+ this.subgoalDispatched = true;
+ } else {
+ GoalEvent event = getGoalEvent();
+ if (event != null) {
+ if (GoalStatus.ACHIEVED.equals(event.getStatus())) {
+ addBelief(((BeliefGoal<?>) event.getGoal())
+ .getOutputBelief());
+ belief(new Threat(flow), null);
+ } else {
+ setEndState(EndState.FAILED);
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void init() {
+ this.subgoalDispatched = false;
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(Threat threat) {
+ this.flow = threat.getConcept();
+ }
+ }
+
+ public class LimitFlowRatePlan14 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Flow flow;
+ private boolean subgoalDispatched;
+
+ @Override
+ public void execute() {
+ if (!subgoalDispatched) {
+ dispatchSubgoalAndListen(new BeliefValueGoal<>(
+ new FlowRateLimited(flow), true));
+ this.subgoalDispatched = true;
+ } else {
+ GoalEvent event = getGoalEvent();
+ if (event != null) {
+ if (GoalStatus.ACHIEVED.equals(event.getStatus())) {
+ addBelief(((BeliefGoal<?>) event.getGoal())
+ .getOutputBelief());
+ belief(new Threat(flow), null);
+ } else {
+ setEndState(EndState.FAILED);
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void init() {
+ this.subgoalDispatched = false;
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(Threat threat) {
+ this.flow = threat.getConcept();
+ }
+ }
+
+ public class LimitFlowRatePlan15 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Flow flow;
+ private boolean subgoalDispatched;
+
+ @Override
+ public void execute() {
+ if (!subgoalDispatched) {
+ dispatchSubgoalAndListen(new BeliefValueGoal<>(
+ new FlowRateLimited(flow), true));
+ this.subgoalDispatched = true;
+ } else {
+ GoalEvent event = getGoalEvent();
+ if (event != null) {
+ if (GoalStatus.ACHIEVED.equals(event.getStatus())) {
+ addBelief(((BeliefGoal<?>) event.getGoal())
+ .getOutputBelief());
+ belief(new Threat(flow), null);
+ } else {
+ setEndState(EndState.FAILED);
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void init() {
+ this.subgoalDispatched = false;
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(Threat threat) {
+ this.flow = threat.getConcept();
+ }
+ }
+
+ public class LimitFlowRatePlan16 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Flow flow;
+ private boolean subgoalDispatched;
+
+ @Override
+ public void execute() {
+ if (!subgoalDispatched) {
+ dispatchSubgoalAndListen(new BeliefValueGoal<>(
+ new FlowRateLimited(flow), true));
+ this.subgoalDispatched = true;
+ } else {
+ GoalEvent event = getGoalEvent();
+ if (event != null) {
+ if (GoalStatus.ACHIEVED.equals(event.getStatus())) {
+ addBelief(((BeliefGoal<?>) event.getGoal())
+ .getOutputBelief());
+ belief(new Threat(flow), null);
+ } else {
+ setEndState(EndState.FAILED);
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void init() {
+ this.subgoalDispatched = false;
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(Threat threat) {
+ this.flow = threat.getConcept();
+ }
+ }
+
+ public class LimitFlowRatePlan17 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Flow flow;
+ private boolean subgoalDispatched;
+
+ @Override
+ public void execute() {
+ if (!subgoalDispatched) {
+ dispatchSubgoalAndListen(new BeliefValueGoal<>(
+ new FlowRateLimited(flow), true));
+ this.subgoalDispatched = true;
+ } else {
+ GoalEvent event = getGoalEvent();
+ if (event != null) {
+ if (GoalStatus.ACHIEVED.equals(event.getStatus())) {
+ addBelief(((BeliefGoal<?>) event.getGoal())
+ .getOutputBelief());
+ belief(new Threat(flow), null);
+ } else {
+ setEndState(EndState.FAILED);
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void init() {
+ this.subgoalDispatched = false;
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(Threat threat) {
+ this.flow = threat.getConcept();
+ }
+ }
+
private static final long serialVersionUID = -1705728861020677126L;
@bdi4jade.annotation.Plan
private Plan analyseIpFlows;
@bdi4jade.annotation.Plan
- private Plan limitFlowRate;
+ private Plan limitFlowRate, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17;
@bdi4jade.annotation.TransientBelief
private final Classifier role;
@@ -179,6 +808,194 @@ public class ClassifierCapability extends RouterAgentCapability implements
return (threat != null && threat.getValue());
};
};
+
+
+ a1 = new DefaultPlan(
+ GoalTemplateFactory.hasNoBeliefOfType(Threat.class),
+ LimitFlowRatePlan1.class) {
+ public boolean isContextApplicable(Goal goal) {
+ BeliefNotPresentGoal<Threat> bg = (BeliefNotPresentGoal<Threat>) goal;
+ Predicate<Threat> threat = (Predicate<Threat>) getBeliefBase()
+ .getBelief(bg.getBeliefName());
+ return (threat != null && threat.getValue());
+ };
+ };
+
+ a2 = new DefaultPlan(
+ GoalTemplateFactory.hasNoBeliefOfType(Threat.class),
+ LimitFlowRatePlan2.class) {
+ public boolean isContextApplicable(Goal goal) {
+ BeliefNotPresentGoal<Threat> bg = (BeliefNotPresentGoal<Threat>) goal;
+ Predicate<Threat> threat = (Predicate<Threat>) getBeliefBase()
+ .getBelief(bg.getBeliefName());
+ return (threat != null && threat.getValue());
+ };
+ };
+
+ a3 = new DefaultPlan(
+ GoalTemplateFactory.hasNoBeliefOfType(Threat.class),
+ LimitFlowRatePlan3.class) {
+ public boolean isContextApplicable(Goal goal) {
+ BeliefNotPresentGoal<Threat> bg = (BeliefNotPresentGoal<Threat>) goal;
+ Predicate<Threat> threat = (Predicate<Threat>) getBeliefBase()
+ .getBelief(bg.getBeliefName());
+ return (threat != null && threat.getValue());
+ };
+ };
+
+ a4 = new DefaultPlan(
+ GoalTemplateFactory.hasNoBeliefOfType(Threat.class),
+ LimitFlowRatePlan4.class) {
+ public boolean isContextApplicable(Goal goal) {
+ BeliefNotPresentGoal<Threat> bg = (BeliefNotPresentGoal<Threat>) goal;
+ Predicate<Threat> threat = (Predicate<Threat>) getBeliefBase()
+ .getBelief(bg.getBeliefName());
+ return (threat != null && threat.getValue());
+ };
+ };
+
+ a5 = new DefaultPlan(
+ GoalTemplateFactory.hasNoBeliefOfType(Threat.class),
+ LimitFlowRatePlan5.class) {
+ public boolean isContextApplicable(Goal goal) {
+ BeliefNotPresentGoal<Threat> bg = (BeliefNotPresentGoal<Threat>) goal;
+ Predicate<Threat> threat = (Predicate<Threat>) getBeliefBase()
+ .getBelief(bg.getBeliefName());
+ return (threat != null && threat.getValue());
+ };
+ };
+
+ a6 = new DefaultPlan(
+ GoalTemplateFactory.hasNoBeliefOfType(Threat.class),
+ LimitFlowRatePlan6.class) {
+ public boolean isContextApplicable(Goal goal) {
+ BeliefNotPresentGoal<Threat> bg = (BeliefNotPresentGoal<Threat>) goal;
+ Predicate<Threat> threat = (Predicate<Threat>) getBeliefBase()
+ .getBelief(bg.getBeliefName());
+ return (threat != null && threat.getValue());
+ };
+ };
+
+ a7 = new DefaultPlan(
+ GoalTemplateFactory.hasNoBeliefOfType(Threat.class),
+ LimitFlowRatePlan7.class) {
+ public boolean isContextApplicable(Goal goal) {
+ BeliefNotPresentGoal<Threat> bg = (BeliefNotPresentGoal<Threat>) goal;
+ Predicate<Threat> threat = (Predicate<Threat>) getBeliefBase()
+ .getBelief(bg.getBeliefName());
+ return (threat != null && threat.getValue());
+ };
+ };
+
+ a8 = new DefaultPlan(
+ GoalTemplateFactory.hasNoBeliefOfType(Threat.class),
+ LimitFlowRatePlan8.class) {
+ public boolean isContextApplicable(Goal goal) {
+ BeliefNotPresentGoal<Threat> bg = (BeliefNotPresentGoal<Threat>) goal;
+ Predicate<Threat> threat = (Predicate<Threat>) getBeliefBase()
+ .getBelief(bg.getBeliefName());
+ return (threat != null && threat.getValue());
+ };
+ };
+
+ a9 = new DefaultPlan(
+ GoalTemplateFactory.hasNoBeliefOfType(Threat.class),
+ LimitFlowRatePlan9.class) {
+ public boolean isContextApplicable(Goal goal) {
+ BeliefNotPresentGoal<Threat> bg = (BeliefNotPresentGoal<Threat>) goal;
+ Predicate<Threat> threat = (Predicate<Threat>) getBeliefBase()
+ .getBelief(bg.getBeliefName());
+ return (threat != null && threat.getValue());
+ };
+ };
+
+ a10 = new DefaultPlan(
+ GoalTemplateFactory.hasNoBeliefOfType(Threat.class),
+ LimitFlowRatePlan10.class) {
+ public boolean isContextApplicable(Goal goal) {
+ BeliefNotPresentGoal<Threat> bg = (BeliefNotPresentGoal<Threat>) goal;
+ Predicate<Threat> threat = (Predicate<Threat>) getBeliefBase()
+ .getBelief(bg.getBeliefName());
+ return (threat != null && threat.getValue());
+ };
+ };
+
+ a11 = new DefaultPlan(
+ GoalTemplateFactory.hasNoBeliefOfType(Threat.class),
+ LimitFlowRatePlan11.class) {
+ public boolean isContextApplicable(Goal goal) {
+ BeliefNotPresentGoal<Threat> bg = (BeliefNotPresentGoal<Threat>) goal;
+ Predicate<Threat> threat = (Predicate<Threat>) getBeliefBase()
+ .getBelief(bg.getBeliefName());
+ return (threat != null && threat.getValue());
+ };
+ };
+
+ a12 = new DefaultPlan(
+ GoalTemplateFactory.hasNoBeliefOfType(Threat.class),
+ LimitFlowRatePlan12.class) {
+ public boolean isContextApplicable(Goal goal) {
+ BeliefNotPresentGoal<Threat> bg = (BeliefNotPresentGoal<Threat>) goal;
+ Predicate<Threat> threat = (Predicate<Threat>) getBeliefBase()
+ .getBelief(bg.getBeliefName());
+ return (threat != null && threat.getValue());
+ };
+ };
+
+ a13 = new DefaultPlan(
+ GoalTemplateFactory.hasNoBeliefOfType(Threat.class),
+ LimitFlowRatePlan13.class) {
+ public boolean isContextApplicable(Goal goal) {
+ BeliefNotPresentGoal<Threat> bg = (BeliefNotPresentGoal<Threat>) goal;
+ Predicate<Threat> threat = (Predicate<Threat>) getBeliefBase()
+ .getBelief(bg.getBeliefName());
+ return (threat != null && threat.getValue());
+ };
+ };
+
+ a14 = new DefaultPlan(
+ GoalTemplateFactory.hasNoBeliefOfType(Threat.class),
+ LimitFlowRatePlan14.class) {
+ public boolean isContextApplicable(Goal goal) {
+ BeliefNotPresentGoal<Threat> bg = (BeliefNotPresentGoal<Threat>) goal;
+ Predicate<Threat> threat = (Predicate<Threat>) getBeliefBase()
+ .getBelief(bg.getBeliefName());
+ return (threat != null && threat.getValue());
+ };
+ };
+
+ a15 = new DefaultPlan(
+ GoalTemplateFactory.hasNoBeliefOfType(Threat.class),
+ LimitFlowRatePlan15.class) {
+ public boolean isContextApplicable(Goal goal) {
+ BeliefNotPresentGoal<Threat> bg = (BeliefNotPresentGoal<Threat>) goal;
+ Predicate<Threat> threat = (Predicate<Threat>) getBeliefBase()
+ .getBelief(bg.getBeliefName());
+ return (threat != null && threat.getValue());
+ };
+ };
+
+ a16 = new DefaultPlan(
+ GoalTemplateFactory.hasNoBeliefOfType(Threat.class),
+ LimitFlowRatePlan16.class) {
+ public boolean isContextApplicable(Goal goal) {
+ BeliefNotPresentGoal<Threat> bg = (BeliefNotPresentGoal<Threat>) goal;
+ Predicate<Threat> threat = (Predicate<Threat>) getBeliefBase()
+ .getBelief(bg.getBeliefName());
+ return (threat != null && threat.getValue());
+ };
+ };
+
+ a17 = new DefaultPlan(
+ GoalTemplateFactory.hasNoBeliefOfType(Threat.class),
+ LimitFlowRatePlan17.class) {
+ public boolean isContextApplicable(Goal goal) {
+ BeliefNotPresentGoal<Threat> bg = (BeliefNotPresentGoal<Threat>) goal;
+ Predicate<Threat> threat = (Predicate<Threat>) getBeliefBase()
+ .getBelief(bg.getBeliefName());
+ return (threat != null && threat.getValue());
+ };
+ };
}
@Override
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/agent/FlowExporterCapability.java b/network-resilience/src/br/ufrgs/inf/bdinetr/agent/FlowExporterCapability.java
index 4d7f903..4b90d1e 100644
--- a/network-resilience/src/br/ufrgs/inf/bdinetr/agent/FlowExporterCapability.java
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/agent/FlowExporterCapability.java
@@ -54,10 +54,300 @@ public class FlowExporterCapability extends RouterAgentCapability {
}
}
+ public class ExportFlowsPlanBody1 extends AbstractPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Ip ip;
+
+ @Override
+ public void action() {
+ role.turnFlowExporterOn(ip);
+ setEndState(EndState.SUCCESSFUL);
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setIp(Ip ip) {
+ this.ip = ip;
+ }
+ }
+ public class ExportFlowsPlanBody2 extends AbstractPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Ip ip;
+
+ @Override
+ public void action() {
+ role.turnFlowExporterOn(ip);
+ setEndState(EndState.SUCCESSFUL);
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setIp(Ip ip) {
+ this.ip = ip;
+ }
+ }
+
+ public class ExportFlowsPlanBody3 extends AbstractPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Ip ip;
+
+ @Override
+ public void action() {
+ role.turnFlowExporterOn(ip);
+ setEndState(EndState.SUCCESSFUL);
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setIp(Ip ip) {
+ this.ip = ip;
+ }
+ }
+
+ public class ExportFlowsPlanBody4 extends AbstractPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Ip ip;
+
+ @Override
+ public void action() {
+ role.turnFlowExporterOn(ip);
+ setEndState(EndState.SUCCESSFUL);
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setIp(Ip ip) {
+ this.ip = ip;
+ }
+ }
+
+ public class ExportFlowsPlanBody5 extends AbstractPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Ip ip;
+
+ @Override
+ public void action() {
+ role.turnFlowExporterOn(ip);
+ setEndState(EndState.SUCCESSFUL);
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setIp(Ip ip) {
+ this.ip = ip;
+ }
+ }
+
+ public class ExportFlowsPlanBody6 extends AbstractPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Ip ip;
+
+ @Override
+ public void action() {
+ role.turnFlowExporterOn(ip);
+ setEndState(EndState.SUCCESSFUL);
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setIp(Ip ip) {
+ this.ip = ip;
+ }
+ }
+
+ public class ExportFlowsPlanBody7 extends AbstractPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Ip ip;
+
+ @Override
+ public void action() {
+ role.turnFlowExporterOn(ip);
+ setEndState(EndState.SUCCESSFUL);
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setIp(Ip ip) {
+ this.ip = ip;
+ }
+ }
+
+ public class ExportFlowsPlanBody8 extends AbstractPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Ip ip;
+
+ @Override
+ public void action() {
+ role.turnFlowExporterOn(ip);
+ setEndState(EndState.SUCCESSFUL);
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setIp(Ip ip) {
+ this.ip = ip;
+ }
+ }
+
+ public class ExportFlowsPlanBody9 extends AbstractPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Ip ip;
+
+ @Override
+ public void action() {
+ role.turnFlowExporterOn(ip);
+ setEndState(EndState.SUCCESSFUL);
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setIp(Ip ip) {
+ this.ip = ip;
+ }
+ }
+
+ public class ExportFlowsPlanBody10 extends AbstractPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Ip ip;
+
+ @Override
+ public void action() {
+ role.turnFlowExporterOn(ip);
+ setEndState(EndState.SUCCESSFUL);
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setIp(Ip ip) {
+ this.ip = ip;
+ }
+ }
+
+ public class ExportFlowsPlanBody11 extends AbstractPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Ip ip;
+
+ @Override
+ public void action() {
+ role.turnFlowExporterOn(ip);
+ setEndState(EndState.SUCCESSFUL);
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setIp(Ip ip) {
+ this.ip = ip;
+ }
+ }
+
+ public class ExportFlowsPlanBody12 extends AbstractPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Ip ip;
+
+ @Override
+ public void action() {
+ role.turnFlowExporterOn(ip);
+ setEndState(EndState.SUCCESSFUL);
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setIp(Ip ip) {
+ this.ip = ip;
+ }
+ }
+
+ public class ExportFlowsPlanBody13 extends AbstractPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Ip ip;
+
+ @Override
+ public void action() {
+ role.turnFlowExporterOn(ip);
+ setEndState(EndState.SUCCESSFUL);
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setIp(Ip ip) {
+ this.ip = ip;
+ }
+ }
+
+ public class ExportFlowsPlanBody14 extends AbstractPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Ip ip;
+
+ @Override
+ public void action() {
+ role.turnFlowExporterOn(ip);
+ setEndState(EndState.SUCCESSFUL);
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setIp(Ip ip) {
+ this.ip = ip;
+ }
+ }
+
+ public class ExportFlowsPlanBody15 extends AbstractPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Ip ip;
+
+ @Override
+ public void action() {
+ role.turnFlowExporterOn(ip);
+ setEndState(EndState.SUCCESSFUL);
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setIp(Ip ip) {
+ this.ip = ip;
+ }
+ }
+
+ public class ExportFlowsPlanBody16 extends AbstractPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Ip ip;
+
+ @Override
+ public void action() {
+ role.turnFlowExporterOn(ip);
+ setEndState(EndState.SUCCESSFUL);
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setIp(Ip ip) {
+ this.ip = ip;
+ }
+ }
+
+ public class ExportFlowsPlanBody17 extends AbstractPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Ip ip;
+
+ @Override
+ public void action() {
+ role.turnFlowExporterOn(ip);
+ setEndState(EndState.SUCCESSFUL);
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setIp(Ip ip) {
+ this.ip = ip;
+ }
+ }
+
+
+
private static final long serialVersionUID = -1705728861020677126L;
@bdi4jade.annotation.Plan
- private Plan exportFlows;
+ private Plan exportFlows, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17;
@bdi4jade.annotation.TransientBelief
private final FlowExporter role;
@@ -66,6 +356,57 @@ public class FlowExporterCapability extends RouterAgentCapability {
this.exportFlows = new DefaultPlan(FlowExport.class,
ExportFlowsPlanBody.class);
+
+ this.a1 = new DefaultPlan(FlowExport.class,
+ ExportFlowsPlanBody1.class);
+
+ this.a2 = new DefaultPlan(FlowExport.class,
+ ExportFlowsPlanBody2.class);
+
+ this.a3 = new DefaultPlan(FlowExport.class,
+ ExportFlowsPlanBody3.class);
+
+ this.a4 = new DefaultPlan(FlowExport.class,
+ ExportFlowsPlanBody4.class);
+
+ this.a5 = new DefaultPlan(FlowExport.class,
+ ExportFlowsPlanBody5.class);
+
+ this.a6 = new DefaultPlan(FlowExport.class,
+ ExportFlowsPlanBody6.class);
+
+ this.a7 = new DefaultPlan(FlowExport.class,
+ ExportFlowsPlanBody7.class);
+
+ this.a8 = new DefaultPlan(FlowExport.class,
+ ExportFlowsPlanBody8.class);
+
+ this.a9 = new DefaultPlan(FlowExport.class,
+ ExportFlowsPlanBody9.class);
+
+ this.a10 = new DefaultPlan(FlowExport.class,
+ ExportFlowsPlanBody10.class);
+
+ this.a11 = new DefaultPlan(FlowExport.class,
+ ExportFlowsPlanBody11.class);
+
+ this.a12 = new DefaultPlan(FlowExport.class,
+ ExportFlowsPlanBody12.class);
+
+ this.a13 = new DefaultPlan(FlowExport.class,
+ ExportFlowsPlanBody13.class);
+
+ this.a14 = new DefaultPlan(FlowExport.class,
+ ExportFlowsPlanBody14.class);
+
+ this.a15 = new DefaultPlan(FlowExport.class,
+ ExportFlowsPlanBody15.class);
+
+ this.a16 = new DefaultPlan(FlowExport.class,
+ ExportFlowsPlanBody16.class);
+
+ this.a17 = new DefaultPlan(FlowExport.class,
+ ExportFlowsPlanBody17.class);
}
@Override
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 153d6ca..18126d9 100644
--- a/network-resilience/src/br/ufrgs/inf/bdinetr/agent/LinkMonitorCapability.java
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/agent/LinkMonitorCapability.java
@@ -94,6 +94,633 @@ public class LinkMonitorCapability extends RouterAgentCapability implements
this.link = attackPrevented.getConcept();
}
}
+ public class LimitLinkRate1 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Link link;
+ private boolean subgoalDispatched;
+
+ @Override
+ public void execute() {
+ if (!subgoalDispatched) {
+ dispatchSubgoalAndListen(new BeliefValueGoal<>(
+ new LinkRateLimited(link), true));
+ this.subgoalDispatched = true;
+ } else {
+ GoalEvent event = getGoalEvent();
+ if (event != null) {
+ if (GoalStatus.ACHIEVED.equals(event.getStatus())) {
+ addBelief(((BeliefGoal<?>) event.getGoal())
+ .getOutputBelief());
+ belief(new AttackPrevented(link), true);
+ } else {
+ setEndState(EndState.FAILED);
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void init() {
+ this.subgoalDispatched = false;
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(AttackPrevented attackPrevented) {
+ this.link = attackPrevented.getConcept();
+ }
+ }
+ public class LimitLinkRate2 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Link link;
+ private boolean subgoalDispatched;
+
+ @Override
+ public void execute() {
+ if (!subgoalDispatched) {
+ dispatchSubgoalAndListen(new BeliefValueGoal<>(
+ new LinkRateLimited(link), true));
+ this.subgoalDispatched = true;
+ } else {
+ GoalEvent event = getGoalEvent();
+ if (event != null) {
+ if (GoalStatus.ACHIEVED.equals(event.getStatus())) {
+ addBelief(((BeliefGoal<?>) event.getGoal())
+ .getOutputBelief());
+ belief(new AttackPrevented(link), true);
+ } else {
+ setEndState(EndState.FAILED);
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void init() {
+ this.subgoalDispatched = false;
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(AttackPrevented attackPrevented) {
+ this.link = attackPrevented.getConcept();
+ }
+ }
+
+ public class LimitLinkRate3 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Link link;
+ private boolean subgoalDispatched;
+
+ @Override
+ public void execute() {
+ if (!subgoalDispatched) {
+ dispatchSubgoalAndListen(new BeliefValueGoal<>(
+ new LinkRateLimited(link), true));
+ this.subgoalDispatched = true;
+ } else {
+ GoalEvent event = getGoalEvent();
+ if (event != null) {
+ if (GoalStatus.ACHIEVED.equals(event.getStatus())) {
+ addBelief(((BeliefGoal<?>) event.getGoal())
+ .getOutputBelief());
+ belief(new AttackPrevented(link), true);
+ } else {
+ setEndState(EndState.FAILED);
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void init() {
+ this.subgoalDispatched = false;
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(AttackPrevented attackPrevented) {
+ this.link = attackPrevented.getConcept();
+ }
+ }
+
+ public class LimitLinkRate4 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Link link;
+ private boolean subgoalDispatched;
+
+ @Override
+ public void execute() {
+ if (!subgoalDispatched) {
+ dispatchSubgoalAndListen(new BeliefValueGoal<>(
+ new LinkRateLimited(link), true));
+ this.subgoalDispatched = true;
+ } else {
+ GoalEvent event = getGoalEvent();
+ if (event != null) {
+ if (GoalStatus.ACHIEVED.equals(event.getStatus())) {
+ addBelief(((BeliefGoal<?>) event.getGoal())
+ .getOutputBelief());
+ belief(new AttackPrevented(link), true);
+ } else {
+ setEndState(EndState.FAILED);
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void init() {
+ this.subgoalDispatched = false;
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(AttackPrevented attackPrevented) {
+ this.link = attackPrevented.getConcept();
+ }
+ }
+
+ public class LimitLinkRate5 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Link link;
+ private boolean subgoalDispatched;
+
+ @Override
+ public void execute() {
+ if (!subgoalDispatched) {
+ dispatchSubgoalAndListen(new BeliefValueGoal<>(
+ new LinkRateLimited(link), true));
+ this.subgoalDispatched = true;
+ } else {
+ GoalEvent event = getGoalEvent();
+ if (event != null) {
+ if (GoalStatus.ACHIEVED.equals(event.getStatus())) {
+ addBelief(((BeliefGoal<?>) event.getGoal())
+ .getOutputBelief());
+ belief(new AttackPrevented(link), true);
+ } else {
+ setEndState(EndState.FAILED);
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void init() {
+ this.subgoalDispatched = false;
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(AttackPrevented attackPrevented) {
+ this.link = attackPrevented.getConcept();
+ }
+ }
+
+ public class LimitLinkRate6 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Link link;
+ private boolean subgoalDispatched;
+
+ @Override
+ public void execute() {
+ if (!subgoalDispatched) {
+ dispatchSubgoalAndListen(new BeliefValueGoal<>(
+ new LinkRateLimited(link), true));
+ this.subgoalDispatched = true;
+ } else {
+ GoalEvent event = getGoalEvent();
+ if (event != null) {
+ if (GoalStatus.ACHIEVED.equals(event.getStatus())) {
+ addBelief(((BeliefGoal<?>) event.getGoal())
+ .getOutputBelief());
+ belief(new AttackPrevented(link), true);
+ } else {
+ setEndState(EndState.FAILED);
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void init() {
+ this.subgoalDispatched = false;
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(AttackPrevented attackPrevented) {
+ this.link = attackPrevented.getConcept();
+ }
+ }
+
+ public class LimitLinkRate7 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Link link;
+ private boolean subgoalDispatched;
+
+ @Override
+ public void execute() {
+ if (!subgoalDispatched) {
+ dispatchSubgoalAndListen(new BeliefValueGoal<>(
+ new LinkRateLimited(link), true));
+ this.subgoalDispatched = true;
+ } else {
+ GoalEvent event = getGoalEvent();
+ if (event != null) {
+ if (GoalStatus.ACHIEVED.equals(event.getStatus())) {
+ addBelief(((BeliefGoal<?>) event.getGoal())
+ .getOutputBelief());
+ belief(new AttackPrevented(link), true);
+ } else {
+ setEndState(EndState.FAILED);
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void init() {
+ this.subgoalDispatched = false;
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(AttackPrevented attackPrevented) {
+ this.link = attackPrevented.getConcept();
+ }
+ }
+
+ public class LimitLinkRate8 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Link link;
+ private boolean subgoalDispatched;
+
+ @Override
+ public void execute() {
+ if (!subgoalDispatched) {
+ dispatchSubgoalAndListen(new BeliefValueGoal<>(
+ new LinkRateLimited(link), true));
+ this.subgoalDispatched = true;
+ } else {
+ GoalEvent event = getGoalEvent();
+ if (event != null) {
+ if (GoalStatus.ACHIEVED.equals(event.getStatus())) {
+ addBelief(((BeliefGoal<?>) event.getGoal())
+ .getOutputBelief());
+ belief(new AttackPrevented(link), true);
+ } else {
+ setEndState(EndState.FAILED);
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void init() {
+ this.subgoalDispatched = false;
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(AttackPrevented attackPrevented) {
+ this.link = attackPrevented.getConcept();
+ }
+ }
+
+ public class LimitLinkRate9 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Link link;
+ private boolean subgoalDispatched;
+
+ @Override
+ public void execute() {
+ if (!subgoalDispatched) {
+ dispatchSubgoalAndListen(new BeliefValueGoal<>(
+ new LinkRateLimited(link), true));
+ this.subgoalDispatched = true;
+ } else {
+ GoalEvent event = getGoalEvent();
+ if (event != null) {
+ if (GoalStatus.ACHIEVED.equals(event.getStatus())) {
+ addBelief(((BeliefGoal<?>) event.getGoal())
+ .getOutputBelief());
+ belief(new AttackPrevented(link), true);
+ } else {
+ setEndState(EndState.FAILED);
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void init() {
+ this.subgoalDispatched = false;
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(AttackPrevented attackPrevented) {
+ this.link = attackPrevented.getConcept();
+ }
+ }
+
+ public class LimitLinkRate10 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Link link;
+ private boolean subgoalDispatched;
+
+ @Override
+ public void execute() {
+ if (!subgoalDispatched) {
+ dispatchSubgoalAndListen(new BeliefValueGoal<>(
+ new LinkRateLimited(link), true));
+ this.subgoalDispatched = true;
+ } else {
+ GoalEvent event = getGoalEvent();
+ if (event != null) {
+ if (GoalStatus.ACHIEVED.equals(event.getStatus())) {
+ addBelief(((BeliefGoal<?>) event.getGoal())
+ .getOutputBelief());
+ belief(new AttackPrevented(link), true);
+ } else {
+ setEndState(EndState.FAILED);
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void init() {
+ this.subgoalDispatched = false;
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(AttackPrevented attackPrevented) {
+ this.link = attackPrevented.getConcept();
+ }
+ }
+
+ public class LimitLinkRate11 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Link link;
+ private boolean subgoalDispatched;
+
+ @Override
+ public void execute() {
+ if (!subgoalDispatched) {
+ dispatchSubgoalAndListen(new BeliefValueGoal<>(
+ new LinkRateLimited(link), true));
+ this.subgoalDispatched = true;
+ } else {
+ GoalEvent event = getGoalEvent();
+ if (event != null) {
+ if (GoalStatus.ACHIEVED.equals(event.getStatus())) {
+ addBelief(((BeliefGoal<?>) event.getGoal())
+ .getOutputBelief());
+ belief(new AttackPrevented(link), true);
+ } else {
+ setEndState(EndState.FAILED);
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void init() {
+ this.subgoalDispatched = false;
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(AttackPrevented attackPrevented) {
+ this.link = attackPrevented.getConcept();
+ }
+ }
+
+ public class LimitLinkRate12 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Link link;
+ private boolean subgoalDispatched;
+
+ @Override
+ public void execute() {
+ if (!subgoalDispatched) {
+ dispatchSubgoalAndListen(new BeliefValueGoal<>(
+ new LinkRateLimited(link), true));
+ this.subgoalDispatched = true;
+ } else {
+ GoalEvent event = getGoalEvent();
+ if (event != null) {
+ if (GoalStatus.ACHIEVED.equals(event.getStatus())) {
+ addBelief(((BeliefGoal<?>) event.getGoal())
+ .getOutputBelief());
+ belief(new AttackPrevented(link), true);
+ } else {
+ setEndState(EndState.FAILED);
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void init() {
+ this.subgoalDispatched = false;
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(AttackPrevented attackPrevented) {
+ this.link = attackPrevented.getConcept();
+ }
+ }
+
+ public class LimitLinkRate13 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Link link;
+ private boolean subgoalDispatched;
+
+ @Override
+ public void execute() {
+ if (!subgoalDispatched) {
+ dispatchSubgoalAndListen(new BeliefValueGoal<>(
+ new LinkRateLimited(link), true));
+ this.subgoalDispatched = true;
+ } else {
+ GoalEvent event = getGoalEvent();
+ if (event != null) {
+ if (GoalStatus.ACHIEVED.equals(event.getStatus())) {
+ addBelief(((BeliefGoal<?>) event.getGoal())
+ .getOutputBelief());
+ belief(new AttackPrevented(link), true);
+ } else {
+ setEndState(EndState.FAILED);
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void init() {
+ this.subgoalDispatched = false;
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(AttackPrevented attackPrevented) {
+ this.link = attackPrevented.getConcept();
+ }
+ }
+
+ public class LimitLinkRate14 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Link link;
+ private boolean subgoalDispatched;
+
+ @Override
+ public void execute() {
+ if (!subgoalDispatched) {
+ dispatchSubgoalAndListen(new BeliefValueGoal<>(
+ new LinkRateLimited(link), true));
+ this.subgoalDispatched = true;
+ } else {
+ GoalEvent event = getGoalEvent();
+ if (event != null) {
+ if (GoalStatus.ACHIEVED.equals(event.getStatus())) {
+ addBelief(((BeliefGoal<?>) event.getGoal())
+ .getOutputBelief());
+ belief(new AttackPrevented(link), true);
+ } else {
+ setEndState(EndState.FAILED);
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void init() {
+ this.subgoalDispatched = false;
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(AttackPrevented attackPrevented) {
+ this.link = attackPrevented.getConcept();
+ }
+ }
+
+ public class LimitLinkRate15 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Link link;
+ private boolean subgoalDispatched;
+
+ @Override
+ public void execute() {
+ if (!subgoalDispatched) {
+ dispatchSubgoalAndListen(new BeliefValueGoal<>(
+ new LinkRateLimited(link), true));
+ this.subgoalDispatched = true;
+ } else {
+ GoalEvent event = getGoalEvent();
+ if (event != null) {
+ if (GoalStatus.ACHIEVED.equals(event.getStatus())) {
+ addBelief(((BeliefGoal<?>) event.getGoal())
+ .getOutputBelief());
+ belief(new AttackPrevented(link), true);
+ } else {
+ setEndState(EndState.FAILED);
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void init() {
+ this.subgoalDispatched = false;
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(AttackPrevented attackPrevented) {
+ this.link = attackPrevented.getConcept();
+ }
+ }
+
+ public class LimitLinkRate16 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Link link;
+ private boolean subgoalDispatched;
+
+ @Override
+ public void execute() {
+ if (!subgoalDispatched) {
+ dispatchSubgoalAndListen(new BeliefValueGoal<>(
+ new LinkRateLimited(link), true));
+ this.subgoalDispatched = true;
+ } else {
+ GoalEvent event = getGoalEvent();
+ if (event != null) {
+ if (GoalStatus.ACHIEVED.equals(event.getStatus())) {
+ addBelief(((BeliefGoal<?>) event.getGoal())
+ .getOutputBelief());
+ belief(new AttackPrevented(link), true);
+ } else {
+ setEndState(EndState.FAILED);
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void init() {
+ this.subgoalDispatched = false;
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(AttackPrevented attackPrevented) {
+ this.link = attackPrevented.getConcept();
+ }
+ }
+
+ public class LimitLinkRate17 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Link link;
+ private boolean subgoalDispatched;
+
+ @Override
+ public void execute() {
+ if (!subgoalDispatched) {
+ dispatchSubgoalAndListen(new BeliefValueGoal<>(
+ new LinkRateLimited(link), true));
+ this.subgoalDispatched = true;
+ } else {
+ GoalEvent event = getGoalEvent();
+ if (event != null) {
+ if (GoalStatus.ACHIEVED.equals(event.getStatus())) {
+ addBelief(((BeliefGoal<?>) event.getGoal())
+ .getOutputBelief());
+ belief(new AttackPrevented(link), true);
+ } else {
+ setEndState(EndState.FAILED);
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void init() {
+ this.subgoalDispatched = false;
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(AttackPrevented attackPrevented) {
+ this.link = attackPrevented.getConcept();
+ }
+ }
public class RestoreLinkRate extends BeliefGoalPlanBody {
private static final long serialVersionUID = -3493377510830902961L;
@@ -136,7 +763,7 @@ public class LinkMonitorCapability extends RouterAgentCapability implements
private static final long serialVersionUID = -1705728861020677126L;
@bdi4jade.annotation.Plan
- private Plan limitLinkRate;
+ private Plan limitLinkRate, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17;
@bdi4jade.annotation.Plan
private Plan restoreLinkRate;
@bdi4jade.annotation.TransientBelief
@@ -178,6 +805,91 @@ public class LinkMonitorCapability extends RouterAgentCapability implements
return (linkRateLimited != null && linkRateLimited.getValue());
}
};
+
+ this.a1 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfTypeWithValue(
+ AttackPrevented.class, Boolean.TRUE),
+ LimitLinkRate1.class);
+
+ this.a2 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfTypeWithValue(
+ AttackPrevented.class, Boolean.TRUE),
+ LimitLinkRate2.class);
+
+ this.a3 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfTypeWithValue(
+ AttackPrevented.class, Boolean.TRUE),
+ LimitLinkRate3.class);
+
+ this.a4 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfTypeWithValue(
+ AttackPrevented.class, Boolean.TRUE),
+ LimitLinkRate4.class);
+
+ this.a5 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfTypeWithValue(
+ AttackPrevented.class, Boolean.TRUE),
+ LimitLinkRate5.class);
+
+ this.a6 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfTypeWithValue(
+ AttackPrevented.class, Boolean.TRUE),
+ LimitLinkRate6.class);
+
+ this.a7 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfTypeWithValue(
+ AttackPrevented.class, Boolean.TRUE),
+ LimitLinkRate7.class);
+
+ this.a8 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfTypeWithValue(
+ AttackPrevented.class, Boolean.TRUE),
+ LimitLinkRate8.class);
+
+ this.a9 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfTypeWithValue(
+ AttackPrevented.class, Boolean.TRUE),
+ LimitLinkRate9.class);
+
+ this.a10 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfTypeWithValue(
+ AttackPrevented.class, Boolean.TRUE),
+ LimitLinkRate10.class);
+
+ this.a11 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfTypeWithValue(
+ AttackPrevented.class, Boolean.TRUE),
+ LimitLinkRate11.class);
+
+ this.a12 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfTypeWithValue(
+ AttackPrevented.class, Boolean.TRUE),
+ LimitLinkRate12.class);
+
+ this.a13 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfTypeWithValue(
+ AttackPrevented.class, Boolean.TRUE),
+ LimitLinkRate13.class);
+
+ this.a14 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfTypeWithValue(
+ AttackPrevented.class, Boolean.TRUE),
+ LimitLinkRate14.class);
+
+ this.a15 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfTypeWithValue(
+ AttackPrevented.class, Boolean.TRUE),
+ LimitLinkRate15.class);
+
+ this.a16 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfTypeWithValue(
+ AttackPrevented.class, Boolean.TRUE),
+ LimitLinkRate16.class);
+
+ this.a17 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfTypeWithValue(
+ AttackPrevented.class, Boolean.TRUE),
+ LimitLinkRate17.class);
}
@Override
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/agent/RateLimiterCapability.java b/network-resilience/src/br/ufrgs/inf/bdinetr/agent/RateLimiterCapability.java
index f545d87..4513d87 100644
--- a/network-resilience/src/br/ufrgs/inf/bdinetr/agent/RateLimiterCapability.java
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/agent/RateLimiterCapability.java
@@ -129,6 +129,295 @@ public class RateLimiterCapability extends RouterAgentCapability {
}
}
+ public class RestoreLinkRate1 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Link link;
+
+ @Override
+ public void execute() {
+ role.unlimitLink(link);
+ belief(new LinkRateLimited(link), false);
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(LinkRateLimited linkRateLimited) {
+ this.link = linkRateLimited.getConcept();
+ }
+ }
+
+ public class RestoreLinkRate2 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Link link;
+
+ @Override
+ public void execute() {
+ role.unlimitLink(link);
+ belief(new LinkRateLimited(link), false);
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(LinkRateLimited linkRateLimited) {
+ this.link = linkRateLimited.getConcept();
+ }
+ }
+
+ public class RestoreLinkRate3 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Link link;
+
+ @Override
+ public void execute() {
+ role.unlimitLink(link);
+ belief(new LinkRateLimited(link), false);
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(LinkRateLimited linkRateLimited) {
+ this.link = linkRateLimited.getConcept();
+ }
+ }
+
+ public class RestoreLinkRate4 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Link link;
+
+ @Override
+ public void execute() {
+ role.unlimitLink(link);
+ belief(new LinkRateLimited(link), false);
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(LinkRateLimited linkRateLimited) {
+ this.link = linkRateLimited.getConcept();
+ }
+ }
+
+ public class RestoreLinkRate5 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Link link;
+
+ @Override
+ public void execute() {
+ role.unlimitLink(link);
+ belief(new LinkRateLimited(link), false);
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(LinkRateLimited linkRateLimited) {
+ this.link = linkRateLimited.getConcept();
+ }
+ }
+
+ public class RestoreLinkRate6 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Link link;
+
+ @Override
+ public void execute() {
+ role.unlimitLink(link);
+ belief(new LinkRateLimited(link), false);
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(LinkRateLimited linkRateLimited) {
+ this.link = linkRateLimited.getConcept();
+ }
+ }
+
+ public class RestoreLinkRate7 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Link link;
+
+ @Override
+ public void execute() {
+ role.unlimitLink(link);
+ belief(new LinkRateLimited(link), false);
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(LinkRateLimited linkRateLimited) {
+ this.link = linkRateLimited.getConcept();
+ }
+ }
+
+ public class RestoreLinkRate8 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Link link;
+
+ @Override
+ public void execute() {
+ role.unlimitLink(link);
+ belief(new LinkRateLimited(link), false);
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(LinkRateLimited linkRateLimited) {
+ this.link = linkRateLimited.getConcept();
+ }
+ }
+
+ public class RestoreLinkRate9 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Link link;
+
+ @Override
+ public void execute() {
+ role.unlimitLink(link);
+ belief(new LinkRateLimited(link), false);
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(LinkRateLimited linkRateLimited) {
+ this.link = linkRateLimited.getConcept();
+ }
+ }
+
+ public class RestoreLinkRate10 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Link link;
+
+ @Override
+ public void execute() {
+ role.unlimitLink(link);
+ belief(new LinkRateLimited(link), false);
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(LinkRateLimited linkRateLimited) {
+ this.link = linkRateLimited.getConcept();
+ }
+ }
+
+ public class RestoreLinkRate11 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Link link;
+
+ @Override
+ public void execute() {
+ role.unlimitLink(link);
+ belief(new LinkRateLimited(link), false);
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(LinkRateLimited linkRateLimited) {
+ this.link = linkRateLimited.getConcept();
+ }
+ }
+
+ public class RestoreLinkRate12 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Link link;
+
+ @Override
+ public void execute() {
+ role.unlimitLink(link);
+ belief(new LinkRateLimited(link), false);
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(LinkRateLimited linkRateLimited) {
+ this.link = linkRateLimited.getConcept();
+ }
+ }
+
+ public class RestoreLinkRate13 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Link link;
+
+ @Override
+ public void execute() {
+ role.unlimitLink(link);
+ belief(new LinkRateLimited(link), false);
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(LinkRateLimited linkRateLimited) {
+ this.link = linkRateLimited.getConcept();
+ }
+ }
+
+ public class RestoreLinkRate14 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Link link;
+
+ @Override
+ public void execute() {
+ role.unlimitLink(link);
+ belief(new LinkRateLimited(link), false);
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(LinkRateLimited linkRateLimited) {
+ this.link = linkRateLimited.getConcept();
+ }
+ }
+
+ public class RestoreLinkRate15 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Link link;
+
+ @Override
+ public void execute() {
+ role.unlimitLink(link);
+ belief(new LinkRateLimited(link), false);
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(LinkRateLimited linkRateLimited) {
+ this.link = linkRateLimited.getConcept();
+ }
+ }
+
+ public class RestoreLinkRate16 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Link link;
+
+ @Override
+ public void execute() {
+ role.unlimitLink(link);
+ belief(new LinkRateLimited(link), false);
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(LinkRateLimited linkRateLimited) {
+ this.link = linkRateLimited.getConcept();
+ }
+ }
+
+ public class RestoreLinkRate17 extends BeliefGoalPlanBody {
+ private static final long serialVersionUID = -3493377510830902961L;
+
+ private Link link;
+
+ @Override
+ public void execute() {
+ role.unlimitLink(link);
+ belief(new LinkRateLimited(link), false);
+ }
+
+ @Parameter(direction = Direction.IN)
+ public void setBeliefName(LinkRateLimited linkRateLimited) {
+ this.link = linkRateLimited.getConcept();
+ }
+ }
+
public static final int FLOW_LIMIT_RATE = 90;
public static final int IP_LIMIT_RATE = 50;
public static final int LINK_LIMIT_RATE = 50;
@@ -143,7 +432,7 @@ public class RateLimiterCapability extends RouterAgentCapability {
@bdi4jade.annotation.Plan
private Plan restoreIpRate;
@bdi4jade.annotation.Plan
- private Plan restoreLinkRate;
+ private Plan restoreLinkRate, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17;
@bdi4jade.annotation.TransientBelief
private final RateLimiter role;
@@ -184,6 +473,228 @@ public class RateLimiterCapability extends RouterAgentCapability {
GoalTemplateFactory.hasBeliefOfTypeWithValue(
FlowRateLimited.class, Boolean.TRUE),
LimitFlowRatePlan.class);
+
+
+ this.a1 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfTypeWithValue(
+ LinkRateLimited.class, Boolean.FALSE),
+ RestoreLinkRate1.class) {
+ public boolean isContextApplicable(Goal goal) {
+ BeliefGoal<LinkRateLimited> bg = (BeliefGoal<LinkRateLimited>) goal;
+ Predicate<LinkRateLimited> rateLimited = (Predicate<LinkRateLimited>) getBeliefBase()
+ .getBelief(bg.getBeliefName());
+ return (rateLimited != null && rateLimited.getValue());
+ };
+ };
+
+
+ this.a2 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfTypeWithValue(
+ LinkRateLimited.class, Boolean.FALSE),
+ RestoreLinkRate2.class) {
+ public boolean isContextApplicable(Goal goal) {
+ BeliefGoal<LinkRateLimited> bg = (BeliefGoal<LinkRateLimited>) goal;
+ Predicate<LinkRateLimited> rateLimited = (Predicate<LinkRateLimited>) getBeliefBase()
+ .getBelief(bg.getBeliefName());
+ return (rateLimited != null && rateLimited.getValue());
+ };
+ };
+
+
+ this.a3 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfTypeWithValue(
+ LinkRateLimited.class, Boolean.FALSE),
+ RestoreLinkRate3.class) {
+ public boolean isContextApplicable(Goal goal) {
+ BeliefGoal<LinkRateLimited> bg = (BeliefGoal<LinkRateLimited>) goal;
+ Predicate<LinkRateLimited> rateLimited = (Predicate<LinkRateLimited>) getBeliefBase()
+ .getBelief(bg.getBeliefName());
+ return (rateLimited != null && rateLimited.getValue());
+ };
+ };
+
+
+ this.a4 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfTypeWithValue(
+ LinkRateLimited.class, Boolean.FALSE),
+ RestoreLinkRate4.class) {
+ public boolean isContextApplicable(Goal goal) {
+ BeliefGoal<LinkRateLimited> bg = (BeliefGoal<LinkRateLimited>) goal;
+ Predicate<LinkRateLimited> rateLimited = (Predicate<LinkRateLimited>) getBeliefBase()
+ .getBelief(bg.getBeliefName());
+ return (rateLimited != null && rateLimited.getValue());
+ };
+ };
+
+
+ this.a5 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfTypeWithValue(
+ LinkRateLimited.class, Boolean.FALSE),
+ RestoreLinkRate5.class) {
+ public boolean isContextApplicable(Goal goal) {
+ BeliefGoal<LinkRateLimited> bg = (BeliefGoal<LinkRateLimited>) goal;
+ Predicate<LinkRateLimited> rateLimited = (Predicate<LinkRateLimited>) getBeliefBase()
+ .getBelief(bg.getBeliefName());
+ return (rateLimited != null && rateLimited.getValue());
+ };
+ };
+
+
+ this.a6 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfTypeWithValue(
+ LinkRateLimited.class, Boolean.FALSE),
+ RestoreLinkRate6.class) {
+ public boolean isContextApplicable(Goal goal) {
+ BeliefGoal<LinkRateLimited> bg = (BeliefGoal<LinkRateLimited>) goal;
+ Predicate<LinkRateLimited> rateLimited = (Predicate<LinkRateLimited>) getBeliefBase()
+ .getBelief(bg.getBeliefName());
+ return (rateLimited != null && rateLimited.getValue());
+ };
+ };
+
+
+ this.a7 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfTypeWithValue(
+ LinkRateLimited.class, Boolean.FALSE),
+ RestoreLinkRate7.class) {
+ public boolean isContextApplicable(Goal goal) {
+ BeliefGoal<LinkRateLimited> bg = (BeliefGoal<LinkRateLimited>) goal;
+ Predicate<LinkRateLimited> rateLimited = (Predicate<LinkRateLimited>) getBeliefBase()
+ .getBelief(bg.getBeliefName());
+ return (rateLimited != null && rateLimited.getValue());
+ };
+ };
+
+
+ this.a8 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfTypeWithValue(
+ LinkRateLimited.class, Boolean.FALSE),
+ RestoreLinkRate8.class) {
+ public boolean isContextApplicable(Goal goal) {
+ BeliefGoal<LinkRateLimited> bg = (BeliefGoal<LinkRateLimited>) goal;
+ Predicate<LinkRateLimited> rateLimited = (Predicate<LinkRateLimited>) getBeliefBase()
+ .getBelief(bg.getBeliefName());
+ return (rateLimited != null && rateLimited.getValue());
+ };
+ };
+
+
+ this.a9 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfTypeWithValue(
+ LinkRateLimited.class, Boolean.FALSE),
+ RestoreLinkRate9.class) {
+ public boolean isContextApplicable(Goal goal) {
+ BeliefGoal<LinkRateLimited> bg = (BeliefGoal<LinkRateLimited>) goal;
+ Predicate<LinkRateLimited> rateLimited = (Predicate<LinkRateLimited>) getBeliefBase()
+ .getBelief(bg.getBeliefName());
+ return (rateLimited != null && rateLimited.getValue());
+ };
+ };
+
+
+ this.a10 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfTypeWithValue(
+ LinkRateLimited.class, Boolean.FALSE),
+ RestoreLinkRate10.class) {
+ public boolean isContextApplicable(Goal goal) {
+ BeliefGoal<LinkRateLimited> bg = (BeliefGoal<LinkRateLimited>) goal;
+ Predicate<LinkRateLimited> rateLimited = (Predicate<LinkRateLimited>) getBeliefBase()
+ .getBelief(bg.getBeliefName());
+ return (rateLimited != null && rateLimited.getValue());
+ };
+ };
+
+
+ this.a11 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfTypeWithValue(
+ LinkRateLimited.class, Boolean.FALSE),
+ RestoreLinkRate11.class) {
+ public boolean isContextApplicable(Goal goal) {
+ BeliefGoal<LinkRateLimited> bg = (BeliefGoal<LinkRateLimited>) goal;
+ Predicate<LinkRateLimited> rateLimited = (Predicate<LinkRateLimited>) getBeliefBase()
+ .getBelief(bg.getBeliefName());
+ return (rateLimited != null && rateLimited.getValue());
+ };
+ };
+
+
+ this.a12 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfTypeWithValue(
+ LinkRateLimited.class, Boolean.FALSE),
+ RestoreLinkRate12.class) {
+ public boolean isContextApplicable(Goal goal) {
+ BeliefGoal<LinkRateLimited> bg = (BeliefGoal<LinkRateLimited>) goal;
+ Predicate<LinkRateLimited> rateLimited = (Predicate<LinkRateLimited>) getBeliefBase()
+ .getBelief(bg.getBeliefName());
+ return (rateLimited != null && rateLimited.getValue());
+ };
+ };
+
+
+ this.a13 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfTypeWithValue(
+ LinkRateLimited.class, Boolean.FALSE),
+ RestoreLinkRate13.class) {
+ public boolean isContextApplicable(Goal goal) {
+ BeliefGoal<LinkRateLimited> bg = (BeliefGoal<LinkRateLimited>) goal;
+ Predicate<LinkRateLimited> rateLimited = (Predicate<LinkRateLimited>) getBeliefBase()
+ .getBelief(bg.getBeliefName());
+ return (rateLimited != null && rateLimited.getValue());
+ };
+ };
+
+
+ this.a14 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfTypeWithValue(
+ LinkRateLimited.class, Boolean.FALSE),
+ RestoreLinkRate14.class) {
+ public boolean isContextApplicable(Goal goal) {
+ BeliefGoal<LinkRateLimited> bg = (BeliefGoal<LinkRateLimited>) goal;
+ Predicate<LinkRateLimited> rateLimited = (Predicate<LinkRateLimited>) getBeliefBase()
+ .getBelief(bg.getBeliefName());
+ return (rateLimited != null && rateLimited.getValue());
+ };
+ };
+
+
+ this.a15 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfTypeWithValue(
+ LinkRateLimited.class, Boolean.FALSE),
+ RestoreLinkRate15.class) {
+ public boolean isContextApplicable(Goal goal) {
+ BeliefGoal<LinkRateLimited> bg = (BeliefGoal<LinkRateLimited>) goal;
+ Predicate<LinkRateLimited> rateLimited = (Predicate<LinkRateLimited>) getBeliefBase()
+ .getBelief(bg.getBeliefName());
+ return (rateLimited != null && rateLimited.getValue());
+ };
+ };
+
+
+ this.a16 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfTypeWithValue(
+ LinkRateLimited.class, Boolean.FALSE),
+ RestoreLinkRate16.class) {
+ public boolean isContextApplicable(Goal goal) {
+ BeliefGoal<LinkRateLimited> bg = (BeliefGoal<LinkRateLimited>) goal;
+ Predicate<LinkRateLimited> rateLimited = (Predicate<LinkRateLimited>) getBeliefBase()
+ .getBelief(bg.getBeliefName());
+ return (rateLimited != null && rateLimited.getValue());
+ };
+ };
+
+
+ this.a17 = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfTypeWithValue(
+ LinkRateLimited.class, Boolean.FALSE),
+ RestoreLinkRate17.class) {
+ public boolean isContextApplicable(Goal goal) {
+ BeliefGoal<LinkRateLimited> bg = (BeliefGoal<LinkRateLimited>) goal;
+ Predicate<LinkRateLimited> rateLimited = (Predicate<LinkRateLimited>) getBeliefBase()
+ .getBelief(bg.getBeliefName());
+ return (rateLimited != null && rateLimited.getValue());
+ };
+ };
+
}
@Override
diff --git a/network-resilience/src/br/ufrgs/inf/bdinetr/BDINetRApp.java b/network-resilience/src/br/ufrgs/inf/bdinetr/BDINetRApp.java
index 07d06b6..76a7cb0 100644
--- a/network-resilience/src/br/ufrgs/inf/bdinetr/BDINetRApp.java
+++ b/network-resilience/src/br/ufrgs/inf/bdinetr/BDINetRApp.java
@@ -122,12 +122,70 @@ public class BDINetRApp {
case ESCAPE:
factory = new EscapeRouterComponentFactory();
//bdi4jade won't send any data to link monitor
- NETWORK.addRouter(new Router(new Ip("whatever"), -1, "LINK_MONITOR", Role.LINK_MONITOR.getId(), factory));
- NETWORK.addRouter(new Router(new Ip("10.0.0.101"), 5550, "RATE_LIMITER", Role.RATE_LIMITER.getId(), factory));
- NETWORK.addRouter(new Router(new Ip("10.0.0.101"), 5551, "ANOMALY_DETECTION", Role.ANOMALY_DETECTION.getId(), factory));
- NETWORK.addRouter(new Router(new Ip("10.0.0.101"), 5552, "CLASSIFIER", Role.CLASSIFIER.getId(), factory));
- NETWORK.addRouter(new Router(new Ip("10.0.0.101"), 5553, "FLOW_EXPORTER", Role.FLOW_EXPORTER.getId(), factory));
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), -1, "LINK_MONITOR", Role.LINK_MONITOR.getId(), factory));
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), 5550, "RATE_LIMITER", Role.RATE_LIMITER.getId(), factory));
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), 5551, "ANOMALY_DETECTION", Role.ANOMALY_DETECTION.getId(), factory));
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), 5552, "CLASSIFIER", Role.CLASSIFIER.getId(), factory));
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), 5553, "FLOW_EXPORTER", Role.FLOW_EXPORTER.getId(), factory));
+
+ //NETWORK.addRouter(new Router(new Ip("10.0.0.17"), -1, "LINK_MONITOR 2", Role.LINK_MONITOR.getId(), factory));
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), 5550, "RATE_LIMITER 2", Role.RATE_LIMITER.getId(), factory));
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), 5551, "ANOMALY_DETECTION 2", Role.ANOMALY_DETECTION.getId(), factory));
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), 5552, "CLASSIFIER 2", Role.CLASSIFIER.getId(), factory));
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), 5553, "FLOW_EXPORTER 2", Role.FLOW_EXPORTER.getId(), factory));
+
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), 5550, "RATE_LIMITER 3", Role.RATE_LIMITER.getId(), factory));
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), 5551, "ANOMALY_DETECTION 3", Role.ANOMALY_DETECTION.getId(), factory));
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), 5552, "CLASSIFIER 3", Role.CLASSIFIER.getId(), factory));
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), 5553, "FLOW_EXPORTER 3", Role.FLOW_EXPORTER.getId(), factory));
+
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), 5550, "RATE_LIMITER 4", Role.RATE_LIMITER.getId(), factory));
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), 5551, "ANOMALY_DETECTION 4", Role.ANOMALY_DETECTION.getId(), factory));
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), 5552, "CLASSIFIER 4", Role.CLASSIFIER.getId(), factory));
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), 5553, "FLOW_EXPORTER 4", Role.FLOW_EXPORTER.getId(), factory));
+
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), 5550, "RATE_LIMITER 5", Role.RATE_LIMITER.getId(), factory));
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), 5551, "ANOMALY_DETECTION 5", Role.ANOMALY_DETECTION.getId(), factory));
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), 5552, "CLASSIFIER 5", Role.CLASSIFIER.getId(), factory));
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), 5553, "FLOW_EXPORTER 5", Role.FLOW_EXPORTER.getId(), factory));
+
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), 5550, "RATE_LIMITER 6", Role.RATE_LIMITER.getId(), factory));
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), 5551, "ANOMALY_DETECTION 6", Role.ANOMALY_DETECTION.getId(), factory));
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), 5552, "CLASSIFIER 6", Role.CLASSIFIER.getId(), factory));
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), 5553, "FLOW_EXPORTER 6", Role.FLOW_EXPORTER.getId(), factory));
+
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), 5550, "RATE_LIMITER 7", Role.RATE_LIMITER.getId(), factory));
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), 5551, "ANOMALY_DETECTION 7", Role.ANOMALY_DETECTION.getId(), factory));
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), 5552, "CLASSIFIER 7", Role.CLASSIFIER.getId(), factory));
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), 5553, "FLOW_EXPORTER 7", Role.FLOW_EXPORTER.getId(), factory));
+
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), 5550, "RATE_LIMITER 8", Role.RATE_LIMITER.getId(), factory));
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), 5551, "ANOMALY_DETECTION 8", Role.ANOMALY_DETECTION.getId(), factory));
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), 5552, "CLASSIFIER 8", Role.CLASSIFIER.getId(), factory));
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), 5553, "FLOW_EXPORTER 8", Role.FLOW_EXPORTER.getId(), factory));
+
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), 5550, "RATE_LIMITER 9", Role.RATE_LIMITER.getId(), factory));
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), 5551, "ANOMALY_DETECTION 9", Role.ANOMALY_DETECTION.getId(), factory));
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), 5552, "CLASSIFIER 9", Role.CLASSIFIER.getId(), factory));
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), 5553, "FLOW_EXPORTER 9", Role.FLOW_EXPORTER.getId(), factory));
+
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), 5550, "RATE_LIMITER 19", Role.RATE_LIMITER.getId(), factory));
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), 5551, "ANOMALY_DETECTION 19", Role.ANOMALY_DETECTION.getId(), factory));
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), 5552, "CLASSIFIER 19", Role.CLASSIFIER.getId(), factory));
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), 5553, "FLOW_EXPORTER 19", Role.FLOW_EXPORTER.getId(), factory));
+
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), 5550, "RATE_LIMITER 29", Role.RATE_LIMITER.getId(), factory));
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), 5551, "ANOMALY_DETECTION 29", Role.ANOMALY_DETECTION.getId(), factory));
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), 5552, "CLASSIFIER 29", Role.CLASSIFIER.getId(), factory));
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), 5553, "FLOW_EXPORTER 29", Role.FLOW_EXPORTER.getId(), factory));
+
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), 5550, "RATE_LIMITER 39", Role.RATE_LIMITER.getId(), factory));
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), 5551, "ANOMALY_DETECTION 39", Role.ANOMALY_DETECTION.getId(), factory));
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), 5552, "CLASSIFIER 39", Role.CLASSIFIER.getId(), factory));
+ NETWORK.addRouter(new Router(new Ip("10.0.0.17"), 5553, "FLOW_EXPORTER 39", Role.FLOW_EXPORTER.getId(), factory));
+
break;
+
}
Set<Router> routers = NETWORK.getRouters();