/* * Client.java * * client data and operations * * Created by: Arthur L. Blais * Visteon/Ford Microelectronics Inc. * Colorado Springs, CO * * Date: Fri Sep 24 08:43:13 MDT 1999 * **************************************************************************** * * Notes and Acknowledgments: * * Active and Inactive off times and the number of embeded references are * generated from distributions modeled by Barford and Crovella at Boston * University. Inactive off times represent think time by the client is * represented by a pareto distribution. The number of embedded references * is also represented by a pareto distribution. The The values for alpha * and k (lowerBound) were fitted the pareto distribution to measured data. * The Inactive off times, the time between embeded references is * represented with a Weibull distribution with an alpha an beta value * fitted to measured data. * Paul A. Barford and Mark Crovella, Generating Representitive Web * Workloads for Network and Server Performance Evaluation, Technical * Paper BU-CS-07-006, Boston University, December 31, 1997 * **************************************************************************** * * Class Methods * * **************************************************************************** */ import java.util.*; import java.text.NumberFormat; public class Client { private Request request; // current request private long numberOfReferences = 0; // number of embeded requests private long totalResponseTime = 0; // sum of all response times private long totalExecutionTime = 0; // sum of all request exec times private long requestCount = 0; // number of requests made private long bytesReceived = 0; // total bytes received private int id; // client id private int lbm; // clients load balancing manager static Random randomNumber; // psuedo random number generator // constructor public Client( int i, int l, long seed ) { id = i; lbm = l; randomNumber = new Random( seed ); } /** * getId * * return this client's id number */ int getId() { return id; } /** * getLbm * * returns the client's lbm */ int getLbm() { return lbm; } /** * newRequest */ void newRequest( Request r ) { request = r; requestCount++; } /** * getRequest * * return the current request */ Request getRequest() { return request; } /** * deleteRequest * * delete the current request */ void deleteRequest() { request = null; } /** * getRequestCount */ long getRequestCount() { return requestCount; } /** * getResponseTime */ long getResponseTime() { return totalResponseTime; } /** * getBytesReceived */ long getBytesReceived() { return bytesReceived; } /** * updateStats * */ void updateStats( Request r ) { totalResponseTime += r.getWaitTime(); totalExecutionTime += r.getExecutionTime(); bytesReceived += r.getSize(); } /** * getExecutionTime */ long getExecutionTime() { return totalExecutionTime; } /** * getNextRequestTime * * Calculates the next time a request is to be made. * * Inactive off time (includes think time) is first calcuated. * Once a reqeust has been made, the reqeust time is calculate * foreach embedded references. * */ long getNextRequestTime() { double lowerBound; double alpha; double beta; double tailStart = 0.95; double x; long requestTime; double Fx = randomNumber.nextDouble(); if ( numberOfReferences == 0 ) { // inactive off time lowerBound = 1.0; alpha = 1.5; x = Pareto.getX( Fx, lowerBound, alpha ); Fx = randomNumber.nextDouble(); numberOfReferences = ( long ) Pareto.getX( Fx, 1.0, 2.43 ); } else { // active off time lowerBound = 1.0; alpha = 1.46; beta = 0.382; numberOfReferences--; x = Weibull.getX( Fx, alpha, beta ); } // convert to milliseconds requestTime = ( long ) ( x * 1000.0 ); return ( requestTime ); } /** * getIdleTime */ long getIdleTime( long t ) { return ( t - totalExecutionTime - totalResponseTime ); } /** * printStats */ void printStats( long clockTime ) { long idleTime; long avgSize; double avgResponseTime; double avgIdleTime; double avgExecutionTime; NumberFormat nf = NumberFormat.getInstance( Locale.US ); nf.setMaximumFractionDigits( 4 ); idleTime = clockTime - totalExecutionTime - totalResponseTime; avgSize = bytesReceived / requestCount; avgResponseTime = ( double ) totalResponseTime / ( double ) requestCount; avgExecutionTime = ( double ) totalExecutionTime / ( double ) requestCount; System.out.println( id + "\t" + requestCount + "\t" + bytesReceived + "\t" + avgSize + "\t" + nf.format( avgResponseTime ) + "\t" + nf.format( avgExecutionTime ) + "\t" + idleTime + "\t" + totalResponseTime + "\t" + totalExecutionTime ); } }