[Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/wustl/tools/java/edu/wustl/mobilab/directory
ExperimentDataCollector.java, 1.16, 1.17 TraceAnalyser.java,
1.13, 1.14
Chien-Liang Fok
chien-liang at users.sourceforge.net
Wed Apr 12 12:31:29 PDT 2006
Update of /cvsroot/tinyos/tinyos-1.x/contrib/wustl/tools/java/edu/wustl/mobilab/directory
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1603/edu/wustl/mobilab/directory
Modified Files:
ExperimentDataCollector.java TraceAnalyser.java
Log Message:
Index: ExperimentDataCollector.java
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/wustl/tools/java/edu/wustl/mobilab/directory/ExperimentDataCollector.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** ExperimentDataCollector.java 11 Apr 2006 06:06:11 -0000 1.16
--- ExperimentDataCollector.java 12 Apr 2006 19:31:26 -0000 1.17
***************
*** 197,201 ****
// Stop the experiment after MAX_NUM_QUERIES has been performed
if (trace.get_action() == QUERY_GET_LOCATION_RESULTS_RECEIVED
! || trace.get_action() == QUERY_GET_CLOSEST_AGENT_RESULTS_RECEIVED) {
if (++numQs == MAX_NUM_QUERIES) {
frame.setVisible(false);
--- 197,202 ----
// Stop the experiment after MAX_NUM_QUERIES has been performed
if (trace.get_action() == QUERY_GET_LOCATION_RESULTS_RECEIVED
! || trace.get_action() == QUERY_GET_CLOSEST_AGENT_RESULTS_RECEIVED
! || trace.get_action() == QUERY_GET_AGENTS_RESULT_RECEIVED) {
if (++numQs == MAX_NUM_QUERIES) {
frame.setVisible(false);
***************
*** 209,215 ****
String logme = ("TRACE_GET_AGENTS: " + trace.get_agentID() + " " + trace.get_nodeID() + " "
+ trace.get_timestamp_high32() + "" + trace.get_timestamp_low32() + " "
! + trace.get_qid() + " " + trace.get_num_agents() + " ");
! for (int i = 0; i < trace.get_num_agents(); i++) {
! logme += trace.getElement_agent_id_id(i) + " " + trace.getElement_loc_x(i) + " " + trace.getElement_loc_y(i);
}
System.out.println(logme);
--- 210,220 ----
String logme = ("TRACE_GET_AGENTS: " + trace.get_agentID() + " " + trace.get_nodeID() + " "
+ trace.get_timestamp_high32() + "" + trace.get_timestamp_low32() + " "
! + trace.get_qid() + " " + trace.get_num_agents());
! int numResults = trace.get_num_agents();
! if (numResults > TraceAnalyser.MAX_AGENT_NUM)
! numResults = TraceAnalyser.MAX_AGENT_NUM;
! for (int i = 0; i < numResults; i++) {
! logme += " " + trace.getElement_agent_id_id(i) + " " + trace.getElement_loc_x(i)
! + " " + trace.getElement_loc_y(i);
}
System.out.println(logme);
Index: TraceAnalyser.java
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/wustl/tools/java/edu/wustl/mobilab/directory/TraceAnalyser.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** TraceAnalyser.java 11 Apr 2006 22:18:44 -0000 1.13
--- TraceAnalyser.java 12 Apr 2006 19:31:26 -0000 1.14
***************
*** 9,13 ****
static int QUERIER_AGENT_ID = 1;
! private static final int MAX_AGENT_NUM = 2; // max number of agents within a GetAgentsResults message.
private boolean debug;
--- 9,15 ----
static int QUERIER_AGENT_ID = 1;
! static int NUM_INTRUDER_AGENTS = 10; // the number of intruder agents within the system
!
! static int MAX_AGENT_NUM = 2; // max number of agents within a GetAgentsResults message.
private boolean debug;
***************
*** 51,55 ****
line.action.equals("QUERY_GET_LOCATION_FORWARDED") ||
line.action.equals("QUERY_GET_CLOSEST_AGENT_ISSUED") ||
! line.action.equals("QUERY_GET_CLOSEST_AGENT_FORWARDED"))
{
numQueryMessages++;
--- 53,59 ----
line.action.equals("QUERY_GET_LOCATION_FORWARDED") ||
line.action.equals("QUERY_GET_CLOSEST_AGENT_ISSUED") ||
! line.action.equals("QUERY_GET_CLOSEST_AGENT_FORWARDED") ||
! line.action.equals("QUERY_GET_AGENTS_ISSUED") ||
! line.action.equals("QUERY_GET_AGENTS_FORWARDED"))
{
numQueryMessages++;
***************
*** 151,174 ****
}
! if (line.action.equals("QUERY_GET_AGENTS_RESULT_RECEIVED")) {
if (line.agentID == QUERIER_AGENT_ID) {
TraceLineGetAgents currLine = (TraceLineGetAgents)line;
! GetAgentsResults result = null;
! if (getAgentsResultsTable.containsKey(new Integer(currLine.qid))) {
! result = getAgentsResultsTable.get(new Integer(currLine.qid));
! } else {
! result = new GetAgentsResults(currLine.qid);
! getAgentsResultsTable.put(new Integer(currLine.qid), result);
}
if (result != null) {
! for (int j = 0; j < currLine.numAgents; j++) {
AgillaAgentID aID = currLine.agentids.get(j);
AgillaLocation loc = currLine.agentLocs.get(j);
AgillaLocation actualLoc = agentLocTable.get(aID);
result.add(new GetAgentsResultsEntry(aID, loc, actualLoc));
! }
! }
}
--- 155,187 ----
}
! if (line.action.equals("QUERY_GET_AGENTS_RESULT_RECEIVED_DATA")) {
if (line.agentID == QUERIER_AGENT_ID) {
TraceLineGetAgents currLine = (TraceLineGetAgents)line;
+ Integer qid = new Integer(currLine.qid);
! // Create a GetAgentsResults object for storing the results
! // if one does not already exist.
! if (!getAgentsResultsTable.containsKey(qid)) {
! getAgentsResultsTable.put(qid, new GetAgentsResults(currLine.qid));
}
+
+ GetAgentsResults result = getAgentsResultsTable.get(qid);
if (result != null) {
! int count = currLine.numAgents;
! if (count > MAX_AGENT_NUM)
! count = MAX_AGENT_NUM;
! for (int j = 0; j < count; j++) {
AgillaAgentID aID = currLine.agentids.get(j);
AgillaLocation loc = currLine.agentLocs.get(j);
AgillaLocation actualLoc = agentLocTable.get(aID);
+ if (actualLoc == null) {
+ System.err.println("ERROR: could not get location of agent " + aID);
+ System.exit(0);
+ }
result.add(new GetAgentsResultsEntry(aID, loc, actualLoc));
! }
! } else
! log("ERROR: could not get GetAgentsResults message for qid = " + qid);
}
***************
*** 177,180 ****
--- 190,206 ----
}
+ // Analyze the results of the GetAgents Query
+ for (Enumeration<GetAgentsResults> e = getAgentsResultsTable.elements(); e.hasMoreElements();) {
+ GetAgentsResults result = e.nextElement();
+
+ if (result.numResults() == 0)
+ numFailedQueries++;
+ else if (result.numResults() != NUM_INTRUDER_AGENTS) {
+ numBadQueries++;
+ } else
+ numGoodQueries++;
+ errorSum += result.errorSum();
+ }
+
System.out.println("\nQuery Statistics: Good: " + numGoodQueries + ", Bad: " + numBadQueries + ", Failed: " + numFailedQueries);
System.out.println("Total Number of Queries: " + (numGoodQueries + numBadQueries + numFailedQueries));
***************
*** 198,201 ****
--- 224,240 ----
results.add(entry);
}
+
+ public int numResults() {
+ return results.size();
+ }
+
+ public double errorSum() {
+ double result = 0;
+ for (Enumeration<GetAgentsResultsEntry> e = results.elements(); e.hasMoreElements();) {
+ GetAgentsResultsEntry entry = e.nextElement();
+ result += entry.error();
+ }
+ return result;
+ }
}
***************
*** 209,212 ****
--- 248,255 ----
this.actualLocation = actualLocation;
}
+
+ public double error() {
+ return reportedLocation.dist(actualLocation);
+ }
}
***************
*** 329,333 ****
//log("timeStamp = " + timeStamp);
! action = "QUERY_GET_AGENTS_RESULT_RECEIVED";
//log("action = " + action);
--- 372,376 ----
//log("timeStamp = " + timeStamp);
! action = "QUERY_GET_AGENTS_RESULT_RECEIVED_DATA";
//log("action = " + action);
***************
*** 342,346 ****
//log("numAgents = " + numAgents);
! for (int i = 0; i < numAgents; i++)
{
int id, x, y;
--- 385,393 ----
//log("numAgents = " + numAgents);
! int count = numAgents;
! if (numAgents > MAX_AGENT_NUM)
! count = MAX_AGENT_NUM;
!
! for (int i = 0; i < count; i++)
{
int id, x, y;
***************
*** 352,359 ****
eIndex = line.indexOf(" ", sIndex+1);
x = Integer.valueOf(line.substring(sIndex+1, eIndex));
!
sIndex = eIndex;
! eIndex = line.indexOf(" ", sIndex+1);
! y = Integer.valueOf(line.substring(sIndex+1, eIndex));
agentids.add(new AgillaAgentID(id));
agentLocs.add(new AgillaLocation(x,y));
--- 399,409 ----
eIndex = line.indexOf(" ", sIndex+1);
x = Integer.valueOf(line.substring(sIndex+1, eIndex));
!
sIndex = eIndex;
! if (i+1 < count) {
! eIndex = line.indexOf(" ", sIndex+1);
! y = Integer.valueOf(line.substring(sIndex+1, eIndex));
! } else
! y = Integer.valueOf(line.substring(sIndex+1));
agentids.add(new AgillaAgentID(id));
agentLocs.add(new AgillaLocation(x,y));
***************
*** 419,422 ****
--- 469,474 ----
} else if (arg.equals("-q")) {
QUERIER_AGENT_ID = Integer.valueOf(args[++index]);
+ } else if (arg.equals("-n")) {
+ MAX_AGENT_NUM = Integer.valueOf(args[++index]);
} else {
System.err.println("Unknown argument \"" + arg + "\"");
***************
*** 440,448 ****
private static void usage() {
! System.err.println("Usage: TraceAnalyser [-h | -d | -q | -i | -f <file>]");
System.err.println("\t-h Print this help message");
System.err.println("\t-d Enable Debug mode");
! System.err.println("\t-i AgentID of intruder");
! System.err.println("\t-q AgentID of querier");
System.err.println("\t-f <file> Where <file> is contains the experiment trace data.");
}
--- 492,501 ----
private static void usage() {
! System.err.println("Usage: TraceAnalyser [-h | -d | -q <num> | -i <num> | -n <num> | -f <file>]");
System.err.println("\t-h Print this help message");
System.err.println("\t-d Enable Debug mode");
! System.err.println("\t-i <num> AgentID of intruder");
! System.err.println("\t-q <num> AgentID of querier");
! System.err.println("\t-n <num> Number of intruder agents (used by GetAgents)");
System.err.println("\t-f <file> Where <file> is contains the experiment trace data.");
}
More information about the Tinyos-contrib-commits
mailing list