You are on page 1of 34

Group Members

1. Kerrie Hooper - 1021269

2. Shameer Amerullah - 1016806

3. Sherwyn Vangenderen - 1020796

4. Cleadon Brummel - 1021270

5. Aditya Tulsie - 1021320

CSE 4101
Assignment #2
Report on Testing the efficiency of
JADE Platform Experiment

Windows10
Contents

EXPERIMENT DESIGN: 2

PC CONFIGURATIONS.................................................................................................................................... 2

INTERNET TECHNOLOGY ............................................................................................................................... 2

SOFTWARE .................................................................................................................................................... 2

RUNNING THE EXPERIMENT: 3

CODING THE AGENTS .................................................................................................................................... 3

ACTUAL CODE ............................................................................................................................................... 4

MASTER AGENT............................................................................................................................................. 4

SPAMMING AGENT ..................................................................................................................................... 11

MESSAGE CONSUMING AGENT .................................................................................................................. 16

ALTERED MESSAGE CONSUMING AGENT ................................................................................................... 20

PROCEDURE ................................................................................................................................................ 25

RESULTS: 26

EXPERIMENT #1 .......................................................................................................................................... 26

EXPERIMENT #2 .......................................................................................................................................... 28

DISCUSSION: 31

FINDINGS/ ANALYSIS ................................................................................................................................... 31

CONCLUSION............................................................................................................................................... 33
EXPERIMENT DESIGN:

PC CONFIGURATIONS

All computers used in this experiment are of the same make and model. The following are the
configurations:
1. Operating System - Windows 10 Pro
2. Processor: I5 Intel Core CPU at 3.20GHz
3. RAM: 8.00 GB
4. System Type: 64-bit Operating System
5. Pen and Touch: No pen or touch input

INTERNET TECHNOLOGY

1. IPv4 Addressing
2. LAN

SOFTWARE

1. Netbeans IDE
2. JADE 4.5 Platform
RUNNING THE EXPERIMENT:

CODING THE AGENTS

After several trial and error testing as well as checking the connectivity and communication
among agents, the agent codes were revised several time. Certain parts of the coding were
used from the recommended textbook for Jade programming.
ACTUAL CODE

MASTER AGENT

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Message;

