package Simulator; /* generate the network traffic we generate the traffic of the network through changing the traffic message size the biggest message size is 1500 bytes (10M traffic) */ public class Traffic { int TrafficMessSize; // the traffic message size String trafficType; // what kind of traffic you want to generate // Flat/Slope/Web distribution // for linear traffic distribution simulation private double segmentValue; // the changed traffic mess size in one segment. private int segmentNo; private boolean angle; // true is positive angle, false is negetive value private int StartTrafficMessSize; // the beginning message size // constractor for flat/static traffic public Traffic(float bandwidth, String trafficType) { // bandwidth means the consumed bandwidth this.TrafficMessSize = (int) ((bandwidth/10)*1500*8); this.trafficType = trafficType; } // constractor for linear/slope traffic public Traffic(String trafficType, boolean angle, double HBand, double LBand, double SMT, double EMT,double TBIntervalTime) { this.angle = angle; if (angle) this.TrafficMessSize = (int) (Math.floor(1500*8*(10-LBand)/10)); // trend is small to big else this.TrafficMessSize = (int) (Math.floor(1500*8*(10-HBand)/10)); // trend is big to small this.trafficType = trafficType; this.StartTrafficMessSize = TrafficMessSize; int segmentNum = (int) (Math.floor((EMT - SMT)/TBIntervalTime)); segmentValue = (double) ((HBand - LBand)*150*8 / segmentNum); segmentNo = 0; } // constractor for web traffic public Traffic(String trafficType) { this.trafficType = trafficType; } public void ArguChange(boolean changed) { if (trafficType.compareTo("Flat")==0) { // do nothing } if (trafficType.compareTo("Slope")==0) { // time gap between two traffic messages is constant // we create different traffic by changing the message size if (changed) { segmentNo ++; if (angle) TrafficMessSize = (int) (Math.floor(StartTrafficMessSize - (segmentNo * segmentValue))); else TrafficMessSize = (int) (Math.ceil(StartTrafficMessSize + (segmentNo * segmentValue))); } } if (trafficType.compareTo("Web")==0) { // time gap between two request messages(sleep time) is pareto distribution // time gap between two reference messages is weibull distribution // the reference number in one web page is the pareto distribution // file size is the pareto distribution // No arguments need to be changed. } } }