public class LoadGenAppBasic extends LoadGenAppBasicBase
{
long numPkts = 0;
// This constant
holds the time at which this class began executing. It is used in the milliseconds()
method below
// to determine how
long this application has been running.
const Date d = new Date();
// This method returns
the current time returned from a new creation of a Date object with the
time this class was created
// subtracted from it.
The result is the time this application has been running in milliseconds.
private long milliSeconds()
{
return new
Date().getTime() - d.getTime();
}
private long Seconds()
{
long s = milliSeconds()
/ (long) 1000;
if(s == 0)
return 1;
if(s < 0) {
System.err.println("Time less than zero.");
halt();
}
return s;
}
private double Rate() {
return (double) numPkts
/ (double) Seconds();
}
public void exec()
{
while(Rate()
< PacketsPerSecond)
{
System.out.println("Packets/Second: "+ Rate());
LoadPacket lp = new LoadPacket();
lp.SendForProcessing("AN-5");
numPkts++;
}
try {
SPThread.currentSPThread().sleep(250);
} catch (InterruptedException
ex)
{}
}
}