import jade.core.AID;
import jade.core.Agent;
import jade.core.behaviours.CyclicBehaviour;
import jade.domain.DFService;
import jade.domain.FIPAAgentManagement.DFAgentDescription;
import jade.domain.FIPAAgentManagement.ServiceDescription;
import jade.domain.FIPAException;
import jade.lang.acl.ACLMessage;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
*
* @author Students
*/
public class Master extends Agent{

long count = 1, threshhold = 2, counter = 0;


String str;
DFAgentDescription[] list2 = null;
DFAgentDescription[] list = null;

@Override
protected void setup(){

DFAgentDescription dgd = new DFAgentDescription();


ServiceDescription sc = new ServiceDescription();
sc.setType("spammer");
dgd.addServices(sc);

try {
list2 = DFService.search(this, dgd);
} catch (FIPAException ex) {
Logger.getLogger(Master.class.getName()).log(Level.SEVERE, null, ex);
}

System.out.println(list2.length + " results");


System.out.println(list2[0].getName().getLocalName());

//.................................................
DFAgentDescription dfd = new DFAgentDescription();
ServiceDescription sd = new ServiceDescription();
sd.setType("consumer");
dfd.addServices(sd);

try {
list = DFService.search(this, dfd);
} catch (FIPAException ex){
Logger.getLogger(Master.class.getName()).log(Level.SEVERE, null, ex);
}

System.out.println(list.length + " results");

System.out.println(list[0].getName().getLocalName());

StringBuilder stringBuilder = new StringBuilder();

for(int e = 0; e <list2.length; e++ ){

stringBuilder.append(list[e].getName().getLocalName());
stringBuilder.append(",");

}
str = stringBuilder.toString();//list of msg consuming agents

System.out.println(str);

addBehaviour(new CyclicBehaviour(this){

@Override
public void action(){

try {

TimeUnit.SECONDS.sleep(1);

} catch (InterruptedException ex) {

Logger.getLogger(Master.class.getName()).log(Level.SEVERE, null, ex);


}

if (list2.length > 0 && counter < 1){ //sends message to spamming agents with list of all
consuming agents

counter++;

for(int i = 0; i <list2.length; i++ ){

ACLMessage tosend;
tosend = new ACLMessage(ACLMessage.INFORM);

tosend.setContent(str); //the array of consuming agnts as a string

tosend.addReceiver(new AID (list2[i].getName().getLocalName(),AID.ISLOCALNAME));

send(tosend);

// if(count <= threshhold){


//
//
// if (list2.length > 0){
//
// for(int i = 0; i <list2.length; i++ ){
//
// ACLMessage response;
//
// response = new ACLMessage(ACLMessage.INFORM);
//
// response.setContent("start");
//
// System.out.println(list2[i].getName().getLocalName());
//
// response.addReceiver(new AID (list2[i].getName().getLocalName(),
AID.ISLOCALNAME));
//
// send(response);
//
// }
//
// }

// System.out.println(response.getContent());

// count++;
// System.out.println(+count);

ACLMessage msg= receive();

if (msg!=null){

System.out.println(" - " +myAgent.getLocalName() + " <- " +msg.getContent());


}
block();
}

});

}
SPAMMING AGENT

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Message;

import jade.core.AID;
import jade.core.Agent;
import jade.core.behaviours.CyclicBehaviour;
import jade.domain.DFService;
import jade.domain.FIPAAgentManagement.DFAgentDescription;
import jade.domain.FIPAAgentManagement.ServiceDescription;
import jade.domain.FIPAException;
import jade.lang.acl.ACLMessage;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
*
* @author Students
*/
public class SA extends Agent{
int count = 0;
int Messagenumber = ?;
String[] list;
String list1;

@Override
protected void setup(){

//register agent as spammer service

DFAgentDescription dfd = new DFAgentDescription();


dfd.setName(getAID());
ServiceDescription sd = new ServiceDescription();
sd.setType("spammer");
sd.setName(getLocalName());
dfd.addServices(sd);

try {
DFService.register(this, dfd);
} catch (FIPAException fe) {
}
addBehaviour(new CyclicBehaviour(){
@Override
public void action(){

ACLMessage msg1 = receive();//receives message from master with all message


consuming agents

if (msg1!=null){

String entireFileText = null;

try {
entireFileText = new Scanner(new
File("C:/Users/Students/Documents/NetBeansProjects/Test/src/Message/file4.txt"))//reades
file sontaining specific number of characters
.useDelimiter("\\A").next();
}catch(FileNotFoundException ex){

Logger.getLogger(SA.class.getName()).log(Level.SEVERE, null, ex);


}

list = msg1.getContent().split("\\s*,\\s*");//splits message received storing each message


consuming agent into separate arrays
if (list.length > 0){ //checks if we did receive MCA agents to spam

for(int i = 0; i <list.length; i++ ){ //sends message to spamming agents in array

ACLMessage tosend;

tosend = new ACLMessage(ACLMessage.INFORM);

tosend.setContent(entireFileText); //the array of consuming agnts as a string

tosend.addReceiver(new AID (list[i],AID.ISLOCALNAME));

while(count < Messagenumber){ //sends a specified amount of messages to the message


consumning agents

send(tosend);

count++;

}
count = 0;//resets count for next agent

}else{
block();//wait for message from master containing list of MCA agents to start spamming

}
}
});
}
}
MESSAGE CONSUMING AGENT

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Message;

import jade.core.AID;
import jade.core.Agent;
import jade.core.behaviours.CyclicBehaviour;
import jade.domain.DFService;
import jade.domain.FIPAAgentManagement.DFAgentDescription;
import jade.domain.FIPAAgentManagement.ServiceDescription;
import jade.domain.FIPAException;
import jade.lang.acl.ACLMessage;

/**
*
* @author Students
*/

public class MCA extends Agent {


long count,total;
@Override
protected void setup(){
DFAgentDescription dfd = new DFAgentDescription();//register agent service consumer
dfd.setName(getAID());
ServiceDescription sd = new ServiceDescription();
sd.setType("consumer");
sd.setName(getLocalName());
dfd.addServices(sd);

try {
DFService.register(this, dfd);
} catch (FIPAException fe) {
}

addBehaviour(new CyclicBehaviour(){

@Override
public void action(){

long Start,End,duration;
long numberOfMessages = 1250;

Start = System.nanoTime();
ACLMessage msg= receive();
End = System.nanoTime();
duration = End - Start;

if (msg!=null){
total = duration + total;

count++;

System.out.println(+count);

if(count == numberOfMessages){

String tosend = Long.toString(total);

ACLMessage response = new ACLMessage(ACLMessage.INFORM);

response.setContent(tosend);

response.addReceiver(new AID("Master",AID.ISLOCALNAME));

send(response);

doDelete();

}
}else{
System.out.println("This is block");

block();

}
});

}
}
ALTERED MESSAGE CONSUMING AGENT

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Message;

import jade.core.AID;
import jade.core.Agent;
import jade.core.behaviours.CyclicBehaviour;
import jade.domain.DFService;
import jade.domain.FIPAAgentManagement.DFAgentDescription;
import jade.domain.FIPAAgentManagement.ServiceDescription;
import jade.domain.FIPAException;
import jade.lang.acl.ACLMessage;
import jade.lang.acl.MessageTemplate;

/**
*
* @author Students
*/

public class MCA extends Agent {


long count,total;
@Override
protected void setup(){
DFAgentDescription dfd = new DFAgentDescription();
dfd.setName(getAID());
ServiceDescription sd = new ServiceDescription();
sd.setType("consumer");
sd.setName(getLocalName());
dfd.addServices(sd);

try {
DFService.register(this, dfd);
} catch (FIPAException fe) {
}

addBehaviour(new CyclicBehaviour(){

@Override
public void action(){

MessageTemplate mt =
MessageTemplate.and(
MessageTemplate.MatchPerformative( ACLMessage.INFORM ),
MessageTemplate.MatchSender( new AID( "SA1",AID.ISLOCALNAME)));

long Start,End,duration;
long MessageAmount = 35 ;
long mySpammer = 5;
if(count < mySpammer){

Start = System.nanoTime();
ACLMessage msg= receive(mt);
End = System.nanoTime();
duration = End - Start;

if (msg!=null){

total = duration + total;

count++;

System.out.println(+count);

}else{

System.out.println("This is first block");


block();

}else if(count >= mySpammer){

Start = System.nanoTime();
ACLMessage msg= receive();
End = System.nanoTime();
duration = End - Start;

if(msg!=null){

total = duration + total;

count++;

System.out.println(+count);

if (count == MessageAmount){

String tosend = Long.toString(total);

ACLMessage response = new ACLMessage(ACLMessage.INFORM);

response.setContent(tosend);

response.addReceiver(new AID("Master",AID.ISLOCALNAME));

send(response);

doDelete();
}
}else{
System.out.println("This is Second block");
block();
}
}
}
});
}
}
PROCEDURE

The agents (spamming agents, message consuming agents and master agent) were loaded onto
respective computer systems. The experiments and testing were performed upon 2, 3, 5 and
then 7 computer systems consecutively. Messages were passed at a size of 100, 500, 1000,
3000 and 5000 characters respectively which were sent a number of 5, 100 and 250 times
repeatedly. On average, testing was performed three times for each to gain a sum time and an
average time taken for the messages to be delivered and spammed.
The alternative experiments and alternative testing were performed on the same number of
computer systems the same number of times at the same message sizes respectively.
RESULTS:

MA - master agent
SA - spamming agent
MCA - message consuming agent

EXPERIMENT #1

Figure 1: Line graph for 2 SA, 2MCA and 1MA displaying the average time in seconds against
the number of characters per message as each color indicates.
Figure 2: Line graph for 3 SA, 3 MCA and 1 MA displaying the average time in seconds against
the number of characters per message as each color indicates.

Figure 3: Line graph for 5 SA, 5 MCA and 1 MA displaying the average time in seconds against
the number of characters per message as each color indicates.
Figure 4: Line graph for 7 SA, 7 MCA and 1 MA displaying the average time in seconds against
the number of characters per message as each color indicates.

EXPERIMENT #2

Figure 5: Line graph for 2 SA, 2 MCA and 1 MA displaying the average time in seconds against
the number of characters per message as each color indicates.
Figure 6: Line graph for 3 SA, 3 MCA and 1 MA displaying the average time in seconds against
the number of characters per message as each color indicates.

Figure 7: Line graph for 5 SA, 5 MCA and 1 MA displaying the average time in seconds against
the number of characters per message as each color indicates.
Figure 8: Line graph for 7 SA, 7 MCA and 1 MA displaying the average time in seconds against
the number of characters per message as each color indicates.
DISCUSSION:

FINDINGS/ ANALYSIS

EXPERIMENT #1
In figure 1, the transmission of five messages, containing specific numbers of characters,
between agents was fairly consistent, spiking at 1000 characters. One hundred messages were
transmitted at a consistent rate but gradually increased when the number exceeded 1000
characters. Two hundred and fifty messages were transmitted at an overall increasing rate as
the number of characters escalated.

With respect to figure 2, the transmission of five messages, containing specific numbers of
characters, between agents was fairly consistent, spiking at 500 characters. One hundred
messages were transmitted at a progressively increasing timing as the number of characters per
message increased. However, two hundred and fifty messages were transmitted at fluctuating
timings.

Depicted in figure 3, the transmission of five, one hundred, and two hundred and fifty
messages, containing specific numbers of characters, between agents was fairly consistent,
with the 250 message transmission rate increasing when exceeding 3000 characters.

In figure 4, the transmission of five messages, containing specific numbers of characters,


between agents was fairly consistent. One hundred message transmission, and two hundred
and fifty message transmission were transmitted at a gradually decreasing timings as the
number of characters per message increased.

Generally, as the number of messages increase, the time taken significantly increases. When
using just the 2, 3 and 5 computers, the time taken as the number of characters increased, had
also increased (positive gradient). However, when 7 computers were used, the time gradually
decreased as the number of characters increased. The reason for the increase in time is the
FIFO order regardless of the computer and network connectivity. FIFO order was implemented
in this particular experiment.
EXPERIMENT #2
Displayed in figure 5, the transmission of five, one hundred, and two hundred and fifty
messages, containing specific numbers of characters, between agents was fairly consistent,
with the 15 message transmission rate spiking at 3000 characters.

From the graph in figure 6, the transmission of five, one hundred, and two hundred and fifty
messages, containing specific numbers of characters, between agents spiked when messages
were increased to 500 characters. The transmission of five messages were fairly consistent
otherwise. The 100 message transmission timings gradually decreased but the 250 message
transmission was highly fluctuating as the number of characters per message changed.

Indicated in figure 7, the transmission of five, and one hundred messages, containing specific
numbers of characters, between agents were fairly consistent. The transmission of 250
message transmission timing was progressively declining as the number of characters per
message escalated.

Finally in figure 8, the transmission of five, one hundred, and two hundred and fifty messages,
containing specific numbers of characters, between agents was fairly consistent, with the 250
message transmission timing spiking when messages contained 100 characters.

In summary, the results are somewhat opposing from experiment one. When using just 2
computers, as the number of characters increase the time was almost constant and barely
increased. However, when 3, 5 and 7 computers were used, the time generally decreased as
the number of characters increased. This experiment did not solely employ the FIFO method
but rather it received messages from its own SA first then received messages from external
agents. This resulted in generally less time when compared to experiment one as indicated in
the decrease in time as the size of the messages increased.
CONCLUSION

The sending and receiving of messages from and to agents were affected by a number of
factors. Based upon observation during the experiments, the predominant factor was the
network traffic. The lesser factors included the network infrastructure, the computer systems
used, the IDE used, the agent codes, the network configuration, and the programmers’
understanding of agent systems.

Regardless of how many characters each message consisted of and how many messages were
transmitted, we can generally conclude that the time reported by the MA generally decreased
as the number of characters increased in experiment #2 while this was the opposite in
experiment #1. Therefore, the JADE platform is much more efficient when messages are sent
across to agents on the same computer as this is a factor that differentiated the results of the
two experiments.

This goes to show that large volumes of data can be transmitted and processed across a
network using automated systems. This was a perfect illustration of how bots can zombify
computers and a central system controlling their activities to attack an organization’s network.