//Title: measurement method parent class //Version: //Copyright: Copyright (c) 1998 //Author: xhe //Company: UCCS package Simulator; import java.io.*; import java.util.*; import javax.swing.*; import java.awt.Graphics; import java.awt.Color; public abstract class Measurement extends NetworkConfigure { StatisChart chart; JPanel p; int numOfRouter; // how many router int numOfLink; // how many link int numOfRoad; // how many different router road int MaxMessNum=0; // the maximum message number int CprobingNum; // how many message in one Cprobing routing double TInternalTime; // Traffic Message sending interval time double RoundTripTime=0.0; // the round trip time of a message with no congestion // used in OverLoad traffic pattern double MaxTimeInterval; double MinTimeInterval; int TrafficMessageSize; int ProbingMessageSize; long LinkLength; Link BottleneckLink; // the bottleneck link PrintWriter LogFile; // log file PrintWriter PFile; // log file for probing message PrintWriter EventFile; // log file for events double Start_MeaTime; // when the start of the probing double end_time; // when the end of the probing boolean trafficoutput; // if the method will output the traffic pattern in the chart public void ThreadInit(JPanel ch,String trafficpattern,double smt,double emt,double tmi, double pmi, boolean trafficoutput) throws Exception { rnd = new Random(10); // warm up random number generator for (int index=0; index<50000; index++) rnd.nextDouble(); PBIntervalTime = pmi; TInternalTime = 0.0012; // using for flat/slope traffic TBIntervalTime = tmi; Start_MeaTime = smt; end_time = emt; this.trafficoutput = trafficoutput; // only read one line in configure file StringTokenizer t; Double DTemp; double FlatTraffic=0; double MaxBand=0; double MinBand=0; boolean SlopeAngle=true; try { BufferedReader ifile = new BufferedReader(new FileReader("configure.txt")); String s; // first line for five parameters s = ifile.readLine(); // skip the first line t = new StringTokenizer(s,"|"); DTemp = Double.valueOf(t.nextToken()); FlatTraffic = DTemp.doubleValue(); // how big traffic generated in flat traffic pattern /* DTemp = Double.valueOf(t.nextToken()); MaxBand = DTemp.doubleValue(); // the Max available bandwidth in slope traffic pattern DTemp = Double.valueOf(t.nextToken()); MinBand = DTemp.doubleValue(); // the Min available bandwidth in slope traffic pattern DTemp = Double.valueOf(t.nextToken()); double Angle = DTemp.doubleValue(); // the line angle in slope traffic pattern int angle = (int) Angle; SlopeAngle = (angle==1) ? true : false; */ DTemp = Double.valueOf(t.nextToken()); // unitrip or roundtrip time measurement double trip = DTemp.doubleValue(); // the line angle in slope traffic pattern int trip1 = (int) trip; UnitripProbe = (trip1==1) ? true : false; DTemp = Double.valueOf(t.nextToken()); MaxTimeInterval = DTemp.doubleValue(); // the Max Time Interval in Overload traffic pattern DTemp = Double.valueOf(t.nextToken()); MinTimeInterval = DTemp.doubleValue(); // the Min Time Interval in OverLoad traffic pattern TrafficMessageSize = Integer.parseInt(t.nextToken()); // the traffic message size in OverLoad traffic Pattern ProbingMessageSize = Integer.parseInt(t.nextToken()); LinkLength = Long.parseLong(t.nextToken()); ifile.close(); } catch (IOException d) { System.out.print("Error" + d); System.exit(1); } if (trafficpattern.equals("flat")) traffic = new Traffic(BottleneckLinkBandwidth,(float) FlatTraffic,"Flat",TrafficMessageSize,TBIntervalTime); if (trafficpattern.equals("slope")) traffic = new Traffic("Slope",MaxTimeInterval,MinTimeInterval,TrafficMessageSize,Start_MeaTime,end_time,PBIntervalTime); if (trafficpattern.equals("web")) traffic = new Traffic("Web"); NeedTraffic = true; chart = new StatisChart(Start_MeaTime,end_time,9,"Seconds",0,10,10,"ABW [Available BandWidth (MBps)]",ch); // color map Graphics g = ch.getGraphics(); g.setColor(Color.red); g.fillRect(15,25,15,5); g.drawString("ABW",8,50); g.setColor(Color.green); g.fillRect(15,65,15,5); g.drawString("SingleMsg",8,90); g.setColor(Color.black); g.fillRect(15,105,15,5); g.drawString("Cprobe",8,130); g.setColor(Color.blue); g.fillRect(15,145,15,5); g.drawString("Adaptive",8,170); g.setColor(Color.magenta); g.fillRect(15,185,15,5); g.drawString("MultiMsg",8,210); // legend g.setColor(Color.white); g.fillRect(70,ch.getHeight()-10,ch.getWidth()-100,10); g.setColor(Color.black); String str1,str2; if (UnitripProbe) str1 = "UniTripProbe"; else str1 = "RoundTripProbe"; g.drawString(str1,50+(ch.getWidth()-100)/2,ch.getHeight()-7); } public abstract void UpdateLog(double update_time); }